protected AssociationDescriptor associationDescriptor(Name name) { PropertyDescriptor descriptor = Types.descriptor((ComplexType) type, name); if (descriptor == null) { String msg = "Could not locate association: " + name + " in type: " + type.getName(); throw new IllegalArgumentException(msg); } if (!(descriptor instanceof AssociationDescriptor)) { String msg = name + " references a non association"; throw new IllegalArgumentException(msg); } return (AssociationDescriptor) descriptor; }
protected boolean skipTopElement(Name topElement, StepList xpath, AttributeType type) { // don't skip simple content e.g. when feature chaining gml:name return Types.equals(topElement, xpath) && !Types.isSimpleContentType(type); }
public static QName toQName(Name featurePath) { return toQName(featurePath, null); }
/** * Template method for creating an attribute name. * * @return {@link org.geotools.feature.Types#typeName(String, String)} */ protected Name createName(String ns, String local) { return Types.typeName(ns, local); }
node = (AttributeDescriptor) Types.descriptor(type, Types.typeName(nsUri, "the_geom")); assertNotNull(node); assertEquals("LineStringPropertyType", node.getType().getName().getLocalPart()); assertNotNull(Types.descriptor(type, Types.typeName(nsUri, "name"))); Name ftNodeName = Types.typeName(nsUri, "fromToNodes"); assertNotNull(Types.descriptor(type, ftNodeName)); AttributeDescriptor descriptor = (AttributeDescriptor) Types.descriptor(type, ftNodeName); assertTrue(fromToNodes.isIdentified()); Name fromNodeName = Types.typeName(nsUri, "fromNode"); AttributeDescriptor fromNode = (AttributeDescriptor) Types.descriptor(fromToNodes, fromNodeName); assertNotNull(fromNode); Name toNodeName = Types.typeName(nsUri, "toNode"); AttributeDescriptor toNode = (AttributeDescriptor) Types .descriptor(fromToNodes, toNodeName); assertNotNull(fromNode); Name subName = Types.typeName(nsUri, "broadTypeEl"); descriptor = (AttributeDescriptor) Types.descriptor(type, subName); .descriptor(subbedType, subName);
typeRegistry.addSchemas(schemaIndex); final Name typeName = Types.typeName(AWNS, "SiteSinglePhenomTimeSeriesType"); final ComplexType testType = (ComplexType) typeRegistry.getAttributeType(typeName); assertNotNull(superType); Name superTypeName = Types.typeName(AWNS, "SamplingSitePurposeType"); assertEquals(superTypeName, superType.getName()); samplingProperties.put(name(AWNS, "samplingRegimeType"), Types.toTypeName(GML.CodeType)); samplingProperties.put(name(AWNS, "waterBodyType"), Types.toTypeName(GML.CodeType)); samplingProperties.put(name(AWNS, "accessTypeCode"), Types.toTypeName(GML.CodeType)); AttributeDescriptor relatedObservation = (AttributeDescriptor) Types.descriptor(testType, name(AWNS, "relatedObservation")); Map relatedObsProps = new HashMap(); AttributeDescriptor phenomenonTimeSeries = (AttributeDescriptor) Types.descriptor( phenomenonTimeSeriesPropertyType, name(AWNS, "PhenomenonTimeSeries")); ComplexType phenomenonTimeSeriesType = (ComplexType) phenomenonTimeSeries.getType(); AttributeDescriptor observedProperty = (AttributeDescriptor) Types.descriptor( phenomenonTimeSeriesType, name(OMNS, "observedProperty")); AttributeDescriptor phenomenon = (AttributeDescriptor) Types.descriptor( phenomenonPropertyType, name(SWENS, "Phenomenon")); ComplexType phenomenonType = (ComplexType) phenomenon.getType();
/** * * @param name * @return * @deprecated use {@link #toTypeName(QName} */ public static Name toName(QName name) { return toTypeName(name); }
String prefix = lastStepQName.getPrefix(); String uri = namespaceSupport.getURI(prefix); lastStepName = Types.typeName(uri, lastStepQName.getLocalPart()); } else { lastStepName = Types.toTypeName(lastStepQName);
QName qname = Types.toQName(Types.typeName(elemDecl.getTargetNamespace(), elemDecl.getName())); for (SchemaIndex schemaIndex : schemas) { String targetNamespace = typeDefinition.getTargetNamespace(); String name = typeDefinition.getName(); Name typeName = Types.typeName(targetNamespace, name); type = getAttributeType(typeName, typeDefinition, crs); if (type == null) { String name = elemDecl.getName(); String targetNamespace = elemDecl.getTargetNamespace(); Name overrideName = Types.typeName(targetNamespace, name); type = createType(overrideName, typeDefinition, crs, true);
/** * Return true if the type is either a simple type or has a simple type as its supertype. In * particular, complex types with simple content will return true. * * @param type * @return */ public static boolean isSimpleContentType(PropertyType type) { if (type == XSSchema.ANYSIMPLETYPE_TYPE) { // should never happen as this type is abstract throw new RuntimeException("Unexpected simple type"); } PropertyType superType = type.getSuper(); if (superType == XSSchema.ANYSIMPLETYPE_TYPE) { return true; } else if (superType == null) { return false; } else { return isSimpleContentType(superType); } } }
Name lastStep = Types.toTypeName(sl.get(lastIndex).getName()); while (!Types.isElement(type, lastStep)) { lastIndex--; if (lastIndex < 0) { return; lastStep = Types.toTypeName(sl.get(lastIndex).getName());
Step rootStep = (Step) steps.get(0); QName stepName = rootStep.getName(); if (Types.equals(rootName, stepName)) { final boolean isLastStep = !stepsIterator.hasNext(); final QName stepName = currStep.getName(); final Name attributeName = Types.toName(stepName); currStepDescriptor = (AttributeDescriptor) Types.findDescriptor(parentType, attributeName.getLocalPart()); } else { currStepDescriptor = (AttributeDescriptor) Types.findDescriptor(parentType, attributeName); AttributeDescriptor actualDescriptor; if (null == attributeName.getNamespaceURI()) { actualDescriptor = (AttributeDescriptor) Types.findDescriptor(parentType, attributeName.getLocalPart()); } else { actualDescriptor = (AttributeDescriptor) Types.findDescriptor(parentType, attributeName);
public FeatureTypeAttributeIterator(NodePointer pointer, ComplexType featureType) { this.pointer = pointer; this.featureType = featureType; //get list of descriptors from types and all supertypes children = Types.descriptors(featureType); position = 1; }
private AttributeDescriptor getTargetDescriptor(TypeMapping dto, CoordinateReferenceSystem crs) throws IOException { String prefixedTargetName = dto.getTargetElementName(); Name targetNodeName = Types.degloseName(prefixedTargetName, namespaces); AttributeDescriptor targetDescriptor = typeRegistry.getDescriptor(targetNodeName, null, null, crs); if (targetDescriptor == null) { throw new NoSuchElementException("descriptor " + targetNodeName + " not found in parsed schema"); } return targetDescriptor; }
private List<Expression> getClientPropertyExpressions(final List attributeMappings, final Name clientPropertyName, StepList parentPath) { List<Expression> clientPropertyExpressions = new ArrayList<Expression>(attributeMappings .size()); AttributeMapping attMapping; Map clientProperties; Expression propertyExpression; for (Iterator it = attributeMappings.iterator(); it.hasNext();) { attMapping = (AttributeMapping) it.next(); if (attMapping instanceof JoiningNestedAttributeMapping) { // if it's joining for simple content feature chaining it has to be empty // so it will be added to the post filter clientPropertyExpressions.add(null); } else { clientProperties = attMapping.getClientProperties(); // NC -added if (Types.equals(clientPropertyName, GML.id)) { clientPropertyExpressions.add(attMapping.getIdentifierExpression()); } else if (clientProperties.containsKey(clientPropertyName)) { // end NC - added propertyExpression = (Expression) clientProperties.get(clientPropertyName); clientPropertyExpressions.add(propertyExpression); } } } return clientPropertyExpressions; }
public PropertyDescriptor getDescriptor() { return Types.findDescriptor(parentType, name); }
/** * Template method for creating a type name. * * @return {@link org.geotools.feature.iso.Types#typeName(String, String)} */ protected Name createTypeName(String ns, String local) { return Types.typeName(ns, local); }
Name typeName = Types.typeName(NS_URI, "wq_plus_Type"); AttributeType type = (AttributeType) typeRegistry.getAttributeType(typeName); Assert.assertTrue(type instanceof FeatureType); typeName = Types.typeName(GML.NAMESPACE, GML.AbstractFeatureType.getLocalPart()); Assert.assertEquals(typeName, wq_plus_Type.getSuper().getName()); Assert.assertNotNull(wq_plus_Type.getDescriptors()); Assert.assertEquals(8, ((ComplexFeatureTypeImpl) wq_plus_Type).getTypeDescriptors().size()); Name name = Types.typeName(NS_URI, "wq_plus"); AttributeDescriptor wqPlusDescriptor = typeRegistry.getDescriptor(name, null, null, null); Assert.assertNotNull(wqPlusDescriptor); typeName = Types.typeName(NS_URI, "measurementType"); type = typeRegistry.getAttributeType(typeName); Assert.assertTrue(type instanceof ComplexType); name = Types.typeName(NS_URI, "measurement"); AttributeDescriptor descriptor; descriptor = (AttributeDescriptor) Types.descriptor(wq_plus_Type, name); Assert.assertNotNull(descriptor); Assert.assertEquals(name, descriptor.getName()); name = Types.typeName(NS_URI, "result"); descriptor = (AttributeDescriptor) Types.descriptor(measurementType, name); typeName = Types.typeName(XS.NAMESPACE, XS.FLOAT.getLocalPart()); assertSimpleAttribute(descriptor, name, typeName, Float.class, 1, 1); name = Types.typeName(NS_URI, "determinand_description");
/** * Returns whether <code>typeDefinition</code> has an ancestor named <code>baseTypeName</code>. * * @param typeDefinition * @param baseTypeName * @return */ private boolean isDerivedFrom(final XSDTypeDefinition typeDefinition, final QName baseTypeName) { Name typeName = Types.toTypeName(baseTypeName); // XSDTypeDefinition baseTypeDefinition = Schemas.getBaseTypeDefinition( // typeDefinition, baseTypeName); // boolean isFeatureType = baseTypeDefinition != null; // return isFeatureType; return isDerivedFrom(typeDefinition, typeName); }
private static boolean isSimpleType(FeatureTypeMapping mapping) { return Types.isSimpleContentType(mapping.getTargetFeature().getType()); }