Search in sources :

Example 11 with CodeType

use of org.n52.shetland.ogc.gml.CodeType in project arctic-sea by 52North.

the class SweAbstractDataComponent method setName.

public SweAbstractDataComponent setName(final String name) {
    getNames().clear();
    getNames().add(new CodeType(name));
    return this;
}
Also used : CodeType(org.n52.shetland.ogc.gml.CodeType)

Example 12 with CodeType

use of org.n52.shetland.ogc.gml.CodeType in project arctic-sea by 52North.

the class MeasurementDecodingTest method testFeatureOfInterestName.

@Test
public void testFeatureOfInterestName() {
    assertThat(observation, is(notNullValue()));
    final OmObservationConstellation oc = observation.getObservationConstellation();
    assertThat(oc, is(notNullValue()));
    final AbstractFeature foi = oc.getFeatureOfInterest();
    assertThat(foi, is(notNullValue()));
    final List<CodeType> name = foi.getName();
    assertThat(name, is(notNullValue()));
    assertThat(name.size(), is(3));
    assertThat(name.get(0), is(notNullValue()));
    assertThat(name.get(0).getValue(), is(equalTo(FEATURE_NAME)));
    assertThat(name.get(0).getCodeSpace().toString(), is(equalTo("http://x.y/z")));
    assertThat(name.get(1), is(notNullValue()));
    assertThat(name.get(1).getValue(), is(equalTo("othername1")));
    assertThat(name.get(1).isSetCodeSpace(), is(false));
    assertThat(name.get(2), is(notNullValue()));
    assertThat(name.get(2).getValue(), is(equalTo("othername2")));
    assertThat(name.get(2).isSetCodeSpace(), is(false));
}
Also used : AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) CodeType(org.n52.shetland.ogc.gml.CodeType) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) Test(org.junit.Test)

Example 13 with CodeType

use of org.n52.shetland.ogc.gml.CodeType in project arctic-sea by 52North.

the class SpecimenDecoderv20 method getSampledFeatures.

/**
 * Parse {@link FeaturePropertyType} sampledFeature to
 * {@link AbstractFeature} list.
 *
 * @param sampledFeature
 *            SampledFeature to parse
 * @return List with the parsed sampledFeature
 * @throws DecodingException
 *             If an error occurs
 */
private List<AbstractFeature> getSampledFeatures(final FeaturePropertyType sampledFeature) throws DecodingException {
    final List<AbstractFeature> sampledFeatures = new ArrayList<AbstractFeature>(1);
    if (sampledFeature != null && !sampledFeature.isNil()) {
        // if xlink:href is set
        if (sampledFeature.getHref() != null && !sampledFeature.getHref().isEmpty()) {
            if (sampledFeature.getHref().startsWith("#")) {
                sampledFeatures.add(new SamplingFeature(null, sampledFeature.getHref().replace("#", "")));
            } else {
                final AbstractSamplingFeature sampFeat = new SamplingFeature(new CodeWithAuthority(sampledFeature.getHref()));
                if (sampledFeature.getTitle() != null && !sampledFeature.getTitle().isEmpty()) {
                    sampFeat.addName(new CodeType(sampledFeature.getTitle()));
                }
                sampledFeatures.add(sampFeat);
            }
        } else {
            XmlObject abstractFeature = null;
            if (sampledFeature.getAbstractFeature() != null) {
                abstractFeature = sampledFeature.getAbstractFeature();
            } else if (sampledFeature.getDomNode().hasChildNodes()) {
                try {
                    abstractFeature = XmlObject.Factory.parse(XmlHelper.getNodeFromNodeList(sampledFeature.getDomNode().getChildNodes()));
                } catch (final XmlException xmle) {
                    throw new DecodingException("Error while parsing feature request!", xmle);
                }
            }
            if (abstractFeature != null) {
                final Object decodedObject = decodeXmlObject(abstractFeature);
                if (decodedObject instanceof AbstractFeature) {
                    sampledFeatures.add((AbstractFeature) decodedObject);
                }
            }
            throw new DecodingException("The requested sampledFeature type is not supported by this service!");
        }
    }
    return sampledFeatures;
}
Also used : AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) XmlException(org.apache.xmlbeans.XmlException) ArrayList(java.util.ArrayList) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) CodeType(org.n52.shetland.ogc.gml.CodeType) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 14 with CodeType

use of org.n52.shetland.ogc.gml.CodeType in project arctic-sea by 52North.

the class SwesDecoderv20 method parseRelatedFeature.

private List<SwesFeatureRelationship> parseRelatedFeature(final RelatedFeature[] relatedFeatureArray) throws DecodingException {
    List<SwesFeatureRelationship> sosRelatedFeatures = new ArrayList<>(relatedFeatureArray.length);
    for (final RelatedFeature relatedFeature : relatedFeatureArray) {
        final SwesFeatureRelationship sosFeatureRelationship = new SwesFeatureRelationship();
        final FeaturePropertyType fpt = relatedFeature.getFeatureRelationship().getTarget();
        if (fpt.getHref() != null && !fpt.getHref().isEmpty()) {
            final String identifier = fpt.getHref();
            final AbstractSamplingFeature feature = new SamplingFeature(new CodeWithAuthority(identifier));
            if (fpt.getTitle() != null && !fpt.getTitle().isEmpty()) {
                feature.setName(Lists.newArrayList(new CodeType(fpt.getTitle())));
            }
            if (checkForRequestUrl(fpt.getHref())) {
                feature.setUrl(fpt.getHref());
            }
            feature.setFeatureType(OGCConstants.UNKNOWN);
            sosFeatureRelationship.setFeature(feature);
        } else {
            final Object decodedObject = decodeXmlElement(fpt);
            if (decodedObject instanceof AbstractSamplingFeature) {
                sosFeatureRelationship.setFeature((AbstractSamplingFeature) decodedObject);
            } else {
                throw new DecoderResponseUnsupportedException(fpt.xmlText(), decodedObject);
            }
        }
        sosFeatureRelationship.setRole(relatedFeature.getFeatureRelationship().getRole());
        sosRelatedFeatures.add(sosFeatureRelationship);
    }
    return sosRelatedFeatures;
}
Also used : DecoderResponseUnsupportedException(org.n52.svalbard.decode.exception.DecoderResponseUnsupportedException) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) RelatedFeature(net.opengis.swes.x20.InsertSensorType.RelatedFeature) ArrayList(java.util.ArrayList) CodeType(org.n52.shetland.ogc.gml.CodeType) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) SwesFeatureRelationship(org.n52.shetland.ogc.swes.SwesFeatureRelationship) FeaturePropertyType(net.opengis.gml.x32.FeaturePropertyType)

Example 15 with CodeType

use of org.n52.shetland.ogc.gml.CodeType in project arctic-sea by 52North.

the class SamplingDecoderv20 method getSampledFeatures.

/**
 * Parse {@link FeaturePropertyType} sampledFeature to
 * {@link AbstractFeature} list.
 *
 * @param sampledFeature
 *            SampledFeature to parse
 * @return List with the parsed sampledFeature
 * @throws DecodingException
 *             If an error occurs
 */
private List<AbstractFeature> getSampledFeatures(final FeaturePropertyType sampledFeature) throws DecodingException {
    final List<AbstractFeature> sampledFeatures = new ArrayList<>(1);
    if (sampledFeature != null && !sampledFeature.isNil()) {
        // if xlink:href is set
        if (sampledFeature.getHref() != null && !sampledFeature.getHref().isEmpty()) {
            if (sampledFeature.getHref().startsWith("#")) {
                sampledFeatures.add(new SamplingFeature(null, sampledFeature.getHref().replace("#", "")));
            } else {
                final SamplingFeature sampFeat = new SamplingFeature(new CodeWithAuthority(sampledFeature.getHref()));
                if (sampledFeature.getTitle() != null && !sampledFeature.getTitle().isEmpty()) {
                    sampFeat.addName(new CodeType(sampledFeature.getTitle()));
                }
                sampledFeatures.add(sampFeat);
            }
        } else {
            XmlObject abstractFeature = null;
            if (sampledFeature.getAbstractFeature() != null) {
                abstractFeature = sampledFeature.getAbstractFeature();
            } else if (sampledFeature.getDomNode().hasChildNodes()) {
                try {
                    abstractFeature = XmlObject.Factory.parse(XmlHelper.getNodeFromNodeList(sampledFeature.getDomNode().getChildNodes()));
                } catch (XmlException xmle) {
                    throw new DecodingException("Error while parsing feature request!", xmle);
                }
            }
            if (abstractFeature != null) {
                final Object decodedObject = decodeXmlObject(abstractFeature);
                if (decodedObject instanceof AbstractFeature) {
                    sampledFeatures.add((AbstractFeature) decodedObject);
                }
            }
            throw new DecodingException(Sos2Constants.InsertObservationParams.observation, "The requested sampledFeature type is not supported by this service!");
        }
    }
    return sampledFeatures;
}
Also used : XmlException(org.apache.xmlbeans.XmlException) ArrayList(java.util.ArrayList) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) CodeType(org.n52.shetland.ogc.gml.CodeType) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Aggregations

CodeType (org.n52.shetland.ogc.gml.CodeType)23 XmlObject (org.apache.xmlbeans.XmlObject)9 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)7 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)7 Test (org.junit.Test)5 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)5 XmlException (org.apache.xmlbeans.XmlException)4 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)4 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 GeographicalName (org.n52.shetland.inspire.GeographicalName)3 Spelling (org.n52.shetland.inspire.Spelling)3 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)3 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)3 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)3 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 XmlOptions (org.apache.xmlbeans.XmlOptions)2 Before (org.junit.Before)2