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 ); } } } }
public GMLFeatureWriter getFeatureWriter() { if ( featureWriter == null ) { featureWriter = new GMLFeatureWriter( this ); } return featureWriter; }
private void exportFeaturePropertyByReference( QName propName, FeatureReference ref, boolean forceInclusionInDocument, GmlXlinkOptions resolveState ) throws XMLStreamException { writeEmptyElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); String uri = null; if ( forceInclusionInDocument ) { resolveState = getResolveStateForNextLevel( resolveState ); uri = referenceExportStrategy.requireObject( ref, resolveState ); } else { uri = referenceExportStrategy.handleReference( ref ); } writeAttributeWithNS( XLNNS, "href", uri ); endEmptyElement(); }
private void exportEmptyProperty( final QName propName, final Map<QName,PrimitiveValue> attrs) throws XMLStreamException { writeEmptyElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); writeAttributes( attrs ); endEmptyElement(); }
private void writeNilledElement( QName propName, Map<QName, PrimitiveValue> attributes ) throws XMLStreamException { writeEmptyElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); writeNilAttributes( attributes ); endEmptyElement(); }
private void exportAlreadyExportedFeaturePropertyByReference( Feature ref, QName propName ) throws XMLStreamException { writeEmptyElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); writeAttributeWithNS( XLNNS, "href", "#" + ref.getId() ); endEmptyElement(); }
if ( pt.getMinOccurs() == 0 ) { LOG.debug( "Optional property '" + propName + "', checking if it is requested." ); if ( !isPropertyRequested( propName ) ) { LOG.debug( "Skipping it." ); return; resolveState = getResolveParams( property, resolveState ); writeNilledElement( propName, attributes ); } else { exportFeatureProperty( (FeaturePropertyType) pt, (Feature) value, attributes, resolveState ); writeNilledElement( propName, attributes ); } else { writeStartElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); if ( pValue != null ) { writer.writeCharacters( pValue.getAsText() ); writeNilledElement( propName, attributes ); } else if ( value == null ) { writeEmptyElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); endEmptyElement(); } else { Geometry gValue = (Geometry) value; if ( !exportSf && gValue.getId() != null && referenceExportStrategy.isObjectExported( gValue.getId() ) ) { writeEmptyElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); writeAttributeWithNS( XLNNS, "href", "#" + gValue.getId() ); endEmptyElement();
setSchema( feature ); writeStartElementWithNS( gmlNs, "FeatureCollection" ); if ( feature.getId() != null ) { if ( fidAttr.getNamespaceURI() == "" ) { writer.writeAttribute( fidAttr.getLocalPart(), feature.getId() ); } else { writeAttributeWithNS( fidAttr.getNamespaceURI(), fidAttr.getLocalPart(), feature.getId() ); exportBoundedBy( feature.getEnvelope(), false ); for ( Feature member : ( (FeatureCollection) feature ) ) { String memberFid = member.getId(); writeStartElementWithNS( gmlNs, "featureMember" ); if ( memberFid != null && referenceExportStrategy.isObjectExported( memberFid ) ) { writeAttributeWithNS( XLNNS, "href", "#" + memberFid ); } else { export( member, getResolveStateForNextLevel( resolveState ) ); String namespaceURI = featureName.getNamespaceURI(); String localName = featureName.getLocalPart(); writeStartElementWithNS( namespaceURI, localName ); writer.writeAttribute( fidAttr.getLocalPart(), feature.getId() ); } else { writeAttributeWithNS( fidAttr.getNamespaceURI(), fidAttr.getLocalPart(), feature.getId() ); props = augmentBoundedBy( feature ); export( prop, resolveState );
/** * 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() ); }
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(); }
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(); }
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(); } }
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(); }
private void exportFeatureProperty( FeaturePropertyType pt, FeatureReference ref, GmlXlinkOptions resolveState, QName propName ) throws XMLStreamException, UnknownCRSException, TransformationException { boolean includeNextLevelInOutput = includeNextLevelInOutput( resolveState ); if ( includeNextLevelInOutput ) { if ( pt.getAllowedRepresentation() == REMOTE ) { exportFeaturePropertyByReference( propName, ref, true, resolveState ); } else { if ( referenceExportStrategy.isObjectExported( ref.getId() ) ) { exportAlreadyExportedFeaturePropertyByReference( ref, propName ); } else { exportFeaturePropertyByValue( propName, ref, resolveState ); } } } else { exportFeaturePropertyByReference( propName, ref, false, resolveState ); } }
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() + "'" ); } }
/** * 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(); } }
featureWriter.export( value, resolveState ); xmlStream.writeEndElement();
} else { xmlStream.writeStartElement( WFS_200_NS, "member" ); featureWriter.export( value, resolveState ); xmlStream.writeEndElement(); numberReturned++;