Search in sources :

Example 1 with SFSpecimenDocument

use of net.opengis.samplingSpecimen.x20.SFSpecimenDocument 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 SFSpecimenDocument

use of net.opengis.samplingSpecimen.x20.SFSpecimenDocument 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)

Aggregations

SFSpecimenDocument (net.opengis.samplingSpecimen.x20.SFSpecimenDocument)2 SFSpecimenType (net.opengis.samplingSpecimen.x20.SFSpecimenType)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1