Search in sources :

Example 1 with SfSpecimen

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;
}
Also used : SfSpecimen(org.n52.shetland.ogc.om.features.samplingFeatures.SfSpecimen)

Example 2 with SfSpecimen

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;
}
Also used : SFSpecimenType(net.opengis.samplingSpecimen.x20.SFSpecimenType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlException(org.apache.xmlbeans.XmlException) XmlObject(org.apache.xmlbeans.XmlObject) SFSpecimenDocument(net.opengis.samplingSpecimen.x20.SFSpecimenDocument)

Example 3 with SfSpecimen

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);
        }
    }
}
Also used : ActuateType(org.w3.x1999.xlink.ActuateType) Actuate(org.n52.shetland.w3c.xlink.Actuate) LocationPropertyType(net.opengis.samplingSpecimen.x20.LocationPropertyType) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) SFProcessPropertyType(net.opengis.sampling.x20.SFProcessPropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) FeatureType(org.n52.shetland.ogc.sos.FeatureType) LocationPropertyType(net.opengis.samplingSpecimen.x20.LocationPropertyType) SFSpecimenType(net.opengis.samplingSpecimen.x20.SFSpecimenType) ShowType(org.w3.x1999.xlink.ShowType) SupportedType(org.n52.shetland.ogc.SupportedType) Reference(org.n52.shetland.w3c.xlink.Reference) Show(org.n52.shetland.w3c.xlink.Show) TypeType(org.w3.x1999.xlink.TypeType) ShowType(org.w3.x1999.xlink.ShowType)

Example 4 with SfSpecimen

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);
        }
    }
}
Also used : ActuateType(org.w3.x1999.xlink.ActuateType) Actuate(org.n52.shetland.w3c.xlink.Actuate) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) SFProcessPropertyType(net.opengis.sampling.x20.SFProcessPropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) FeatureType(org.n52.shetland.ogc.sos.FeatureType) LocationPropertyType(net.opengis.samplingSpecimen.x20.LocationPropertyType) SFSpecimenType(net.opengis.samplingSpecimen.x20.SFSpecimenType) ShowType(org.w3.x1999.xlink.ShowType) SupportedType(org.n52.shetland.ogc.SupportedType) Reference(org.n52.shetland.w3c.xlink.Reference) Show(org.n52.shetland.w3c.xlink.Show) SFProcessPropertyType(net.opengis.sampling.x20.SFProcessPropertyType) TypeType(org.w3.x1999.xlink.TypeType) ShowType(org.w3.x1999.xlink.ShowType)

Aggregations

SFSpecimenType (net.opengis.samplingSpecimen.x20.SFSpecimenType)3 SFProcessPropertyType (net.opengis.sampling.x20.SFProcessPropertyType)2 LocationPropertyType (net.opengis.samplingSpecimen.x20.LocationPropertyType)2 SupportedType (org.n52.shetland.ogc.SupportedType)2 FeatureType (org.n52.shetland.ogc.sos.FeatureType)2 Actuate (org.n52.shetland.w3c.xlink.Actuate)2 Reference (org.n52.shetland.w3c.xlink.Reference)2 Show (org.n52.shetland.w3c.xlink.Show)2 Type (org.n52.shetland.w3c.xlink.Type)2 ActuateType (org.w3.x1999.xlink.ActuateType)2 ShowType (org.w3.x1999.xlink.ShowType)2 TypeType (org.w3.x1999.xlink.TypeType)2 SFSpecimenDocument (net.opengis.samplingSpecimen.x20.SFSpecimenDocument)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 SfSpecimen (org.n52.shetland.ogc.om.features.samplingFeatures.SfSpecimen)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1