Search in sources :

Example 1 with AbstractProcess

use of org.n52.shetland.ogc.sensorML.AbstractProcess 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 AbstractProcess

use of org.n52.shetland.ogc.sensorML.AbstractProcess in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseAbstractProcess.

private void parseAbstractProcess(final AbstractProcessType xbAbstractProcess, final AbstractProcess abstractProcess) throws DecodingException {
    if (xbAbstractProcess.getId() != null) {
        abstractProcess.setGmlId(xbAbstractProcess.getId());
    }
    if (xbAbstractProcess.getIdentificationArray() != null) {
        parseIdentifications(abstractProcess, xbAbstractProcess.getIdentificationArray());
    }
    if (xbAbstractProcess.getClassificationArray() != null) {
        abstractProcess.setClassifications(parseClassification(xbAbstractProcess.getClassificationArray()));
    }
    if (xbAbstractProcess.getCharacteristicsArray() != null) {
        abstractProcess.setCharacteristics(parseCharacteristics(xbAbstractProcess.getCharacteristicsArray()));
    }
    if (xbAbstractProcess.getCapabilitiesArray() != null) {
        parseCapabilities(abstractProcess, xbAbstractProcess.getCapabilitiesArray());
        checkCapabilitiesForRemoval(xbAbstractProcess.getCapabilitiesArray()).forEach(xbAbstractProcess::removeCapabilities);
    }
    if (xbAbstractProcess.isSetDescription()) {
        abstractProcess.addDescription(xbAbstractProcess.getDescription().getStringValue());
    }
    if (xbAbstractProcess.isSetValidTime()) {
        abstractProcess.setValidTime(parseValidTime(xbAbstractProcess.getValidTime()));
    }
    if (xbAbstractProcess.getContactArray() != null) {
        abstractProcess.setContact(parseContact(xbAbstractProcess.getContactArray()));
    }
    if (xbAbstractProcess.getDocumentationArray() != null) {
        abstractProcess.setDocumentation(parseDocumentation(xbAbstractProcess.getDocumentationArray()));
    }
    if (xbAbstractProcess.getHistoryArray() != null) {
        abstractProcess.setHistory(parseHistory(xbAbstractProcess.getHistoryArray()));
    }
    if (xbAbstractProcess.getKeywordsArray() != null) {
        abstractProcess.setKeywords(parseKeywords(xbAbstractProcess.getKeywordsArray()));
    }
    if (xbAbstractProcess.getNameArray() != null) {
        final int length = xbAbstractProcess.getNameArray().length;
        for (int i = 0; i < length; i++) {
            final Object decodedElement = decodeXmlElement(xbAbstractProcess.getNameArray(i));
            if (decodedElement instanceof CodeType) {
                abstractProcess.addName((CodeType) decodedElement);
            }
        }
    }
}
Also used : CodeType(org.n52.shetland.ogc.gml.CodeType) XmlObject(org.apache.xmlbeans.XmlObject) Point(org.locationtech.jts.geom.Point)

Example 3 with AbstractProcess

use of org.n52.shetland.ogc.sensorML.AbstractProcess in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseIdentifications.

/**
 * Parses the identifications and sets the AbstractProcess' identifiers
 *
 * @param abstractProcess The AbstractProcess to which identifiers are added
 * @param identificationArray XML identification
 */
private void parseIdentifications(final AbstractProcess abstractProcess, final Identification[] identificationArray) {
    for (final Identification xbIdentification : identificationArray) {
        if (xbIdentification.getIdentifierList() != null) {
            for (final Identifier xbIdentifier : xbIdentification.getIdentifierList().getIdentifierArray()) {
                if (xbIdentifier.getName() != null && xbIdentifier.getTerm() != null) {
                    final SmlIdentifier identifier = new SmlIdentifier(xbIdentifier.getName(), xbIdentifier.getTerm().getDefinition(), xbIdentifier.getTerm().getValue());
                    abstractProcess.addIdentifier(identifier);
                    if (isIdentificationProcedureIdentifier(identifier)) {
                        abstractProcess.setIdentifier(identifier.getValue());
                    }
                }
            }
        }
    }
}
Also used : Identifier(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList.Identifier) SmlIdentifier(org.n52.shetland.ogc.sensorML.elements.SmlIdentifier) Identification(net.opengis.sensorML.x101.IdentificationDocument.Identification) SmlIdentifier(org.n52.shetland.ogc.sensorML.elements.SmlIdentifier)

Example 4 with AbstractProcess

use of org.n52.shetland.ogc.sensorML.AbstractProcess in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseCapabilities.

/**
 * Parses the capabilities, processing and removing special insertion metadata
 *
 * @param abstractProcess The AbstractProcess to which capabilities and insertion metadata are added
 * @param capabilitiesArray XML capabilities
 *
 * @throws DecodingException if an error occurs
 */
private void parseCapabilities(final AbstractProcess abstractProcess, final Capabilities[] capabilitiesArray) throws DecodingException {
    for (final Capabilities xbcaps : capabilitiesArray) {
        final SmlCapabilities caps = new SmlCapabilities();
        if (xbcaps.isSetName()) {
            caps.setName(xbcaps.getName());
        }
        if (xbcaps.isSetAbstractDataRecord()) {
            final Object o = decodeXmlElement(xbcaps.getAbstractDataRecord());
            if (o instanceof DataRecord) {
                final DataRecord record = (DataRecord) o;
                caps.setDataRecord(record).setName(xbcaps.getName());
            } else {
                throw new DecodingException(XmlHelper.getLocalName(xbcaps), "Error while parsing the capabilities of the SensorML (the " + "capabilities data record is not of type DataRecordPropertyType)!");
            }
        } else if (xbcaps.isSetHref()) {
            caps.setHref(xbcaps.getHref());
            if (xbcaps.isSetTitle()) {
                caps.setTitle(xbcaps.getTitle());
            }
        }
        if (caps.isSetName()) {
            abstractProcess.addCapabilities(caps);
        }
    }
}
Also used : SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DataRecord(org.n52.shetland.ogc.swe.DataRecord)

Example 5 with AbstractProcess

use of org.n52.shetland.ogc.sensorML.AbstractProcess in project arctic-sea by 52North.

the class SensorMLEncoderv101 method addAbstractProcessValues.

// TODO refactor/rename
private void addAbstractProcessValues(final AbstractProcessType abstractProcess, final AbstractProcess sosAbstractProcess) throws EncodingException {
    if (sosAbstractProcess.isSetGmlID()) {
        abstractProcess.setId(sosAbstractProcess.getGmlId());
    }
    if (sosAbstractProcess.isSetCapabilities()) {
        final Capabilities[] existing = abstractProcess.getCapabilitiesArray();
        final Set<String> names = Sets.newHashSetWithExpectedSize(existing.length);
        for (final Capabilities element : existing) {
            if (element.getName() != null) {
                names.add(element.getName());
            }
        }
        for (final SmlCapabilities sosCapability : sosAbstractProcess.getCapabilities()) {
            final Capabilities c = createCapability(sosCapability);
            // replace existing capability with the same name
            if (names.contains(c.getName())) {
                removeCapability(abstractProcess, c);
            }
            abstractProcess.addNewCapabilities().set(c);
        }
    }
    // set description
    if (sosAbstractProcess.isSetDescription() && !abstractProcess.isSetDescription()) {
        abstractProcess.addNewDescription().setStringValue(sosAbstractProcess.getDescription());
    }
    if (sosAbstractProcess.isSetName() && CollectionHelper.isNullOrEmpty(abstractProcess.getNameArray())) {
        // TODO check if override existing names
        addNamesToAbstractProcess(abstractProcess, sosAbstractProcess.getNames());
    }
    // set identification
    if (sosAbstractProcess.isSetIdentifications()) {
        abstractProcess.setIdentificationArray(createIdentification(sosAbstractProcess.getIdentifications()));
    }
    // set classification
    if (sosAbstractProcess.isSetClassifications()) {
        abstractProcess.setClassificationArray(createClassification(sosAbstractProcess.getClassifications()));
    }
    // set characteristics
    if (sosAbstractProcess.isSetCharacteristics()) {
        abstractProcess.setCharacteristicsArray(createCharacteristics(sosAbstractProcess.getCharacteristics()));
    }
    // set documentation
    if (sosAbstractProcess.isSetDocumentation() && CollectionHelper.isNullOrEmpty(abstractProcess.getDocumentationArray())) {
        abstractProcess.setDocumentationArray(createDocumentationArray(sosAbstractProcess.getDocumentation()));
    }
    // process
    if (sosAbstractProcess.isSetContact() && CollectionHelper.isNullOrEmpty(abstractProcess.getContactArray())) {
        ContactList contactList = createContactList(sosAbstractProcess.getContact());
        if (contactList != null && contactList.getMemberArray().length > 0) {
            abstractProcess.addNewContact().setContactList(contactList);
        }
    }
    // set keywords
    if (sosAbstractProcess.isSetKeywords()) {
        final List<String> keywords = sosAbstractProcess.getKeywords();
        final int length = abstractProcess.getKeywordsArray().length;
        for (int i = 0; i < length; ++i) {
            abstractProcess.removeKeywords(i);
        }
        abstractProcess.addNewKeywords().addNewKeywordList().setKeywordArray(keywords.toArray(new String[keywords.size()]));
    }
    if (sosAbstractProcess.isSetValidTime()) {
        if (abstractProcess.isSetValidTime()) {
            // remove existing validTime element
            final XmlCursor newCursor = abstractProcess.getValidTime().newCursor();
            newCursor.removeXml();
            newCursor.dispose();
        }
        final Time time = sosAbstractProcess.getMergedValidTime();
        final XmlObject xbtime = encodeObjectToXml(GmlConstants.NS_GML, time);
        if (time instanceof TimeInstant) {
            abstractProcess.addNewValidTime().addNewTimeInstant().set(xbtime);
        } else if (time instanceof TimePeriod) {
            abstractProcess.addNewValidTime().addNewTimePeriod().set(xbtime);
        }
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) Time(org.n52.shetland.ogc.gml.time.Time) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) ContactList(net.opengis.sensorML.x101.ContactListDocument.ContactList) SmlContactList(org.n52.shetland.ogc.sensorML.SmlContactList) XmlCursor(org.apache.xmlbeans.XmlCursor) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) XmlObject(org.apache.xmlbeans.XmlObject) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Aggregations

AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)15 SystemType (net.opengis.sensorML.x101.SystemType)14 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)12 Test (org.junit.Test)10 XmlObject (org.apache.xmlbeans.XmlObject)6 SmlComponent (org.n52.shetland.ogc.sensorML.elements.SmlComponent)6 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)6 Capabilities (net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities)5 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)4 IdentifierList (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)4 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)4 ComponentType (net.opengis.sensorML.x101.ComponentType)3 AbstractSensorML (org.n52.shetland.ogc.sensorML.AbstractSensorML)3 SensorML (org.n52.shetland.ogc.sensorML.SensorML)3 System (org.n52.shetland.ogc.sensorML.System)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3 AbstractProcessType (net.opengis.sensorML.x101.AbstractProcessType)2 ComponentList (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList)2 ContactList (net.opengis.sensorML.x101.ContactListDocument.ContactList)2 ProcessModelType (net.opengis.sensorML.x101.ProcessModelType)2