Search in sources :

Example 1 with AbstractSensorML

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;
}
Also used : AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) PhysicalComponent(org.n52.shetland.ogc.sensorML.v20.PhysicalComponent) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) Component(net.opengis.sensorml.x20.ComponentListType.Component) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent)

Example 2 with AbstractSensorML

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;
}
Also used : AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 3 with AbstractSensorML

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;
}
Also used : AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) EncodingException(org.n52.svalbard.encode.exception.EncodingException) XmlException(org.apache.xmlbeans.XmlException) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Aggregations

AbstractSensorML (org.n52.shetland.ogc.sensorML.AbstractSensorML)3 XmlObject (org.apache.xmlbeans.XmlObject)2 EncodingException (org.n52.svalbard.encode.exception.EncodingException)2 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)2 Component (net.opengis.sensorml.x20.ComponentListType.Component)1 XmlException (org.apache.xmlbeans.XmlException)1 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)1 SmlComponent (org.n52.shetland.ogc.sensorML.elements.SmlComponent)1 PhysicalComponent (org.n52.shetland.ogc.sensorML.v20.PhysicalComponent)1 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)1