use of org.n52.shetland.ogc.sos.SosProcedureDescription in project arctic-sea by 52North.
the class InsertSensorRequestDecoder method parseProcedureDescription.
private SosProcedureDescription<?> parseProcedureDescription(JsonNode path, String pdf) throws DecodingException {
try {
final XmlObject xb = XmlObject.Factory.parse(path.textValue());
Decoder<?, XmlObject> decoder = getProcedureDescriptionDecoder(pdf, xb);
if (decoder == null) {
throw new DecodingException(JSONConstants.PROCEDURE_DESCRIPTION_FORMAT, "The requested %s is not supported!", JSONConstants.PROCEDURE_DESCRIPTION_FORMAT);
}
Object decode = decoder.decode(xb);
if (decode instanceof SosProcedureDescription<?>) {
return (SosProcedureDescription<?>) decode;
} else if (decode instanceof AbstractFeature) {
return new SosProcedureDescription<AbstractFeature>((AbstractFeature) decode);
} else {
throw new DecodingException("The decoded element {} is not of type {}!", decode.getClass().getName(), AbstractFeature.class.getName());
}
} catch (final XmlException xmle) {
throw new DecodingException("Error while parsing procedure description of InsertSensor request!", xmle);
}
}
use of org.n52.shetland.ogc.sos.SosProcedureDescription in project arctic-sea by 52North.
the class SwesDecoderv20 method parseInsertSensor.
private OwsServiceRequest parseInsertSensor(final InsertSensorDocument xbInsSensDoc) throws DecodingException {
final InsertSensorRequest request = new InsertSensorRequest();
final InsertSensorType xbInsertSensor = xbInsSensDoc.getInsertSensor();
request.setService(xbInsertSensor.getService());
request.setVersion(xbInsertSensor.getVersion());
// format
request.setProcedureDescriptionFormat(xbInsertSensor.getProcedureDescriptionFormat());
// observable properties
if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getObservablePropertyArray())) {
request.setObservableProperty(Arrays.asList(xbInsertSensor.getObservablePropertyArray()));
}
// related features
if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getRelatedFeatureArray())) {
request.setRelatedFeature(parseRelatedFeature(xbInsertSensor.getRelatedFeatureArray()));
}
// metadata
if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getMetadataArray())) {
request.setMetadata(parseMetadata(xbInsertSensor.getMetadataArray()));
}
// extensions
request.setExtensions(parseExtensibleRequest(xbInsertSensor));
try {
final XmlObject xbProcedureDescription = XmlObject.Factory.parse(getNodeFromNodeList(xbInsertSensor.getProcedureDescription().getDomNode().getChildNodes()));
checkFormatWithNamespace(xbInsertSensor.getProcedureDescriptionFormat(), XmlHelper.getNamespace(xbProcedureDescription));
final Decoder<?, XmlObject> decoder = getDecoder(new XmlNamespaceDecoderKey(xbInsertSensor.getProcedureDescriptionFormat(), xbProcedureDescription.getClass()));
if (decoder != null) {
final Object decodedProcedureDescription = decoder.decode(xbProcedureDescription);
if (decodedProcedureDescription instanceof SosProcedureDescription) {
request.setProcedureDescription((SosProcedureDescription) decodedProcedureDescription);
} else if (decodedProcedureDescription instanceof AbstractFeature) {
request.setProcedureDescription(new SosProcedureDescription<>((AbstractFeature) decodedProcedureDescription));
}
}
} catch (final XmlException xmle) {
throw new DecodingException("Error while parsing procedure description of InsertSensor request!", xmle);
}
return request;
}
use of org.n52.shetland.ogc.sos.SosProcedureDescription in project arctic-sea by 52North.
the class SwesDecoderv20 method parseUpdateSensorDescription.
/**
* parses the Xmlbeans UpdateSensorDescription document to a SOS request.
*
* @param xbUpSenDoc
* UpdateSensorDescription document
* @return SOS UpdateSensor request
*
* @throws DecodingException
* * if an error occurs.
*/
private OwsServiceRequest parseUpdateSensorDescription(final UpdateSensorDescriptionDocument xbUpSenDoc) throws DecodingException {
final UpdateSensorRequest request = new UpdateSensorRequest();
final UpdateSensorDescriptionType xbUpdateSensor = xbUpSenDoc.getUpdateSensorDescription();
request.setService(xbUpdateSensor.getService());
request.setVersion(xbUpdateSensor.getVersion());
request.setProcedureIdentifier(xbUpdateSensor.getProcedure());
request.setProcedureDescriptionFormat(xbUpdateSensor.getProcedureDescriptionFormat());
// extensions
request.setExtensions(parseExtensibleRequest(xbUpdateSensor));
for (final Description description : xbUpdateSensor.getDescriptionArray()) {
SensorDescriptionType sensorDescription = description.getSensorDescription();
try {
// TODO exception if valid time is set
final XmlObject xmlObject = XmlObject.Factory.parse(getNodeFromNodeList(sensorDescription.getData().getDomNode().getChildNodes()));
Decoder<?, XmlObject> decoder = getDecoder(getDecoderKey(xmlObject));
if (decoder == null) {
throw new DecodingException(UpdateSensorDescriptionParams.procedureDescriptionFormat, "The requested procedureDescritpionFormat is not supported!");
}
final Object decodedObject = decoder.decode(xmlObject);
SosProcedureDescription<?> sosProcedureDescription = null;
if (decodedObject instanceof SosProcedureDescription) {
sosProcedureDescription = (SosProcedureDescription) decodedObject;
} else if (decodedObject instanceof AbstractFeature) {
sosProcedureDescription = new SosProcedureDescription<>((AbstractFeature) decodedObject);
}
if (sosProcedureDescription != null) {
if (sensorDescription.isSetValidTime()) {
sosProcedureDescription.setValidTime(getValidTime(sensorDescription.getValidTime()));
}
}
request.addProcedureDescriptionString(sosProcedureDescription);
} catch (final XmlException xmle) {
throw new DecodingException("Error while parsing procedure description of UpdateSensor request!", xmle);
}
}
return request;
}
use of org.n52.shetland.ogc.sos.SosProcedureDescription in project arctic-sea by 52North.
the class AbstractOmEncoderv20 method encode.
@Override
public XmlObject encode(Object element, EncodingContext additionalValues) throws EncodingException {
XmlObject encodedObject = null;
if (element instanceof OmObservation) {
encodedObject = encodeOmObservation((OmObservation) element, additionalValues);
} else if (element instanceof NamedValue) {
NamedValueType nvt = createNamedValue((NamedValue<?>) element);
if (additionalValues.has(XmlBeansEncodingFlags.DOCUMENT)) {
NamedValueDocument nvd = NamedValueDocument.Factory.newInstance();
nvd.setNamedValue(nvt);
encodedObject = nvd;
} else if (additionalValues.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
NamedValuePropertyType nvpt = NamedValuePropertyType.Factory.newInstance();
nvpt.setNamedValue(nvt);
encodedObject = nvpt;
} else {
encodedObject = nvt;
}
} else if (element instanceof AbstractFeature) {
encodedObject = encodeFeatureOfInterest((AbstractFeature) element);
} else if (element instanceof SosProcedureDescription) {
encodedObject = encodeProcedureDescription((SosProcedureDescription<?>) element);
} else {
throw new UnsupportedEncoderInputException(this, element);
}
// XmlHelper.validateDocument(encodedObject));
return encodedObject;
}
use of org.n52.shetland.ogc.sos.SosProcedureDescription in project arctic-sea by 52North.
the class UpdateSensorRequestDecoder method parseProcedureDesciption.
private SosProcedureDescription<?> parseProcedureDesciption(String xml, String pdf) throws DecodingException {
try {
final XmlObject xb = XmlObject.Factory.parse(xml);
Decoder<?, XmlObject> decoder = getDecoder(new XmlNamespaceDecoderKey(pdf, xb.getClass()));
if (decoder == null) {
throw new DecodingException(JSONConstants.PROCEDURE_DESCRIPTION_FORMAT, "The requested %s is not supported!", JSONConstants.PROCEDURE_DESCRIPTION_FORMAT);
}
Object decode = decoder.decode(xb);
if (decode instanceof SosProcedureDescription<?>) {
return (SosProcedureDescription<?>) decode;
} else if (decode instanceof AbstractFeature) {
return new SosProcedureDescription<AbstractFeature>((AbstractFeature) decode);
} else {
throw new DecodingException("The decoded element {} is not of type {}!", decode.getClass().getName(), AbstractFeature.class.getName());
}
} catch (XmlException xmle) {
throw new DecodingException("Error while parsing procedure description of InsertSensor request!", xmle);
}
}
Aggregations