Search in sources :

Example 1 with CodeWithAuthority

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

the class SamplingFeatureComplexTest method should_set_relatedSamplingFeature_correct.

@Test
public void should_set_relatedSamplingFeature_correct() {
    final SamplingFeature feature = new SamplingFeature(new CodeWithAuthority("test-feature"));
    final SamplingFeatureComplex sfc = new SamplingFeatureComplex("test-role", feature);
    assertThat(sfc.getRelatedSamplingFeature(), is(feature));
}
Also used : SamplingFeatureComplex(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeatureComplex) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) Test(org.junit.Test)

Example 2 with CodeWithAuthority

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

the class SamplingFeatureTest method addRelatedSamplingFeature_should_add_a_relatedSamplingFeature.

@Test
public final void addRelatedSamplingFeature_should_add_a_relatedSamplingFeature() {
    final SamplingFeature feature = new SamplingFeature(null);
    final SamplingFeatureComplex relatedSamplingFeature = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature")));
    feature.addRelatedSamplingFeature(relatedSamplingFeature);
    assertThat(feature.isSetRelatedSamplingFeatures(), is(TRUE));
    assertThat(feature.getRelatedSamplingFeatures(), hasSize(1));
    assertThat(feature.getRelatedSamplingFeatures().get(0), is(relatedSamplingFeature));
    final SamplingFeatureComplex relatedSamplingFeature2 = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature-2")));
    feature.addRelatedSamplingFeature(relatedSamplingFeature2);
    validate(feature, relatedSamplingFeature, relatedSamplingFeature2);
    feature.addRelatedSamplingFeature(null);
    validate(feature, relatedSamplingFeature, relatedSamplingFeature2);
}
Also used : SamplingFeatureComplex(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeatureComplex) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) Test(org.junit.Test)

Example 3 with CodeWithAuthority

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

the class SamplingFeatureTest method addAllRelatedSamplingFeatures_should_add_all_elements.

@Test
public final void addAllRelatedSamplingFeatures_should_add_all_elements() {
    final SamplingFeature feature = new SamplingFeature(null);
    final SamplingFeatureComplex relatedSamplingFeature = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature")));
    final SamplingFeatureComplex relatedSamplingFeature2 = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature-2")));
    List<SamplingFeatureComplex> list = Lists.newArrayList(relatedSamplingFeature, relatedSamplingFeature2);
    feature.addAllRelatedSamplingFeatures(list);
    validate(feature, relatedSamplingFeature, relatedSamplingFeature2);
    final SamplingFeatureComplex relatedSamplingFeature3 = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature-3")));
    final SamplingFeatureComplex relatedSamplingFeature4 = new SamplingFeatureComplex("test-role", new SamplingFeature(new CodeWithAuthority("test-feature-4")));
    list = Lists.newArrayList(relatedSamplingFeature3, relatedSamplingFeature4);
    feature.addAllRelatedSamplingFeatures(list);
    validate(feature, relatedSamplingFeature, relatedSamplingFeature2, relatedSamplingFeature3, relatedSamplingFeature4);
}
Also used : SamplingFeatureComplex(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeatureComplex) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) Test(org.junit.Test)

Example 4 with CodeWithAuthority

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

the class JSONDecoder method parseCodeWithAuthority.

protected CodeWithAuthority parseCodeWithAuthority(JsonNode node) {
    if (node.isObject()) {
        String value = node.path(JSONConstants.VALUE).textValue();
        String codespace = node.path(JSONConstants.CODESPACE).textValue();
        if (codespace == null || codespace.isEmpty()) {
            codespace = OGCConstants.UNKNOWN;
        }
        return new CodeWithAuthority(value, codespace);
    } else if (node.isTextual()) {
        return new CodeWithAuthority(node.textValue(), OGCConstants.UNKNOWN);
    } else {
        return null;
    }
}
Also used : CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 5 with CodeWithAuthority

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

the class AbstractGmlDecoderv321 method parseCodeWithAuthorityTye.

protected CodeWithAuthority parseCodeWithAuthorityTye(CodeWithAuthorityType xbCodeWithAuthority) {
    if (xbCodeWithAuthority.getStringValue() != null && !xbCodeWithAuthority.getStringValue().isEmpty()) {
        CodeWithAuthority sosCodeWithAuthority = new CodeWithAuthority(xbCodeWithAuthority.getStringValue());
        sosCodeWithAuthority.setCodeSpace(xbCodeWithAuthority.getCodeSpace());
        return sosCodeWithAuthority;
    }
    return null;
}
Also used : CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Aggregations

CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)28 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)17 Test (org.junit.Test)9 CodeType (org.n52.shetland.ogc.gml.CodeType)7 XmlObject (org.apache.xmlbeans.XmlObject)6 OmObservation (org.n52.shetland.ogc.om.OmObservation)6 SamplingFeatureComplex (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeatureComplex)6 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)5 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)5 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)4 EncodingException (org.n52.svalbard.encode.exception.EncodingException)4 ArrayList (java.util.ArrayList)3 DateTime (org.joda.time.DateTime)3 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)3 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)3 XmlException (org.apache.xmlbeans.XmlException)2 XmlOptions (org.apache.xmlbeans.XmlOptions)2 Before (org.junit.Before)2 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)2 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)2