private GMLObjectType getType( XMLStreamReader xmlStream ) { GMLObjectType type = null; if ( schema != null && schema.getGMLSchema() != null ) { QName name = xmlStream.getName(); type = schema.getGeometryType( name ); if ( type == null ) { LOG.debug( "GML geometry element '" + name + "' is not defined in application schema!?" ); } } return type; }
private void setSchema( Feature feature ) { if ( schema == null ) { schema = feature.getType().getSchema(); if ( schema != null ) { schemaInfoset = schema.getGMLSchema(); } } }
private AppSchema buildGMLSchema( String configURL, List<String> gmlSchemas ) throws FeatureStoreException { LOG.debug( "Building application schema from GML schema files." ); AppSchema appSchema = null; try { XMLAdapter resolver = new XMLAdapter(); resolver.setSystemId( configURL ); String[] schemaURLs = new String[gmlSchemas.size()]; int i = 0; for ( String gmlSchema : gmlSchemas ) { schemaURLs[i++] = resolver.resolve( gmlSchema.trim() ).toString(); } GMLAppSchemaReader decoder = null; if ( schemaURLs.length == 1 && schemaURLs[0].startsWith( "file:" ) ) { File file = new File( new URL( schemaURLs[0] ).toURI() ); decoder = new GMLAppSchemaReader( null, null, file ); } else { decoder = new GMLAppSchemaReader( null, null, schemaURLs ); } appSchema = decoder.extractAppSchema(); } catch ( Throwable t ) { t.printStackTrace(); String msg = "Error building GML application schema: " + t.getMessage(); throw new FeatureStoreException( msg ); } LOG.debug( "GML version: " + appSchema.getGMLSchema().getVersion() ); return appSchema; }
/** * Returns the {@link MappedAppSchema} derived from GML application schemas / configuration. * * @return mapped application schema, never <code>null</code> */ @Override public MappedAppSchema getMappedSchema() { FeatureType[] fts = gmlSchema.getFeatureTypes(); org.deegree.feature.persistence.sql.FeatureTypeMapping[] ftMappings = ftNameToMapping.values().toArray( new org.deegree.feature.persistence.sql.FeatureTypeMapping[ftNameToMapping.size()] ); Map<FeatureType, FeatureType> ftToSuperFt = gmlSchema.getFtToSuperFt(); Map<String, String> prefixToNs = new HashMap<String, String>(); Iterator<String> prefixIter = nsBindings.getPrefixes(); while ( prefixIter.hasNext() ) { String prefix = prefixIter.next(); prefixToNs.put( prefix, nsBindings.getNamespaceURI( prefix ) ); } GMLSchemaInfoSet xsModel = gmlSchema.getGMLSchema(); return new MappedAppSchema( fts, ftToSuperFt, prefixToNs, xsModel, ftMappings, bboxMapping, blobMapping, geometryParams, deleteCascadingByDB, null, gmlSchema.getGmlObjectTypes(), gmlSchema.getGeometryToSuperType() ); }
GMLVersion gmlVersion = getAppSchema().getGMLSchema().getVersion(); return new GetFeatureResponse<Feature>( response, getAppSchema(), gmlVersion );
private BlobMapping generateBlobMapping() { // TODO String table = "GML_OBJECTS"; // TODO BlobCodec codec = new BlobCodec( appSchema.getGMLSchema().getVersion(), NONE ); return new BlobMapping( table, geometryParams.getCrs(), codec ); }
schemaNSBindings = gmlSchema.getGMLSchema().getNamespacePrefixes(); for ( String prefix : schemaNSBindings.keySet() ) { String nsUri = schemaNSBindings.get( prefix );
private GMLSchemaInfoSet findGmlSchema( Collection<String> namespaces, GMLVersion version ) { LOG.debug( "Try to find GML schema from store supporting namespaces {}", namespaces ); WfsFeatureStoreManager storeManager = format.getMaster().getStoreManager(); for ( FeatureStore store : storeManager.getStores() ) { if ( storeSupportsAllRequestedNamespaces( store, namespaces ) ) { GMLSchemaInfoSet gmlSchema = store.getSchema().getGMLSchema(); if ( gmlSchema != null && gmlSchema.getVersion() == version ) return gmlSchema; } } return null; }
private FeatureTypeMapping buildFtMapping( FeatureTypeMappingJAXB ftMappingConf ) throws FeatureStoreException { QName ftName = ftMappingConf.getName(); TableName ftTable = new TableName( ftMappingConf.getTable() ); FIDMapping fidMapping = buildFIDMapping( ftTable, ftName, ftMappingConf.getFIDMapping() ); List<Mapping> particleMappings = new ArrayList<Mapping>(); XSElementDeclaration elDecl = gmlSchema.getGMLSchema().getElementDecl( ftName ); for ( JAXBElement<? extends AbstractParticleJAXB> particle : ftMappingConf.getAbstractParticle() ) { particleMappings.add( buildMapping( ftTable, new Pair<XSElementDeclaration, Boolean>( elDecl, TRUE ), particle.getValue() ) ); } return new FeatureTypeMapping( ftName, ftTable, fidMapping, particleMappings ); }
List<FeatureType> blackList = new ArrayList<FeatureType>(); for ( FeatureType ft : ftList ) { if ( ft.getName().getNamespaceURI().equals( appSchema.getGMLSchema().getVersion().getNamespace() ) ) { blackList.add( ft ); GMLSchemaInfoSet xsModel = appSchema.getGMLSchema();
private Property recreatePropertyFromGml( final PropertyType pt, final GenericXMLElement particle ) { try { final GMLSchemaInfoSet gmlSchema = ft.getSchema().getGMLSchema(); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final XMLStreamWriter xmlWriter = XMLOutputFactory.newInstance().createXMLStreamWriter( bos ); final GMLVersion version = ft.getSchema().getGMLSchema().getVersion(); final GMLStreamWriter gmlWriter = GMLOutputFactory.createGMLStreamWriter( version, xmlWriter ); gmlWriter.setNamespaceBindings( gmlSchema.getNamespacePrefixes() ); final GmlXlinkOptions resolveState = new GmlXlinkOptions(); gmlWriter.getFeatureWriter().export( particle, resolveState ); gmlWriter.close(); xmlWriter.close(); bos.close(); final InputStream is = new ByteArrayInputStream( bos.toByteArray() ); final XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader( is ); final GMLStreamReader gmlReader = GMLInputFactory.createGMLStreamReader( version, xmlReader ); gmlReader.setApplicationSchema( ft.getSchema() ); gmlReader.setLaxMode( true ); final Property property = gmlReader.getFeatureReader().parseProperty( new XMLStreamReaderWrapper( xmlReader, null ), pt, null ); return property; } catch ( final Exception e ) { LOG.error( e.getMessage(), e ); } return new GenericProperty( pt, particle.getName(), null, particle.getAttributes(), particle.getChildren() ); }
GMLSchemaInfoSet analyzer = ft.getSchema().getGMLSchema(); if ( analyzer == null ) { if ( hasSubTypes ) {
/** * Performs the given {@link GetFeature} request. * * @return WFS response, never <code>null</code> * @throws OWSExceptionReport * if the server responded with a service exception report * @throws XMLStreamException * @throws IOException */ public GetFeatureResponse<Feature> doGetFeature( GetFeature request ) throws OWSExceptionReport, XMLStreamException, IOException { URL endPoint = getPostUrl( GetFeature.name() ); StreamBufferStore requestSink = new StreamBufferStore(); try { XMLStreamWriter xmlWriter = XMLOutputFactory.newInstance().createXMLStreamWriter( requestSink ); // TODO handle other WFS versions GetFeature110XMLEncoder.export( request, null, xmlWriter ); xmlWriter.close(); requestSink.close(); } catch ( Throwable t ) { throw new RuntimeException( "Error creating XML request: " + request ); } OwsHttpResponse response = httpClient.doPost( endPoint, "text/xml", requestSink, null ); GMLVersion gmlVersion = getAppSchema().getGMLSchema().getVersion(); return new GetFeatureResponse<Feature>( response, getAppSchema(), gmlVersion ); }
List<XSElementDeclaration> substitutions = appSchema.getGMLSchema().getSubstitutions( elDecl, null, true, true ); for ( XSElementDeclaration substitution : substitutions ) { ObjectPropertyType opt = appSchema.getGMLSchema().getCustomElDecl( substitution );
if ( !pt.getName().getNamespaceURI().equals( appSchema.getGMLSchema().getVersion().getNamespace() ) ) { mappings.addAll( generatePropMapping( pt, mc ) ); } else if ( pt.getName().getLocalPart().equals( "identifier" ) ) {
node = parseSimpleXMLElement( xmlStream, elDecl ); } else { ObjectPropertyType propDecl = schema.getGMLSchema().getCustomElDecl( elDecl ); if ( propDecl != null ) { node = parseObjectProperty( xmlStream, propDecl, crs );
XSElementDeclaration elDecl = (XSElementDeclaration) term.first; if ( elDecl.getScope() == XSConstants.SCOPE_GLOBAL ) { for ( XSElementDeclaration substitution : appSchema.getGMLSchema().getSubstitutions( elDecl, null, true, false ) ) { QName elDeclName = getQName( substitution );
public MappedSchemaBuilderGML( String configURL, List<String> gmlSchemas, StorageCRS storageCRS, List<NamespaceHint> nsHints, BLOBMapping blobConf, List<FeatureTypeMappingJAXB> ftMappingConfs, boolean deleteCascadingByDB ) throws FeatureStoreException { gmlSchema = buildGMLSchema( configURL, gmlSchemas ); CRSRef crs = CRSManager.getCRSRef( storageCRS.getValue() ); CoordinateDimension dim = crs.getDimension() == 3 ? DIM_3 : DIM_2; geometryParams = new GeometryStorageParams( crs, storageCRS.getSrid(), dim ); // add namespace bindings addNamespaceBindings( configURL, gmlSchema, nsHints ); schemaWalker = new XPathSchemaWalker( gmlSchema, nsBindings ); if ( blobConf != null ) { Pair<BlobMapping, BBoxTableMapping> pair = buildBlobMapping( blobConf, gmlSchema.getGMLSchema().getVersion() ); blobMapping = pair.first; bboxMapping = pair.second; } if ( ftMappingConfs != null ) { for ( FeatureTypeMappingJAXB ftMappingConf : ftMappingConfs ) { org.deegree.feature.persistence.sql.FeatureTypeMapping ftMapping = buildFtMapping( ftMappingConf ); ftNameToMapping.put( ftMapping.getFeatureType(), ftMapping ); } } this.deleteCascadingByDB = deleteCascadingByDB; }
private GeometryMapping buildMapping( TableName currentTable, Pair<XSElementDeclaration, Boolean> elDecl, GeometryParticleJAXB config ) { ValueReference path = new ValueReference( config.getPath(), nsBindings ); MappingExpression me = parseMappingExpression( config.getMapping() ); elDecl = schemaWalker.getTargetElement( elDecl, path ); QName ptName = new QName( elDecl.first.getNamespace(), elDecl.getFirst().getName() ); ObjectPropertyType pt = gmlSchema.getGMLSchema().getGMLPropertyDecl( elDecl.first, ptName, 1, 1, null ); GeometryType type = GeometryType.GEOMETRY; if ( pt instanceof GeometryPropertyType ) { type = ( (GeometryPropertyType) pt ).getGeometryType(); } boolean escalateVoid = determineParticleVoidability( elDecl.second, config.getNullEscalation() ); List<TableJoin> joinedTable = buildJoinTable( currentTable, config.getJoin() ); return new GeometryMapping( path, escalateVoid, me, type, geometryParams, joinedTable, config.getCustomConverter() ); }
private FeatureMapping buildMapping( TableName currentTable, Pair<XSElementDeclaration, Boolean> elDecl, FeatureParticleJAXB config ) { ValueReference path = new ValueReference( config.getPath(), nsBindings ); MappingExpression hrefMe = null; if ( config.getHref() != null ) { hrefMe = parseMappingExpression( config.getHref().getMapping() ); } elDecl = schemaWalker.getTargetElement( elDecl, path ); QName ptName = new QName( elDecl.first.getNamespace(), elDecl.first.getName() ); // TODO rework this FeaturePropertyType pt = (FeaturePropertyType) gmlSchema.getGMLSchema().getGMLPropertyDecl( elDecl.first, ptName, 0, 1, null ); boolean escalateVoid = determineParticleVoidability( elDecl.second, config.getNullEscalation() ); List<TableJoin> joinedTable = buildJoinTable( currentTable, config.getJoin() ); return new FeatureMapping( path, escalateVoid, hrefMe, pt.getFTName(), joinedTable, config.getCustomConverter() ); }