/** * Exports the given {@link Property}. * * @param prop * property to be exported, must not be <code>null</code> * @throws XMLStreamException * @throws UnknownCRSException * @throws TransformationException */ public void export( Property prop ) throws XMLStreamException, UnknownCRSException, TransformationException { export( prop, referenceExportStrategy.getResolveOptions() ); }
public void export( TypedObjectNode node, GmlXlinkOptions resolveState ) throws XMLStreamException, UnknownCRSException, TransformationException { if ( node instanceof GMLObject ) { if ( node instanceof Feature ) { export( (Feature) node, resolveState ); } else if ( node instanceof Geometry ) { gmlStreamWriter.getGeometryWriter().export( (Geometry) node ); } else { throw new UnsupportedOperationException(); } } else if ( node instanceof PrimitiveValue ) { writer.writeCharacters( ( (PrimitiveValue) node ).getAsText() ); } else if ( node instanceof Property ) { export( (Property) node, resolveState ); } else if ( node instanceof ElementNode ) { ElementNode xmlContent = (ElementNode) node; exportGenericXmlElement( xmlContent, resolveState ); } else if ( node instanceof TypedObjectNodeArray<?> ) { for ( TypedObjectNode elem : ( (TypedObjectNodeArray<?>) node ).getElements() ) { export( elem, resolveState ); } } else if ( node == null ) { LOG.warn( "Null node encountered!?" ); } else { throw new RuntimeException( "Unhandled node type '" + node.getClass() + "'" ); } }
private void exportFeatureProperty( FeaturePropertyType pt, Feature subFeature, Map<QName, PrimitiveValue> attributes, GmlXlinkOptions resolveState ) throws XMLStreamException, UnknownCRSException, TransformationException { QName propName = pt.getName(); LOG.debug( "Exporting feature property '" + propName + "'" ); if ( subFeature == null ) { exportEmptyProperty( propName, attributes ); } else if ( subFeature instanceof FeatureReference ) { exportFeatureProperty( pt, (FeatureReference) subFeature, resolveState, propName ); } else { // normal feature String subFid = subFeature.getId(); if ( subFid == null ) { // no feature id -> no other chance, but inlining it writeStartElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); writer.writeComment( "Inlined feature '" + subFid + "'" ); export( subFeature, getResolveStateForNextLevel( resolveState ) ); writer.writeEndElement(); } else { // has feature id if ( referenceExportStrategy.isObjectExported( subFid ) ) { exportAlreadyExportedFeaturePropertyByReference( subFeature, propName ); } else { exportFeaturePropertyByValue( propName, subFeature, resolveState ); } } } }
private void exportGenericObjectProperty( final Property prop, final GMLObject object, final GmlXlinkOptions resolveState ) throws XMLStreamException, UnknownCRSException, TransformationException { final ObjectPropertyType pt = (ObjectPropertyType) prop.getType(); final QName propName = pt.getName(); LOG.debug( "Exporting object property '" + propName + "'" ); if ( object == null ) { exportEmptyProperty( propName, prop.getAttributes() ); } else { writeStartElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); switch ( pt.getCategory() ) { case TIME_OBJECT: new GmlTimeGeometricPrimitiveWriter().write( writer, (TimeGeometricPrimitive) object ); break; case TIME_SLICE: export( (TimeSlice) object, resolveState ); break; default: throw new RuntimeException(); } writer.writeEndElement(); } }
private void exportGenericXmlElement( ElementNode xmlContent, GmlXlinkOptions resolveState ) throws XMLStreamException, UnknownCRSException, TransformationException { QName elName = xmlContent.getName(); LOG.debug( "Exporting " + elName ); XSElementDeclaration elDecl = xmlContent.getXSType(); if ( elDecl != null && schemaInfoset != null ) { ObjectPropertyType gmlPropertyDecl = schemaInfoset.getGMLPropertyDecl( elDecl, elName, 0, 1, null ); if ( gmlPropertyDecl instanceof FeaturePropertyType ) { List<TypedObjectNode> children = xmlContent.getChildren(); if ( children != null && children.size() == 1 && children.get( 0 ) instanceof Feature ) { LOG.debug( "Exporting as nested feature property." ); exportFeatureProperty( (FeaturePropertyType) gmlPropertyDecl, (Feature) children.get( 0 ), null, resolveState ); return; } } } writeStartElementWithNS( elName.getNamespaceURI(), elName.getLocalPart() ); writeAttributes (xmlContent.getAttributes()); if ( xmlContent.getChildren() != null ) { for ( TypedObjectNode childNode : xmlContent.getChildren() ) { export( childNode, resolveState ); } } writer.writeEndElement(); }
/** * Exports the given {@link Feature} (or {@link FeatureCollection}). * * @param feature * feature to be exported, must not be <code>null</code> * @throws XMLStreamException * @throws UnknownCRSException * @throws TransformationException */ public void export( Feature feature ) throws XMLStreamException, UnknownCRSException, TransformationException { export( feature, referenceExportStrategy.getResolveOptions() ); }
/** * Writes a GML representation of the given {@link Feature} to the stream. * * @param feature * feature to be written, must not be <code>null</code> * @throws XMLStreamException * @throws UnknownCRSException * @throws TransformationException */ public void write( Feature feature ) throws XMLStreamException, UnknownCRSException, TransformationException { getFeatureWriter().export( feature ); }
protected void writeMemberFeature( Feature member, GMLStreamWriter gmlStream, XMLStreamWriter xmlStream, GmlXlinkOptions resolveState, QName featureMemberEl ) throws XMLStreamException, UnknownCRSException, TransformationException { if ( gmlStream.getReferenceResolveStrategy().isObjectExported( member.getId() ) ) { xmlStream.writeEmptyElement( featureMemberEl.getNamespaceURI(), featureMemberEl.getLocalPart() ); if ( xmlStream.getPrefix( XLNNS ) == null ) { xmlStream.setPrefix( "xlink", XLNNS ); xmlStream.writeNamespace( "xlink", XLNNS ); } xmlStream.writeAttribute( "xlink", XLNNS, "href", "#" + member.getId() ); } else { xmlStream.writeStartElement( featureMemberEl.getNamespaceURI(), featureMemberEl.getLocalPart() ); gmlStream.getFeatureWriter().export( member, resolveState ); xmlStream.writeEndElement(); } }
private void exportFeaturePropertyByValue( QName propName, Feature subFeature, GmlXlinkOptions resolveState ) throws XMLStreamException, UnknownCRSException, TransformationException { referenceExportStrategy.addExportedId( subFeature.getId() ); writeStartElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); writer.writeComment( "Inlined feature '" + subFeature.getId() + "'" ); export( subFeature, getResolveStateForNextLevel( resolveState ) ); writer.writeEndElement(); }
} else { xmlStream.writeStartElement( WFS_200_NS, "member" ); featureWriter.export( value, resolveState ); xmlStream.writeEndElement(); numberReturned++;
featureWriter.export( value, resolveState ); xmlStream.writeEndElement();
public void export( final TimeSlice timeSlice, final GmlXlinkOptions resolveState ) throws XMLStreamException, UnknownCRSException, TransformationException { if ( timeSlice.getId() != null ) { referenceExportStrategy.addExportedId( timeSlice.getId() ); } final QName featureName = timeSlice.getType().getName(); LOG.debug( "Exporting TimeSlice {} with ID {}", featureName, timeSlice.getId() ); final String namespaceURI = featureName.getNamespaceURI(); final String localName = featureName.getLocalPart(); writeStartElementWithNS( namespaceURI, localName ); if ( timeSlice.getId() != null ) { if ( fidAttr.getNamespaceURI() == "" ) { writer.writeAttribute( fidAttr.getLocalPart(), timeSlice.getId() ); } else { writeAttributeWithNS( fidAttr.getNamespaceURI(), fidAttr.getLocalPart(), timeSlice.getId() ); } } for ( final Property prop : timeSlice.getProperties() ) { export( prop, resolveState ); } writer.writeEndElement(); }
gmlStream.getFeatureWriter().export( member, resolveState ); break;
private void exportStandardProps( Geometry geom ) throws XMLStreamException, UnknownCRSException, TransformationException { if ( geom.getProperties() != null ) { for ( Property prop : geom.getProperties() ) { if ( isStandardProperty( prop.getName() ) ) { gmlStreamWriter.getFeatureWriter().export( prop ); } } } }
private void exportAdditionalProps( Geometry geom ) throws XMLStreamException, UnknownCRSException, TransformationException { if ( geom.getProperties() != null ) { for ( Property prop : geom.getProperties() ) { if ( !isStandardProperty( prop.getName() ) ) { gmlStreamWriter.getFeatureWriter().export( prop ); } } } }
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() ); }