/** @return The {@link XSDSchema} representation of the schema. */ public XSDSchema schema(String baseUrl) throws IOException { return builder.build(new FeatureTypeInfo[] {featureType}, baseUrl); }
@Override protected XSDSchema buildSchema() throws IOException { FeatureTypeInfo[] types = this.featureTypes .values() .stream() .flatMap(Collection::stream) .toArray(FeatureTypeInfo[]::new); XSDSchema schema; if (containsComplexTypes(types)) { // we have complex features so we add all the available catalog feature types schema = schemaBuilder.build(new FeatureTypeInfo[0], baseURL, true, true); schemaBuilder.addApplicationTypes(schema); } else { // simple feature so we add only the feature types we need schema = schemaBuilder.build(types, baseURL, true, true); } // add an explicit dependency on WFS 1.0.0 schema return importWfsSchema(schema); }
public XSDSchema build( FeatureTypeInfo[] featureTypeInfos, String baseUrl, boolean resolveAppSchemaImports, boolean scheduleSchemaCleanup) throws IOException { // build the schema and make sure to schedule it for destruction at the end of the request XSDSchema schema = buildSchemaInternal(featureTypeInfos, baseUrl, resolveAppSchemaImports); if (schema != null && scheduleSchemaCleanup) { SchemaCleanerCallback.addSchema(schema); } return schema; }
importGMLSchema(schema, factory, baseUrl); schema.setTargetNamespace(gmlSchema().getTargetNamespace()); } else if (ns2featureTypeInfos.entrySet().size() == 1) { boolean simple = isSimpleFeature(featureTypeInfos); addAllNamespacesFromCatalog(schema); if (!findTypeInSchema(featureTypeInfos[0], schema, factory)) { addReference( schema, factory, importGMLSchema(schema, factory, baseUrl); buildSchemaContent(featureTypeInfos[i], schema, factory, baseUrl); } catch (Exception e) { logger.log( if (!isSimpleFeature(featureTypeInfos)) { addAllNamespacesFromCatalog(schema); addReference( schema, factory, build( featureTypes.toArray(
resolveTypeInSchema(schema, new NameImpl(gmlNamespace, baseType))); AttributeDescriptor attribute = (AttributeDescriptor) pd; if (filterAttributeType(attribute)) { GMLInfo gml = getGMLConfig(gs.getService(WFSInfo.class)); if (gml == null || !gml.getOverrideGMLAttributes()) { continue; typeName.getNamespaceURI(), typeName.getLocalPart()) == null) { buildComplexSchemaContent( (ComplexType) attribute.getType(), schema, factory); typeName = findTypeName(binding); if (typeName == null) { + attribute.getName() + " to String"); typeName = findTypeName(String.class); if (typeName == null) { throw new NullPointerException( XSDTypeDefinition type = resolveTypeInSchema(schema, typeName); element.setTypeDefinition(type);
Map<String, String> imports, Set<String> includes) { if (getWfsSchema() != null && imports.get(getWfsSchema().getTargetNamespace()) == null) { synchronized (Schemas.class) { .put("wfs", getWfsSchema().getTargetNamespace()); XSDImport wfsImport = factory.createXSDImport(); wfsImport.setNamespace(getWfsSchema().getTargetNamespace()); wfsImport.setSchemaLocation(getWfsSchema().getSchemaLocation()); wfsImport.setResolvedSchema(getWfsSchema()); schema.getContents().add(wfsImport); final XSDSchemaImpl wfsSchema = (XSDSchemaImpl) getWfsSchema(); synchronized (wfsSchema.eAdapters()) { wfsSchema.imported(wfsImport); getWfsSchema().getTargetNamespace(), getWfsSchema().getSchemaLocation()); + schema.getTargetNamespace()); } else { addInclude(schema, factory, schemaLocation); includes.add(schemaLocation); addImport(schema, factory, namespace, schemaLocation); imports.put(namespace, schemaLocation);
private void buildSchemaContent( FeatureTypeInfo featureTypeMeta, XSDSchema schema, XSDFactory factory, String baseUrl) throws IOException { if (!findTypeInSchema(featureTypeMeta, schema, factory)) { // build the type manually FeatureType featureType = featureTypeMeta.getFeatureType(); if (featureTypeMeta.isCircularArcPresent() && this.getClass().equals(GML3.class)) { featureType = new CurveTypeWrapper(featureType); } XSDComplexTypeDefinition xsdComplexType = buildComplexSchemaContent(featureType, schema, factory); XSDElementDeclaration element = factory.createXSDElementDeclaration(); element.setName(featureTypeMeta.getName()); element.setTargetNamespace(featureTypeMeta.getNamespace().getURI()); synchronized (Schemas.class) { // this call changes the global schemas too, need to be synchronized element.setSubstitutionGroupAffiliation(getFeatureElement()); } element.setTypeDefinition(xsdComplexType); schema.getContents().add(element); schema.updateElement(); } }
protected boolean filterAttributeType(AttributeDescriptor attribute) { return super.filterAttributeType(attribute) || "metaDataProperty".equals(attribute.getLocalName()) || "location".equals(attribute.getLocalName()); }
/** * Suplements the schema built by the parent by adding hte aplication schema feature typs * defined in GeoServer. */ protected XSDSchema buildSchema() throws IOException { XSDSchema wfsSchema = super.buildSchema(); wfsSchema = schemaBuilder.addApplicationTypes(wfsSchema); return wfsSchema; } }
protected boolean filterAttributeType( AttributeType attribute ) { return super.filterAttributeType( attribute ) || "metaDataProperty".equals( attribute.getName() ) || "location".equals( attribute.getName() ); } }
public XSDSchema build( FeatureTypeInfo[] featureTypeInfos, String baseUrl, int resolveAppSchemaImports) throws IOException { return build(featureTypeInfos, baseUrl, resolveAppSchemaImports != 0, true); }
public XSDSchema build(FeatureTypeInfo[] featureTypeInfos, String baseUrl) throws IOException { return build(featureTypeInfos, baseUrl, true); }
public XSDSchema build(FeatureTypeInfo featureTypeInfo, String baseUrl) throws IOException { return build(new FeatureTypeInfo[] {featureTypeInfo}, baseUrl); }
@Override protected XSDSchema buildSchema() throws IOException { Set<FeatureTypeInfo> types = new HashSet(); for (Set<FeatureTypeInfo> fts : featureTypes.values()) { types.addAll(fts); } XSDSchema schema = schemaBuilder.build(types.toArray(new FeatureTypeInfo[types.size()]), baseURL, 1); // make sure that GML 3.2 namespace is used schema.getQNamePrefixToNamespaceMap().put("gml", GML.NAMESPACE); return schema; } }
public ElementHandler createElementHandler(QName name, Handler parent, ParserHandler parser) { String namespaceURI = name.getNamespaceURI(); if (namespaceURI == null) { // assume default namespaceURI = catalog.getDefaultNamespace().getURI(); } try { // look for a FeatureType FeatureTypeInfo meta = catalog.getFeatureTypeByName(namespaceURI, name.getLocalPart()); if (meta != null) { // found it XSDSchema schema = schemaBuilder.build(meta, null); for (Iterator e = schema.getElementDeclarations().iterator(); e.hasNext(); ) { XSDElementDeclaration element = (XSDElementDeclaration) e.next(); if (name.getLocalPart().equals(element.getName())) { return new ElementHandlerImpl(element, parent, parser); } } } } catch (IOException e) { logger.log(Level.WARNING, "Error building schema", e); } return null; }
protected void doWrite( FeatureTypeInfo[] featureTypeInfos, OutputStream output, Operation describeFeatureType) throws IOException { // create the schema Object request = describeFeatureType.getParameters()[0]; DescribeFeatureTypeRequest req = DescribeFeatureTypeRequest.adapt(request); XSDSchema schema = schemaBuilder.build(featureTypeInfos, req.getBaseURL()); // serialize schema.updateElement(); final String encoding = gs.getSettings().getCharset(); XSDResourceImpl.serialize(output, schema.getElement(), encoding); }
public void write(Object value, OutputStream output, Operation describeFeatureType) throws IOException { VersionedDescribeResults results = (VersionedDescribeResults) value; // create the schema DescribeFeatureTypeType req = (DescribeFeatureTypeType) describeFeatureType .getParameters()[0]; String proxifiedBaseUrl = RequestUtils.proxifiedBaseURL(req .getBaseUrl(), wfs.getGeoServer().getProxyBaseUrl()); FeatureTypeSchemaBuilder builder = null; if (results.isVersioned()) { builder = new VersionedSchemaBuilder(wfs, catalog, resourceLoader, configuration); } else { builder = new FeatureTypeSchemaBuilder.GML3(wfs, catalog, resourceLoader); } XSDSchema schema = builder.build(results.getFeatureTypeInfo(), proxifiedBaseUrl); // serialize schema.updateElement(); XSDResourceImpl.serialize(output, schema.getElement()); }
@Test public void testBuildGml2() throws Exception { FeatureTypeSchemaBuilder builder = new FeatureTypeSchemaBuilder.GML2(getGeoServer()); FeatureTypeInfo lines = getFeatureTypeInfo(SystemTestData.LINES); XSDSchema schema = builder.build(new FeatureTypeInfo[] {lines}, null); assertNotNull(schema); XSDElementDeclaration element = Schemas.getElementDeclaration(schema, SystemTestData.LINES); assertNotNull(element); assertTrue(element.getType() instanceof XSDComplexTypeDefinition); XSDElementDeclaration id = Schemas.getChildElementDeclaration( element, new QName(SystemTestData.CGF_URI, "id")); assertNotNull(id); XSDElementDeclaration lineStringProperty = Schemas.getChildElementDeclaration( element, new QName(SystemTestData.CGF_URI, "lineStringProperty")); assertNotNull(lineStringProperty); XSDTypeDefinition lineStringPropertyType = lineStringProperty.getType(); assertEquals(GML.NAMESPACE, lineStringPropertyType.getTargetNamespace()); assertEquals(GML.LINESTRINGPROPERTYTYPE.getLocalPart(), lineStringPropertyType.getName()); XSDTypeDefinition geometryAssociationType = lineStringPropertyType.getBaseType(); assertNotNull(geometryAssociationType); assertEquals(GML.NAMESPACE, geometryAssociationType.getTargetNamespace()); assertEquals(GML.GEOMETRYASSOCIATIONTYPE.getLocalPart(), geometryAssociationType.getName()); }