use of org.n52.shetland.ogc.sensorML.AbstractSensorML in project arctic-sea by 52North.
the class SensorMLDecoderV20 method parseComponents.
private List<SmlComponent> parseComponents(ComponentListPropertyType components) throws DecodingException {
final List<SmlComponent> sosSmlComponents = Lists.newLinkedList();
if (components.isSetComponentList() && components.getComponentList().getComponentArray() != null) {
for (final Component component : components.getComponentList().getComponentArray()) {
if (component.isSetAbstractProcess() || component.isSetHref() || component.isSetTitle()) {
final SmlComponent sosSmlcomponent = new SmlComponent(component.getName());
AbstractSensorML abstractProcess;
if (component.isSetAbstractProcess()) {
abstractProcess = parse(component.getAbstractProcess());
} else {
if (component.isSetTitle()) {
sosSmlcomponent.setTitle(component.getTitle());
}
if (component.isSetHref()) {
sosSmlcomponent.setHref(component.getHref());
}
abstractProcess = new AbstractProcess();
if (sosSmlcomponent.isSetTitle()) {
abstractProcess.setIdentifier(sosSmlcomponent.getTitle());
} else if (!sosSmlcomponent.isSetTitle() && sosSmlcomponent.isSetHref()) {
abstractProcess.setIdentifier(sosSmlcomponent.getHref());
}
}
sosSmlcomponent.setProcess(abstractProcess);
sosSmlComponents.add(sosSmlcomponent);
}
}
}
return sosSmlComponents;
}
use of org.n52.shetland.ogc.sensorML.AbstractSensorML in project arctic-sea by 52North.
the class SensorMLEncoderv101 method encode.
@Override
public XmlObject encode(final Object response, final EncodingContext additionalValues) throws EncodingException {
XmlObject encodedObject = null;
if (response instanceof AbstractSensorML) {
encodedObject = createSensorDescription((AbstractSensorML) response);
// }
// FIXME workaround? if of type UnknowProcedureType try to parse the
// description string, UNIT is missing "NOT_DEFINED"?!
// else if (response instanceof SosProcedureDescriptionUnknownType)
// {
// final String procDescXMLString = ((SosProcedureDescription)
// response).getXml();
// final AbstractSensorML sensorDesc = new AbstractSensorML();
// sensorDesc.setXml(procDescXMLString);
// encodedObject = createSensorDescriptionFromString(sensorDesc);
} else {
throw new UnsupportedEncoderInputException(this, response);
}
// check if all gml:id are unique
XmlHelper.makeGmlIdsUnique(encodedObject.getDomNode());
XmlHelper.validateDocument(encodedObject, EncodingException::new);
return encodedObject;
}
use of org.n52.shetland.ogc.sensorML.AbstractSensorML in project arctic-sea by 52North.
the class SensorMLEncoderv20 method encode.
@Override
public XmlObject encode(Object objectToEncode, EncodingContext additionalValues) throws EncodingException {
XmlObject encodedObject = null;
try {
if (objectToEncode instanceof AbstractSensorML) {
AbstractSensorML description = (AbstractSensorML) objectToEncode;
if (description.isSetXml()) {
encodedObject = XmlObject.Factory.parse(((AbstractSensorML) objectToEncode).getXml());
addValuesToXmlObject(encodedObject, (AbstractSensorML) objectToEncode);
encodedObject = checkForAdditionalValues(encodedObject, additionalValues);
} else {
encodedObject = encodeDescription(description, additionalValues);
}
} else {
throw new UnsupportedEncoderInputException(this, objectToEncode);
}
} catch (XmlException xmle) {
throw new EncodingException(xmle);
}
// check if all gml:id are unique
XmlHelper.makeGmlIdsUnique(encodedObject.getDomNode());
XmlHelper.validateDocument(encodedObject, EncodingException::new);
return encodedObject;
}
Aggregations