Search in sources :

Example 6 with SwesExtension

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));
}
Also used : SweText(org.n52.shetland.ogc.swe.simpleType.SweText) Extensions(org.n52.shetland.ogc.ows.extension.Extensions) Test(org.junit.Test)

Example 7 with SwesExtension

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;
}
Also used : SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent)

Example 8 with SwesExtension

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;
}
Also used : GetFeatureOfInterestRequest(org.n52.shetland.ogc.sos.request.GetFeatureOfInterestRequest) GetFeatureOfInterestType(net.opengis.sos.x20.GetFeatureOfInterestType)

Example 9 with SwesExtension

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
}
Also used : InsertObservationDocument(net.opengis.sos.x20.InsertObservationDocument) InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) BooleanType(net.opengis.swe.x20.BooleanType) XmlObject(org.apache.xmlbeans.XmlObject) SwesExtension(org.n52.shetland.ogc.swes.SwesExtension) BooleanPropertyType(net.opengis.swe.x20.BooleanPropertyType) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) InsertObservationType(net.opengis.sos.x20.InsertObservationType) Test(org.junit.Test)

Example 10 with SwesExtension

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()));
}
Also used : Extensions(org.n52.shetland.ogc.ows.extension.Extensions) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 Extensions (org.n52.shetland.ogc.ows.extension.Extensions)10 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)4 XmlObject (org.apache.xmlbeans.XmlObject)3 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)3 SwesExtension (org.n52.shetland.ogc.swes.SwesExtension)3 BooleanPropertyType (net.opengis.swe.x20.BooleanPropertyType)2 BooleanType (net.opengis.swe.x20.BooleanType)2 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)2 GetFeatureOfInterestType (net.opengis.sos.x20.GetFeatureOfInterestType)1 InsertObservationDocument (net.opengis.sos.x20.InsertObservationDocument)1 InsertObservationType (net.opengis.sos.x20.InsertObservationType)1 GetFeatureOfInterestRequest (org.n52.shetland.ogc.sos.request.GetFeatureOfInterestRequest)1 InsertObservationRequest (org.n52.shetland.ogc.sos.request.InsertObservationRequest)1 UnsupportedDecoderXmlInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException)1