Search in sources :

Example 1 with Capabilities

use of net.opengis.sos.x10.CapabilitiesDocument.Capabilities 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 2 with Capabilities

use of net.opengis.sos.x10.CapabilitiesDocument.Capabilities 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 Capabilities

use of net.opengis.sos.x10.CapabilitiesDocument.Capabilities in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createCapability.

private Capabilities createCapability(final SmlCapabilities capabilities) throws EncodingException {
    final Capabilities xbCapabilities = Capabilities.Factory.newInstance(getXmlOptions());
    if (capabilities.isSetName()) {
        xbCapabilities.setName(capabilities.getName());
    }
    if (capabilities.isSetAbstractDataRecord() && capabilities.getDataRecord().isSetFields()) {
        final XmlObject encodedDataRecord = encodeObjectToXml(SweConstants.NS_SWE_101, capabilities.getDataRecord());
        final XmlObject substituteElement = XmlHelper.substituteElement(xbCapabilities.addNewAbstractDataRecord(), encodedDataRecord);
        substituteElement.set(encodedDataRecord);
    } else if (capabilities.isSetHref()) {
        xbCapabilities.setHref(capabilities.getHref());
        if (capabilities.isSetTitle()) {
            xbCapabilities.setTitle(capabilities.getTitle());
        }
    }
    return xbCapabilities;
}
Also used : Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) XmlObject(org.apache.xmlbeans.XmlObject)

Example 4 with Capabilities

use of net.opengis.sos.x10.CapabilitiesDocument.Capabilities in project arctic-sea by 52North.

the class SosV1GetCapabilitiesResponseEncoder method create.

@Override
protected XmlObject create(GetCapabilitiesResponse response) throws EncodingException {
    CapabilitiesDocument xbCapsDoc = CapabilitiesDocument.Factory.newInstance(getXmlOptions());
    // cursor for getting prefixes
    Capabilities xbCaps = xbCapsDoc.addNewCapabilities();
    // set version.
    xbCaps.setVersion(response.getVersion());
    SosCapabilities sosCapabilities = (SosCapabilities) response.getCapabilities();
    if (sosCapabilities.getServiceIdentification().isPresent()) {
        xbCaps.addNewServiceIdentification().set(encodeObjectToXml(OWSConstants.NS_OWS, sosCapabilities.getServiceIdentification().get()));
    }
    if (sosCapabilities.getServiceProvider().isPresent()) {
        xbCaps.addNewServiceProvider().set(encodeObjectToXml(OWSConstants.NS_OWS, sosCapabilities.getServiceProvider().get()));
    }
    if (sosCapabilities.getOperationsMetadata().isPresent()) {
        xbCaps.addNewOperationsMetadata().set(encodeObjectToXml(OWSConstants.NS_OWS, sosCapabilities.getOperationsMetadata().get()));
    }
    if (sosCapabilities.getFilterCapabilities().isPresent()) {
        setFilterCapabilities(xbCaps.addNewFilterCapabilities(), sosCapabilities.getFilterCapabilities().get());
    }
    if (sosCapabilities.getContents().isPresent()) {
        setContents(xbCaps.addNewContents(), sosCapabilities.getContents().get(), response.getVersion());
    }
    N52XmlHelper.setSchemaLocationsToDocument(xbCapsDoc, Sets.newHashSet(N52XmlHelper.getSchemaLocationForSOS100()));
    return xbCapsDoc;
}
Also used : Capabilities(net.opengis.sos.x10.CapabilitiesDocument.Capabilities) FilterCapabilities(net.opengis.sos.x10.FilterCapabilitiesDocument.FilterCapabilities) SosCapabilities(org.n52.shetland.ogc.sos.SosCapabilities) SosCapabilities(org.n52.shetland.ogc.sos.SosCapabilities) CapabilitiesDocument(net.opengis.sos.x10.CapabilitiesDocument)

Example 5 with Capabilities

use of net.opengis.sos.x10.CapabilitiesDocument.Capabilities in project arctic-sea by 52North.

the class SosV1GetCapabilitiesResponseEncoder method setContents.

/**
 * Sets the content section to the Capabilities document.
 *
 * @param xbContents SOS 2.0 contents section
 * @param offerings  SOS offerings for contents
 * @param version    SOS response version
 *
 * @throws EncodingException * if an error occurs.
 */
protected void setContents(Contents xbContents, Collection<SosObservationOffering> offerings, String version) throws EncodingException {
    // Contents xbContType = xbContents.addNewContents();
    ObservationOfferingList xbObservationOfferings = xbContents.addNewObservationOfferingList();
    for (SosObservationOffering offering : offerings) {
        ObservationOfferingType xbObservationOffering = xbObservationOfferings.addNewObservationOffering();
        // TODO check NAme or ID
        xbObservationOffering.setId(NcName.makeValid(offering.getOffering().getIdentifier()));
        // envelope
        if (offering.isSetObservedArea()) {
            xbObservationOffering.addNewBoundedBy().addNewEnvelope().set(encodeObjectToXml(GmlConstants.NS_GML, offering.getObservedArea()));
        }
        // set gml:name to offering's id (not ncname resolved)
        for (CodeType name : offering.getOffering().getName()) {
            xbObservationOffering.addNewName().set(encodeObjectToXml(GmlConstants.NS_GML, name));
        }
        // set up time
        if (offering.getPhenomenonTime() instanceof TimePeriod) {
            xbObservationOffering.addNewTime().set(encodeObjectToXml(SweConstants.NS_SWE_101, offering.getPhenomenonTime()));
        }
        offering.getObservableProperties().forEach(phenomenon -> xbObservationOffering.addNewObservedProperty().setHref(phenomenon));
        offering.getFeatureOfInterestTypes().forEach(featureOfInterestType -> xbObservationOffering.addNewFeatureOfInterest().setHref(featureOfInterestType));
        offering.getProcedureDescriptionFormats().forEach(procedureDescriptionFormat -> xbObservationOffering.addNewProcedure().setHref(procedureDescriptionFormat));
        offering.getProcedures().forEach(procedure -> xbObservationOffering.addNewProcedure().setHref(procedure));
        offering.getFeatureOfInterest().forEach(featureOfInterest -> xbObservationOffering.addNewFeatureOfInterest().setHref(featureOfInterest));
        offering.getResultModels().forEach(xbObservationOffering::addResultModel);
        offering.getResponseFormats().forEach(responseFormat -> xbObservationOffering.addNewResponseFormat().setStringValue(responseFormat));
        offering.getResponseModes().forEach(responseMode -> xbObservationOffering.addNewResponseMode().setStringValue(responseMode));
    }
}
Also used : ObservationOfferingList(net.opengis.sos.x10.ContentsDocument.Contents.ObservationOfferingList) ObservationOfferingType(net.opengis.sos.x10.ObservationOfferingType) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) CodeType(org.n52.shetland.ogc.gml.CodeType) SosObservationOffering(org.n52.shetland.ogc.sos.SosObservationOffering)

Aggregations

Capabilities (net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities)7 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)4 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)3 SystemType (net.opengis.sensorML.x101.SystemType)3 XmlObject (org.apache.xmlbeans.XmlObject)3 Test (org.junit.Test)3 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)3 SmlCapabilities (org.n52.shetland.ogc.sensorML.elements.SmlCapabilities)3 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)2 ContactList (net.opengis.sensorML.x101.ContactListDocument.ContactList)1 CapabilitiesDocument (net.opengis.sos.x10.CapabilitiesDocument)1 Capabilities (net.opengis.sos.x10.CapabilitiesDocument.Capabilities)1 ObservationOfferingList (net.opengis.sos.x10.ContentsDocument.Contents.ObservationOfferingList)1 FilterCapabilities (net.opengis.sos.x10.FilterCapabilitiesDocument.FilterCapabilities)1 ObservationOfferingType (net.opengis.sos.x10.ObservationOfferingType)1 XmlCursor (org.apache.xmlbeans.XmlCursor)1 CodeType (org.n52.shetland.ogc.gml.CodeType)1 Time (org.n52.shetland.ogc.gml.time.Time)1 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)1 SmlContactList (org.n52.shetland.ogc.sensorML.SmlContactList)1