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;
}
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));
}
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;
}
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;
}
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;
}
Aggregations