Search in sources :

Example 1 with Identification

use of net.opengis.sensorML.x101.IdentificationDocument.Identification 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 2 with Identification

use of net.opengis.sensorML.x101.IdentificationDocument.Identification 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)

Example 3 with Identification

use of net.opengis.sensorML.x101.IdentificationDocument.Identification in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createIdentification.

/**
 * Creates the valueentification section of the SensorML description.
 *
 * @param identifications
 *            SOS valueentifications
 *
 * @return XML Identification array
 */
protected Identification[] createIdentification(List<SmlIdentifier> identifications) {
    Identification xbIdentification = Identification.Factory.newInstance(getXmlOptions());
    IdentifierList xbIdentifierList = xbIdentification.addNewIdentifierList();
    identifications.forEach(sosSMLIdentifier -> {
        Identifier xbIdentifier = xbIdentifierList.addNewIdentifier();
        if (sosSMLIdentifier.getName() != null) {
            xbIdentifier.setName(sosSMLIdentifier.getName());
        }
        Term xbTerm = xbIdentifier.addNewTerm();
        xbTerm.setDefinition(sosSMLIdentifier.getDefinition());
        xbTerm.setValue(sosSMLIdentifier.getValue());
    });
    return new Identification[] { xbIdentification };
}
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) Term(net.opengis.sensorML.x101.TermDocument.Term) IdentifierList(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)

Aggregations

Identification (net.opengis.sensorML.x101.IdentificationDocument.Identification)2 Identifier (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList.Identifier)2 SmlIdentifier (org.n52.shetland.ogc.sensorML.elements.SmlIdentifier)2 Capabilities (net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities)1 ContactList (net.opengis.sensorML.x101.ContactListDocument.ContactList)1 IdentifierList (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)1 Term (net.opengis.sensorML.x101.TermDocument.Term)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 XmlObject (org.apache.xmlbeans.XmlObject)1 Time (org.n52.shetland.ogc.gml.time.Time)1 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)1 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)1 SmlContactList (org.n52.shetland.ogc.sensorML.SmlContactList)1 SmlCapabilities (org.n52.shetland.ogc.sensorML.elements.SmlCapabilities)1 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)1