use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.
the class SosDecoderv100 method parseGetObservationById.
private OwsServiceRequest parseGetObservationById(GetObservationByIdDocument getObsByIdDoc) throws DecodingException {
GetObservationByIdRequest getObsByIdRequest = new GetObservationByIdRequest();
GetObservationById getObsById = getObsByIdDoc.getGetObservationById();
getObsByIdRequest.setService(getObsById.getService());
getObsByIdRequest.setVersion(getObsById.getVersion());
if (getObsById.isSetResponseFormat()) {
getObsByIdRequest.setResponseFormat(decodeResponseFormat(getObsById.getResponseFormat()));
} else {
getObsByIdRequest.setResponseFormat(OmConstants.CONTENT_TYPE_OM.toString());
}
net.opengis.sos.x10.ResponseModeType.Enum responseMode = getObsById.getResponseMode();
if (responseMode != null && responseMode.toString().equalsIgnoreCase(SosConstants.RESPONSE_MODE_INLINE)) {
getObsByIdRequest.setResponseMode(SosConstants.RESPONSE_MODE_INLINE);
}
if (getObsById.isSetResultModel()) {
getObsByIdRequest.setResultModel(OMHelper.getObservationTypeFor(getObsById.getResultModel()));
}
getObsByIdRequest.setObservationIdentifier(Arrays.asList(getObsById.getObservationId()));
return getObsByIdRequest;
}
use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.
the class SosDecoderv20 method parseInsertObservation.
private OwsServiceRequest parseInsertObservation(final InsertObservationDocument insertObservationDoc) throws DecodingException {
// set namespace for default XML type (e.g. xs:string, xs:integer,
// xs:boolean, ...)
// Fix for problem with XmlBeans: namespace is not set in child elements
// when defined in root of request (SOAP)
final XmlCursor cursor = insertObservationDoc.newCursor();
if (cursor.toFirstChild() && cursor.namespaceForPrefix(W3CConstants.NS_XS_PREFIX) == null) {
cursor.prefixForNamespace(W3CConstants.NS_XS);
}
cursor.dispose();
final InsertObservationRequest insertObservationRequest = new InsertObservationRequest();
final InsertObservationType insertObservationType = insertObservationDoc.getInsertObservation();
insertObservationRequest.setService(insertObservationType.getService());
insertObservationRequest.setVersion(insertObservationType.getVersion());
if (insertObservationDoc.getInsertObservation().getOfferingArray() != null) {
insertObservationRequest.setOfferings(Arrays.asList(insertObservationType.getOfferingArray()));
}
insertObservationRequest.setExtensions(parseExtensibleRequest(insertObservationType));
if (insertObservationType.getObservationArray() != null) {
final int length = insertObservationType.getObservationArray().length;
final Map<String, Time> phenomenonTimes = new HashMap<>(length);
final Map<String, TimeInstant> resultTimes = new HashMap<>(length);
final Map<String, AbstractFeature> features = new HashMap<>(length);
CompositeException exceptions = new CompositeException();
for (final Observation observation : insertObservationType.getObservationArray()) {
final Object decodedObject = decodeXmlElement(observation.getOMObservation());
if (decodedObject instanceof OmObservation) {
final OmObservation sosObservation = (OmObservation) decodedObject;
checkAndAddPhenomenonTime(sosObservation.getPhenomenonTime(), phenomenonTimes);
checkAndAddResultTime(sosObservation.getResultTime(), resultTimes);
checkAndAddFeatures(sosObservation.getObservationConstellation().getFeatureOfInterest(), features);
insertObservationRequest.addObservation(sosObservation);
} else {
exceptions.add(new DecodingException(Sos2Constants.InsertObservationParams.observation, "The requested observation type (%s) is not supported by this server!", observation.getOMObservation().getDomNode().getNodeName()));
}
}
checkReferencedElements(insertObservationRequest.getObservations(), phenomenonTimes, resultTimes, features);
try {
exceptions.throwIfNotEmpty();
} catch (CompositeException ex) {
throw new DecodingException(ex, Sos2Constants.InsertObservationParams.observation);
}
} else {
// TODO MissingMandatoryParameterException?
throw new DecodingException(Sos2Constants.InsertObservationParams.observation, "The request does not contain an observation");
}
return insertObservationRequest;
}
use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.
the class SosDecoderv20 method parseGetResultTemplate.
private OwsServiceRequest parseGetResultTemplate(final GetResultTemplateDocument getResultTemplateDoc) throws DecodingException {
final GetResultTemplateType getResultTemplate = getResultTemplateDoc.getGetResultTemplate();
final GetResultTemplateRequest sosGetResultTemplateRequest = new GetResultTemplateRequest();
sosGetResultTemplateRequest.setService(getResultTemplate.getService());
sosGetResultTemplateRequest.setVersion(getResultTemplate.getVersion());
sosGetResultTemplateRequest.setOffering(getResultTemplate.getOffering());
sosGetResultTemplateRequest.setObservedProperty(getResultTemplate.getObservedProperty());
sosGetResultTemplateRequest.setExtensions(parseExtensibleRequest(getResultTemplate));
return sosGetResultTemplateRequest;
}
use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.
the class SosDecoderv20 method parseGetFeatureOfInterest.
// private SwesExtensions parseSwesExtensions(final XmlObject[]
// extensionArray) throws OwsExceptionReport
// {
// final SwesExtensions extensions = new SwesExtensions();
// for (final XmlObject xbSwesExtension : extensionArray) {
//
// final Object obj = CodingHelper.decodeXmlElement(xbSwesExtension);
// if (obj instanceof SwesExtension<?>) {
// extensions.addSwesExtension((SwesExtension<?>) obj);
// }
// }
// return extensions;
// }
/**
* parses the passes XmlBeans document and creates a SOS
* getFeatureOfInterest request
*
* @param getFoiDoc
* XmlBeans document representing the getFeatureOfInterest
* request
* @return Returns SOS getFeatureOfInterest request
*
* @throws DecodingException
* * if validation of the request failed
*/
private OwsServiceRequest parseGetFeatureOfInterest(final GetFeatureOfInterestDocument getFoiDoc) throws DecodingException {
final GetFeatureOfInterestRequest getFoiRequest = new GetFeatureOfInterestRequest();
final GetFeatureOfInterestType getFoiType = getFoiDoc.getGetFeatureOfInterest();
getFoiRequest.setService(getFoiType.getService());
getFoiRequest.setVersion(getFoiType.getVersion());
getFoiRequest.setFeatureIdentifiers(Arrays.asList(getFoiType.getFeatureOfInterestArray()));
getFoiRequest.setObservedProperties(Arrays.asList(getFoiType.getObservedPropertyArray()));
getFoiRequest.setProcedures(Arrays.asList(getFoiType.getProcedureArray()));
getFoiRequest.setSpatialFilters(parseSpatialFilters4GetFeatureOfInterest(getFoiType.getSpatialFilterArray()));
getFoiRequest.setExtensions(parseExtensibleRequest(getFoiType));
return getFoiRequest;
}
use of org.n52.shetland.ogc.ows.service.OwsServiceRequest in project arctic-sea by 52North.
the class SosDecoderv20 method parseInsertResultTemplate.
private OwsServiceRequest parseInsertResultTemplate(final InsertResultTemplateDocument insertResultTemplateDoc) throws DecodingException {
InsertResultTemplateRequest sosInsertResultTemplate = new InsertResultTemplateRequest();
InsertResultTemplateType insertResultTemplate = insertResultTemplateDoc.getInsertResultTemplate();
sosInsertResultTemplate.setService(insertResultTemplate.getService());
sosInsertResultTemplate.setVersion(insertResultTemplate.getVersion());
ResultTemplateType resultTemplate = insertResultTemplate.getProposedTemplate().getResultTemplate();
sosInsertResultTemplate.setIdentifier(resultTemplate.getIdentifier());
OmObservationConstellation sosObservationConstellation = parseObservationTemplate(resultTemplate.getObservationTemplate());
sosObservationConstellation.addOffering(resultTemplate.getOffering());
sosInsertResultTemplate.setObservationTemplate(sosObservationConstellation);
try {
sosInsertResultTemplate.setResultStructure(parseResultStructure(XmlObject.Factory.parse(resultTemplate.getResultStructure().xmlText())));
sosInsertResultTemplate.setResultEncoding(parseResultEncoding(XmlObject.Factory.parse(resultTemplate.getResultEncoding().xmlText())));
} catch (XmlException e) {
throw new DecodingException(e, "Error while parsing InsertResultTemplate request!");
}
sosInsertResultTemplate.setExtensions(parseExtensibleRequest(insertResultTemplate));
return sosInsertResultTemplate;
}
Aggregations