Procházet zdrojové kódy

added docker, change @NavigationLink to absolute url

Lukas Cerny před 5 roky
rodič
revize
4db7e6c1cf

+ 9 - 1
README.md

@@ -1,3 +1,11 @@
 # connector
 
-New version based on Vert.x tools.
+New version based on Vert.x tools.
+
+### Build docker image
+
+`docker build -t <custom_name> --build-arg config_file=<yaml_file> --build-arg port=<server_port> -f ./docker/Dockerfile .`
+
+### Run docker image
+
+`docker run --name <custon_name> -p <user_port>:<server_port> <image_id>`

+ 0 - 9
config/test.yaml

@@ -24,15 +24,6 @@ services:
         <<: *apiDomain
         path: "FeederServlet"
 
-  OGC_SensorThings:
-
-      name: "OGC SensorThings V1"
-      provider: "io.connector.module.ogc.sensorthings.SensorThingsModuleProvider"
-
-      host:
-        <<: *apiDomain
-        path: "<path>"
-
   IMA:
       api: &apiDomain
         domain: "https://iotlorawan.azurewebsites.net"

+ 5 - 3
connector-module-afarcloud/src/main/java/io/connector/module/afarcloud/AFCClient.java

@@ -72,8 +72,10 @@ public class AFCClient {
         URLBuilder urlBuilder = URLBuilder.newBuilder(host.getDomain(), host.getPath());
 
         if (filter.startTime != null) {
-            urlBuilder.addParam("start_time", filter.startTime());
+            throw new RuntimeException("Parameter 'startTime' is required.");
         }
+        urlBuilder.addParam("start_time", filter.startTime());
+
         if (filter.endTime != null) {
             urlBuilder.addParam("end_time", filter.endTime());
         }
@@ -135,7 +137,7 @@ public class AFCClient {
         return responseModel.results.resources;
     }
 
-    public List<MultiSensor> getAllMultiSensors() {
+    public List<MultiSensor> getAllSensors() {
 
         HostConfig host = new HostConfig(config.getInfoDomain(), "registry/getAllSensors");
 
@@ -175,7 +177,7 @@ public class AFCClient {
     }
 
     public MultiSensor getSensorByResourceUrn(String resourceUrn) {
-        List<MultiSensor> multiSensors = getAllMultiSensors();
+        List<MultiSensor> multiSensors = getAllSensors();
         for (MultiSensor multiSensor : multiSensors) {
             if (multiSensor.getResourceUrn().equals(resourceUrn)) {
                 return multiSensor;

+ 31 - 29
connector-module-afarcloud/src/main/java/io/connector/module/afarcloud/gateway/OGCSensorThingsGateway.java

@@ -38,7 +38,7 @@ public class OGCSensorThingsGateway extends AbstractGateway {
 
         router().get(create("Things")).handler(ctx -> {
             RequestUriComponent uriComponent = parseUriToComponents(ctx.request());
-            List<MultiSensor> afcMultiSensors = client.getAllMultiSensors();
+            List<MultiSensor> afcMultiSensors = client.getAllSensors();
             List<Thing> ogcThings = Converter.convertToThing(afcMultiSensors, uriComponent);
             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 final String DELIMITER = String.valueOf(0x1F); //
+        private static final String DELIMITER = "&";
 
         static String assemblyId(String... parts) {
             return String.join(DELIMITER, parts);
@@ -533,17 +533,16 @@ public class OGCSensorThingsGateway extends AbstractGateway {
 
             Filter afcFilter = new Filter();
 
-            Instant startTime = null, endTime = null;
             for (io.connector.model.sensorthings.Filter.Expression expression : ogcFilter.getAddExpressions()) {
                 switch (expression.getAttribute()) {
                     case "time":
                     case "resultTime": {
                         switch (expression.getOperator()) {
                             case "lt": {
-                                endTime = Instant.parse(expression.getValue());
+                                afcFilter.endTime(Instant.parse(expression.getValue()));
                             } break;
                             case "gt": {
-                                startTime = Instant.parse(expression.getValue());
+                                afcFilter.startTime(Instant.parse(expression.getValue()));
                             }break;
                             default: throw new IllegalArgumentException(format(
                                         "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;
         }
 
         static HistoricalLocation convertToHistoricalLocation(MultiSensor afcMultiSensor, AFCAggrLocation afcLocation, RequestUriComponent uriComponent) {
             HistoricalLocation historicalLocation = new HistoricalLocation();
             String locationId = assemblyId(afcMultiSensor.getResourceUrn(), afcLocation.measurement, afcLocation.observation.getTime());
+            String absoluteUrl = uriComponent.getGatewayUri();
             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());
             return historicalLocation;
         }
@@ -582,9 +579,10 @@ public class OGCSensorThingsGateway extends AbstractGateway {
         static Location convertToLocation(MultiSensor afcMultiSensor, AFCAggrLocation afcLocation, RequestUriComponent uriComponent) {
             Location location = new Location();
             String locationId = assemblyId(afcMultiSensor.getResourceUrn(), afcLocation.measurement, afcLocation.observation.getTime());
+            String absoluteUrl = uriComponent.getGatewayUri();
             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.setDescription(afcLocation.observation.getProvider());
             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) {
             Observation observation = new Observation();
             String observationId = assemblyId(afcMeasurement.getResource(), afcTelemetry.getMeasurement(), afcObservation.getTime());
+            String absoluteUrl = uriComponent.getGatewayUri();
             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("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.setResultTime(afcObservation.getTime());
             observation.setResult(afcObservation.getValue());
@@ -631,9 +630,10 @@ public class OGCSensorThingsGateway extends AbstractGateway {
 
             ObservedProperty observedProperty = new ObservedProperty();
             String observedPropertyId = assemblyId(afcMultiSensor.getResourceUrn(), afcSensor.getObservedProperty());
+            String absoluteUrl = uriComponent.getGatewayUri();
             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.setDescription(afcSensor.getObservedProperty());
             observedProperty.setDefinition(afcSensor.getUom());
@@ -646,11 +646,12 @@ public class OGCSensorThingsGateway extends AbstractGateway {
 
             Thing thing = new Thing();
             String thingId = afcMultiSensor.getResourceUrn();
+            String absoluteUrl = uriComponent.getGatewayUri();
             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.setDescription(afcMultiSensor.getResourceType());
             thing.setProperties(null);
@@ -672,12 +673,13 @@ public class OGCSensorThingsGateway extends AbstractGateway {
 
             Datastream datastream = new Datastream();
             String dataStreamId = assemblyId(afcMultiSensor.getResourceUrn(), afcSensor.getObservedProperty());
+            String absoluteUrl = uriComponent.getGatewayUri();
             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.setDescription(afcSensor.getObservedProperty());
 
@@ -731,9 +733,10 @@ public class OGCSensorThingsGateway extends AbstractGateway {
 
             Sensor sensor = new Sensor();
             String thingId = afcMultiSensor.getResourceUrn();
+            String absoluteUrl = uriComponent.getGatewayUri();
             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.setDescription(afcMultiSensor.getResourceType());
             sensor.setEncodingType("application/json");
@@ -741,6 +744,5 @@ public class OGCSensorThingsGateway extends AbstractGateway {
 
             return sensor;
         }
-
     }
 }

+ 0 - 0
connector-module-ogc-sensorthings/build.gradle


+ 0 - 14
connector-module-ogc-sensorthings/src/main/java/io/connector/module/ogc/sensorthings/SensorThingsClient.java

@@ -1,14 +0,0 @@
-package io.connector.module.ogc.sensorthings;
-
-import cz.senslog.common.http.HttpClient;
-
-public class SensorThingsClient {
-
-    private final SensorThingsConfig config;
-    private final HttpClient httpClient;
-
-    public SensorThingsClient(SensorThingsConfig config, HttpClient httpClient) {
-        this.config = config;
-        this.httpClient = httpClient;
-    }
-}

+ 0 - 10
connector-module-ogc-sensorthings/src/main/java/io/connector/module/ogc/sensorthings/SensorThingsConfig.java

@@ -1,10 +0,0 @@
-package io.connector.module.ogc.sensorthings;
-
-import io.connector.core.config.DefaultConfig;
-
-class SensorThingsConfig {
-
-    SensorThingsConfig(DefaultConfig defaultConfig) {
-
-    }
-}

+ 0 - 28
connector-module-ogc-sensorthings/src/main/java/io/connector/module/ogc/sensorthings/SensorThingsModule.java

@@ -1,28 +0,0 @@
-package io.connector.module.ogc.sensorthings;
-
-import io.connector.core.AbstractModule;
-import io.connector.core.ModuleDescriptor;
-import io.connector.core.ModuleInfo;
-import io.connector.module.ogc.sensorthings.gateway.AFarCloudGateway;
-import io.connector.module.ogc.sensorthings.gateway.SensorThingsGateway;
-
-public class SensorThingsModule extends AbstractModule {
-
-    private final SensorThingsClient client;
-
-    SensorThingsModule(String id, ModuleDescriptor descriptor, SensorThingsClient client) {
-        super(id, descriptor);
-        this.client = client;
-    }
-
-    @Override
-    public void run() {
-        registerGateway(new SensorThingsGateway("OGCSensorThings", client));
-        registerGateway(new AFarCloudGateway("AFarCloud", client));
-    }
-
-    @Override
-    public ModuleInfo info() {
-        return new ModuleInfo(id());
-    }
-}

+ 0 - 21
connector-module-ogc-sensorthings/src/main/java/io/connector/module/ogc/sensorthings/SensorThingsModuleProvider.java

@@ -1,21 +0,0 @@
-package io.connector.module.ogc.sensorthings;
-
-import io.connector.core.ModuleDescriptor;
-import io.connector.core.AbstractModule;
-import io.connector.core.ModuleProvider;
-
-import static cz.senslog.common.http.HttpClient.newHttpClient;
-
-public class SensorThingsModuleProvider implements ModuleProvider {
-
-
-    @Override
-    public AbstractModule createModule(ModuleDescriptor descriptor) {
-
-        SensorThingsConfig config = new SensorThingsConfig(descriptor.getServiceConfig());
-        SensorThingsClient client = new SensorThingsClient(config, newHttpClient());
-        SensorThingsModule module = new SensorThingsModule("OGCSensorThings", descriptor, client);
-
-        return module;
-    }
-}

+ 0 - 288
connector-module-ogc-sensorthings/src/main/java/io/connector/module/ogc/sensorthings/gateway/AFarCloudGateway.java

@@ -1,288 +0,0 @@
-package io.connector.module.ogc.sensorthings.gateway;
-
-import io.connector.core.AbstractGateway;
-import io.connector.model.afarcloud.*;
-import io.connector.module.ogc.sensorthings.SensorThingsClient;
-import io.vertx.core.MultiMap;
-import io.vertx.core.http.HttpServerRequest;
-import io.vertx.core.json.JsonObject;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
-import static io.connector.core.http.ContentType.APPLICATION_JSON;
-import static io.connector.core.http.Header.CONTENT_TYPE;
-import static io.connector.core.AddressPath.Creator.create;
-import static io.vertx.core.json.Json.encode;
-import static java.lang.Double.parseDouble;
-import static java.lang.Integer.parseInt;
-import static java.lang.String.format;
-import static java.util.Arrays.asList;
-import static java.util.Collections.emptyList;
-import static java.util.Collections.singletonList;
-import static java.util.Comparator.comparing;
-
-public class AFarCloudGateway extends AbstractGateway {
-
-    private final SensorThingsClient client;
-
-    public AFarCloudGateway(String id, SensorThingsClient client) {
-        super(id);
-        this.client = client;
-    }
-
-    private static String getRequiredParam(MultiMap params, String paramName) {
-        String param = getParam(params, paramName);
-        if (param == null) {
-            throw new IllegalArgumentException(format("Parameter '%s' is required.", paramName));
-        }
-        return param;
-    }
-
-    private static String getParam(MultiMap params, String paramName) {
-        return params.contains(paramName) ? params.get(paramName) : null;
-    }
-
-    private static String getParam(MultiMap params, String paramName, String defValue) {
-        return params.contains(paramName) ? params.get(paramName) : defValue;
-    }
-
-    private static List<String> getSplittedParam(MultiMap params, String paramName) {
-        String param = getParam(params, paramName);
-        return param != null ? asList(param.split(",")) : emptyList();
-    }
-
-    @Override
-    protected void run() {
-
-        // Query sensor telemetry
-        router().get(create("getSensorTelemetry/latest")).handler(ctx -> {
-
-            HttpServerRequest req = ctx.request();
-            MultiMap params = req.params();
-
-            final int limit = parseInt(getRequiredParam(params, "limit"));
-            final List<String> entityNames = getSplittedParam(params, "entityNames");
-            final List<String> devices = getSplittedParam(params, "devices");
-            final List<String> services = getSplittedParam(params, "services");
-            final List<String> types = getSplittedParam(params, "types");
-            final List<String> providers = getSplittedParam(params, "providers");
-            final List<String> measurements = getSplittedParam(params, "measurements");
-            final Integer minAltitude = params.contains("altitude") ? parseInt(params.get("altitude")) : null; // TODO
-            final String order = getParam(params, "order", "DESC").toUpperCase();
-
-            ResponseModel<SensorTelemetry> responseModel = new ResponseModel<>();
-
-            for (Map.Entry<String, String> entry : params.entries()) {
-                responseModel.addParam(entry.getKey(), entry.getValue());
-            }
-            responseModel.setQuery(req.path()+"&"+req.query());
-
-            // GET all telemetries
-            List<SensorTelemetry> telemetries = new ArrayList<>(limit);
-            for (int i = 0; i < limit; i++) {
-                SensorTelemetry telemetry = new SensorTelemetry();
-                telemetry.setMeasurement("wind_speed");
-
-                Observation observation = new Observation();
-                observation.setTime("2020-04-19T14:17:00Z");
-                observation.setAltitude(282.);
-                observation.setLatitude(50.0393219);
-                observation.setLongitude(14.6106731);
-                observation.setGeohash("u2fksmrhjmeq");
-                observation.setValue(0.55);
-                observation.setEntityName("1305167562287832");
-                observation.setSequenceNumber("123");
-                observation.setService("environmentalObservations");
-                observation.setProvider("LESP");
-                observation.setType("air_sensor");
-                observation.setUom("http://qudt.org/vocab/multiSensor/M-PER-SEC");
-                telemetry.addObservation(observation);
-
-                telemetries.add(telemetry);
-            }
-            responseModel.setNumResults(telemetries.size());
-
-            Comparator<SensorTelemetry> comparator = comparing(SensorTelemetry::getMeasurement);
-            if (order.equals("DESC")) {
-                comparator = comparator.reversed();
-            }
-            telemetries.sort(comparator);
-
-            responseModel.setResults(telemetries);
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(encode(responseModel));
-        });
-
-        router().get(create("getObservationsBySensor/latest")).handler(ctx -> {
-
-            HttpServerRequest req = ctx.request();
-            MultiMap params = req.params();
-
-            final int limit = parseInt(getRequiredParam(params, "limit"));
-            final List<String> entityNames = getSplittedParam(params, "entityNames");
-            final List<String> devices = getSplittedParam(params, "devices");
-            final List<String> services = getSplittedParam(params, "services");
-            final List<String> types = getSplittedParam(params, "types");
-            final List<String> providers = getSplittedParam(params, "providers");
-            final List<String> measurements = getSplittedParam(params, "measurements");
-            final String order = getParam(params, "order", "DESC").toUpperCase();
-            final Integer minAltitude = params.contains("altitude") ? parseInt(params.get("altitude")) : null; // TODO
-            final Double centrLong = params.contains("centr_long") ? parseDouble(params.get("centr_long")) : null; // TODO
-            final Double centrLat = params.contains("centr_lat") ? parseDouble(params.get("centr_lat")) : null; // TODO
-            final Integer radius = params.contains("radius") ? parseInt(params.get("radius")) : null; // TODO
-
-            ResponseModel<ResourceMeasurement> responseModel = new ResponseModel<>();
-
-            for (Map.Entry<String, String> entry : params.entries()) {
-                responseModel.addParam(entry.getKey(), entry.getValue());
-            }
-            responseModel.setQuery(req.path()+"&"+req.query());
-
-            ResourceMeasurement measurement = new ResourceMeasurement();
-            measurement.setResource("10002376");
-            responseModel.setResults(singletonList(measurement));
-
-            SensorTelemetry telemetry = new SensorTelemetry();
-            telemetry.setMeasurement("wind_speed");
-            measurement.setMeasurements(singletonList(telemetry));
-
-            for (int i = 0; i < limit; i++) {
-                Observation observation = new Observation();
-                observation.setTime("2020-04-19T14:17:00Z");
-                observation.setAltitude(282.);
-                observation.setLatitude(50.0393219);
-                observation.setLongitude(14.6106731);
-                observation.setGeohash("u2fksmrhjmeq");
-                observation.setValue(0.55);
-                observation.setEntityName("1305167562287832");
-                observation.setSequenceNumber("123");
-                observation.setService("environmentalObservations");
-                observation.setProvider("LESP");
-                observation.setType("air_sensor");
-                observation.setUom("http://qudt.org/vocab/multiSensor/M-PER-SEC");
-                telemetry.addObservation(observation);
-            }
-
-            int counter = 0;
-            for (ResourceMeasurement result : responseModel.getResults()) {
-
-                Comparator<SensorTelemetry> comparator = comparing(SensorTelemetry::getMeasurement);
-                if (order.equals("DESC")) {
-                    comparator = comparator.reversed();
-                }
-                result.getMeasurements().sort(comparator);
-
-                for (SensorTelemetry resultMeasurement : result.getMeasurements()) {
-                    counter += resultMeasurement.getObservations().size();
-                }
-            }
-            responseModel.setNumResults(counter);
-
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(encode(responseModel));
-        });
-
-        // Query sensor telemetry interval
-        router().get(create("getSensorTelemetry/historic")).handler(ctx -> {
-
-            HttpServerRequest req = ctx.request();
-            MultiMap params = req.params();
-
-            final int limit = 100;
-            final String startTime = getRequiredParam(params, "start_time");
-            final String endTime = getParam(params, "end_time");
-
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(
-                    new JsonObject().put("message", "not implemented yet").encode());
-        });
-
-        router().get(create("getObservationsBySensor/historic")).handler(ctx -> {
-
-            HttpServerRequest req = ctx.request();
-            MultiMap params = req.params();
-
-            final int limit = 100;
-            final String startTime = getRequiredParam(params, "start_time");
-            final String endTime = getParam(params, "end_time");
-
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(
-                    new JsonObject().put("message", "not implemented yet").encode());
-        });
-
-        // Query region telemetry
-        router().get(create("getRegionTelemetry/latest")).handler(ctx -> {
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(
-                    new JsonObject().put("message", "not implemented yet").encode());
-        });
-
-        // Query region telemetry interval
-        router().get(create("getRegionTelemetry/historic")).handler(ctx -> {
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(
-                    new JsonObject().put("message", "not implemented yet").encode());
-        });
-
-        // Query collar telemetry
-        router().get(create("getCollarTelemetry/latest")).handler(ctx -> {
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(
-                    new JsonObject().put("message", "not implemented yet").encode());
-        });
-
-        router().get(create("getObservationsByCollar/latest")).handler(ctx -> {
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(
-                    new JsonObject().put("message", "not implemented yet").encode());
-        });
-
-        router().get(create("getObservationsByCollar/historic")).handler(ctx -> {
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(
-                    new JsonObject().put("message", "not implemented yet").encode());
-        });
-
-        // Query collar telemetry interval
-        router().get(create("getCollarTelemetry/historic")).handler(ctx -> {
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(
-                    new JsonObject().put("message", "not implemented yet").encode());
-        });
-
-        // Schema-measurement
-        router().get(create("getMeasurements")).handler(ctx -> {
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(
-                    new JsonObject().put("message", "not implemented yet").encode());
-        });
-
-        // Registry
-        router().get(create("registry/getSensor/:id")).handler(ctx -> {
-            // domain is different
-
-            String resourceId = ctx.pathParam("id");
-
-            MultiSensor multiSensor = new MultiSensor();
-            multiSensor.setResourceId(resourceId);
-            multiSensor.setResourceType("AFC 8CF95740000008AE");
-            multiSensor.setResourceUrn("urn:afc:AS07:enviro:IMA:air_quality:10002222");
-            multiSensor.setLatitude(50.0382589);
-            multiSensor.setLongitude(14.6112164);
-            multiSensor.setAltitude(280.0);
-            multiSensor.setPreprocessing(false);
-            multiSensor.setPythonScript("");
-
-            MultiSensor.SensorSchema sensorSchema = new MultiSensor.SensorSchema();
-            sensorSchema.setObservedProperty("air_temperature");
-            sensorSchema.setUom("http://qudt.org/vocab/multiSensor/DEG_C");
-            sensorSchema.setAccuracy(0.1);
-            sensorSchema.setPropertyId(456);
-            sensorSchema.setMin_value(-40.0);
-            sensorSchema.setMax_value(60.0);
-            multiSensor.setObservations(singletonList(sensorSchema));
-
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(encode(multiSensor));
-        });
-
-        router().get(create("registry/getCollar/:id")).handler(ctx -> {
-            // domain is different
-
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(
-                    new JsonObject().put("message", "not implemented yet").encode());
-        });
-    }
-}

+ 0 - 42
connector-module-ogc-sensorthings/src/main/java/io/connector/module/ogc/sensorthings/gateway/SensorThingsGateway.java

@@ -1,42 +0,0 @@
-package io.connector.module.ogc.sensorthings.gateway;
-
-import io.connector.core.AbstractGateway;
-import io.connector.module.ogc.sensorthings.SensorThingsClient;
-import io.vertx.core.MultiMap;
-import io.vertx.core.eventbus.DeliveryOptions;
-import io.vertx.core.json.JsonObject;
-
-import static io.connector.core.Handler.replyToHttpContext;
-import static io.connector.core.AddressPath.Creator.create;
-
-public class SensorThingsGateway extends AbstractGateway {
-
-    private final SensorThingsClient client;
-
-    public SensorThingsGateway(String id, SensorThingsClient client) {
-        super(id, true);
-        this.client = client;
-    }
-
-    @Override
-    protected void run() {
-
-        router().get(create("Things(:id)")).handler(ctx -> {
-
-            DeliveryOptions options = new DeliveryOptions()
-                    .addHeader("id", ctx.pathParam("id"));
-
-            event().send("things", ctx.getBody(), options, replyToHttpContext(ctx));
-        });
-
-        event().consume("things", message -> {
-            MultiMap headers = message.headers();
-            String id = headers.get("id");
-            message.reply(new JsonObject().put("id", id));
-        });
-
-        event().consume("test", message -> {
-            message.reply("OK");
-        });
-    }
-}

+ 0 - 1
connector-module-ogc-sensorthings/src/main/resources/META-INF/services/io.connector.core.ModuleProvider

@@ -1 +0,0 @@
-io.connector.module.ogc.sensorthings.SensorThingsModuleProvider

+ 14 - 0
docker/Dockerfile

@@ -0,0 +1,14 @@
+FROM java:8-alpine
+
+ARG config_file
+ARG port
+
+ENV APP_PARAMS "-cf config/$config_file -p $port"
+
+COPY docker/start.sh /app/
+COPY bin/libs/ /app/bin
+COPY config/$config_file /app/config/$config_file
+
+WORKDIR /app
+
+ENTRYPOINT ["/bin/sh", "-C", "start.sh"]

+ 7 - 0
docker/start.sh

@@ -0,0 +1,7 @@
+#!/bin/sh
+
+BUILD_FOLDER="bin"
+MAIN_CLASS="io.connector.Main"
+LOG_PATH="/var/log/connector-app"
+
+java -cp "$BUILD_FOLDER/*" -DlogPath=$LOG_PATH $MAIN_CLASS $APP_PARAMS