use of org.n52.shetland.ogc.om.features.samplingFeatures.SfSpecimen in project arctic-sea by 52North.
the class SpecimenDecoderv20 method parseSpatialSamplingFeature.
private AbstractFeature parseSpatialSamplingFeature(final SFSpecimenType sfst) throws DecodingException {
final SfSpecimen specimen = new SfSpecimen(null, sfst.getId());
// parse identifier, names, description
parseAbstractFeatureType(sfst, specimen);
specimen.setSampledFeatures(getSampledFeatures(sfst.getSampledFeatureArray()));
specimen.setXml(getXmlDescription(sfst));
if (sfst.getParameterArray() != null) {
specimen.setParameters(parseNamedValueTypeArray(sfst.getParameterArray()));
}
// TODO
sfst.getMaterialClass();
specimen.setMaterialClass((ReferenceType) decodeXmlElement(sfst.getMaterialClass()));
specimen.setSamplingTime(getSamplingTime(sfst));
// samplingLocation
if (sfst.isSetSamplingLocation()) {
specimen.setSamplingLocation(getGeometry(sfst));
}
// sfst.getProcessingDetailsArray();
if (sfst.isSetSize()) {
specimen.setSize(getSize(sfst.getSize()));
}
// }
if (sfst.isSetSpecimenType()) {
specimen.setSpecimenType((ReferenceType) decodeXmlElement(sfst.getSpecimenType()));
}
return specimen;
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.SfSpecimen in project arctic-sea by 52North.
the class SpecimenEncoderv20 method createSpecimen.
private XmlObject createSpecimen(SfSpecimen specimen) throws EncodingException {
SFSpecimenDocument sfsd = SFSpecimenDocument.Factory.newInstance(getXmlOptions());
if (specimen.isSetXml()) {
try {
final XmlObject feature = XmlObject.Factory.parse(specimen.getXml(), getXmlOptions());
XmlHelper.updateGmlIDs(feature.getDomNode().getFirstChild(), specimen.getGmlId(), null);
if (XmlHelper.getNamespace(feature).equals(SfConstants.NS_SPEC) && feature instanceof SFSpecimenType) {
sfsd.setSFSpecimen((SFSpecimenType) feature);
addName(sfsd.getSFSpecimen(), specimen);
addDescription(sfsd.getSFSpecimen(), specimen);
return sfsd;
}
addName(((SFSpecimenDocument) feature).getSFSpecimen(), specimen);
addDescription(((SFSpecimenDocument) feature).getSFSpecimen(), specimen);
return feature;
} catch (final XmlException xmle) {
throw new EncodingException("Error while encoding GetFeatureOfInterest response, invalid specimen description!", xmle);
}
}
final SFSpecimenType sfst = sfsd.addNewSFSpecimen();
// TODO: CHECK for all fields set gml:id
addId(sfst, specimen);
addIdentifier(sfst, specimen);
// set type
addFeatureType(sfst, specimen);
addName(sfst, specimen);
addDescription(sfst, specimen);
// set sampledFeatures
addSampledFeatures(sfst, specimen);
addParameter(sfst, specimen);
// set specimen specific data
addMaterialClass(sfst, specimen);
addSamplingTime(sfst, specimen);
addSamplingMethod(sfst, specimen);
addSamplingLocation(sfst, specimen);
addProcessingDetails(sfst, specimen);
addSize(sfst, specimen);
addCurrentLocation(sfst, specimen);
addSpecimenType(sfst, specimen);
specimen.wasEncoded();
return sfsd;
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.SfSpecimen in project arctic-sea by 52North.
the class SpecimenEncoderv20 method addCurrentLocation.
private void addCurrentLocation(SFSpecimenType sfst, SfSpecimen specimen) {
if (specimen.isSetCurrentLocation()) {
if (!specimen.getCurrentLocation().getInstance().isPresent()) {
Reference reference = specimen.getCurrentLocation().getReference();
LocationPropertyType lpt = sfst.addNewCurrentLocation();
reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(lpt::setActuate);
reference.getArcrole().ifPresent(lpt::setArcrole);
reference.getHref().map(URI::toString).ifPresent(lpt::setHref);
reference.getRole().ifPresent(lpt::setRole);
reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(lpt::setShow);
reference.getTitle().ifPresent(lpt::setTitle);
reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(lpt::setType);
}
}
}
use of org.n52.shetland.ogc.om.features.samplingFeatures.SfSpecimen in project arctic-sea by 52North.
the class SpecimenEncoderv20 method addSamplingMethod.
private void addSamplingMethod(SFSpecimenType sfst, SfSpecimen specimen) {
if (specimen.isSetSamplingMethod()) {
if (!specimen.getSamplingMethod().getInstance().isPresent()) {
sfst.addNewSamplingMethod().setHref(specimen.getSamplingMethod().getReference().getHref().get().toString());
Reference reference = specimen.getCurrentLocation().getReference();
SFProcessPropertyType sfppt = sfst.addNewSamplingMethod();
reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(sfppt::setActuate);
reference.getArcrole().ifPresent(sfppt::setArcrole);
reference.getHref().map(URI::toString).ifPresent(sfppt::setHref);
reference.getRole().ifPresent(sfppt::setRole);
reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(sfppt::setShow);
reference.getTitle().ifPresent(sfppt::setTitle);
reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(sfppt::setType);
}
}
}
Aggregations