From d449cc53d2fd94ac4d33f868dcd7aef2a056c591 Mon Sep 17 00:00:00 2001 From: CarstenHollmann Date: Tue, 26 Aug 2014 15:46:22 +0200 Subject: [PATCH 1/6] Add InsertResultTemplate and InsertResult examples with time period for om:phenomenonTime and time instant for om:resultTime. --- .../webapp/static/conf/client-config.json | 52 +++++++++++++ .../InsertResultTemplateWithResultTime.xml | 76 +++++++++++++++++++ .../InsertResultWithResultTime.xml | 11 +++ .../InsertResultTemplateWithResultTime.xml | 69 +++++++++++++++++ .../InsertResultWithResultTime.xml | 7 ++ 5 files changed, 215 insertions(+) create mode 100644 webapp/src/main/webapp/static/examples/sos_v20/requests_soap/ResultHandling/InsertResultTemplateWithResultTime.xml create mode 100644 webapp/src/main/webapp/static/examples/sos_v20/requests_soap/ResultHandling/InsertResultWithResultTime.xml create mode 100644 webapp/src/main/webapp/static/examples/sos_v20/requests_xml/ResultHandling/InsertResultTemplateWithResultTime.xml create mode 100644 webapp/src/main/webapp/static/examples/sos_v20/requests_xml/ResultHandling/InsertResultWithResultTime.xml diff --git a/webapp/src/main/webapp/static/conf/client-config.json b/webapp/src/main/webapp/static/conf/client-config.json index 5f4a40736c..a14ba0186a 100644 --- a/webapp/src/main/webapp/static/conf/client-config.json +++ b/webapp/src/main/webapp/static/conf/client-config.json @@ -1361,6 +1361,32 @@ }, "method":"POST" }, + { + "request":"static/examples/sos_v20/requests_xml/ResultHandling/InsertResultWithResultTime.xml", + "service":"SOS", + "version":"2.0.0", + "binding": "application/xml", + "operation":"InsertResult", + "title":"with ResultTime", + "headers":{ + "Accept":"application/xml", + "Content-Type":"application/xml" + }, + "method":"POST" + }, + { + "request":"static/examples/sos_v20/requests_xml/ResultHandling/InsertResultTemplateWithResultTime.xml", + "service":"SOS", + "version":"2.0.0", + "binding": "application/xml", + "operation":"InsertResultTemplate", + "title":"with ResultTime", + "headers":{ + "Accept":"application/xml", + "Content-Type":"application/xml" + }, + "method":"POST" + }, { "request":"static/examples/sos_v20/requests_xml/Transactional/InsertSensor.xml", "service":"SOS", @@ -1763,6 +1789,32 @@ }, "method":"POST" }, + { + "request":"static/examples/sos_v20/requests_soap/ResultHandling/InsertResultWithResultTime.xml", + "service":"SOS", + "version":"2.0.0", + "binding": "application/soap+xml", + "operation":"InsertResult", + "title":"with ResultTime", + "headers":{ + "Accept":"application/soap+xml", + "Content-Type":"application/soap+xml" + }, + "method":"POST" + }, + { + "request":"static/examples/sos_v20/requests_soap/ResultHandling/InsertResultTemplateWithResultTime.xml", + "service":"SOS", + "version":"2.0.0", + "binding": "application/soap+xml", + "operation":"InsertResultTemplate", + "title":"with ResultTime", + "headers":{ + "Accept":"application/soap+xml", + "Content-Type":"application/soap+xml" + }, + "method":"POST" + }, { "request":"static/examples/sos_v20/requests_soap/Transactional/InsertSensor.xml", "service":"SOS", diff --git a/webapp/src/main/webapp/static/examples/sos_v20/requests_soap/ResultHandling/InsertResultTemplateWithResultTime.xml b/webapp/src/main/webapp/static/examples/sos_v20/requests_soap/ResultHandling/InsertResultTemplateWithResultTime.xml new file mode 100644 index 0000000000..d8dc54993d --- /dev/null +++ b/webapp/src/main/webapp/static/examples/sos_v20/requests_soap/ResultHandling/InsertResultTemplateWithResultTime.xml @@ -0,0 +1,76 @@ + + + + + + + + http://www.52north.org/test/procedure/9/template/2 + http://www.52north.org/test/offering/9 + + + + + + + + + + http://www.52north.org/test/featureOfInterest/9 + 52°North + + + + + 51.935101100104916 7.651968812254194 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp/src/main/webapp/static/examples/sos_v20/requests_soap/ResultHandling/InsertResultWithResultTime.xml b/webapp/src/main/webapp/static/examples/sos_v20/requests_soap/ResultHandling/InsertResultWithResultTime.xml new file mode 100644 index 0000000000..05e5b94761 --- /dev/null +++ b/webapp/src/main/webapp/static/examples/sos_v20/requests_soap/ResultHandling/InsertResultWithResultTime.xml @@ -0,0 +1,11 @@ + + + + + http://www.52north.org/test/procedure/9/template/2 + 15@2012-11-19T13:30:00+02:00/2012-11-19T13:30:59+02:00#2012-11-19T13:31:01+02:00#159@2012-11-19T13:31:00+02:00/2012-11-19T13:31:59+02:00#2012-11-19T13:32:01+02:00#159@2012-11-19T13:32:00+02:00/2012-11-19T13:32:59+02:00#2012-11-19T13:33:01+02:00#159@2012-11-19T13:33:00+02:00/2012-11-19T13:33:59+02:00#2012-11-19T13:34:01+02:00#160@2012-11-19T13:34:00+02:00/2012-11-19T13:34:59+02:00#2012-11-19T13:35:01+02:00#160@2012-11-19T13:35:00+02:00/2012-11-19T13:35:59+02:00#2012-11-19T13:36:01+02:00#160@2012-11-19T13:36:00+02:00/2012-11-19T13:36:59+02:00#2012-11-19T13:37:01+02:00#160@2012-11-19T13:37:00+02:00/2012-11-19T13:37:59+02:00#2012-11-19T13:38:01+02:00#160@2012-11-19T13:38:00+02:00/2012-11-19T13:38:59+02:00#2012-11-19T13:39:01+02:00#160@2012-11-19T13:39:00+02:00/2012-11-19T13:39:59+02:00#2012-11-19T13:40:01+02:00#160@2012-11-19T13:40:00+02:00/2012-11-19T13:40:59+02:00#2012-11-19T13:41:01+02:00#160@2012-11-19T13:41:00+02:00/2012-11-19T13:41:59+02:00#2012-11-19T13:42:01+02:00#160@2012-11-19T13:42:00+02:00/2012-11-19T13:42:59+02:00#2012-11-19T13:43:01+02:00#159@2012-11-19T13:43:00+02:00/2012-11-19T13:43:59+02:00#2012-11-19T13:44:01+02:00#159@2012-11-19T13:44:00+02:00/2012-11-19T13:44:59+02:00#2012-11-19T13:45:01+02:00#159@ + + + diff --git a/webapp/src/main/webapp/static/examples/sos_v20/requests_xml/ResultHandling/InsertResultTemplateWithResultTime.xml b/webapp/src/main/webapp/static/examples/sos_v20/requests_xml/ResultHandling/InsertResultTemplateWithResultTime.xml new file mode 100644 index 0000000000..f86b7f910a --- /dev/null +++ b/webapp/src/main/webapp/static/examples/sos_v20/requests_xml/ResultHandling/InsertResultTemplateWithResultTime.xml @@ -0,0 +1,69 @@ + + + + + + http://www.52north.org/test/procedure/9/template/2 + http://www.52north.org/test/offering/9 + + + + + + + + + + http://www.52north.org/test/featureOfInterest/9 + 52°North + + + + + 51.935101100104916 7.651968812254194 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp/src/main/webapp/static/examples/sos_v20/requests_xml/ResultHandling/InsertResultWithResultTime.xml b/webapp/src/main/webapp/static/examples/sos_v20/requests_xml/ResultHandling/InsertResultWithResultTime.xml new file mode 100644 index 0000000000..5968a1222b --- /dev/null +++ b/webapp/src/main/webapp/static/examples/sos_v20/requests_xml/ResultHandling/InsertResultWithResultTime.xml @@ -0,0 +1,7 @@ + + + http://www.52north.org/test/procedure/9/template/2 + 15@2012-11-19T13:30:00+02:00/2012-11-19T13:30:59+02:00#2012-11-19T13:31:01+02:00#159@2012-11-19T13:31:00+02:00/2012-11-19T13:31:59+02:00#2012-11-19T13:32:01+02:00#159@2012-11-19T13:32:00+02:00/2012-11-19T13:32:59+02:00#2012-11-19T13:33:01+02:00#159@2012-11-19T13:33:00+02:00/2012-11-19T13:33:59+02:00#2012-11-19T13:34:01+02:00#160@2012-11-19T13:34:00+02:00/2012-11-19T13:34:59+02:00#2012-11-19T13:35:01+02:00#160@2012-11-19T13:35:00+02:00/2012-11-19T13:35:59+02:00#2012-11-19T13:36:01+02:00#160@2012-11-19T13:36:00+02:00/2012-11-19T13:36:59+02:00#2012-11-19T13:37:01+02:00#160@2012-11-19T13:37:00+02:00/2012-11-19T13:37:59+02:00#2012-11-19T13:38:01+02:00#160@2012-11-19T13:38:00+02:00/2012-11-19T13:38:59+02:00#2012-11-19T13:39:01+02:00#160@2012-11-19T13:39:00+02:00/2012-11-19T13:39:59+02:00#2012-11-19T13:40:01+02:00#160@2012-11-19T13:40:00+02:00/2012-11-19T13:40:59+02:00#2012-11-19T13:41:01+02:00#160@2012-11-19T13:41:00+02:00/2012-11-19T13:41:59+02:00#2012-11-19T13:42:01+02:00#160@2012-11-19T13:42:00+02:00/2012-11-19T13:42:59+02:00#2012-11-19T13:43:01+02:00#159@2012-11-19T13:43:00+02:00/2012-11-19T13:43:59+02:00#2012-11-19T13:44:01+02:00#159@2012-11-19T13:44:00+02:00/2012-11-19T13:44:59+02:00#2012-11-19T13:45:01+02:00#159@ + From 8a835c90af1bfc430c20be183aa2c243ad06502a Mon Sep 17 00:00:00 2001 From: CarstenHollmann Date: Tue, 26 Aug 2014 15:46:44 +0200 Subject: [PATCH 2/6] Add om:resultTime definition constant --- core/api/src/main/java/org/n52/sos/ogc/om/OmConstants.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/api/src/main/java/org/n52/sos/ogc/om/OmConstants.java b/core/api/src/main/java/org/n52/sos/ogc/om/OmConstants.java index c339affc47..aa16087629 100644 --- a/core/api/src/main/java/org/n52/sos/ogc/om/OmConstants.java +++ b/core/api/src/main/java/org/n52/sos/ogc/om/OmConstants.java @@ -168,6 +168,8 @@ public interface OmConstants { String PHEN_SAMPLING_TIME = "http://www.opengis.net/def/property/OGC/0/SamplingTime"; String PHENOMENON_TIME = "http://www.opengis.net/def/property/OGC/0/PhenomenonTime"; + + String RESULT_TIME = "http://www.opengis.net/def/property/OGC/0/ResultTime"; String PHENOMENON_TIME_NAME = EN_PHENOMENON_TIME; From a029280fb7d71aee18fe83a2ecef8c613b4af172 Mon Sep 17 00:00:00 2001 From: CarstenHollmann Date: Tue, 26 Aug 2014 15:49:49 +0200 Subject: [PATCH 3/6] Add checks: - has swe:Time or swe:TimeRange with definition http://www.opengis.net/def/property/OGC/0/PhenomenonTime - had swe:field content with element definition equals to observedProperty defined in observationTemplate --- .../ds/hibernate/InsertResultTemplateDAO.java | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/hibernate/dao/src/main/java/org/n52/sos/ds/hibernate/InsertResultTemplateDAO.java b/hibernate/dao/src/main/java/org/n52/sos/ds/hibernate/InsertResultTemplateDAO.java index 3570cceb41..58e1e7d9d4 100644 --- a/hibernate/dao/src/main/java/org/n52/sos/ds/hibernate/InsertResultTemplateDAO.java +++ b/hibernate/dao/src/main/java/org/n52/sos/ds/hibernate/InsertResultTemplateDAO.java @@ -39,8 +39,10 @@ import org.n52.sos.ds.hibernate.dao.ResultTemplateDAO; import org.n52.sos.ds.hibernate.entities.FeatureOfInterest; import org.n52.sos.ds.hibernate.entities.ObservationConstellation; +import org.n52.sos.ds.hibernate.util.ResultHandlingHelper; import org.n52.sos.exception.ows.NoApplicableCodeException; import org.n52.sos.exception.ows.concrete.InvalidObservationTypeException; +import org.n52.sos.ogc.om.OmConstants; import org.n52.sos.ogc.om.OmObservationConstellation; import org.n52.sos.ogc.ows.OwsExceptionReport; import org.n52.sos.ogc.sos.CapabilitiesExtension; @@ -104,7 +106,7 @@ public InsertResultTemplateResponse insertResultTemplate(InsertResultTemplateReq featureOfInterestDAO.checkOrInsertFeatureOfInterestRelatedFeatureRelation(feature, obsConst.getOffering(), session); // check if result structure elements are supported - checkResultStructure(request.getResultStructure()); + checkResultStructure(request.getResultStructure(), obsConst.getObservableProperty().getIdentifier()); new ResultTemplateDAO().checkOrInsertResultTemplate(request, obsConst, feature, session); } else { // TODO make better exception. @@ -158,15 +160,35 @@ public String getRelatedOperation() { } - private void checkResultStructure(SosResultStructure resultStructure) throws OwsExceptionReport { - // TODO modify or remove if complex field elements are supported - final SweDataRecord record = setRecordFrom(resultStructure.getResultStructure()); - - for (final SweField swefield : record.getFields()) { - if (!(swefield.getElement() instanceof SweAbstractSimpleType)) { - throw new NoApplicableCodeException().withMessage("The swe:Field element of type %s is not yet supported!", swefield.getElement().getClass().getName()); - } - } - } + private void checkResultStructure(SosResultStructure resultStructure, + String observedProperty) throws OwsExceptionReport { + // TODO modify or remove if complex field elements are supported + final SweDataRecord record = setRecordFrom(resultStructure + .getResultStructure()); + + for (final SweField swefield : record.getFields()) { + if (!(swefield.getElement() instanceof SweAbstractSimpleType)) { + throw new NoApplicableCodeException() + .withMessage( + "The swe:Field element of type %s is not yet supported!", + swefield.getElement().getClass().getName()); + } + } + if (ResultHandlingHelper.hasPhenomenonTime(record) == -1) { + throw new NoApplicableCodeException() + .at(Sos2Constants.InsertResultTemplateParams.resultStructure) + .withMessage( + "Missing swe:Time or swe:TimeRange with definition %s", + OmConstants.PHENOMENON_TIME); + } + if (ResultHandlingHelper.checkFields(record.getFields(), + observedProperty) == -1) { + throw new NoApplicableCodeException() + .at(Sos2Constants.InsertResultTemplateParams.resultStructure) + .withMessage( + "Missing swe:field content with element definition %s", + observedProperty); + } + } } From 836d196841546d69dff47a755a75872c32dfe4ea Mon Sep 17 00:00:00 2001 From: CarstenHollmann Date: Tue, 26 Aug 2014 15:50:18 +0200 Subject: [PATCH 4/6] Use OmConstants definitions --- .../org/n52/sos/ds/hibernate/util/ResultHandlingHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hibernate/dao/src/main/java/org/n52/sos/ds/hibernate/util/ResultHandlingHelper.java b/hibernate/dao/src/main/java/org/n52/sos/ds/hibernate/util/ResultHandlingHelper.java index 0e2afb1c3a..51084a2d98 100644 --- a/hibernate/dao/src/main/java/org/n52/sos/ds/hibernate/util/ResultHandlingHelper.java +++ b/hibernate/dao/src/main/java/org/n52/sos/ds/hibernate/util/ResultHandlingHelper.java @@ -46,6 +46,7 @@ import org.n52.sos.ds.hibernate.entities.interfaces.GeometryObservation; import org.n52.sos.ds.hibernate.entities.interfaces.NumericObservation; import org.n52.sos.ds.hibernate.entities.interfaces.TextObservation; +import org.n52.sos.ogc.om.OmConstants; import org.n52.sos.ogc.ows.OwsExceptionReport; import org.n52.sos.ogc.sos.SosResultEncoding; import org.n52.sos.ogc.sos.SosResultStructure; @@ -68,9 +69,9 @@ */ public class ResultHandlingHelper { - private static final String RESULT_TIME = "http://www.opengis.net/def/property/OGC/0/ResultTime"; + private static final String RESULT_TIME = OmConstants.RESULT_TIME; - private static final String PHENOMENON_TIME = "http://www.opengis.net/def/property/OGC/0/PhenomenonTime"; + private static final String PHENOMENON_TIME = OmConstants.PHENOMENON_TIME; /** * Create internal ResultEncoding from String representation From 2df516579179124ff44663d6a815abbbb360e828 Mon Sep 17 00:00:00 2001 From: CarstenHollmann Date: Tue, 26 Aug 2014 15:51:41 +0200 Subject: [PATCH 5/6] Add check/getter for om:resultTime in elementType definition and set om:resultTime if not null. --- .../util/observation/ObservationUnfolder.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/hibernate/common/src/main/java/org/n52/sos/ds/hibernate/util/observation/ObservationUnfolder.java b/hibernate/common/src/main/java/org/n52/sos/ds/hibernate/util/observation/ObservationUnfolder.java index b7707a4fad..255def14ea 100644 --- a/hibernate/common/src/main/java/org/n52/sos/ds/hibernate/util/observation/ObservationUnfolder.java +++ b/hibernate/common/src/main/java/org/n52/sos/ds/hibernate/util/observation/ObservationUnfolder.java @@ -41,6 +41,7 @@ import org.n52.sos.ogc.gml.time.TimePeriod; import org.n52.sos.ogc.om.MultiObservationValues; import org.n52.sos.ogc.om.ObservationValue; +import org.n52.sos.ogc.om.OmConstants; import org.n52.sos.ogc.om.OmObservation; import org.n52.sos.ogc.om.OmObservationConstellation; import org.n52.sos.ogc.om.SingleObservationValue; @@ -97,6 +98,7 @@ public List unfold() throws OwsExceptionReport { for (final List block : values) { int tokenIndex = 0; Time phenomenonTime = null; + TimeInstant resultTime = null; final List> observedValues = new LinkedList>(); // map to store the observed properties final Map, String> definitionsForObservedValues = Maps.newHashMap(); @@ -111,7 +113,13 @@ public List unfold() throws OwsExceptionReport { */ if (fieldForToken instanceof SweTime) { try { - phenomenonTime = new TimeInstant(DateTimeHelper.parseIsoString2DateTime(token)); + if (fieldForToken.isSetDefinition() && OmConstants.RESULT_TIME.equals(fieldForToken.getDefinition())) { + resultTime = new TimeInstant(DateTimeHelper.parseIsoString2DateTime(token)); + } else { + if (phenomenonTime == null) { + phenomenonTime = new TimeInstant(DateTimeHelper.parseIsoString2DateTime(token)); + } + } } catch (final OwsExceptionReport e) { throw e; } catch (final Exception e) { @@ -167,7 +175,7 @@ else if (fieldForToken instanceof SweQuantity) { } for (final Value iValue : observedValues) { final OmObservation newObservation = - createSingleValueObservation(multiObservation, phenomenonTime, iValue); + createSingleValueObservation(multiObservation, phenomenonTime, resultTime, iValue); observationCollection.add(newObservation); } } @@ -177,7 +185,7 @@ else if (fieldForToken instanceof SweQuantity) { @SuppressWarnings({ "unchecked", "rawtypes" }) private OmObservation createSingleValueObservation(final OmObservation multiObservation, - final Time phenomenonTime, final Value iValue) { + final Time phenomenonTime, TimeInstant resultTime, final Value iValue) { final ObservationValue value = new SingleObservationValue(phenomenonTime, iValue); final OmObservation newObservation = new OmObservation(); newObservation.setNoDataValue(multiObservation.getNoDataValue()); @@ -193,7 +201,17 @@ private OmObservation createSingleValueObservation(final OmObservation multiObse */ newObservation.setObservationConstellation(obsConst); newObservation.setValidTime(multiObservation.getValidTime()); - newObservation.setResultTime(multiObservation.getResultTime()); + if (resultTime != null && !resultTime.isEmpty()) { + newObservation.setResultTime(resultTime); + } else if (multiObservation.isSetResultTime() && !multiObservation.getResultTime().isEmpty()) { + newObservation.setResultTime(multiObservation.getResultTime()); + } else { + if (phenomenonTime instanceof TimeInstant) { + newObservation.setResultTime((TimeInstant)phenomenonTime); + } else if (phenomenonTime instanceof TimePeriod) { + newObservation.setResultTime(new TimeInstant(((TimePeriod)phenomenonTime).getEnd())); + } + } newObservation.setTokenSeparator(multiObservation.getTokenSeparator()); newObservation.setTupleSeparator(multiObservation.getTupleSeparator()); newObservation.setResultType(multiObservation.getResultType()); From d38df7d9fa4a0f473125befb9dc09593f7d87c27 Mon Sep 17 00:00:00 2001 From: CarstenHollmann Date: Tue, 26 Aug 2014 15:52:58 +0200 Subject: [PATCH 6/6] Add element definitions for om:phenomenonTime and observedProperty element in InsertResultTemplate - resultStructure. --- .../src/test/java/org/n52/sos/ds/hibernate/InsertDAOTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hibernate/dao/src/test/java/org/n52/sos/ds/hibernate/InsertDAOTest.java b/hibernate/dao/src/test/java/org/n52/sos/ds/hibernate/InsertDAOTest.java index 8917ddbbe7..9178d55208 100644 --- a/hibernate/dao/src/test/java/org/n52/sos/ds/hibernate/InsertDAOTest.java +++ b/hibernate/dao/src/test/java/org/n52/sos/ds/hibernate/InsertDAOTest.java @@ -290,8 +290,10 @@ private void insertResultTemplate(String identifier, String procedureId, String SweDataRecord dataRecord = new SweDataRecord(); SweTime sweTime = new SweTime(); sweTime.setUom(OmConstants.PHEN_UOM_ISO8601); + sweTime.setDefinition(OmConstants.PHENOMENON_TIME); dataRecord.addField(new SweField("time", sweTime)); SweQuantity airTemp = new SweQuantity(); + airTemp.setDefinition(obsPropId); airTemp.setUom(TEMP_UNIT); dataRecord.addField(new SweField("air_temperature", airTemp)); SosResultStructure resultStructure = new SosResultStructure();