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

Use server assigned offering #84

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions feeder/src/main/java/org/n52/sos/importer/feeder/Feeder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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<List<OmParameter<?>>> omParameter = dataFile.getOmParameters(mVColumnId, values);
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
* <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 @@ -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());
Expand Down