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;
}
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;
}
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!");
}
}
}
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;
}
Aggregations