|
@@ -38,7 +38,7 @@ public class OGCSensorThingsGateway extends AbstractGateway {
|
|
|
|
|
|
|
|
router().get(create("Things")).handler(ctx -> {
|
|
router().get(create("Things")).handler(ctx -> {
|
|
|
RequestUriComponent uriComponent = parseUriToComponents(ctx.request());
|
|
RequestUriComponent uriComponent = parseUriToComponents(ctx.request());
|
|
|
- List<MultiSensor> afcMultiSensors = client.getAllMultiSensors();
|
|
|
|
|
|
|
+ List<MultiSensor> afcMultiSensors = client.getAllSensors();
|
|
|
List<Thing> ogcThings = Converter.convertToThing(afcMultiSensors, uriComponent);
|
|
List<Thing> ogcThings = Converter.convertToThing(afcMultiSensors, uriComponent);
|
|
|
ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(encode(ogcThings));
|
|
ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(encode(ogcThings));
|
|
|
});
|
|
});
|
|
@@ -515,7 +515,7 @@ public class OGCSensorThingsGateway extends AbstractGateway {
|
|
|
|
|
|
|
|
private static class Converter {
|
|
private static class Converter {
|
|
|
|
|
|
|
|
- private static final String DELIMITER = String.valueOf(0x1F); //
|
|
|
|
|
|
|
+ private static final String DELIMITER = "&";
|
|
|
|
|
|
|
|
static String assemblyId(String... parts) {
|
|
static String assemblyId(String... parts) {
|
|
|
return String.join(DELIMITER, parts);
|
|
return String.join(DELIMITER, parts);
|
|
@@ -533,17 +533,16 @@ public class OGCSensorThingsGateway extends AbstractGateway {
|
|
|
|
|
|
|
|
Filter afcFilter = new Filter();
|
|
Filter afcFilter = new Filter();
|
|
|
|
|
|
|
|
- Instant startTime = null, endTime = null;
|
|
|
|
|
for (io.connector.model.sensorthings.Filter.Expression expression : ogcFilter.getAddExpressions()) {
|
|
for (io.connector.model.sensorthings.Filter.Expression expression : ogcFilter.getAddExpressions()) {
|
|
|
switch (expression.getAttribute()) {
|
|
switch (expression.getAttribute()) {
|
|
|
case "time":
|
|
case "time":
|
|
|
case "resultTime": {
|
|
case "resultTime": {
|
|
|
switch (expression.getOperator()) {
|
|
switch (expression.getOperator()) {
|
|
|
case "lt": {
|
|
case "lt": {
|
|
|
- endTime = Instant.parse(expression.getValue());
|
|
|
|
|
|
|
+ afcFilter.endTime(Instant.parse(expression.getValue()));
|
|
|
} break;
|
|
} break;
|
|
|
case "gt": {
|
|
case "gt": {
|
|
|
- startTime = Instant.parse(expression.getValue());
|
|
|
|
|
|
|
+ afcFilter.startTime(Instant.parse(expression.getValue()));
|
|
|
}break;
|
|
}break;
|
|
|
default: throw new IllegalArgumentException(format(
|
|
default: throw new IllegalArgumentException(format(
|
|
|
"Unsupported operator '%s' in the filter expression '%s'.", expression.getOperator(), ogcFilter));
|
|
"Unsupported operator '%s' in the filter expression '%s'.", expression.getOperator(), ogcFilter));
|
|
@@ -554,19 +553,17 @@ public class OGCSensorThingsGateway extends AbstractGateway {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- afcFilter.startTime(startTime)
|
|
|
|
|
- .endTime(endTime);
|
|
|
|
|
-
|
|
|
|
|
return afcFilter;
|
|
return afcFilter;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static HistoricalLocation convertToHistoricalLocation(MultiSensor afcMultiSensor, AFCAggrLocation afcLocation, RequestUriComponent uriComponent) {
|
|
static HistoricalLocation convertToHistoricalLocation(MultiSensor afcMultiSensor, AFCAggrLocation afcLocation, RequestUriComponent uriComponent) {
|
|
|
HistoricalLocation historicalLocation = new HistoricalLocation();
|
|
HistoricalLocation historicalLocation = new HistoricalLocation();
|
|
|
String locationId = assemblyId(afcMultiSensor.getResourceUrn(), afcLocation.measurement, afcLocation.observation.getTime());
|
|
String locationId = assemblyId(afcMultiSensor.getResourceUrn(), afcLocation.measurement, afcLocation.observation.getTime());
|
|
|
|
|
+ String absoluteUrl = uriComponent.getGatewayUri();
|
|
|
historicalLocation.setId(locationId);
|
|
historicalLocation.setId(locationId);
|
|
|
- historicalLocation.setSelfLink(format("%s/HistoricalLocations(%s)", uriComponent.getGatewayUri(), locationId));
|
|
|
|
|
- historicalLocation.setLocationsNavigationLink(format("HistoricalLocations(%s)/Locations", locationId));
|
|
|
|
|
- historicalLocation.setThingNavigationLink(format("HistoricalLocations(%s)/Thing", locationId));
|
|
|
|
|
|
|
+ historicalLocation.setSelfLink(format("%s/HistoricalLocations(%s)", absoluteUrl, locationId));
|
|
|
|
|
+ historicalLocation.setLocationsNavigationLink(format("%s/HistoricalLocations(%s)/Locations", absoluteUrl, locationId));
|
|
|
|
|
+ historicalLocation.setThingNavigationLink(format("%s/HistoricalLocations(%s)/Thing", absoluteUrl, locationId));
|
|
|
historicalLocation.setTime(afcLocation.observation.getTime());
|
|
historicalLocation.setTime(afcLocation.observation.getTime());
|
|
|
return historicalLocation;
|
|
return historicalLocation;
|
|
|
}
|
|
}
|
|
@@ -582,9 +579,10 @@ public class OGCSensorThingsGateway extends AbstractGateway {
|
|
|
static Location convertToLocation(MultiSensor afcMultiSensor, AFCAggrLocation afcLocation, RequestUriComponent uriComponent) {
|
|
static Location convertToLocation(MultiSensor afcMultiSensor, AFCAggrLocation afcLocation, RequestUriComponent uriComponent) {
|
|
|
Location location = new Location();
|
|
Location location = new Location();
|
|
|
String locationId = assemblyId(afcMultiSensor.getResourceUrn(), afcLocation.measurement, afcLocation.observation.getTime());
|
|
String locationId = assemblyId(afcMultiSensor.getResourceUrn(), afcLocation.measurement, afcLocation.observation.getTime());
|
|
|
|
|
+ String absoluteUrl = uriComponent.getGatewayUri();
|
|
|
location.setId(locationId);
|
|
location.setId(locationId);
|
|
|
- location.setSelfLink(format("%s/Locations(%s)", uriComponent.getGatewayUri(), locationId));
|
|
|
|
|
- location.setHistoricalLocationsNavigationLink(format("Locations(%s)/HistoricalLocations", locationId));
|
|
|
|
|
|
|
+ location.setSelfLink(format("%s/Locations(%s)", absoluteUrl, locationId));
|
|
|
|
|
+ location.setHistoricalLocationsNavigationLink(format("%s/Locations(%s)/HistoricalLocations", absoluteUrl, locationId));
|
|
|
location.setName(afcMultiSensor.getResourceType());
|
|
location.setName(afcMultiSensor.getResourceType());
|
|
|
location.setDescription(afcLocation.observation.getProvider());
|
|
location.setDescription(afcLocation.observation.getProvider());
|
|
|
location.setEncodingType("application/vnd.geo+json");
|
|
location.setEncodingType("application/vnd.geo+json");
|
|
@@ -605,11 +603,12 @@ public class OGCSensorThingsGateway extends AbstractGateway {
|
|
|
static Observation convertToObservation(ResourceMeasurement afcMeasurement, SensorTelemetry afcTelemetry, io.connector.model.afarcloud.Observation afcObservation, RequestUriComponent uriComponent) {
|
|
static Observation convertToObservation(ResourceMeasurement afcMeasurement, SensorTelemetry afcTelemetry, io.connector.model.afarcloud.Observation afcObservation, RequestUriComponent uriComponent) {
|
|
|
Observation observation = new Observation();
|
|
Observation observation = new Observation();
|
|
|
String observationId = assemblyId(afcMeasurement.getResource(), afcTelemetry.getMeasurement(), afcObservation.getTime());
|
|
String observationId = assemblyId(afcMeasurement.getResource(), afcTelemetry.getMeasurement(), afcObservation.getTime());
|
|
|
|
|
+ String absoluteUrl = uriComponent.getGatewayUri();
|
|
|
observation.setId(observationId);
|
|
observation.setId(observationId);
|
|
|
- observation.setSelfLink(format("%s/Observations(%s)", uriComponent.getGatewayUri(), observationId));
|
|
|
|
|
|
|
+ observation.setSelfLink(format("%s/Observations(%s)", absoluteUrl, observationId));
|
|
|
// observation.setFeatureOfInterestNavigationLink(format("Observations(%s)/FeatureOfInterest", observationId));
|
|
// observation.setFeatureOfInterestNavigationLink(format("Observations(%s)/FeatureOfInterest", observationId));
|
|
|
observation.setFeatureOfInterestNavigationLink("https://storage07-afarcloud.qa.pdmfc.com/storage/rest/registry/getAllObservationTypes");
|
|
observation.setFeatureOfInterestNavigationLink("https://storage07-afarcloud.qa.pdmfc.com/storage/rest/registry/getAllObservationTypes");
|
|
|
- observation.setDataStreamNavigationLink(format("Observations(%s)/Datastream", observationId));
|
|
|
|
|
|
|
+ observation.setDataStreamNavigationLink(format("%s/Observations(%s)/Datastream", absoluteUrl, observationId));
|
|
|
observation.setPhenomenonTime(afcObservation.getTime());
|
|
observation.setPhenomenonTime(afcObservation.getTime());
|
|
|
observation.setResultTime(afcObservation.getTime());
|
|
observation.setResultTime(afcObservation.getTime());
|
|
|
observation.setResult(afcObservation.getValue());
|
|
observation.setResult(afcObservation.getValue());
|
|
@@ -631,9 +630,10 @@ public class OGCSensorThingsGateway extends AbstractGateway {
|
|
|
|
|
|
|
|
ObservedProperty observedProperty = new ObservedProperty();
|
|
ObservedProperty observedProperty = new ObservedProperty();
|
|
|
String observedPropertyId = assemblyId(afcMultiSensor.getResourceUrn(), afcSensor.getObservedProperty());
|
|
String observedPropertyId = assemblyId(afcMultiSensor.getResourceUrn(), afcSensor.getObservedProperty());
|
|
|
|
|
+ String absoluteUrl = uriComponent.getGatewayUri();
|
|
|
observedProperty.setId(observedPropertyId);
|
|
observedProperty.setId(observedPropertyId);
|
|
|
- observedProperty.setSelfLink(format("%s/ObservedProperties(%s)", uriComponent.getGatewayUri(), observedPropertyId));
|
|
|
|
|
- observedProperty.setDataStreamNavigationLink(format("ObservedProperties(%s)/Datastream", observedPropertyId));
|
|
|
|
|
|
|
+ observedProperty.setSelfLink(format("%s/ObservedProperties(%s)", absoluteUrl, observedPropertyId));
|
|
|
|
|
+ observedProperty.setDataStreamNavigationLink(format("%s/ObservedProperties(%s)/Datastream", absoluteUrl, observedPropertyId));
|
|
|
observedProperty.setName(afcSensor.getObservedProperty());
|
|
observedProperty.setName(afcSensor.getObservedProperty());
|
|
|
observedProperty.setDescription(afcSensor.getObservedProperty());
|
|
observedProperty.setDescription(afcSensor.getObservedProperty());
|
|
|
observedProperty.setDefinition(afcSensor.getUom());
|
|
observedProperty.setDefinition(afcSensor.getUom());
|
|
@@ -646,11 +646,12 @@ public class OGCSensorThingsGateway extends AbstractGateway {
|
|
|
|
|
|
|
|
Thing thing = new Thing();
|
|
Thing thing = new Thing();
|
|
|
String thingId = afcMultiSensor.getResourceUrn();
|
|
String thingId = afcMultiSensor.getResourceUrn();
|
|
|
|
|
+ String absoluteUrl = uriComponent.getGatewayUri();
|
|
|
thing.setId(thingId);
|
|
thing.setId(thingId);
|
|
|
- thing.setSelfLink(format("%s/Things(%s)", uriComponent.getGatewayUri(), thingId));
|
|
|
|
|
- thing.setLocationsNavigationLink(format("Things(%s)/Locations", thingId));
|
|
|
|
|
- thing.setDataStreamNavigationLink(format("Things(%s)/Datastreams", thingId));
|
|
|
|
|
- thing.setHistoricalLocationsNavigationLink(format("Things(%s)/HistoricalLocations", thingId));
|
|
|
|
|
|
|
+ thing.setSelfLink(format("%s/Things(%s)", absoluteUrl, thingId));
|
|
|
|
|
+ thing.setLocationsNavigationLink(format("%s/Things(%s)/Locations", absoluteUrl, thingId));
|
|
|
|
|
+ thing.setDataStreamNavigationLink(format("%s/Things(%s)/Datastreams", absoluteUrl, thingId));
|
|
|
|
|
+ thing.setHistoricalLocationsNavigationLink(format("%s/Things(%s)/HistoricalLocations", absoluteUrl, thingId));
|
|
|
thing.setName(afcMultiSensor.getResourceType());
|
|
thing.setName(afcMultiSensor.getResourceType());
|
|
|
thing.setDescription(afcMultiSensor.getResourceType());
|
|
thing.setDescription(afcMultiSensor.getResourceType());
|
|
|
thing.setProperties(null);
|
|
thing.setProperties(null);
|
|
@@ -672,12 +673,13 @@ public class OGCSensorThingsGateway extends AbstractGateway {
|
|
|
|
|
|
|
|
Datastream datastream = new Datastream();
|
|
Datastream datastream = new Datastream();
|
|
|
String dataStreamId = assemblyId(afcMultiSensor.getResourceUrn(), afcSensor.getObservedProperty());
|
|
String dataStreamId = assemblyId(afcMultiSensor.getResourceUrn(), afcSensor.getObservedProperty());
|
|
|
|
|
+ String absoluteUrl = uriComponent.getGatewayUri();
|
|
|
datastream.setId(dataStreamId);
|
|
datastream.setId(dataStreamId);
|
|
|
- datastream.setSelfLink(format("%s/Datastreams(%s)", uriComponent.getGatewayUri(), dataStreamId));
|
|
|
|
|
- datastream.setThingNavigationLink(format("Datastreams(%s)/Thing", dataStreamId));
|
|
|
|
|
- datastream.setSensorNavigationLink(format("Datastreams(%s)/Sensor", dataStreamId));
|
|
|
|
|
- datastream.setObservedPropertyNavigationLink(format("Datastreams(%s)/ObservedProperty", dataStreamId));
|
|
|
|
|
- datastream.setObservationsNavigationLink(format("Datastreams(%s)/Observations", dataStreamId));
|
|
|
|
|
|
|
+ datastream.setSelfLink(format("%s/Datastreams(%s)", absoluteUrl, dataStreamId));
|
|
|
|
|
+ datastream.setThingNavigationLink(format("%s/Datastreams(%s)/Thing", absoluteUrl, dataStreamId));
|
|
|
|
|
+ datastream.setSensorNavigationLink(format("%s/Datastreams(%s)/Sensor", absoluteUrl, dataStreamId));
|
|
|
|
|
+ datastream.setObservedPropertyNavigationLink(format("%s/Datastreams(%s)/ObservedProperty", absoluteUrl, dataStreamId));
|
|
|
|
|
+ datastream.setObservationsNavigationLink(format("%s/Datastreams(%s)/Observations", absoluteUrl, dataStreamId));
|
|
|
datastream.setName(afcSensor.getObservedProperty());
|
|
datastream.setName(afcSensor.getObservedProperty());
|
|
|
datastream.setDescription(afcSensor.getObservedProperty());
|
|
datastream.setDescription(afcSensor.getObservedProperty());
|
|
|
|
|
|
|
@@ -731,9 +733,10 @@ public class OGCSensorThingsGateway extends AbstractGateway {
|
|
|
|
|
|
|
|
Sensor sensor = new Sensor();
|
|
Sensor sensor = new Sensor();
|
|
|
String thingId = afcMultiSensor.getResourceUrn();
|
|
String thingId = afcMultiSensor.getResourceUrn();
|
|
|
|
|
+ String absoluteUrl = uriComponent.getGatewayUri();
|
|
|
sensor.setId(thingId);
|
|
sensor.setId(thingId);
|
|
|
- sensor.setSelfLink(format("%s/Sensors(%s)", uriComponent.getGatewayUri(), thingId));
|
|
|
|
|
- sensor.setDataStreamNavigationLink(format("Sensors(%s)/Datastreams", thingId));
|
|
|
|
|
|
|
+ sensor.setSelfLink(format("%s/Sensors(%s)", absoluteUrl, thingId));
|
|
|
|
|
+ sensor.setDataStreamNavigationLink(format("%s/Sensors(%s)/Datastreams", absoluteUrl, thingId));
|
|
|
sensor.setName(afcMultiSensor.getResourceType());
|
|
sensor.setName(afcMultiSensor.getResourceType());
|
|
|
sensor.setDescription(afcMultiSensor.getResourceType());
|
|
sensor.setDescription(afcMultiSensor.getResourceType());
|
|
|
sensor.setEncodingType("application/json");
|
|
sensor.setEncodingType("application/json");
|
|
@@ -741,6 +744,5 @@ public class OGCSensorThingsGateway extends AbstractGateway {
|
|
|
|
|
|
|
|
return sensor;
|
|
return sensor;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|