Search in sources :

Example 1 with SFSpecimenType

use of net.opengis.samplingSpecimen.x20.SFSpecimenType in project arctic-sea by 52North.

the class SpecimenDecoderv20 method getXmlDescription.

private String getXmlDescription(final SFSpecimenType sfst) {
    final SFSpecimenDocument sfsd = SFSpecimenDocument.Factory.newInstance(getXmlOptions());
    sfsd.setSFSpecimen(sfst);
    return sfsd.xmlText(getXmlOptions());
}
Also used : SFSpecimenDocument(net.opengis.samplingSpecimen.x20.SFSpecimenDocument)

Example 2 with SFSpecimenType

use of net.opengis.samplingSpecimen.x20.SFSpecimenType in project arctic-sea by 52North.

the class SpecimenEncoderv20 method addSize.

private void addSize(SFSpecimenType sfst, SfSpecimen specimen) {
    if (specimen.isSetSize()) {
        Size size = sfst.addNewSize();
        size.setDoubleValue(specimen.getSize().getValue().doubleValue());
        if (specimen.getSize().isSetUnit()) {
            size.setUom(specimen.getSize().getUnit());
        }
    }
}
Also used : Size(net.opengis.samplingSpecimen.x20.SFSpecimenType.Size)

Example 3 with SFSpecimenType

use of net.opengis.samplingSpecimen.x20.SFSpecimenType 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 4 with SFSpecimenType

use of net.opengis.samplingSpecimen.x20.SFSpecimenType 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 5 with SFSpecimenType

use of net.opengis.samplingSpecimen.x20.SFSpecimenType 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 SFSpecimenDocument (net.opengis.samplingSpecimen.x20.SFSpecimenDocument)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 Size (net.opengis.samplingSpecimen.x20.SFSpecimenType.Size)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1