use of org.n52.shetland.w3c.SchemaLocation in project arctic-sea by 52North.
the class GetDataAvailabilityV20StreamWriter method writeGetDataAvailabilityResponse.
@Override
protected void writeGetDataAvailabilityResponse() throws XMLStreamException, EncodingException {
start(GetDataAvailabilityConstants.GDA_GET_DATA_AVAILABILITY_20_RESPONSE);
namespace(GetDataAvailabilityConstants.NS_GDA_PREFIX, GetDataAvailabilityConstants.NS_GDA_20);
namespace(GmlConstants.NS_GML_PREFIX, GmlConstants.NS_GML_32);
namespace(SweConstants.NS_SWE_PREFIX, SweConstants.NS_SWE_20);
namespace(W3CConstants.NS_XLINK_PREFIX, W3CConstants.NS_XLINK);
schemaLocation(Sets.newHashSet(GetDataAvailabilityConstants.GET_DATA_AVAILABILITY_20_SCHEMA_LOCATION));
for (DataAvailability da : getElement()) {
wirteDataAvailabilityMember(da);
}
end(GetDataAvailabilityConstants.GDA_GET_DATA_AVAILABILITY_20_RESPONSE);
}
use of org.n52.shetland.w3c.SchemaLocation in project arctic-sea by 52North.
the class GetFeatureOfInterestXmlStreamWriter method writeGetFeatureOfInterestResponseDoc.
private void writeGetFeatureOfInterestResponseDoc() throws XMLStreamException, EncodingException {
start(Sos2StreamingConstants.QN_GET_FEATURE_OF_INTEREST_RESPONSE);
namespace(W3CConstants.NS_XLINK_PREFIX, W3CConstants.NS_XLINK);
namespace(Sos2Constants.NS_SOS_PREFIX, Sos2Constants.NS_SOS_20);
// write schemaLocation
schemaLocation(getSchemaLocation());
AbstractFeature feature = getElement().getAbstractFeature();
if (feature instanceof FeatureCollection) {
for (AbstractFeature f : (FeatureCollection) feature) {
writeFeatureMember(f);
}
} else if (feature instanceof AbstractSamplingFeature) {
writeFeatureMember(feature);
}
end(Sos2StreamingConstants.QN_GET_FEATURE_OF_INTEREST_RESPONSE);
}
use of org.n52.shetland.w3c.SchemaLocation in project arctic-sea by 52North.
the class UpdateSensorResponseEncoderTest method should_return_correct_schema_location.
@Test
public void should_return_correct_schema_location() {
assertThat(encoder.getSchemaLocations().size(), is(1));
SchemaLocation schemLoc = encoder.getSchemaLocations().iterator().next();
assertThat(schemLoc.getNamespace(), is("http://www.opengis.net/swes/2.0"));
assertThat(schemLoc.getSchemaFileUrl(), is("http://schemas.opengis.net/swes/2.0/swes.xsd"));
}
use of org.n52.shetland.w3c.SchemaLocation in project arctic-sea by 52North.
the class GetObservationResponseXmlStreamWriter method writeGetObservationResponseDoc.
private void writeGetObservationResponseDoc() throws XMLStreamException, EncodingException {
start(Sos2StreamingConstants.GET_OBSERVATION_RESPONSE);
namespace(W3CConstants.NS_XLINK_PREFIX, W3CConstants.NS_XLINK);
namespace(SosConstants.NS_SOS_PREFIX, Sos2Constants.NS_SOS_20);
GetObservationResponse response = getElement();
// get observation encoder
ObservationEncoder<XmlObject, OmObservation> encoder = findObservationEncoder(response.getResponseFormat());
// write schemaLocation
schemaLocation(getSchemaLocation(encoder));
EncodingContext ctx = getContext().with(XmlEncoderFlags.ENCODE_NAMESPACE, response.getResponseFormat()).with(XmlBeansEncodingFlags.DOCUMENT).with(StreamingEncoderFlags.EMBEDDED).without(XmlBeansEncodingFlags.PROPERTY_TYPE).without(XmlBeansEncodingFlags.TYPE);
try {
ObservationStream stream = response.getObservationCollection();
if (encoder.shouldObservationsWithSameXBeMerged()) {
stream = stream.merge();
}
while (stream.hasNext()) {
OmObservation o = stream.next();
if (o.getValue() instanceof ObservationStream) {
ObservationStream value = (ObservationStream) o.getValue();
if (encoder.supportsResultStreamingForMergedValues()) {
writeObservationData(ctx, o, encoder);
} else {
while (value.hasNext()) {
writeObservationData(ctx, value.next(), encoder);
}
}
} else {
writeObservationData(ctx, o, encoder);
}
}
} catch (OwsExceptionReport owse) {
throw new EncodingException(owse);
}
end(Sos2StreamingConstants.GET_OBSERVATION_RESPONSE);
}
use of org.n52.shetland.w3c.SchemaLocation in project arctic-sea by 52North.
the class AbstractWmlEncoderv20 method createWmlGetObservationResponse.
/**
* Encodes a SOS GetObservationResponse to a single WaterML 2.0 observation
* or to a WaterML 1.0 ObservationCollection
*
* @param getObservationResonse
* SOS GetObservationResponse
* @return Encoded response
* @throws EncodingException
* If an error occurs
*/
protected XmlObject createWmlGetObservationResponse(GetObservationResponse getObservationResonse) throws EncodingException {
// TODO: set schemaLocation if final
Map<CodeWithAuthority, String> gmlID4sfIdentifier = Maps.newHashMap();
int sfIdCounter = 1;
try {
if (getObservationResonse.getObservationCollection() != null && !getObservationResonse.getObservationCollection().hasNext()) {
ObservationStream observations = getObservationResonse.getObservationCollection();
OmObservation observation = observations.next();
if (!observations.hasNext()) {
OMObservationDocument omObservationDoc = OMObservationDocument.Factory.newInstance(getXmlOptions());
omObservationDoc.setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
return omObservationDoc;
} else {
CollectionDocument xmlCollectionDoc = CollectionDocument.Factory.newInstance(getXmlOptions());
CollectionType wmlCollection = xmlCollectionDoc.addNewCollection();
wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observation, gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
while (observations.hasNext()) {
wmlCollection.addNewObservationMember().setOMObservation(encodeObservation(observations.next(), gmlID4sfIdentifier, sfIdCounter));
sfIdCounter++;
}
return xmlCollectionDoc;
}
} else {
// TODO: HydrologieProfile-Exception
throw new EncodingException("Combination does not exists!");
}
} catch (NoSuchElementException | OwsExceptionReport e) {
throw new EncodingException(e);
}
}
Aggregations