private void createFoundationTypes() { synchronized (FOUNDATION_TYPES) { if (!FOUNDATION_TYPES.isEmpty()) { typeRegistry.putAll(FOUNDATION_TYPES); return; } importSchema(new XSSchema()); for (Schema schema : helper.getSchemas()) { importSchema(schema); } for (Configuration config : helper.getConfigurations()) { addSchemas(Schemas.findSchemas(config)); } FOUNDATION_TYPES.putAll(typeRegistry); } }
public AttributeType getAttributeType(final Name typeName) { return getAttributeType(typeName, null, null); }
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; }
public AttributeType getAttributeType(final Name typeName, XSDTypeDefinition xsdType, CoordinateReferenceSystem crs) { AttributeType type = (AttributeType) typeRegistry.get(typeName); if (type == null || type instanceof AbstractLazyComplexTypeImpl) { // recreate lazy types too if (xsdType == null) { xsdType = getTypeDefinition(typeName); } LOGGER.finest("Creating attribute type " + typeName); type = createType(typeName, xsdType, crs, false); LOGGER.finest("Registering attribute type " + typeName); } return type; }
public AttributeDescriptor getDescriptor( final Name descriptorName, CoordinateReferenceSystem crs) { AttributeDescriptor descriptor = descriptorRegistry.get(descriptorName); if (descriptor == null) { // top level elements XSDElementDeclaration elemDecl = getElementDeclaration(descriptorName); descriptor = createAttributeDescriptor(null, elemDecl, crs); LOGGER.finest("Registering attribute descriptor " + descriptor.getName()); register(descriptor); } return descriptor; }
FeatureTypeRegistry typeRegistry = new FeatureTypeRegistry(); try { typeRegistry.addSchemas(schemaIndex); ComplexType mf = (ComplexType) typeRegistry.getAttributeType(typeName); assertNotNull(mf); assertTrue(mf instanceof FeatureType); mf = (ComplexType) typeRegistry.getAttributeType(typeName); assertNotNull(mf); assertTrue(mf instanceof FeatureType); typeRegistry.disposeSchemaIndexes();
LOGGER.fine("Recursion found for type " + assignedName + ". Proxying it."); attType = createProxiedType(assignedName, typeDefinition, anonymous ? anonTypeRegistry : typeRegistry); return attType; if (name != null) { Name baseTypeName = new NameImpl(targetNamespace, name); superType = getAttributeType(baseTypeName, baseType, crs); childDecl = (XSDElementDeclaration) it.next(); try { descriptor = createAttributeDescriptor(complexTypeDef, childDecl, crs); } catch (NoSuchElementException e) { String msg = "Failed to create descriptor for '" setSubstitutionGroup(complexTypeDef, elemDecl, att, crs); attType = createComplexAttributeType(assignedName, schema, complexTypeDef, superType); } else { Class<?> binding = String.class; register(attType, anonymous);
|| !(sub.getTargetNamespace().equals(elemDecl.getTargetNamespace()))) { Name elemName = Types.typeName(sub.getTargetNamespace(), sub.getName()); AttributeType type = getTypeOf(sub, crs); if (type != null) { substitutionGroup.add(createAttributeDescriptor(type, crs, elemName, minOccurs, maxOccurs, nillable, null)); createType(typeName, typeDef, crs, false); LOGGER.finest("Registering attribute type " + typeName); } else if (attType instanceof ComplexType) { setSubstitutionGroup((XSDComplexTypeDefinition) typeDef, element, childDesc, crs);
typeRegistry = new FeatureTypeRegistry(namespaces); typeRegistry.addSchemas(schemaIndex);
@Override public FeatureType getSchema(Name name) throws IOException { // If there are no values in this.names it probably means that getNames // hasn't been called yet. if (this.names.size() == 0) { this.getNames(); } // Generate the URL for the feature request: // ----------------------------------------- DescribeFeatureTypeRequest describeFeatureTypeRequest = client.createDescribeFeatureTypeRequest(); QName qname = this.names.get(name); describeFeatureTypeRequest.setTypeName(qname); URL describeRequestURL = describeFeatureTypeRequest.getFinalURL(); // Create type registry and add the schema to it: // ---------------------------------------------- FeatureTypeRegistry typeRegistry = this.getFeatureTypeRegistry(); SchemaIndex schemaIndex = this.getSchemaParser().parse(describeRequestURL); typeRegistry.addSchemas(schemaIndex); // Create the attribute type and cast it as a FeatureType: // ------------------------------------------------------- AttributeDescriptor attributeDescriptor = typeRegistry.getDescriptor(name, null); return (FeatureType) attributeDescriptor.getType(); }
String name = typeDefinition.getName(); Name typeName = Types.typeName(targetNamespace, name); type = getAttributeType(typeName, typeDefinition, crs); if (type == null) { type = createType(typeName, typeDefinition, crs, false); String targetNamespace = elemDecl.getTargetNamespace(); Name overrideName = Types.typeName(targetNamespace, name); type = createType(overrideName, typeDefinition, crs, true);
private AttributeDescriptor createAttributeDescriptor( final XSDElementDeclaration elemDecl, int minOccurs, int maxOccurs, CoordinateReferenceSystem crs) { String targetNamespace = elemDecl.getTargetNamespace(); String name = elemDecl.getName(); Name elemName = Types.typeName(targetNamespace, name); AttributeType type = getTypeOf(elemDecl, crs); boolean nillable = elemDecl.isNillable(); Object defaultValue = null; AttributeDescriptor descriptor = createAttributeDescriptor(type, crs, elemName, minOccurs, maxOccurs, nillable, defaultValue); descriptor.getUserData().put(XSDElementDeclaration.class, elemDecl); return descriptor; }
/** * Get the type registry, creating it first if necessary. * * @return the type registry. Guaranteed non-null. */ private FeatureTypeRegistry getFeatureTypeRegistry() { if (this.typeRegistry == null) { this.typeRegistry = new FeatureTypeRegistry( new ComplexFeatureTypeFactoryImpl(), new GmlFeatureTypeRegistryConfiguration(null)); } return this.typeRegistry; }
private AttributeDescriptor createAttributeDescriptor(final XSDComplexTypeDefinition container, final XSDElementDeclaration elemDecl, CoordinateReferenceSystem crs) { int minOccurs = container == null ? 0 : Schemas.getMinOccurs(container, elemDecl); int maxOccurs = container == null ? Integer.MAX_VALUE : Schemas.getMaxOccurs(container, elemDecl); return createAttributeDescriptor(elemDecl, minOccurs, maxOccurs, crs); }
public FeatureTypeRegistry( NamespaceSupport namespaces, FeatureTypeFactory typeFactory, FeatureTypeRegistryConfiguration helper, boolean includeAttributes) { schemas = new ArrayList<SchemaIndex>(); this.typeFactory = typeFactory; descriptorRegistry = new HashMap<Name, AttributeDescriptor>(); typeRegistry = new HashMap<Name, AttributeType>(); anonTypeRegistry = new HashMap<Name, AttributeType>(); processingTypes = new Stack<Name>(); this.helper = helper; this.includeAttributes = includeAttributes; createFoundationTypes(); }
typeRegistry.disposeSchemaIndexes(); typeRegistry = null;
@Test public void testSimpleAttributeFromComplexDeclaration() throws Exception { String res = "/test-data/complexFeature.xsd"; URL resource = getClass().getResource(res); SchemaIndex schemaIndex = EmfAppSchemaReader.newInstance().parse(resource); FeatureTypeRegistry registry = new FeatureTypeRegistry(); try { registry.addSchemas(schemaIndex); Name tcl = Types.typeName(NS_URI, "TypedCategoryListType"); AttributeType typedCategoryListType = registry.getAttributeType(tcl); Assert.assertNotNull(typedCategoryListType); Assert.assertTrue(typedCategoryListType instanceof ComplexType); AttributeType superType = typedCategoryListType.getSuper(); Assert.assertNotNull(superType); Name superName = superType.getName(); Assert.assertEquals(XS.STRING.getNamespaceURI(), superName.getNamespaceURI()); Assert.assertEquals(XS.STRING.getLocalPart(), superName.getLocalPart()); Assert.assertNotNull(typedCategoryListType.getUserData().get(XSDTypeDefinition.class)); } finally { registry.disposeSchemaIndexes(); } }
createProxiedType( assignedName, typeDefinition, if (name != null) { Name baseTypeName = new NameImpl(targetNamespace, name); superType = getAttributeType(baseTypeName, baseType, crs); childDecl = (XSDElementDeclaration) it.next(); try { descriptor = createAttributeDescriptor(complexTypeDef, childDecl, crs); } catch (NoSuchElementException e) { String msg = XSDAttributeDeclaration att = attgcontent.getContent(); descriptor = createAttributeDescriptor( getXmlAttributeType(), null, new NameImpl(null, "@" + att.getName()), setSubstitutionGroup(complexTypeDef, elemDecl, att, crs); attType = createComplexAttributeType(assignedName, schema, complexTypeDef, superType); } else { Class<?> binding = String.class; register(attType, anonymous);
|| !(sub.getTargetNamespace().equals(elemDecl.getTargetNamespace()))) { Name elemName = Types.typeName(sub.getTargetNamespace(), sub.getName()); AttributeType type = getTypeOf(sub, crs); if (type != null) { substitutionGroup.add( createAttributeDescriptor( type, crs, elemName, minOccurs, maxOccurs, nillable, null)); createType(typeName, typeDef, crs, false); LOGGER.finest("Registering attribute type " + typeName); } else if (attType instanceof ComplexType) { setSubstitutionGroup( (XSDComplexTypeDefinition) typeDef, element, childDesc, crs);
public AttributeDescriptor getDescriptor(final Name descriptorName, XSDComplexTypeDefinition typeDef, XSDElementDeclaration elemDecl, CoordinateReferenceSystem crs) { AttributeDescriptor descriptor = descriptorRegistry.get(descriptorName); if (descriptor == null) { try { if (elemDecl == null) { elemDecl = getElementDeclaration(descriptorName); } } catch (NoSuchElementException e) { String msg = "Type not found for " + descriptorName + " at type container " + (typeDef == null ? null : typeDef.getTargetNamespace() + "#" + typeDef.getName() + " at " + typeDef.getSchema().getSchemaLocation()); NoSuchElementException nse = new NoSuchElementException(msg); nse.initCause(e); throw nse; } descriptor = createAttributeDescriptor(typeDef, elemDecl, crs); LOGGER.finest("Registering attribute descriptor " + descriptor.getName()); register(descriptor); } return descriptor; }