Search in sources :

Example 1 with ObservationProcess

use of org.n52.shetland.ogc.om.series.wml.ObservationProcess in project arctic-sea by 52North.

the class WmlObservationProcessDecoderv20 method parseObservationProcess.

private Object parseObservationProcess(ObservationProcessType opt) throws DecodingException {
    ObservationProcess observationProcess = new ObservationProcess();
    observationProcess.setGmlId(opt.getId());
    // parse identifier, names, description, locations
    parseAbstractFeatureType(opt, observationProcess);
    parseProcessType(opt, observationProcess);
    parseOriginatingProcess(opt, observationProcess);
    parseAggregatingDuration(opt, observationProcess);
    parseVerticalDatum(opt, observationProcess);
    parseComment(opt, observationProcess);
    parseProcessReference(opt, observationProcess);
    parseInput(opt, observationProcess);
    parseParameter(opt, observationProcess);
    setDescriptionXml(opt, observationProcess);
    return observationProcess;
}
Also used : ObservationProcess(org.n52.shetland.ogc.om.series.wml.ObservationProcess)

Example 2 with ObservationProcess

use of org.n52.shetland.ogc.om.series.wml.ObservationProcess 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)

Example 3 with ObservationProcess

use of org.n52.shetland.ogc.om.series.wml.ObservationProcess in project arctic-sea by 52North.

the class AbstractWmlEncoderv20 method checkAndAddIdentifier.

private void checkAndAddIdentifier(ObservationProcess op, ObservationProcessType opt) throws EncodingException {
    if (op.isSetIdentifier() && !opt.isSetIdentifier()) {
        CodeWithAuthority codeWithAuthority = op.getIdentifierCodeWithAuthority();
        Encoder<?, CodeWithAuthority> encoder = getEncoder(getEncoderKey(GmlConstants.NS_GML_32, codeWithAuthority));
        if (encoder != null) {
            XmlObject xmlObject = (XmlObject) encoder.encode(codeWithAuthority);
            opt.addNewIdentifier().set(xmlObject);
        } else {
            throw new EncodingException("Error while encoding geometry value, needed encoder is missing!");
        }
    }
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 4 with ObservationProcess

use of org.n52.shetland.ogc.om.series.wml.ObservationProcess in project arctic-sea by 52North.

the class WmlObservationProcessDecoderv20Test method getObservationProcess.

private ObservationProcess getObservationProcess() {
    ObservationProcess op = new ObservationProcess();
    op.addParameter(getReferencedNamedValue());
    op.addParameter(getTextNamedValue());
    return op;
}
Also used : ObservationProcess(org.n52.shetland.ogc.om.series.wml.ObservationProcess)

Aggregations

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