use of org.n52.shetland.ogc.swes.SwesExtension in project arctic-sea by 52North.
the class SwesExtensionsTest method containsExtension_for_enum_schould_return_true.
@Test
public void containsExtension_for_enum_schould_return_true() {
final Extensions extensions = new Extensions();
extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_1).setValue(new SweText()));
extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_2).setValue(new SweText()));
extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_3).setValue(new SweText()));
assertThat(extensions.containsExtension(DEFINITION_1), is(TRUE));
assertThat(extensions.containsExtension(DEFINITION_2), is(TRUE));
assertThat(extensions.containsExtension(DEFINITION_3), is(TRUE));
}
use of org.n52.shetland.ogc.swes.SwesExtension in project arctic-sea by 52North.
the class SwesExtension method setValue.
@Override
public SwesExtension<T> setValue(T value) {
this.value = value;
if (value != null && value instanceof SweAbstractDataComponent) {
SweAbstractDataComponent c = (SweAbstractDataComponent) value;
setIdentifier(getIdentifier() == null && c.isSetIdentifier() ? c.getIdentifier() : getIdentifier());
setDefinition(getDefinition() == null && c.isSetDefinition() ? c.getDefinition() : getDefinition());
}
return this;
}
use of org.n52.shetland.ogc.swes.SwesExtension in project arctic-sea by 52North.
the class SosDecoderv20 method parseGetFeatureOfInterest.
// private SwesExtensions parseSwesExtensions(final XmlObject[]
// extensionArray) throws OwsExceptionReport
// {
// final SwesExtensions extensions = new SwesExtensions();
// for (final XmlObject xbSwesExtension : extensionArray) {
//
// final Object obj = CodingHelper.decodeXmlElement(xbSwesExtension);
// if (obj instanceof SwesExtension<?>) {
// extensions.addSwesExtension((SwesExtension<?>) obj);
// }
// }
// return extensions;
// }
/**
* parses the passes XmlBeans document and creates a SOS
* getFeatureOfInterest request
*
* @param getFoiDoc
* XmlBeans document representing the getFeatureOfInterest
* request
* @return Returns SOS getFeatureOfInterest request
*
* @throws DecodingException
* * if validation of the request failed
*/
private OwsServiceRequest parseGetFeatureOfInterest(final GetFeatureOfInterestDocument getFoiDoc) throws DecodingException {
final GetFeatureOfInterestRequest getFoiRequest = new GetFeatureOfInterestRequest();
final GetFeatureOfInterestType getFoiType = getFoiDoc.getGetFeatureOfInterest();
getFoiRequest.setService(getFoiType.getService());
getFoiRequest.setVersion(getFoiType.getVersion());
getFoiRequest.setFeatureIdentifiers(Arrays.asList(getFoiType.getFeatureOfInterestArray()));
getFoiRequest.setObservedProperties(Arrays.asList(getFoiType.getObservedPropertyArray()));
getFoiRequest.setProcedures(Arrays.asList(getFoiType.getProcedureArray()));
getFoiRequest.setSpatialFilters(parseSpatialFilters4GetFeatureOfInterest(getFoiType.getSpatialFilterArray()));
getFoiRequest.setExtensions(parseExtensibleRequest(getFoiType));
return getFoiRequest;
}
use of org.n52.shetland.ogc.swes.SwesExtension in project arctic-sea by 52North.
the class InsertObservationRequestEncoderTest method shouldEncodeSwesExtensions.
@Test
public void shouldEncodeSwesExtensions() throws InvalidSridException, ParseException, EncodingException, DecodingException {
String definition = Sos2Constants.Extensions.SplitDataArrayIntoObservations.name();
boolean value = true;
SweBoolean sweBoolean = new SweBoolean();
sweBoolean.setValue(value);
sweBoolean.setDefinition(definition);
SwesExtension<SweBoolean> swesExtension = new SwesExtension<>();
swesExtension.setValue(sweBoolean);
InsertObservationRequest request = createInsertObservationRequest();
request.addExtension(swesExtension);
XmlObject encodedRequest = encoder.create(request);
encodedRequest.xmlText();
XmlHelper.validateDocument(encodedRequest);
InsertObservationType insertObservation = ((InsertObservationDocument) encodedRequest).getInsertObservation();
Assert.assertThat(insertObservation.sizeOfExtensionArray(), Is.is(1));
XmlObject xbExtension = insertObservation.getExtensionArray(0);
Assert.assertThat(xbExtension, Matchers.instanceOf(BooleanPropertyType.class));
BooleanType xbBoolean = ((BooleanPropertyType) xbExtension).getBoolean();
Assert.assertThat(xbBoolean.getDefinition(), Is.is(definition));
Assert.assertThat(xbBoolean.getValue(), Is.is(value));
// no check for observation values, because that MUST be part of OmEncoderv20Test
}
use of org.n52.shetland.ogc.swes.SwesExtension in project arctic-sea by 52North.
the class SwesExtensionsTest method getExtension_for_string_created_with_enum_schould_return_true.
@Test
public void getExtension_for_string_created_with_enum_schould_return_true() {
final Extensions extensions = new Extensions();
extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_1).setValue(VALUE_1));
extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_2).setValue(VALUE_2));
extensions.addExtension(new SwesExtension<>().setDefinition(DEFINITION_3).setValue(VALUE_3));
assertThat(extensions.getExtension(DEFINITION_1).orElse(null).getValue(), instanceOf(VALUE_1.getClass()));
assertThat(extensions.getExtension(DEFINITION_2).orElse(null).getValue(), instanceOf(VALUE_2.getClass()));
assertThat(extensions.getExtension(DEFINITION_3).orElse(null).getValue(), instanceOf(VALUE_3.getClass()));
}
Aggregations