Search in sources :

Example 1 with ObservationProcessDocument

use of net.opengis.waterml.x20.ObservationProcessDocument in project arctic-sea by 52North.

the class WmlObservationProcessDecoderv20 method setDescriptionXml.

private void setDescriptionXml(ObservationProcessType opt, ObservationProcess observationProcess) {
    ObservationProcessDocument doc = ObservationProcessDocument.Factory.newInstance(getXmlOptions());
    doc.setObservationProcess(opt);
    observationProcess.setXml(doc.xmlText(getXmlOptions()));
}
Also used : ObservationProcessDocument(net.opengis.waterml.x20.ObservationProcessDocument)

Example 2 with ObservationProcessDocument

use of net.opengis.waterml.x20.ObservationProcessDocument in project arctic-sea by 52North.

the class AbstractWmlEncoderv20 method createObservationProcess.

/**
 * Creates an WaterML 2.0 ObservationProcess XML object from SOS
 * ObservationProcess object
 *
 * @param procedure
 *            SOS ObservationProcess
 * @param context
 *            Additional values
 * @return WaterML 2.0 ObservationProcess XML object
 * @throws EncodingException
 *             If an error occurs
 */
protected ObservationProcessDocument createObservationProcess(ObservationProcess procedure, EncodingContext context) throws EncodingException {
    XmlObject encodedObject = null;
    try {
        if (procedure.isSetXml()) {
            encodedObject = XmlObject.Factory.parse(procedure.getXml());
            checkAndAddIdentifier(procedure, ((ObservationProcessDocument) encodedObject).getObservationProcess());
        } else {
            encodedObject = ObservationProcessDocument.Factory.newInstance();
            ObservationProcessType observationProcess = ((ObservationProcessDocument) encodedObject).addNewObservationProcess();
            if (context.has(XmlBeansEncodingFlags.GMLID)) {
                observationProcess.setId(PROCESS_ID_PREFIX + context.get(XmlBeansEncodingFlags.GMLID));
            } else {
                observationProcess.setId(PROCESS_ID_PREFIX + JavaHelper.generateID(procedure.toString()));
            }
            if (procedure.isSetIdentifier()) {
                observationProcess.addNewIdentifier().set(encodeGML(procedure.getIdentifierCodeWithAuthority()));
            }
            if (procedure.isSetName()) {
                for (final CodeType sosName : procedure.getName()) {
                    observationProcess.addNewName().set(encodeGML(sosName));
                }
            }
            addProcessType(observationProcess, procedure);
            addOriginatingProcess(observationProcess, procedure);
            addAggregatingDuration(observationProcess, procedure);
            addVerticalDatum(observationProcess, procedure);
            addComment(observationProcess, procedure);
            addProcessReference(observationProcess, procedure);
            addInput(observationProcess, procedure);
            addParameter(observationProcess, procedure);
        }
    } catch (final XmlException xmle) {
        throw new EncodingException(xmle);
    }
    try {
        LOGGER.debug("Encoded object {} is valid: {}", encodedObject.schemaType().toString(), XmlHelper.validateDocument(encodedObject));
    } catch (DecodingException e) {
        throw new EncodingException(e);
    }
    return (ObservationProcessDocument) encodedObject;
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) ObservationProcessType(net.opengis.waterml.x20.ObservationProcessType) XmlException(org.apache.xmlbeans.XmlException) ObservationProcessDocument(net.opengis.waterml.x20.ObservationProcessDocument) CodeType(org.n52.shetland.ogc.gml.CodeType) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException)

Aggregations

ObservationProcessDocument (net.opengis.waterml.x20.ObservationProcessDocument)2 ObservationProcessType (net.opengis.waterml.x20.ObservationProcessType)1 XmlException (org.apache.xmlbeans.XmlException)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CodeType (org.n52.shetland.ogc.gml.CodeType)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1