diff --git a/feeder/src/main/java/org/n52/sos/importer/feeder/Feeder.java b/feeder/src/main/java/org/n52/sos/importer/feeder/Feeder.java index 25719723..d232d214 100644 --- a/feeder/src/main/java/org/n52/sos/importer/feeder/Feeder.java +++ b/feeder/src/main/java/org/n52/sos/importer/feeder/Feeder.java @@ -248,9 +248,7 @@ public Feeder(final Configuration config) } failedInsertObservations = new LinkedList<>(); registeredSensors = new LinkedList<>(); - if (sosVersion.equals(SOS_200_VERSION)) { - offerings = new HashMap<>(); - } + offerings = new HashMap<>(); if (config.getHunkSize() > 0) { hunkSize = config.getHunkSize(); } @@ -762,7 +760,13 @@ private InsertObservation getInsertObservationForColumnIdFromValues(final int mV final ObservedProperty observedProperty = dataFile.getObservedProperty(mVColumnId, values); LOG.debug("ObservedProperty: {}", observedProperty); // OFFERING - final Offering offer = dataFile.getOffering(sensor); + final Offering offer; + if (offerings.containsKey(sensor.getUri())) { + String offering = offerings.get(sensor.getUri()); + offer = new Offering(offering, offering); + } else { + offer = dataFile.getOffering(sensor); + } LOG.debug("Offering: {}", offer); // OM:PARAMETER final Optional>> omParameter = dataFile.getOmParameters(mVColumnId, values); @@ -813,7 +817,11 @@ private void insertTimeSeries(final TimeSeriesRepository timeSeriesRepository) } } // insert observation - final String observationId = insertSweArrayObservation(timeSeries.getSweArrayObservation(sosVersion)); + String offering = null; + if (offerings.containsKey(timeSeries.getSensorURI())) { + offering = offerings.get(timeSeries.getSensorURI()); + } + final String observationId = insertSweArrayObservation(timeSeries.getSweArrayObservation(sosVersion, offering)); if (observationId == null || observationId.equalsIgnoreCase("")) { LOG.error(String.format(INSERT_OBSERVATION_FAILED, timeSeries.getSensorName(), @@ -1315,6 +1323,7 @@ private boolean isSensorRegistered(final String sensorURI) { final String[] sensorIds = offering.getProcedures(); for (final String sensorId : sensorIds) { if (sensorId.equals(sensorURI)) { + offerings.put(sensorId, offering.getIdentifier()); return true; } } diff --git a/feeder/src/main/java/org/n52/sos/importer/feeder/model/TimeSeries.java b/feeder/src/main/java/org/n52/sos/importer/feeder/model/TimeSeries.java index 825277b1..3df23609 100644 --- a/feeder/src/main/java/org/n52/sos/importer/feeder/model/TimeSeries.java +++ b/feeder/src/main/java/org/n52/sos/importer/feeder/model/TimeSeries.java @@ -195,6 +195,19 @@ public String getMeasuredValueType() { * @return a {@link org.n52.oxf.sos.request.InsertObservationParameters} object. */ public InsertObservationParameters getSweArrayObservation(final String sosVersion) { + return getSweArrayObservation(sosVersion, getFirst().getOffering().getUri()); + } + + /** + *

getSweArrayObservation.

+ * + * @param sosVersion a {@link java.lang.String} object. + * @param offering Optional paramater allowing to override the offering in the timeseries. + * if {@code null} the setted offering will be used. + * + * @return a {@link org.n52.oxf.sos.request.InsertObservationParameters} object. + */ + public InsertObservationParameters getSweArrayObservation(final String sosVersion, String offering) { final SweArrayObservationParameters obsParameter = new SweArrayObservationParameters(); // add extension obsParameter.addExtension( @@ -216,9 +229,13 @@ public InsertObservationParameters getSweArrayObservation(final String sosVersio obsParameter.addPhenomenonTime(getPhenomenonTime()); // temporal bbox for result time obsParameter.addResultTime(getResultTime()); + // offering + if (offering == null) { + offering = getFirst().getOffering().getUri(); + } return new org.n52.oxf.sos.request.v200.InsertObservationParameters( obsParameter, - Collections.singletonList(getFirst().getOffering().getUri())); + Collections.singletonList(offering)); } obsParameter.addSrsPosition(Configuration.SOS_100_EPSG_CODE_PREFIX + getFirst().getEpsgCode());