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);
}
}
}
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);
}
}
}
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;
}
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;
}
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));
}
}
Aggregations