Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Use server assigned offering
Browse files Browse the repository at this point in the history
  • Loading branch information
glegal committed Sep 4, 2017
1 parent 6a0c419 commit 9d6bd66
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ public SensorObservationService(final Configuration config)
}
failedInsertObservations = new LinkedList<InsertObservation>();
registeredSensors = new LinkedList<String>();
if (sosVersion.equals(SOS_200_VERSION)) {
offerings = new HashMap<String, String>();
}
offerings = new HashMap<String, String>();
if (config.getHunkSize() > 0) {
hunkSize = config.getHunkSize();
}
Expand Down Expand Up @@ -718,7 +716,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<List<OmParameter<?>>> omParameter = dataFile.getOmParameter(mVColumnId, values);
Expand Down Expand Up @@ -769,7 +773,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(),
Expand Down Expand Up @@ -1268,6 +1276,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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,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());
}

/**
* <p>getSweArrayObservation.</p>
*
* @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(
Expand All @@ -218,9 +231,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());
Expand Down

0 comments on commit 9d6bd66

Please sign in to comment.