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, 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; }
build( featureTypes.toArray( new FeatureTypeInfo[featureTypes.size()]),
public XSDSchema build(FeatureTypeInfo featureTypeInfo, String baseUrl) throws IOException { return build(new FeatureTypeInfo[] {featureTypeInfo}, baseUrl); }
/** @return The {@link XSDSchema} representation of the schema. */ public XSDSchema schema(String baseUrl) throws IOException { return builder.build(new FeatureTypeInfo[] {featureType}, baseUrl); }
public XSDSchema build(FeatureTypeInfo[] featureTypeInfos, String baseUrl) throws IOException { return build(featureTypeInfos, baseUrl, true); }
@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; } }
@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 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()); }