Selaa lähdekoodia

Prepared project for the release.

Lukas Cerny 5 vuotta sitten
vanhempi
commit
a739e94b5f
47 muutettua tiedostoa jossa 33 lisäystä ja 2656 poistoa
  1. 5 7
      README.md
  2. 0 220
      connector-core/src/main/java/io/connector/core/AbstractGateway.java
  3. 0 8
      connector-core/src/main/java/io/connector/core/AbstractModule.java
  4. 0 8
      connector-core/src/main/java/io/connector/core/AddressPath.java
  5. 0 37
      connector-core/src/main/java/io/connector/core/Fail.java
  6. 0 43
      connector-core/src/main/java/io/connector/core/Handler.java
  7. 0 71
      connector-core/src/main/java/io/connector/core/Message.java
  8. 0 5
      connector-core/src/main/java/io/connector/core/ModuleDeployer.java
  9. 0 27
      connector-core/src/main/java/io/connector/core/Reply.java
  10. 0 47
      connector-core/src/main/java/io/connector/core/VertxHttpServer.java
  11. 0 178
      connector-core/src/main/java/io/connector/core/VertxScheduler.java
  12. 0 9
      connector-core/src/main/java/io/connector/core/config/ConfigurationService.java
  13. 0 54
      connector-core/src/main/java/io/connector/core/config/database/DatabaseBuilder.java
  14. 0 56
      connector-core/src/main/java/io/connector/core/config/database/DatabaseBuilderImpl.java
  15. 0 25
      connector-core/src/main/java/io/connector/core/config/database/DatabaseConfigurationService.java
  16. 0 69
      connector-core/src/main/java/io/connector/core/config/database/DatabaseConfigurationServiceImpl.java
  17. 0 23
      connector-model/src/main/java/io/connector/model/ima/IMAModel.java
  18. 0 123
      connector-model/src/main/java/io/connector/model/senslog1/Observation.java
  19. 0 45
      connector-model/src/main/java/io/connector/model/senslog1/Phenomenon.java
  20. 0 74
      connector-model/src/main/java/io/connector/model/senslog1/Position.java
  21. 0 31
      connector-model/src/main/java/io/connector/model/senslog1/Sensor.java
  22. 0 127
      connector-model/src/main/java/io/connector/model/senslog1/SensorData.java
  23. 0 99
      connector-model/src/main/java/io/connector/model/senslog1/SensorInfo.java
  24. 0 31
      connector-model/src/main/java/io/connector/model/senslog1/Unit.java
  25. 0 184
      connector-model/src/main/java/io/connector/model/senslog1/UnitData.java
  26. 0 93
      connector-model/src/main/java/io/connector/model/senslog1/UnitInfo.java
  27. 3 4
      connector-model/src/main/java/io/connector/model/sensorthings/Filter.java
  28. 1 17
      connector-module-afarcloud/src/main/java/io/connector/module/afarcloud/AFCHttpClient.java
  29. 0 2
      connector-module-afarcloud/src/main/java/io/connector/module/afarcloud/AFCModule.java
  30. 24 3
      connector-module-afarcloud/src/main/java/io/connector/module/afarcloud/gateway/OGCSensorThingsGateway.java
  31. 0 73
      connector-module-afarcloud/src/main/java/io/connector/module/afarcloud/gateway/SensLog1Gateway.java
  32. 0 0
      connector-module-ima/build.gradle
  33. 0 16
      connector-module-ima/src/main/java/io/connector/module/ima/ImaClient.java
  34. 0 10
      connector-module-ima/src/main/java/io/connector/module/ima/ImaConfig.java
  35. 0 26
      connector-module-ima/src/main/java/io/connector/module/ima/ImaModule.java
  36. 0 18
      connector-module-ima/src/main/java/io/connector/module/ima/ImaModuleProvider.java
  37. 0 20
      connector-module-ima/src/main/java/io/connector/module/ima/gateway/ImaGateway.java
  38. 0 1
      connector-module-ima/src/main/resources/META-INF/services/io.connector.core.ModuleProvider
  39. 0 0
      connector-module-senslog1/build.gradle
  40. 0 43
      connector-module-senslog1/src/main/java/io/connector/module/senslog1/SensLog1Config.java
  41. 0 448
      connector-module-senslog1/src/main/java/io/connector/module/senslog1/SensLog1HttpClient.java
  42. 0 45
      connector-module-senslog1/src/main/java/io/connector/module/senslog1/SensLog1Module.java
  43. 0 22
      connector-module-senslog1/src/main/java/io/connector/module/senslog1/SensLog1ModuleProvider.java
  44. 0 6
      connector-module-senslog1/src/main/java/io/connector/module/senslog1/SensLog1SQLClient.java
  45. 0 19
      connector-module-senslog1/src/main/java/io/connector/module/senslog1/gateway/OGCSensorThingsGateway.java
  46. 0 188
      connector-module-senslog1/src/main/java/io/connector/module/senslog1/gateway/SensLog1Gateway.java
  47. 0 1
      connector-module-senslog1/src/main/resources/META-INF/services/io.connector.core.ModuleProvider

+ 5 - 7
README.md

@@ -13,24 +13,22 @@ format for communication with external systems). This project was created as a p
 
 Requirements: *Gradle*
 
-To build the project run following command.
-
 `./gradle build`
 
 ### Run
 
 Requirements: *Java 8+*
 
-To run the connector run following command.
-
 `java -cp "bin/libs/*" io.connector.Main -cf config/ogc2afc.yaml -p <port>`
 
 ### Build docker image
 
-Requirements: *Docker*
-
 `docker build -t <image_custom_name> --build-arg config_file=<yaml_file> --build-arg port=<server_port> -f ./docker/Dockerfile .`
 
 ### Run docker image
 
-`docker run --name <container_name> -p <host_port>:<server_port> <image>`
+`docker run --name <container_name> -p <host_port>:<server_port> <image>`
+
+### Usage
+
+`http://www.<domain>:<port>/api/AFarCloud/OGCSensorThings/Things`

+ 0 - 220
connector-core/src/main/java/io/connector/core/AbstractGateway.java

@@ -5,26 +5,11 @@ package io.connector.core;
 
 import io.connector.core.http.RequestUriComponent;
 import io.connector.core.http.RequestUriParser;
-import io.vertx.core.eventbus.DeliveryOptions;
-import io.vertx.core.eventbus.EventBus;
 import io.vertx.core.http.HttpServerRequest;
-import io.vertx.core.json.JsonObject;
 import io.vertx.ext.web.Router;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.function.Consumer;
-
-import static io.connector.core.AbstractGateway.ConsumerType.*;
-import static io.connector.core.AddressPath.Creator.createNormalized;
-import static io.connector.core.AddressPath.SCHEDULER_CONSUMER;
-import static io.connector.core.AddressPath.SCHEDULER_PROVIDER;
-import static io.connector.core.MessageHeader.*;
-import static java.lang.String.format;
-
 /**
  *
  * @author Lukas Cerny
@@ -35,36 +20,14 @@ public abstract class AbstractGateway {
 
     private final static Logger logger = LogManager.getLogger(AbstractGateway.class);
 
-    enum ConsumerType {
-        SCHEDULER   (true),
-        SUBSCRIBER  (false),
-        OTHER       (true),
-
-        ;
-        private final boolean canBeDefault;
-        ConsumerType(boolean canBeDefault) {
-            this.canBeDefault = canBeDefault;
-        }
-        public boolean canBeDefault() {
-            return canBeDefault;
-        }
-    }
-
     private final boolean isDefault;
-    private EventBus eventBus;
     private Router router;
-    private Event event;
     private String moduleId;
     protected String gatewayId;
-    private final Set<String>[] registeredConsumersMap;
 
     protected AbstractGateway(String id, boolean isDefault) {
         this.gatewayId = id;
         this.isDefault = isDefault;
-        registeredConsumersMap = new Set[ConsumerType.values().length];
-        for (ConsumerType value : ConsumerType.values()) {
-            registeredConsumersMap[value.ordinal()] = new HashSet<>();
-        }
     }
 
     protected AbstractGateway(String id) {
@@ -81,202 +44,19 @@ public abstract class AbstractGateway {
         return router;
     }
 
-    protected final Event event() {
-        return event;
-    }
-
     protected void setModuleId(String moduleId) {
         this.moduleId = moduleId;
     }
 
-    protected void setEventBus(EventBus eventBus) {
-        this.eventBus = eventBus;
-        this.event = new EventImpl(eventBus);
-    }
-
     protected void setRouter(Router router) {
         this.router = router;
     }
 
     public final void start() {
         run();
-        registerSchedulerConsumers();
-    }
-
-    private boolean isConsumerRegistered(String consumerName) {
-        for (ConsumerType type : ConsumerType.values()) {
-            if (isConsumerRegistered(type, consumerName)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private boolean isConsumerRegistered(ConsumerType type, String name) {
-        return registeredConsumersMap[type.ordinal()].contains(name);
-    }
-
-    private Set<String> getRegisterConsumers(ConsumerType type) {
-        return registeredConsumersMap[type.ordinal()];
-    }
-
-    private void registerConsumer(ConsumerType type, String name) {
-        getRegisterConsumers(type).add(name);
-    }
-
-    private String createAddress(String consumerName) {
-        if (!isConsumerRegistered(consumerName)) {
-            throw logger.throwing(new RuntimeException(
-                    format("Consumer '%s' in module %s and gateway %s is not registered.",
-                            consumerName, moduleId, gatewayId)
-            ));
-        }
-        return createNormalized(moduleId, gatewayId, consumerName);
     }
 
     protected RequestUriComponent parseUriToComponents(HttpServerRequest request) {
         return RequestUriParser.parse(request, moduleId, gatewayId);
     }
-
-    private void registerSchedulerConsumers() {
-
-        for (ConsumerType type : values()) {
-            Set<String> consumers = getRegisterConsumers(type);
-
-            if (isDefault && !type.canBeDefault() && !consumers.isEmpty()) {
-                logger.warn("Following consumer can not be registered. These consumers can be registered only for default gateways. {}",
-                        Arrays.toString(consumers.toArray())
-                ); continue;
-            }
-
-            for (String consumer : consumers) {
-                // TODO
-            }
-        }
-
-
-        String baseAddr = isDefault ? SCHEDULER_PROVIDER : SCHEDULER_CONSUMER;
-        String gatewayAddr = createNormalized(baseAddr, gatewayId);
-        logger.info("[{}/{}] Creating a consumer at the address {}.", moduleId, gatewayId, gatewayAddr);
-
-        eventBus.consumer(gatewayAddr, message -> {
-            logger.info("[{}/{}] Handling request from address {}.", moduleId, gatewayId, message.address());
-            String schedulerConsumerName = message.headers().get(ADDRESS);
-
-            // TODO split 'consumeScheduler' and 'subscribe' -> set different address
-            if (!isConsumerRegistered(SCHEDULER, schedulerConsumerName)) {
-                logger.error("[{}/{}] Creating a fail message for the address {}.", moduleId, gatewayId, schedulerConsumerName);
-                message.fail(400, "No registered consumer for the address " + schedulerConsumerName);
-            } else {
-                String schedulerConsumerAddr = createAddress(schedulerConsumerName);
-                logger.info("[{}/{}] Creating a request at the address {}.", moduleId, gatewayId, schedulerConsumerAddr);
-                eventBus.request(schedulerConsumerAddr, message.body(), schedulerConsumerReply -> {
-                    if (schedulerConsumerReply.succeeded()) {
-                        io.vertx.core.eventbus.Message<Object> schedulerConsumerMsg = schedulerConsumerReply.result();
-                        DeliveryOptions options = new DeliveryOptions().setHeaders(schedulerConsumerMsg.headers());
-                        logger.info("[{}/{}] Handling request from address {}.", moduleId, gatewayId, schedulerConsumerMsg.address());
-                        message.reply(schedulerConsumerMsg.body(), options);
-                    } else {
-                        logger.error("[{}/{}] Creating a fail message for the address {}.", moduleId, gatewayId, schedulerConsumerAddr);
-                        message.fail(400, schedulerConsumerReply.cause().getMessage());
-                    }
-                });
-            }
-        });
-    }
-
-
-    protected interface Event {
-        <T> void consumeScheduler(String address, Consumer<Message<T>> handler);
-        <T> void subscribe(String address, Consumer<Message<T>> handler);
-        <T> void consume(String address, Consumer<Message<T>> handler);
-        <T> void send(String address, Object body, DeliveryOptions options, Consumer<Message<T>> handler);
-        <T> void send(String address, Object body, Consumer<Message<T>> handler);
-    }
-
-    private class EventImpl implements Event {
-
-        private final EventBus eventBus;
-
-        private EventImpl(EventBus eventBus) {
-            this.eventBus = eventBus;
-        }
-
-        @Override
-        public <T> void consumeScheduler(String address, Consumer<Message<T>> handler) {
-            consume(SCHEDULER, address, handler);
-        }
-
-        @Override
-        public <T> void subscribe(String address, Consumer<Message<T>> handler) {
-            consume(SUBSCRIBER, address, handler);
-        }
-
-        @Override
-        public <T> void consume(String address, Consumer<Message<T>> handler) {
-            registerConsumer(OTHER, address);
-            String consumerAddr = createAddress(address);
-            logger.info("[{}/{}] Creating a consumer at the address {}.", moduleId, gatewayId, consumerAddr);
-            eventBus.<T>consumer(consumerAddr, message -> {
-                logger.info("[{}/{}] Handling request from address {}.", moduleId, gatewayId, message.address());
-                Message<T> msg = new Message<>(message);
-                try {
-                    handler.accept(msg);
-                } catch (Exception e) {
-                    msg.fail(e);
-                }
-                if (msg.isFail()) {
-                    Fail fail = msg.cause();
-                    logger.error("[{}/{}] Creating a fail message for the address {}.", moduleId, gatewayId, message.address());
-                    message.fail(fail.getCode(), fail.getMessage());
-                } else {
-                    Reply<Object> reply = msg.reply;
-                    if (reply != null) {
-                        reply.options()
-                                .addHeader(MODULE_TYPE, moduleId)
-                                .addHeader(GATEWAY_TYPE, gatewayId)
-                                .addHeader(ADDRESS, address);
-                        logger.info("[{}/{}] Reply of the message {}.", moduleId, gatewayId, message.address());
-                        message.reply(reply.data, reply.options());
-                    } else {
-                        logger.info("[{}/{}] Reply empty message for the address {}.", moduleId, gatewayId, message.address());
-                        message.reply(new JsonObject());
-                    }
-                }
-            });
-        }
-
-        @Override
-        public <T> void send(String address, Object body, DeliveryOptions options, Consumer<Message<T>> handler) {
-            String requestAddr = createAddress(address);
-            logger.info("[{}/{}] Creating a request at the address {}.", moduleId, gatewayId, requestAddr);
-            eventBus.<T>request(requestAddr, body, options, reply -> {
-                Message<T> message;
-                if (reply.succeeded()) {
-                    logger.info("[{}/{}] Handling request from address {}.", moduleId, gatewayId, reply.result().address());
-                    message = new Message<>(reply.result());
-                } else {
-                    message = new Message<>(reply.cause());
-                }
-                handler.accept(message);
-            });
-        }
-
-        @Override
-        public <T> void send(String address, Object body, Consumer<Message<T>> handler) {
-            send(address, body, new DeliveryOptions(), handler);
-        }
-
-        private <T> void consume(ConsumerType type, String address, Consumer<Message<T>> handler) {
-            if (isConsumerRegistered(type, address)) {
-                throw logger.throwing(new RuntimeException(
-                        format("Consumer '%s' in module %s and gateway %s is already registered as a %s consumer.",
-                                address, moduleId, gatewayId, type.name().toLowerCase()
-                        )
-                ));
-            }
-            registerConsumer(type, address);
-            consume(address, handler);
-        }
-    }
 }

+ 0 - 8
connector-core/src/main/java/io/connector/core/AbstractModule.java

@@ -5,12 +5,10 @@ package io.connector.core;
 
 import io.vertx.ext.web.Router;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
 import static io.connector.core.AddressPath.Creator.create;
-import static io.connector.core.AddressPath.INFO;
 
 /**
  *
@@ -32,7 +30,6 @@ public abstract class AbstractModule extends Module {
 
     protected void registerGateway(AbstractGateway gateway) {
         if (!gateways.containsKey(gateway.id())) {
-            gateway.setEventBus(vertx.eventBus());
             gateway.setRouter(Router.router(vertx));
             gateway.setModuleId(moduleId);
             gateways.put(gateway.id(), gateway);
@@ -58,10 +55,5 @@ public abstract class AbstractModule extends Module {
     public void start() throws Exception {
         run();
         gateways.values().forEach(AbstractGateway::start);
-        vertx.eventBus().consumer(create(moduleId, INFO), msg -> {
-            ModuleInfo info = info();
-            info.setGateways(new ArrayList<>(gateways.keySet()));
-            msg.reply(info);
-        });
     }
 }

+ 0 - 8
connector-core/src/main/java/io/connector/core/AddressPath.java

@@ -3,8 +3,6 @@
 
 package io.connector.core;
 
-import static io.connector.core.AddressPath.Creator.create;
-
 /**
  *
  * @author Lukas Cerny
@@ -13,12 +11,6 @@ import static io.connector.core.AddressPath.Creator.create;
  */
 public final class AddressPath {
 
-    public static final String SCHEDULER_CONSUMER = create("scheduler", "consumer");
-    public static final String SCHEDULER_PROVIDER = create("scheduler", "provider");
-
-    public static final String EVENT = "event";
-    public static final String INFO = "info";
-
     public static final class Creator {
 
         private final static char DELIMITER = '/';

+ 0 - 37
connector-core/src/main/java/io/connector/core/Fail.java

@@ -1,37 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.core;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class Fail {
-
-    private final int code;
-    private final String message;
-
-    Fail(int code, String message) {
-        this.code = code;
-        this.message = message;
-    }
-
-    public int getCode() {
-        return code;
-    }
-
-    public String getMessage() {
-        return message;
-    }
-
-    @Override
-    public String toString() {
-        return "Fail{" +
-                "code=" + code +
-                ", message='" + message + '\'' +
-                '}';
-    }
-}

+ 0 - 43
connector-core/src/main/java/io/connector/core/Handler.java

@@ -1,43 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.core;
-
-import io.vertx.core.json.Json;
-import io.vertx.ext.web.RoutingContext;
-
-import java.util.function.Consumer;
-
-import static io.connector.core.http.ContentType.APPLICATION_JSON;
-import static io.connector.core.http.Header.CONTENT_TYPE;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public final class Handler {
-
-    public static <T> Consumer<Message<T>> replyToHttpContext(RoutingContext httpContext) {
-        return reply -> {
-            if (reply.success()) {
-                httpContext.response().putHeader(CONTENT_TYPE, APPLICATION_JSON);
-                httpContext.response().end(Json.encode(reply.body()));
-            } else {
-                Fail fail = reply.cause();
-                httpContext.fail(fail.getCode(), new RuntimeException(fail.getMessage()));
-            }
-        };
-    }
-
-    public static <T> Consumer<Message<T>> replyToEventContext(Message<T> message) {
-        return reply -> {
-            if (reply.success()) {
-                message.reply(reply.body());
-            } else {
-                message.fail(reply.cause().getCode(), reply.cause().getMessage());
-            }
-        };
-    }
-}

+ 0 - 71
connector-core/src/main/java/io/connector/core/Message.java

@@ -1,71 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.core;
-
-import io.vertx.core.MultiMap;
-import io.vertx.core.eventbus.ReplyException;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class Message<T> {
-
-    private final io.vertx.core.eventbus.Message<T> message;
-    protected Reply<Object> reply;
-    private Fail fail;
-
-    Message(io.vertx.core.eventbus.Message<T> message) {
-        this.message=  message;
-    }
-
-    Message(Throwable throwable) {
-        this.message = null;
-
-        if (throwable instanceof ReplyException) {
-            this.fail = new Fail(((ReplyException)throwable).failureCode(), throwable.getMessage());
-        } else {
-            this.fail = new Fail(400, throwable.getMessage());
-        }
-    }
-
-    public T body() {
-        return message.body();
-    }
-
-    public MultiMap headers() {
-        return message.headers();
-    }
-
-    public String address() {
-        return message.address();
-    }
-
-    public void fail(int code, String message) {
-        fail = new Fail(code, message);
-    }
-
-    public void fail(Throwable throwable) {
-        fail = new Fail(400, throwable.getMessage());
-    }
-
-    public boolean success() {
-        return fail == null;
-    }
-
-    public boolean isFail() {
-        return !success();
-    }
-
-    public Fail cause() {
-        return fail;
-    }
-
-    public Reply<Object> reply(Object data) {
-        reply = new Reply<>(data);
-        return reply;
-    }
-}

+ 0 - 5
connector-core/src/main/java/io/connector/core/ModuleDeployer.java

@@ -43,11 +43,6 @@ public class ModuleDeployer extends AbstractVerticle {
             extendedModules.add(module);
         }
 
-        VertxScheduler vertxScheduler = new VertxScheduler(modules);
-        DeploymentOptions schedulerOpt = new DeploymentOptions().setWorker(true);
-        futureModules.add(deployHelper(vertx, schedulerOpt, vertxScheduler));
-        extendedModules.add(vertxScheduler);
-
         CompositeFuture.all(futureModules).onComplete(result -> {
             if(result.succeeded()) {
                 DeploymentOptions options = new DeploymentOptions()

+ 0 - 27
connector-core/src/main/java/io/connector/core/Reply.java

@@ -1,27 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.core;
-
-import io.vertx.core.eventbus.DeliveryOptions;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class Reply<T> {
-
-    protected final T data;
-    private final DeliveryOptions options;
-
-    Reply(T data) {
-        this.data = data;
-        this.options = new DeliveryOptions();
-    }
-
-    public DeliveryOptions options() {
-        return options;
-    }
-}

+ 0 - 47
connector-core/src/main/java/io/connector/core/VertxHttpServer.java

@@ -7,33 +7,22 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import io.connector.core.json.JsonAttributeFormatter;
 import io.vertx.core.AbstractVerticle;
-import io.vertx.core.CompositeFuture;
-import io.vertx.core.Future;
 import io.vertx.core.Promise;
-import io.vertx.core.eventbus.DeliveryOptions;
 import io.vertx.core.eventbus.EventBus;
 import io.vertx.core.http.HttpServerResponse;
-import io.vertx.core.json.Json;
 import io.vertx.core.json.JsonObject;
 import io.vertx.core.json.jackson.DatabindCodec;
 import io.vertx.ext.web.Router;
-import io.vertx.ext.web.handler.BodyHandler;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
 import java.time.OffsetDateTime;
-import java.util.ArrayList;
 import java.util.List;
 
 import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
 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.connector.core.AddressPath.Creator.createNormalized;
-import static io.connector.core.AddressPath.EVENT;
-import static io.connector.core.AddressPath.INFO;
-import static io.connector.core.MessageHeader.RESOURCE;
-import static io.connector.core.MessageHeader.Resource.HTTP_SERVER;
 import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME;
 
 /**
@@ -86,42 +75,6 @@ public class VertxHttpServer extends AbstractVerticle {
             response.setStatusCode(code).end(error.encode());
         });
 
-
-        router.get(create(domainPrefix, EVENT)).handler(BodyHandler.create()).handler(ctx -> {
-            HttpServerResponse response = ctx.response();
-            response.putHeader(CONTENT_TYPE, APPLICATION_JSON);
-
-            EventInfo info = Json.decodeValue(ctx.getBody(), EventInfo.class);
-            String address = createNormalized(info.getModule(), info.getGateway(), info.getAddress());
-            DeliveryOptions options = new DeliveryOptions().addHeader(RESOURCE, HTTP_SERVER);
-
-            response.end(new JsonObject().put("message", "Events are not implemented yet.").encode());
-        });
-
-        router.get(create(domainPrefix, INFO)).handler(ctx -> {
-            List<Future> futures = new ArrayList<>(modules.size());
-            for (Module module : modules) {
-                final Promise<ModuleInfo> promise = Promise.promise();
-                eventBus.<ModuleInfo>request(create(module.id(), INFO), new JsonObject(), reply -> {
-                    if (reply.succeeded()) {
-                        promise.complete(reply.result().body());
-                    } else {
-                        promise.fail(reply.cause());
-                    }
-                });
-                futures.add(promise.future());
-            }
-            CompositeFuture.all(futures).onComplete(reply -> {
-                HttpServerResponse response = ctx.response();
-                if(reply.succeeded()) {
-                    response.putHeader(CONTENT_TYPE, APPLICATION_JSON);
-                    response.end(Json.encode(reply.result().list()));
-                } else {
-                    response.end(reply.cause().getMessage());
-                }
-            });
-        });
-
         int port = config().getInteger("http.server.port");
         vertx.createHttpServer().requestHandler(router)
                 .listen(port, result -> {

+ 0 - 178
connector-core/src/main/java/io/connector/core/VertxScheduler.java

@@ -1,178 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.core;
-
-import io.connector.core.config.SchedulerConfig;
-import io.vertx.core.MultiMap;
-import io.vertx.core.eventbus.DeliveryOptions;
-import io.vertx.core.eventbus.EventBus;
-import io.vertx.core.eventbus.Message;
-import io.vertx.core.json.JsonArray;
-import io.vertx.core.json.JsonObject;
-import io.vertx.ext.web.handler.BodyHandler;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.time.LocalDateTime;
-import java.util.HashMap;
-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.connector.core.AddressPath.Creator.createNormalized;
-import static io.connector.core.AddressPath.SCHEDULER_CONSUMER;
-import static io.connector.core.AddressPath.SCHEDULER_PROVIDER;
-import static io.connector.core.MessageHeader.*;
-import static io.connector.core.MessageHeader.Resource.SCHEDULER;
-import static java.lang.String.format;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-class VertxScheduler extends Module {
-
-    private final static Logger logger = LogManager.getLogger(VertxScheduler.class);
-
-    // <moduleId, config>
-    private final Map<String, SchedulerConfig> schedulerConfigs;
-
-    // <moduleId, schedulerId>
-    private final Map<String, Long> scheduledModules;
-
-    VertxScheduler(List<AbstractModule> modules) {
-        super("scheduler");
-        this.schedulerConfigs = new HashMap<>();
-        for (AbstractModule module : modules) {
-            String moduleId = module.id();
-            ModuleDescriptor descriptor = module.descriptor();
-            if (descriptor != null && descriptor.getSchedulerConfig() != null) {
-                SchedulerConfig config = descriptor.getSchedulerConfig();
-                schedulerConfigs.put(moduleId, config);
-            }
-        }
-        this.scheduledModules = new HashMap<>(schedulerConfigs.size());
-    }
-
-    private long registerNewSchedulingRole(String moduleId, SchedulerConfig config) {
-        EventBus eventBus = vertx.eventBus();
-        if (config != null && config.getPeriodSecond() > 0) {
-            return vertx.setPeriodic(config.getPeriodMillisecond(), ctx -> {
-                if (config.shouldTerminate()) { return; }
-                DeliveryOptions fetcherOpt = new DeliveryOptions()
-                        .addHeader(RESOURCE, SCHEDULER)
-                        .addHeader(ADDRESS, config.getConsumer());
-                String providerAddress = createNormalized(SCHEDULER_PROVIDER, moduleId);
-                logger.info("Sending a message to the address {}.", providerAddress);
-                eventBus.request(providerAddress, config.getConfig(), fetcherOpt, reply -> {
-                    if (reply.succeeded()) {
-                        Message<Object> result = reply.result();
-                        String source = result.headers().get(MODULE_TYPE);
-                        DeliveryOptions pusherOpt = new DeliveryOptions();
-                        MultiMap headers = result.headers().addAll(fetcherOpt.getHeaders());
-                        for (Map.Entry<String, String> entryHeader : headers.entries()) {
-                            if (entryHeader.getKey().startsWith(MessageHeader.getPrefix())) {
-                                pusherOpt.addHeader(entryHeader.getKey(), entryHeader.getValue());
-                            }
-                        }
-                        String consumerAddress = createNormalized(SCHEDULER_CONSUMER, source);
-                        eventBus.publish(consumerAddress, result.body(), pusherOpt);
-                    } else {
-                        logger.catching(reply.cause());
-                    }
-                });
-            });
-        }
-        return -1;
-    }
-
-    @Override
-    public void run() {
-
-        vertx.setPeriodic(60000, ctx -> { // 60000 = every minute
-            for (Map.Entry<String, SchedulerConfig> entry : schedulerConfigs.entrySet()) {
-                if (entry.getValue().shouldTerminate()) {
-                    long schedulerId = scheduledModules.getOrDefault(entry.getKey(), -1L);
-                    if (schedulerId >= 0) {
-                        SchedulerConfig config = entry.getValue();
-                        boolean successfullyDeleted = vertx.cancelTimer(schedulerId);
-                        if (successfullyDeleted) {
-                            logger.info("Scheduler {} of the module {} was successfully deleted.", config.getId(), entry.getKey());
-                        } else {
-                            logger.error("Scheduler {} of the module {} was not deleted successfully.", config.getId(), entry.getKey());
-                        }
-                    }
-                }
-            }
-        });
-
-        for (Map.Entry<String, SchedulerConfig> configEntry : schedulerConfigs.entrySet()) {
-            String moduleId = configEntry.getKey();
-            SchedulerConfig config = configEntry.getValue();
-            long schedulerId = registerNewSchedulingRole(moduleId, config);
-            if (schedulerId >= 0) {
-                scheduledModules.put(moduleId, schedulerId);
-            }
-        }
-
-        router().get(create("rules")).handler(ctx -> {
-            JsonArray rules = new JsonArray();
-            for (Map.Entry<String, Long> entry : scheduledModules.entrySet()) {
-                String moduleId = entry.getKey();
-                Long schedulerId = entry.getValue();
-
-                SchedulerConfig config = schedulerConfigs.get(moduleId);
-
-                JsonObject settings = new JsonObject()
-                        .put("consumer", config.getConsumer())
-                        .put("period", config.getPeriodSecond());
-                if (!config.getDeadLine().equals(LocalDateTime.MAX)) {
-                    settings.put("deadLine", config.getDeadLine());
-                }
-                settings.put("config", config.getConfig());
-
-                rules.add(new JsonObject()
-                        .put("id", schedulerId)
-                        .put("module", moduleId)
-                        .put("settings", settings)
-                );
-            }
-            ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(rules.encode());
-        });
-
-        router().post(create("rule")).handler(BodyHandler.create()).handler(ctx -> {
-            ctx.response().end("added new rule with id");
-        });
-
-        router().delete(create("rule/:id")).handler(ctx -> {
-            String idString = ctx.pathParam("id");
-            long id;
-            try {
-                id = Long.parseLong(idString);
-            } catch (NumberFormatException e) {
-                throw new RuntimeException(format("Param '%s' can not be converted to integer.", idString));
-            }
-
-            if (!scheduledModules.containsValue(id)) {
-                throw new RuntimeException(format("Identifier '%s' does not exist.", id));
-            }
-
-            boolean result = vertx.cancelTimer(id);
-
-            if (result) {
-                ctx.response().putHeader(CONTENT_TYPE, APPLICATION_JSON).end(new JsonObject()
-                        .put("message", format("Scheduling rule of the ID %s was successfully terminated.", id))
-                        .encode());
-            } else {
-                throw new RuntimeException(format(
-                        "Scheduling rule of the ID %s was not terminated successfully.", id
-                ));
-            }
-        });
-    }
-}

+ 0 - 9
connector-core/src/main/java/io/connector/core/config/ConfigurationService.java

@@ -4,7 +4,6 @@
 package io.connector.core.config;
 
 import io.connector.core.ModuleDescriptor;
-import io.connector.core.config.database.DatabaseBuilder;
 import io.connector.core.config.file.FileBuilder;
 
 import java.util.Optional;
@@ -33,14 +32,6 @@ public interface ConfigurationService {
     }
 
     /**
-     * Creates a builder for a configuration from a database.
-     * @return new instance of {@link DatabaseBuilder}.
-     */
-    static DatabaseBuilder newDatabaseBuilder() {
-        return DatabaseBuilder.create();
-    }
-
-    /**
      * @return set of connector descriptors.
      */
     Set<ModuleDescriptor> getModuleDescriptors();

+ 0 - 54
connector-core/src/main/java/io/connector/core/config/database/DatabaseBuilder.java

@@ -1,54 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.core.config.database;
-
-
-/**
- * The interface {@code DatabaseBuilder} provides a configuration
- * to create new connection to a database.
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public interface DatabaseBuilder {
-
-    static DatabaseBuilder create() {
-        return new DatabaseBuilderImpl();
-    }
-
-    /**
-     * Sets connection url to the configuration.
-     * @param connectionUrl - connection url to the database.
-     * @return instance of builder {@code DatabaseBuilder}.
-     */
-    DatabaseBuilder connectionUrl(String connectionUrl);
-
-    /**
-     * Sets username to the configuration.
-     * @param username - username to the database.
-     * @return instance of builder {@code DatabaseBuilder}.
-     */
-    DatabaseBuilder username(String username);
-
-    /**
-     * Sets password to the configuration.
-     * @param password - password to the database.
-     * @return instance of builder {@code DatabaseBuilder}.
-     */
-    DatabaseBuilder password(String password);
-
-    /**
-     * Identifier of connector name in a configuration database.
-     * @param connectorName connector name.
-     * @return instance of builder {@code DatabaseBuilder}.
-     */
-    DatabaseBuilder connectorName(String connectorName);
-
-    /**
-     * Creates a new instance with the configuration.
-     * @return new instance of {@link DatabaseConfigurationService}.
-     */
-    DatabaseConfigurationService build();
-}

+ 0 - 56
connector-core/src/main/java/io/connector/core/config/database/DatabaseBuilderImpl.java

@@ -1,56 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.core.config.database;
-
-
-/**
- * The class {@code DatabaseBuilderImpl} represents an implementation of {@link DatabaseBuilder}.
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-class DatabaseBuilderImpl implements DatabaseBuilder {
-
-    /** Connection url to a database. */
-    private String connectionUrl;
-
-    /** Username to a database. */
-    private String username;
-
-    /** Password to a database. */
-    private String password;
-
-    /** Name of connector in database. */
-    private String connectorName;
-
-    @Override
-    public DatabaseBuilder connectionUrl(String connectionUrl) {
-        this.connectionUrl = connectionUrl;
-        return this;
-    }
-
-    @Override
-    public DatabaseBuilder username(String username) {
-        this.username = username;
-        return this;
-    }
-
-    @Override
-    public DatabaseBuilder password(String password) {
-        this.password = password;
-        return this;
-    }
-
-    @Override
-    public DatabaseBuilder connectorName(String connectorName) {
-        this.connectorName = connectorName;
-        return this;
-    }
-
-    @Override
-    public DatabaseConfigurationService build() {
-        return new DatabaseConfigurationServiceImpl(connectionUrl, username, password, connectorName);
-    }
-}

+ 0 - 25
connector-core/src/main/java/io/connector/core/config/database/DatabaseConfigurationService.java

@@ -1,25 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.core.config.database;
-
-import io.connector.core.config.ConfigurationService;
-
-import java.io.IOException;
-
-/**
- * The interface {@code DatabaseConfigurationService} provides functionality
- * which is mandatory only for a database and is important to use it correctly.
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public interface DatabaseConfigurationService extends ConfigurationService {
-
-    /**
-     * Creates a new connection to the database.
-     * @throws IOException throws if the connection is not created successfully.
-     */
-    void connect() throws IOException;
-}

+ 0 - 69
connector-core/src/main/java/io/connector/core/config/database/DatabaseConfigurationServiceImpl.java

@@ -1,69 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.core.config.database;
-
-import io.connector.core.ModuleDescriptor;
-import io.connector.core.config.ConfigurationService;
-import io.connector.core.config.DefaultConfig;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.util.Optional;
-import java.util.Set;
-
-import static java.lang.String.format;
-
-/**
- * The class {@code DatabaseConfigurationServiceImpl} represents an implementation of {@link DatabaseConfigurationService}.
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-class DatabaseConfigurationServiceImpl implements ConfigurationService, DatabaseConfigurationService {
-
-    private static Logger logger = LogManager.getLogger(DatabaseConfigurationServiceImpl.class);
-
-    /** Connection url to a database. */
-    private final String connectionUrl;
-
-    /** Username to a database. */
-    private final String username;
-
-    /** Password to a database. */
-    private final String password;
-
-    /** Name of connector in a database. */
-    private final String connectorName;
-
-    /**
-     * Constructor sets all attributes.
-     * @param connectionUrl - connection url.
-     * @param username - username.
-     * @param password - password.
-     */
-    DatabaseConfigurationServiceImpl(String connectionUrl, String username, String password, String connectorName) {
-        this.connectionUrl = connectionUrl;
-        this.username = username;
-        this.password = password;
-        this.connectorName = connectorName;
-    }
-
-    @Override
-    public void connect() {
-        throw logger.throwing(new UnsupportedOperationException(format(
-                "%s#connect() is not implemented.", DatabaseConfigurationServiceImpl.class
-        )));
-    }
-
-    @Override
-    public Set<ModuleDescriptor> getModuleDescriptors() {
-        return null;
-    }
-
-    @Override
-    public Optional<ModuleDescriptor> getModuleDescriptor(String id) {
-        return Optional.empty();
-    }
-}

+ 0 - 23
connector-model/src/main/java/io/connector/model/ima/IMAModel.java

@@ -1,23 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.model.ima;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class IMAModel {
-
-    private final String data;
-
-    public IMAModel(String data) {
-        this.data = data;
-    }
-
-    public String getData() {
-        return data;
-    }
-}

+ 0 - 123
connector-model/src/main/java/io/connector/model/senslog1/Observation.java

@@ -1,123 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.model.senslog1;
-
-import io.vertx.core.buffer.Buffer;
-import io.vertx.core.eventbus.MessageCodec;
-import io.vertx.core.json.JsonObject;
-
-import java.time.OffsetDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Objects;
-
-import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME;
-import static java.time.format.DateTimeFormatter.ofPattern;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class Observation {
-
-    private final OffsetDateTime timestamp;
-    private final double value;
-
-    public static Observation parse(JsonObject jsonObject) {
-        // TODO check by schema
-
-        double value;
-        if (jsonObject.containsKey("value")) {
-            value = jsonObject.getDouble("value");
-        } else if (jsonObject.containsKey("observedValue")) {
-            value = jsonObject.getDouble("observedValue");
-        } else {
-            return null;
-        }
-
-        OffsetDateTime timestamp;
-        // TODO create a specific DateTimeFormatterBuilder to parse it
-        if (jsonObject.containsKey("time")) {
-            final DateTimeFormatter formatter = ofPattern("yyyy-MM-dd HH:mm:ssZ");
-            String timeString = jsonObject.getString("time");
-            timestamp = OffsetDateTime.parse(timeString + "00", formatter);
-        } else if (jsonObject.containsKey("timeStamp")) {
-            final DateTimeFormatter formatter = ofPattern("yyyy-MM-dd HH:mm:ssZ");
-            String timeString = jsonObject.getString("timeStamp");
-            timestamp = OffsetDateTime.parse(timeString + "00", formatter);
-        } else if (jsonObject.containsKey("timestamp")) {
-            String timeString = jsonObject.getString("timestamp");
-            timestamp = OffsetDateTime.parse(timeString, ISO_OFFSET_DATE_TIME);
-        } else {
-            return null;
-        }
-
-        return new Observation(value, timestamp);
-    }
-
-    public Observation(double value, OffsetDateTime timestamp) {
-        Objects.requireNonNull(timestamp);
-        this.value = value;
-        this.timestamp = timestamp;
-    }
-
-    public double getValue() {
-        return value;
-    }
-
-    public OffsetDateTime getTimestamp() {
-        return timestamp;
-    }
-
-    public static MessageCodec<Observation, Observation> createCodec() {
-        return new MessageCodec<Observation, Observation>() {
-
-            @Override
-            public void encodeToWire(Buffer buffer, Observation entries) {
-                JsonObject jsonToEncode = new JsonObject();
-                jsonToEncode.put("value", entries.getValue());
-                jsonToEncode.put("timestamp", entries.getTimestamp().format(ISO_OFFSET_DATE_TIME));
-
-                String jsonToStr = jsonToEncode.encode();
-                int length = jsonToStr.getBytes().length;
-
-                buffer.appendInt(length);
-                buffer.appendString(jsonToStr);
-            }
-
-            @Override
-            public Observation decodeFromWire(int i, Buffer buffer) {
-                int _pos = i;
-                int length = buffer.getInt(_pos);
-
-                String jsonStr = buffer.getString(_pos += 4, _pos += length);
-                JsonObject contentJson = new JsonObject(jsonStr);
-
-                double value = contentJson.getDouble("value");
-                String timestampString = contentJson.getString("timestamp");
-                OffsetDateTime timestamp = OffsetDateTime.parse(timestampString, ISO_OFFSET_DATE_TIME);
-
-                return new Observation(value, timestamp);
-            }
-
-            @Override
-            public Observation transform(Observation observation) {
-                return observation;
-            }
-
-            @Override
-            public String name() {
-                return this.getClass().getName();
-            }
-
-            @Override
-            public byte systemCodecID() {
-                return -1;
-            }
-        };
-    }
-}
-
-

+ 0 - 45
connector-model/src/main/java/io/connector/model/senslog1/Phenomenon.java

@@ -1,45 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.model.senslog1;
-
-import io.vertx.core.json.JsonObject;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class Phenomenon {
-
-    private final long id;
-    private final String name;
-    private final String unit;
-
-    public static Phenomenon parse(JsonObject jsonObject) {
-        // TODO check by schema
-        long id = Long.parseLong(jsonObject.getString("phenomenonId"));
-        String name = jsonObject.getString("phenomenonName");
-        String unit = jsonObject.getString("unit");
-        return new Phenomenon(id, name, unit);
-    }
-
-    public Phenomenon(long id, String name, String unit) {
-        this.id = id;
-        this.name = name;
-        this.unit = unit;
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public String getUnit() {
-        return unit;
-    }
-}

+ 0 - 74
connector-model/src/main/java/io/connector/model/senslog1/Position.java

@@ -1,74 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.model.senslog1;
-
-import io.vertx.core.json.JsonObject;
-
-import java.time.OffsetDateTime;
-import java.time.format.DateTimeFormatter;
-
-import static java.time.format.DateTimeFormatter.ofPattern;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class Position {
-
-    private final Double latitude;
-    private final Double longitude;
-    private final Double altitude;
-    private final Double speed;
-    private final Integer dilutionOfPrecision;
-    private final OffsetDateTime timestamp;
-
-    public static Position parse(JsonObject jsonObject) {
-        // TODO check by schema
-        double x = jsonObject.getDouble("x");
-        double y = jsonObject.getDouble("y");
-        String timeString = jsonObject.getString("time_stamp");
-        final DateTimeFormatter formatter = ofPattern("yyyy-MM-dd HH:mm:ssZ");
-        OffsetDateTime time = OffsetDateTime.parse(timeString+"00", formatter);
-        return new Position(x, y, time);
-    }
-
-    private Position(Double latitude, Double longitude, Double altitude, Double speed, Integer dilutionOfPrecision, OffsetDateTime timestamp) {
-        this.latitude = latitude;
-        this.longitude = longitude;
-        this.altitude = altitude;
-        this.speed = speed;
-        this.dilutionOfPrecision = dilutionOfPrecision;
-        this.timestamp = timestamp;
-    }
-
-    public Position(double latitude, double longitude, OffsetDateTime timestamp) {
-        this(latitude, longitude, null, null, null, timestamp);
-    }
-
-    public Double getLatitude() {
-        return latitude;
-    }
-
-    public Double getLongitude() {
-        return longitude;
-    }
-
-    public Double getAltitude() {
-        return altitude;
-    }
-
-    public Double getSpeed() {
-        return speed;
-    }
-
-    public Integer getDilutionOfPrecision() {
-        return dilutionOfPrecision;
-    }
-
-    public OffsetDateTime getTimestamp() {
-        return timestamp;
-    }
-}

+ 0 - 31
connector-model/src/main/java/io/connector/model/senslog1/Sensor.java

@@ -1,31 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.model.senslog1;
-
-import java.util.List;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class Sensor {
-
-    private final SensorInfo info;
-    private final List<Observation> observations;
-
-    public Sensor(SensorInfo info, List<Observation> observations) {
-        this.info = info;
-        this.observations = observations;
-    }
-
-    public SensorInfo getInfo() {
-        return info;
-    }
-
-    public List<Observation> getObservations() {
-        return observations;
-    }
-}

+ 0 - 127
connector-model/src/main/java/io/connector/model/senslog1/SensorData.java

@@ -1,127 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.model.senslog1;
-
-import io.vertx.core.buffer.Buffer;
-import io.vertx.core.eventbus.MessageCodec;
-import io.vertx.core.json.Json;
-import io.vertx.core.json.JsonArray;
-import io.vertx.core.json.JsonObject;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class SensorData {
-
-    private final long id;
-    private final List<Observation> observations;
-
-    public static SensorData parse(JsonObject jsonObject) {
-        // TODO check by schema
-        long id = jsonObject.getLong("id");
-        JsonArray observationsJson = jsonObject.getJsonArray("observations");
-        List<Observation> observations = new ArrayList<>(observationsJson.size());
-        for (int i = 0; i < observationsJson.size(); i++) {
-            observations.add(Observation.parse(observationsJson.getJsonObject(i)));
-        }
-        return new SensorData(id, observations);
-    }
-
-    public SensorData(long id) {
-        this(id, new ArrayList<>());
-    }
-
-    public SensorData(long id, List<Observation> observations) {
-        Objects.requireNonNull(observations);
-        this.id = id;
-        this.observations = observations;
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void addObservation(Observation observation) {
-        this.observations.add(observation);
-    }
-
-    public List<Observation> getObservations() {
-        return observations;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        SensorData sensorData = (SensorData) o;
-        return Objects.equals(getId(), sensorData.getId());
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(getId());
-    }
-
-    public static MessageCodec<SensorData, SensorData> createCodec() {
-        return new MessageCodec<SensorData, SensorData>() {
-
-            @Override
-            public void encodeToWire(Buffer buffer, SensorData sensor) {
-                JsonObject jsonToEncode = new JsonObject();
-                jsonToEncode.put("sensorId", sensor.getId());
-                jsonToEncode.put("observations", Json.encode(sensor.getObservations()));
-
-                String jsonToStr = jsonToEncode.encode();
-                int length = jsonToStr.getBytes().length;
-
-                buffer.appendInt(length);
-                buffer.appendString(jsonToStr);
-            }
-
-            @Override
-            public SensorData decodeFromWire(int i, Buffer buffer) {
-                int _pos = i;
-                int length = buffer.getInt(_pos);
-
-                String jsonStr = buffer.getString(_pos += 4, _pos += length);
-                JsonObject contentJson = new JsonObject(jsonStr);
-
-                long sensorId = contentJson.getLong("sensorId");
-
-                /*
-                String jsonObservationStr = contentJson.getString("observations");
-                JsonArray jsonObservationsArr = contentJson.getJsonArray("observations");
-
-                // TODO
-                TypeReference<List<Observation>> ref = new TypeReference<>() {};
-                List<Observation> observations = Json.decodeValue(jsonObservationStr, ref);
-                */
-
-                return new SensorData(sensorId, new ArrayList<>());
-            }
-
-            @Override
-            public SensorData transform(SensorData sensor) {
-                return sensor;
-            }
-
-            @Override
-            public String name() {
-                return this.getClass().getName();
-            }
-
-            @Override
-            public byte systemCodecID() {
-                return -1;
-            }
-        };
-    }
-}

+ 0 - 99
connector-model/src/main/java/io/connector/model/senslog1/SensorInfo.java

@@ -1,99 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.model.senslog1;
-
-import io.vertx.core.json.JsonObject;
-
-import java.time.OffsetDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Objects;
-
-import static java.lang.String.format;
-import static java.time.format.DateTimeFormatter.ofPattern;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class SensorInfo {
-
-    private final long id;
-    private final String name;
-    private final String type;
-    private final Phenomenon phenomenon;
-
-    private final OffsetDateTime firstObservationTime;
-    private final OffsetDateTime lastObservationTime;
-
-    public static SensorInfo parse(JsonObject jsonObject) {
-        // TODO check by schema
-        long id = jsonObject.getLong("sensorId");
-        String name = jsonObject.getString("sensorName");
-        String type = jsonObject.getString("sensorType");
-        Phenomenon phenomenon = Phenomenon.parse(jsonObject.getJsonObject("phenomenon"));
-
-        final DateTimeFormatter formatter = ofPattern("yyyy-MM-dd HH:mm:ssZ");
-        String firstTimeStr = jsonObject.getString("firstObservationTime");
-        OffsetDateTime firstTime = OffsetDateTime.parse(format("%s00", firstTimeStr), formatter);
-        String lastTimeStr = jsonObject.getString("lastObservationTime");
-        OffsetDateTime lastTime = OffsetDateTime.parse(format("%s00", lastTimeStr), formatter);
-
-        return new SensorInfo(id, name, type, phenomenon, firstTime, lastTime);
-    }
-
-    public SensorInfo(long id, String name, String type, Phenomenon phenomenon,
-                      OffsetDateTime firstObservationTime, OffsetDateTime lastObservationTime)
-    {
-        Objects.requireNonNull(name);
-        Objects.requireNonNull(type);
-        Objects.requireNonNull(phenomenon);
-        Objects.requireNonNull(firstObservationTime);
-        Objects.requireNonNull(lastObservationTime);
-        this.id = id;
-        this.name = name;
-        this.type = type;
-        this.phenomenon = phenomenon;
-        this.firstObservationTime = firstObservationTime;
-        this.lastObservationTime = lastObservationTime;
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public Phenomenon getPhenomenon() {
-        return phenomenon;
-    }
-
-    public OffsetDateTime getFirstObservationTime() {
-        return firstObservationTime;
-    }
-
-    public OffsetDateTime getLastObservationTime() {
-        return lastObservationTime;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        SensorInfo sensorInfo = (SensorInfo) o;
-        return Objects.equals(id, sensorInfo.id);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(id);
-    }
-}

+ 0 - 31
connector-model/src/main/java/io/connector/model/senslog1/Unit.java

@@ -1,31 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.model.senslog1;
-
-import java.util.List;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class Unit {
-
-    private final UnitInfo info;
-    private final List<Sensor> sensors;
-
-    public Unit(UnitInfo info, List<Sensor> sensors) {
-        this.info = info;
-        this.sensors = sensors;
-    }
-
-    public UnitInfo getInfo() {
-        return info;
-    }
-
-    public List<Sensor> getSensors() {
-        return sensors;
-    }
-}

+ 0 - 184
connector-model/src/main/java/io/connector/model/senslog1/UnitData.java

@@ -1,184 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.model.senslog1;
-
-import io.vertx.core.buffer.Buffer;
-import io.vertx.core.eventbus.MessageCodec;
-import io.vertx.core.json.Json;
-import io.vertx.core.json.JsonArray;
-import io.vertx.core.json.JsonObject;
-
-import java.util.*;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class UnitData {
-
-    private final long id;
-
-    private Map<Long, SensorData> sensorCache;
-    private List<Position> positions;
-
-    public static UnitData parse(JsonObject jsonObject) {
-        // TODO check by schema
-        long id = jsonObject.getLong("id");
-        JsonArray positionsJson = jsonObject.getJsonArray("positions");
-        List<Position> positions = new ArrayList<>(positionsJson.size());
-        for (Object position : positionsJson) {
-            if (position instanceof JsonObject) {
-                positions.add(Position.parse((JsonObject)position));
-            }
-        }
-        JsonArray sensorsJson = jsonObject.getJsonArray("sensors");
-        List<SensorData> sensors = new ArrayList<>(sensorsJson.size());
-        for (Object sensor : sensorsJson) {
-            if (sensor instanceof JsonObject) {
-                sensors.add(SensorData.parse((JsonObject)sensor));
-            }
-        }
-        return new UnitData(id, sensors, positions);
-    }
-
-    public UnitData(long id) {
-        this(id, new ArrayList<>(), new ArrayList<>());
-    }
-
-    public UnitData(long id, List<SensorData> sensors, List<Position> positions) {
-        this.id = id;
-        setSensors(sensors);
-        setPositions(positions);
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void setSensors(Collection<SensorData> sensors) {
-        this.sensorCache = new HashMap<>(sensors.size());
-        for (SensorData sensor : sensors) {
-            sensorCache.put(sensor.getId(), sensor);
-        }
-    }
-
-    public void addSensor(SensorData sensor) {
-        Objects.requireNonNull(sensor);
-        sensorCache.put(sensor.getId(), sensor);
-    }
-
-    public SensorData getSensor(long sensorId) {
-        if (sensorCache.containsKey(sensorId)) {
-            return sensorCache.get(sensorId);
-        }
-        return null;
-    }
-
-    public Collection<SensorData> getSensors() {
-        return sensorCache.values();
-    }
-
-    public void setPositions(List<Position> positions) {
-        Objects.requireNonNull(positions);
-        this.positions = positions;
-    }
-
-    public void addPosition(Position position) {
-        this.positions.add(position);
-    }
-
-    public List<Position> getPositions() {
-        return positions;
-    }
-
-    public final void mergeIn(UnitData unitData) {
-        if (this.id != unitData.getId()) { return; }
-
-        Collection<SensorData> sensors = unitData.getSensors();
-        if (this.sensorCache.isEmpty() && !sensors.isEmpty()) {
-            setSensors(sensors);
-        }
-
-        List<Position> positions = unitData.getPositions();
-        if (this.positions.isEmpty()) {
-            setPositions(positions);
-        }
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        UnitData unitData = (UnitData) o;
-        return Objects.equals(getId(), unitData.getId());
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(getId());
-    }
-
-    public static MessageCodec<UnitData, UnitData> createCodec() {
-        return new MessageCodec<UnitData, UnitData>() {
-
-            @Override
-            public void encodeToWire(Buffer buffer, UnitData multiSensor) {
-                JsonObject jsonToEncode = new JsonObject();
-                jsonToEncode.put("unitId", multiSensor.getId());
-                jsonToEncode.put("sensors", Json.encode(multiSensor.getSensors()));
-                jsonToEncode.put("positions", Json.encode(multiSensor.getPositions()));
-
-                String jsonToStr = jsonToEncode.encode();
-                int length = jsonToStr.getBytes().length;
-
-                buffer.appendInt(length);
-                buffer.appendString(jsonToStr);
-            }
-
-            @Override
-            public UnitData decodeFromWire(int i, Buffer buffer) {
-                int _pos = i;
-                int length = buffer.getInt(_pos);
-
-                String jsonStr = buffer.getString(_pos += 4, _pos += length);
-                JsonObject contentJson = new JsonObject(jsonStr);
-
-                long unitId = contentJson.getLong("unitId");
-
-                /*
-                String jsonSensorsStr = contentJson.getString("sensors");
-                JsonArray jsonSensorsArr = contentJson.getJsonArray("sensors");
-                // TODO
-                TypeReference<List<SensorObservation>> refSensors = new TypeReference<>() {};
-                List<SensorObservation> sensors = Json.decodeValue(jsonSensorsStr, refSensors);
-
-                String jsonPositionsStr = contentJson.getString("positions");
-                JsonArray jsonPositionsArr = contentJson.getJsonArray("positions");
-                // TODO
-                TypeReference<List<Position>> refPosition = new TypeReference<>() {};
-                List<Position> positions = Json.decodeValue(jsonPositionsStr, refPosition);
-                */
-
-                return new UnitData(unitId, new ArrayList<>(), new ArrayList<>());
-            }
-
-            @Override
-            public UnitData transform(UnitData unitData) {
-                return unitData;
-            }
-
-            @Override
-            public String name() {
-                return this.getClass().getSimpleName();
-            }
-
-            @Override
-            public byte systemCodecID() {
-                return -1;
-            }
-        };
-    }
-}

+ 0 - 93
connector-model/src/main/java/io/connector/model/senslog1/UnitInfo.java

@@ -1,93 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.model.senslog1;
-
-import io.vertx.core.json.JsonObject;
-
-import java.util.*;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class UnitInfo {
-
-    private final long id;
-    private final long holderId;
-    private final String description;
-
-    private Map<Long, SensorInfo> sensorCache;
-
-    public static UnitInfo parse(JsonObject jsonObject) {
-        // TODO check by schema
-        long id = jsonObject.getLong("unitId");
-        int holderId = jsonObject.getInteger("holderId");
-        String description = jsonObject.getString("description");
-
-        return new UnitInfo(id, holderId, description);
-    }
-
-    public UnitInfo(long unitId, int holderId, String description) {
-        this(unitId, holderId, description, new ArrayList<>());
-    }
-
-    public UnitInfo(long unitId, int holderId, String description, List<SensorInfo> sensors) {
-        Objects.requireNonNull(description);
-        this.id = unitId;
-        this.holderId = holderId;
-        this.description = description;
-        setSensors(sensors);
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public long getHolderId() {
-        return holderId;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public void addSensor(SensorInfo sensor) {
-        Objects.requireNonNull(sensor);
-        sensorCache.put(sensor.getId(), sensor);
-    }
-
-    public void setSensors(List<SensorInfo> sensors) {
-        Objects.requireNonNull(sensors);
-        this.sensorCache = new HashMap<>(sensors.size());
-        for (SensorInfo sensor : sensors) {
-            sensorCache.put(sensor.getId(), sensor);
-        }
-    }
-
-    public Collection<SensorInfo> getSensors() {
-        return sensorCache.values();
-    }
-
-    public SensorInfo getSensor(long sensorId) {
-        if (sensorCache.containsKey(sensorId)) {
-            return sensorCache.get(sensorId);
-        }
-        return null;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        UnitInfo unitInfo = (UnitInfo) o;
-        return Objects.equals(id, unitInfo.id);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(id);
-    }
-}

+ 3 - 4
connector-model/src/main/java/io/connector/model/sensorthings/Filter.java

@@ -50,7 +50,7 @@ public class Filter {
 
         String [] cmp = filterString.split("\\s(and)\\s");
         if (cmp.length != 2) { // supported only 'and'
-            return emptyFilter(); // TODO exception
+            throw new RuntimeException("Filter supports only the logical operator 'and'.");
         }
 
         final Pattern pattern = Pattern.compile("^(?<attribute>[a-zA-Z]+)\\s*(?<operator>(gt|lt))\\s*(?<date>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z)");
@@ -65,8 +65,7 @@ public class Filter {
                         matcher.group("attribute"), matcher.group("operator"), matcher.group("date"))
                 );
             } else {
-                // TODO exception
-                return emptyFilter();
+                throw new RuntimeException("Filter does not accept this operation.");
             }
         }
 
@@ -75,7 +74,7 @@ public class Filter {
 
     private List<Expression> expressionsAdd;
 
-    private static Filter emptyFilter() {
+    public static Filter emptyFilter() {
         return new Filter(false, "");
     }
 

+ 1 - 17
connector-module-afarcloud/src/main/java/io/connector/module/afarcloud/AFCHttpClient.java

@@ -61,29 +61,13 @@ public class AFCHttpClient {
         this.httpClient = httpClient;
     }
 
-    public void uploadAggregatedMeasurements(List<MultiSimpleObservation> observations) {
-
-        if (observations == null || observations.isEmpty()) {
-            logger.warn("Nothing to upload. Received observations of multi-sensor are empty."); return;
-        }
-
-        HostConfig host = new HostConfig(config.getTelemetryDomain(), "telemetry");
-        logger.debug("Getting observations from {}.", host.getDomain());
-
-        for (MultiSimpleObservation multiSensor : observations) {
-            System.out.println(Json.encode(multiSensor)); // TODO upload to the server
-        }
-        
-        logger.info("Converted {} observations.", observations.size());
-    }
-
     public List<ResourceMeasurement> getObservationsBySensor(Filter filter) {
         HostConfig host = new HostConfig(config.getRetrievalDomain(), "getObservationsBySensor/historic");
         logger.debug("Getting observations from {}.", host.getDomain());
 
         URLBuilder urlBuilder = URLBuilder.newBuilder(host.getDomain(), host.getPath());
 
-        if (filter.startTime != null) {
+        if (filter.startTime == null) {
             throw new RuntimeException("Parameter 'startTime' is required.");
         }
         urlBuilder.addParam("start_time", filter.startTime());

+ 0 - 2
connector-module-afarcloud/src/main/java/io/connector/module/afarcloud/AFCModule.java

@@ -7,7 +7,6 @@ import io.connector.core.AbstractModule;
 import io.connector.core.ModuleDescriptor;
 import io.connector.core.ModuleInfo;
 import io.connector.module.afarcloud.gateway.OGCSensorThingsGateway;
-import io.connector.module.afarcloud.gateway.SensLog1Gateway;
 
 /**
  *
@@ -26,7 +25,6 @@ public class AFCModule extends AbstractModule {
 
     @Override
     public void run() {
-        registerGateway(new SensLog1Gateway("SensLogV1", client));
         registerGateway(new OGCSensorThingsGateway("OGCSensorThings", client));
     }
 

+ 24 - 3
connector-module-afarcloud/src/main/java/io/connector/module/afarcloud/gateway/OGCSensorThingsGateway.java

@@ -231,7 +231,14 @@ public class OGCSensorThingsGateway extends AbstractGateway {
             RequestUriComponent uriComponent = parseUriToComponents(ctx.request());
             String id = ctx.pathParam("id"); // resourceUrn + observedProperty
             String filterParam = ctx.request().getParam("filter");
-            io.connector.model.sensorthings.Filter filter = io.connector.model.sensorthings.Filter.parse(filterParam);
+
+            io.connector.model.sensorthings.Filter filter = null;
+            try {
+                filter = io.connector.model.sensorthings.Filter.parse(filterParam);
+            } catch (RuntimeException e) {
+                ctx.response().setStatusCode(501).end(new JsonObject()
+                        .put("message", e.getMessage()).encode()); return;
+            }
 
             String [] idCmp = Converter.disassemblyId(id);
             String resourceUrn = idCmp[0], observedProperty = idCmp[1];
@@ -370,7 +377,14 @@ public class OGCSensorThingsGateway extends AbstractGateway {
             RequestUriComponent uriComponent = parseUriToComponents(ctx.request());
             String resourceUrn = ctx.pathParam("id"); // resourceUrn
             String filterParam = ctx.request().getParam("filter");
-            io.connector.model.sensorthings.Filter filter = io.connector.model.sensorthings.Filter.parse(filterParam);
+
+            io.connector.model.sensorthings.Filter filter = null;
+            try {
+                filter = io.connector.model.sensorthings.Filter.parse(filterParam);
+            } catch (RuntimeException e) {
+                ctx.response().setStatusCode(501).end(new JsonObject()
+                        .put("message", e.getMessage()).encode()); return;
+            }
 
             MultiSensor afcMultiSensor = client.getSensorByResourceUrn(resourceUrn);
             List<ResourceMeasurement> afcMeasurements;
@@ -407,7 +421,14 @@ public class OGCSensorThingsGateway extends AbstractGateway {
             RequestUriComponent uriComponent = parseUriToComponents(ctx.request());
             String id = ctx.pathParam("id"); // resourceUrn + observedProperty + time
             String filterParam = ctx.request().getParam("filter");
-            io.connector.model.sensorthings.Filter filter = io.connector.model.sensorthings.Filter.parse(filterParam);
+
+            io.connector.model.sensorthings.Filter filter = null;
+            try {
+                filter = io.connector.model.sensorthings.Filter.parse(filterParam);
+            } catch (RuntimeException e) {
+                ctx.response().setStatusCode(501).end(new JsonObject()
+                        .put("message", e.getMessage()).encode()); return;
+            }
 
             String [] idCmp = Converter.disassemblyId(id);
             String resourceUrn = idCmp[0], observedProperty = idCmp[1], time = idCmp[2];

+ 0 - 73
connector-module-afarcloud/src/main/java/io/connector/module/afarcloud/gateway/SensLog1Gateway.java

@@ -1,73 +0,0 @@
-// Licensed to the UWB & LESP under one or more agreements.
-// The UWB & LESP licenses this file to you under the MIT license.
-
-package io.connector.module.afarcloud.gateway;
-
-import io.connector.core.AbstractGateway;
-import io.connector.model.afarcloud.MultiSimpleObservation;
-import io.connector.model.afarcloud.SimpleObservation;
-import io.connector.model.senslog1.Observation;
-import io.connector.model.senslog1.Sensor;
-import io.connector.model.senslog1.Unit;
-import io.connector.module.afarcloud.AFCHttpClient;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.util.ArrayList;
-
-/**
- *
- * @author Lukas Cerny
- * @version 1.0
- * @since 1.0
- */
-public class SensLog1Gateway extends AbstractGateway {
-
-    private final static Logger logger = LogManager.getLogger(SensLog1Gateway.class);
-
-    /** Attribute of a client that accesses to the AFarCloud system.  */
-    private final AFCHttpClient client;
-
-    /**
-     * Public constructor of the class that initializes final attributes.
-     * @param id - identifier of the gateway
-     * @param client - client allows access to the AFarCloud system
-     */
-    public SensLog1Gateway(String id, AFCHttpClient client) {
-        super(id);
-        this.client = client;
-    }
-
-    @Override
-    public void run() {
-
-        event().subscribe("test", message -> {
-            if (message.isFail()) {
-                logger.error(message.cause()); return;
-            }
-            System.out.println(message.body());
-        });
-    }
-
-    private static class Converter {
-
-        static MultiSimpleObservation convertToMultiSimpleObservation(Unit sensLogUnit) {
-            MultiSimpleObservation afcResult = new MultiSimpleObservation();
-            String resourceId = Long.toString(sensLogUnit.getInfo().getId());
-            afcResult.setResourceId(resourceId);
-            afcResult.setObservations(new ArrayList<>());
-
-            for (Sensor sensor : sensLogUnit.getSensors()) {
-                for (Observation sensLogObservation : sensor.getObservations()) {
-                    SimpleObservation afcObservation = new SimpleObservation();
-                    String observedProperty = sensor.getInfo().getPhenomenon().getName()+"_"+sensor.getInfo().getName();
-                    afcObservation.setObservedProperty(observedProperty.replaceAll("\\s+", "_"));
-                    afcObservation.setResult(sensLogObservation.getValue());
-                    afcObservation.setResultTime(sensLogObservation.getTimestamp().toEpochSecond());
-                    afcResult.getObservations().add(afcObservation);
-                }
-            }
-            return afcResult;
-        }
-    }
-}

+ 0 - 0
connector-module-ima/build.gradle


+ 0 - 16
connector-module-ima/src/main/java/io/connector/module/ima/ImaClient.java

@@ -1,16 +0,0 @@
-package io.connector.module.ima;
-
-import io.connector.model.ima.IMAModel;
-
-public class ImaClient {
-
-    private final ImaConfig config;
-
-    public ImaClient(ImaConfig config) {
-        this.config = config;
-    }
-
-    public void push(IMAModel model) {
-        System.out.println(model.getData());
-    }
-}

+ 0 - 10
connector-module-ima/src/main/java/io/connector/module/ima/ImaConfig.java

@@ -1,10 +0,0 @@
-package io.connector.module.ima;
-
-import io.connector.core.config.DefaultConfig;
-
-public class ImaConfig {
-
-    ImaConfig(DefaultConfig defaultConfig) {
-
-    }
-}

+ 0 - 26
connector-module-ima/src/main/java/io/connector/module/ima/ImaModule.java

@@ -1,26 +0,0 @@
-package io.connector.module.ima;
-
-import io.connector.core.ModuleDescriptor;
-import io.connector.core.AbstractModule;
-import io.connector.core.ModuleInfo;
-import io.connector.module.ima.gateway.ImaGateway;
-
-public class ImaModule extends AbstractModule {
-
-    private final ImaClient client;
-
-    public ImaModule(String id, ModuleDescriptor descriptor, ImaClient client) {
-        super(id, descriptor);
-        this.client = client;
-    }
-
-    @Override
-    public void run() {
-        registerGateway(new ImaGateway("ima", client));
-    }
-
-    @Override
-    public ModuleInfo info() {
-        return new ModuleInfo(id());
-    }
-}

+ 0 - 18
connector-module-ima/src/main/java/io/connector/module/ima/ImaModuleProvider.java

@@ -1,18 +0,0 @@
-package io.connector.module.ima;
-
-import io.connector.core.ModuleDescriptor;
-import io.connector.core.AbstractModule;
-import io.connector.core.ModuleProvider;
-
-public final class ImaModuleProvider implements ModuleProvider {
-
-    @Override
-    public AbstractModule createModule(ModuleDescriptor descriptor) {
-
-        ImaConfig config = new ImaConfig(descriptor.getServiceConfig());
-        ImaClient client = new ImaClient(config);
-        ImaModule module = new ImaModule("ima", descriptor, client);
-
-        return module;
-    }
-}

+ 0 - 20
connector-module-ima/src/main/java/io/connector/module/ima/gateway/ImaGateway.java

@@ -1,20 +0,0 @@
-package io.connector.module.ima.gateway;
-
-import io.connector.core.AbstractGateway;
-import io.connector.module.ima.ImaClient;
-
-public class ImaGateway extends AbstractGateway {
-
-    private final ImaClient client;
-
-    public ImaGateway(String id, ImaClient client) {
-        super(id, true);
-        this.client = client;
-    }
-
-    @Override
-    public void run() {
-
-
-    }
-}

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

@@ -1 +0,0 @@
-io.connector.module.ima.ImaModuleProvider

+ 0 - 0
connector-module-senslog1/build.gradle


+ 0 - 43
connector-module-senslog1/src/main/java/io/connector/module/senslog1/SensLog1Config.java

@@ -1,43 +0,0 @@
-package io.connector.module.senslog1;
-
-import io.connector.core.config.DefaultConfig;
-import io.connector.core.config.HostConfig;
-
-class SensLog1Config {
-
-    private final HostConfig sensorServiceHost;
-    private final HostConfig dataServiceHost;
-    private final HostConfig feederServiceHost;
-
-    private final String user;
-    private final String group;
-
-    SensLog1Config(DefaultConfig config) {
-        this.sensorServiceHost = new HostConfig(config.getPropertyConfig("sensorServiceHost"));
-        this.dataServiceHost = new HostConfig(config.getPropertyConfig("dataServiceHost"));
-        this.feederServiceHost = new HostConfig(config.getPropertyConfig("feederServiceHost"));
-
-        this.user = config.getStringProperty("user");
-        this.group = config.getStringProperty("group");
-    }
-
-    public HostConfig getSensorServiceHost() {
-        return sensorServiceHost;
-    }
-
-    public HostConfig getDataServiceHost() {
-        return dataServiceHost;
-    }
-
-    public HostConfig getFeederServiceHost() {
-        return feederServiceHost;
-    }
-
-    public String getUser() {
-        return user;
-    }
-
-    public String getGroup() {
-        return group;
-    }
-}

+ 0 - 448
connector-module-senslog1/src/main/java/io/connector/module/senslog1/SensLog1HttpClient.java

@@ -1,448 +0,0 @@
-package io.connector.module.senslog1;
-
-import io.connector.core.http.HttpClient;
-import io.connector.core.http.HttpRequest;
-import io.connector.core.http.HttpResponse;
-import io.connector.core.http.URLBuilder;
-import io.connector.core.config.HostConfig;
-import io.connector.model.senslog1.*;
-import io.vertx.core.json.JsonArray;
-import io.vertx.core.json.JsonObject;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.time.OffsetDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.*;
-
-import static io.connector.core.http.ContentType.TEXT_PLAIN;
-import static java.lang.String.format;
-import static java.time.format.DateTimeFormatter.ofPattern;
-
-public class SensLog1HttpClient {
-
-    private static final Logger logger = LogManager.getLogger(SensLog1HttpClient.class);
-
-    private static final DateTimeFormatter FORMATTER = ofPattern("yyyy-MM-dd HH:mm:ssZ");
-
-    private Map<Long, UnitInfo> unitInfoList;
-
-    private final SensLog1Config config;
-    private final HttpClient httpClient;
-
-    SensLog1HttpClient(SensLog1Config config, HttpClient httpClient) {
-        this.config = config;
-        this.httpClient = httpClient;
-    }
-
-    private Map<Long, UnitInfo> getUnitInfos() {
-        if (unitInfoList == null || unitInfoList.isEmpty()) {
-            units();
-        }
-
-//        {
-//            Map<Long, UnitInfo> infos = new HashMap<>(1);
-//            for (Map.Entry<Long, UnitInfo> unitEntry : unitInfoList.entrySet()) {
-//                for (SensorInfo sensor : unitEntry.getValue().getSensors()) {
-//                    List<SensorInfo> sensors = new ArrayList<>();
-//                    sensors.add(sensor);
-//                    unitEntry.getValue().setSensors(sensors);
-//                    break;
-//                }
-//                infos.put(unitEntry.getKey(), unitEntry.getValue());
-//                break;
-//            }
-//            unitInfoList = infos;
-//        }
-
-        return unitInfoList;
-    }
-
-    public List<UnitData> lastObservations() {
-
-        HostConfig host = config.getSensorServiceHost();
-        logger.info("Getting observations from {}.", host.getDomain());
-
-        HttpRequest request = HttpRequest.newBuilder().GET()
-                .url(URLBuilder.newBuilder(host.getDomain(), host.getPath())
-                        .addParam("Operation", "GetLastObservations")
-                        .addParam("user", config.getUser())
-                        .addParam("group", config.getGroup())
-                        .build())
-                .build();
-        logger.info("Creating a http request to {}.", request);
-
-        HttpResponse response = httpClient.send(request);
-        logger.info("Received a response with a status: {} for the domain {}.", response.getStatus(), host.getDomain());
-
-        if (response.isOk()) {
-            JsonArray jsonArray = new JsonArray(response.getBody());
-            Map<Long, UnitData> units = new HashMap<>(1);
-            for (Object jsonObject : jsonArray) {
-                if (jsonObject instanceof JsonObject) {
-                    JsonObject jsonObservations = (JsonObject)jsonObject;
-                    long unitId = jsonObservations.getLong("unitId");
-                    long sensorId = jsonObservations.getLong("sensorId");
-                    SensorData sensor = units.computeIfAbsent(unitId, UnitData::new).getSensor(sensorId);
-                    if (sensor == null) {
-                        sensor = new SensorData(sensorId);
-                        units.get(unitId).addSensor(sensor);
-                    }
-
-                    Observation observation = Observation.parse(jsonObservations);
-                    if (observation != null) {
-                        sensor.addObservation(observation);
-                    }
-                }
-            }
-
-            return new ArrayList<>(units.values());
-
-        }
-
-        return Collections.emptyList();
-    }
-
-    public void uploadPositions(List<UnitData> unitData) {
-        HostConfig host = config.getFeederServiceHost();
-
-        for (UnitData multiSensor : unitData) {
-            for (Position position : multiSensor.getPositions()) {
-
-                HttpRequest request = HttpRequest.newBuilder()
-                        .contentType(TEXT_PLAIN)
-                        .url(URLBuilder.newBuilder(host.getDomain(), host.getPath())
-                                .addParam("Operation", "InsertPosition")
-                                .addParam("date", position.getTimestamp().format(FORMATTER))
-                                .addParam("unit_id", multiSensor.getId())
-                                .addParam("lat", position.getLatitude())
-                                .addParam("lon", position.getLongitude())
-                                .addParam("alt", position.getAltitude())
-                                .addParam("speed", position.getSpeed())
-                                .addParam("dop", position.getDilutionOfPrecision())
-                                .build())
-                        .GET().build();
-
-                HttpResponse response = httpClient.send(request);
-
-                if (response.isOk()) {
-                    logger.debug("Parsing body of the response.");
-                    boolean result = Boolean.parseBoolean(response.getBody());
-
-                    if (!result) {
-                        logger.warn("Position {} was rejected.", position);
-                    }
-                } else {
-                    logger.warn("Position {} was rejected.", position);
-                }
-            }
-        }
-    }
-
-    public List<UnitData> uploadObservations(List<UnitData> unitData) {
-
-        HostConfig host = config.getFeederServiceHost();
-
-        Map<Long, UnitData> badObservations = new HashMap<>();
-        for (UnitData multiSensor : unitData) {
-            for (SensorData sensor : multiSensor.getSensors()) {
-                for (Observation observation : sensor.getObservations()) {
-
-
-                    HttpRequest request = HttpRequest.newBuilder()
-                            .contentType(TEXT_PLAIN)
-                            .url(URLBuilder.newBuilder(host.getDomain(), host.getPath())
-                                    .addParam("Operation", "InsertObservation")
-                                    .addParam("value", observation.getValue())
-                                    .addParam("date", observation.getTimestamp().format(FORMATTER))
-                                    .addParam("unit_id", multiSensor.getId())
-                                    .addParam("sensor_id", sensor.getId())
-                                    .build())
-                            .GET().build();
-
-                    /*
-                    HttpResponse response = httpClient.send(request);
-
-                    if (response.isOk()) {
-                        logger.debug("Parsing body of the response.");
-                        boolean result = Boolean.parseBoolean(response.getBody());
-
-                        if (!result) {
-                            logger.warn("Observation {} was rejected.", observation);
-                        }
-                    } else {
-
-                        SensorObservation sensorObservation = badObservations
-                                .computeIfAbsent(multiSensor.getId(), UnitData::new)
-                                .getSensor(sensor.getId());
-
-                        if (sensorObservation == null) {
-                            sensorObservation = new SensorObservation(sensor.getId());
-                            badObservations.get(multiSensor.getId()).addSensor(sensorObservation);
-                        }
-
-                        sensorObservation.addObservation(observation);
-
-                        logger.warn("Observation {} was rejected.", observation);
-                    }
-
-                     */
-                }
-            }
-        }
-
-        return new ArrayList<>(badObservations.values());
-    }
-
-    public List<UnitData> positions(OffsetDateTime fromDate, OffsetDateTime toDate) {
-        List<UnitData> units = new ArrayList<>();
-        for (UnitInfo multiSensor : getUnitInfos().values()) {
-            units.addAll(positions(multiSensor.getId(), fromDate, toDate));
-        }
-        return units;
-    }
-
-    public List<UnitData> positions(long unitId, OffsetDateTime fromDate, OffsetDateTime toDate) {
-        UnitData unitData = new UnitData(unitId);
-        positions(unitData, fromDate, toDate);
-        return Collections.singletonList(unitData);
-    }
-
-    private void positions(UnitData multiSensor, OffsetDateTime fromDate, OffsetDateTime toDate) {
-        HostConfig host = config.getDataServiceHost();
-        logger.info("Getting observations from {}.", host.getDomain());
-
-        HttpRequest request = HttpRequest.newBuilder().GET()
-                .url(URLBuilder.newBuilder(host.getDomain(), host.getPath())
-                        .addParam("Operation", "GetPositionsDay")
-                        .addParam("user", config.getUser())
-                        .addParam("unit_id", multiSensor.getId())
-                        .addParam("fromTime", fromDate.format(FORMATTER))
-                        .addParam("toTime", toDate.format(FORMATTER))
-                        .build())
-                .build();
-        logger.info("Creating a http request to {}.", request);
-
-        HttpResponse response = httpClient.send(request);
-        logger.info("Received a response with a status: {} for the domain {}.", response.getStatus(), host.getDomain());
-
-        if (response.isOk()) {
-            JsonArray json = new JsonArray(response.getBody());
-            for (Object objJson : json) {
-                if (objJson instanceof JsonObject) {
-                    Position position = Position.parse((JsonObject)objJson);
-
-                    if (position != null) {
-                        multiSensor.addPosition(position);
-                    }
-                }
-            }
-        }
-    }
-
-    public List<Unit> observationsWithInfo(OffsetDateTime fromDate, OffsetDateTime toDate) {
-        Collection<UnitInfo> unitInfos = getUnitInfos().values();
-        List<Unit> units = new ArrayList<>(unitInfos.size());
-        for (UnitInfo unitInfo : unitInfos) {
-            UnitData unitData = new UnitData(unitInfo.getId());
-            Collection<SensorInfo> sensorInfos = unitInfo.getSensors();
-            List<Sensor> sensors = new ArrayList<>(sensorInfos.size());
-            for (SensorInfo sensorInfo : sensorInfos) {
-                SensorData sensorObs = new SensorData(sensorInfo.getId());
-                observations(unitData, sensorObs, fromDate, toDate);
-                sensors.add(new Sensor(sensorInfo, sensorObs.getObservations()));
-            }
-            units.add(new Unit(unitInfo, sensors));
-        }
-        return units;
-    }
-
-    public List<Unit> observationsWithInfo(long unitId, OffsetDateTime fromDate, OffsetDateTime toDate) {
-        UnitInfo unitInfo = getUnitInfos().get(unitId);
-        if (unitInfo == null) {
-            throw new RuntimeException(format("Unknown multiSensor with id %s.", unitId));
-        }
-
-        UnitData unitData = new UnitData(unitInfo.getId());
-        Collection<SensorInfo> sensorInfos = unitInfo.getSensors();
-        List<Sensor> sensors = new ArrayList<>(sensorInfos.size());
-        for (SensorInfo sensorInfo : sensorInfos) {
-            SensorData sensorObs = new SensorData(sensorInfo.getId());
-            observations(unitData, sensorObs, fromDate, toDate);
-            sensors.add(new Sensor(sensorInfo, sensorObs.getObservations()));
-        }
-        List<Unit> units = new ArrayList<>(1);
-        units.add(new Unit(unitInfo, sensors));
-        return units;
-    }
-
-    public List<Unit> observationsWithInfo(long unitId, long sensorId, OffsetDateTime fromDate, OffsetDateTime toDate) {
-        UnitInfo unitInfo = getUnitInfos().get(unitId);
-        if (unitInfo == null) {
-            throw new RuntimeException(format("Unknown multiSensor with id %s.", unitId));
-        }
-        SensorInfo sensorInfo = unitInfo.getSensor(sensorId);
-        if (sensorInfo == null) {
-            throw new RuntimeException(format("Unknown sensor with id %s for the multiSensor %s.", sensorId, unitId));
-        }
-        UnitData unitData = new UnitData(unitInfo.getId());
-        SensorData sensorObs = new SensorData(sensorInfo.getId());
-        observations(unitData, sensorObs, fromDate, toDate);
-        List<Sensor> sensors = new ArrayList<>(1);
-        sensors.add(new Sensor(sensorInfo, sensorObs.getObservations()));
-
-        List<Unit> units = new ArrayList<>(1);
-        units.add(new Unit(unitInfo, sensors));
-        return units;
-    }
-
-    public List<UnitData> observations(OffsetDateTime fromDate, OffsetDateTime toDate) {
-        List<UnitData> units = new ArrayList<>();
-        for (UnitInfo multiSensor : getUnitInfos().values()) {
-            units.addAll(observations(multiSensor.getId(), fromDate, toDate));
-        }
-        return units;
-    }
-
-    public List<UnitData> observations(long unitId, OffsetDateTime fromDate, OffsetDateTime toDate) {
-        UnitInfo unitInfo = getUnitInfos().get(unitId);
-        if (unitInfo != null) {
-            UnitData multiSensor = new UnitData(unitInfo.getId());
-            for (SensorInfo sensorInfo : unitInfo.getSensors()) {
-                SensorData sensor = new SensorData(sensorInfo.getId());
-                multiSensor.addSensor(sensor);
-                observations(multiSensor, sensor, fromDate, toDate);
-            }
-            return Arrays.asList(multiSensor);
-        }
-        return Collections.emptyList();
-    }
-
-    public List<UnitData> observations(long unitId, long sensorId, OffsetDateTime fromDate, OffsetDateTime toDate) {
-        UnitData multiSensor = new UnitData(unitId);
-        SensorData sensor = new SensorData(sensorId);
-        multiSensor.addSensor(sensor);
-        observations(multiSensor, sensor, fromDate, toDate);
-        return Arrays.asList(multiSensor);
-    }
-
-    private void observations(UnitData multiSensor, SensorData sensor, OffsetDateTime fromDate, OffsetDateTime toDate) {
-
-        HostConfig host = config.getSensorServiceHost();
-        logger.info("Getting observations from {}.", host.getDomain());
-
-        HttpRequest request = HttpRequest.newBuilder().GET()
-                .url(URLBuilder.newBuilder(host.getDomain(), host.getPath())
-                        .addParam("Operation", "GetObservations")
-                        .addParam("user", config.getUser())
-                        .addParam("unit_id", multiSensor.getId())
-                        .addParam("sensor_id", sensor.getId())
-                        .addParam("from", fromDate.format(FORMATTER))
-                        .addParam("to", toDate.format(FORMATTER))
-                        .build())
-                .build();
-        logger.info("Creating a http request to {}.", request);
-
-        HttpResponse response = httpClient.send(request);
-        logger.info("Received a response with a status: {} for the domain {}.", response.getStatus(), host.getDomain());
-
-        if (response.isOk()) {
-
-            JsonArray json = new JsonArray(response.getBody());
-            for (Object obsJson : json) {
-                if (obsJson instanceof JsonObject) {
-                    Observation observation = Observation.parse((JsonObject)obsJson);
-
-                    if (observation != null) {
-                        sensor.addObservation(observation);
-                    }
-                }
-            }
-        }
-    }
-
-    public List<UnitInfo> units() {
-        HostConfig host = config.getDataServiceHost();
-        logger.info("Getting last observations from {}.", host.getDomain());
-
-        HttpRequest request = HttpRequest.newBuilder().GET()
-                .url(URLBuilder.newBuilder(host.getDomain(), host.getPath())
-                        .addParam("Operation", "GetUnitsList")
-                        .addParam("user", config.getUser())
-                        .build())
-                .build();
-        logger.info("Creating a http request to {}.", request);
-
-        HttpResponse response = httpClient.send(request);
-        logger.info("Received a response with a status: {} for the domain {}.", response.getStatus(), host.getDomain());
-
-        if (response.isOk()) {
-            logger.debug("Parsing body of the response to the list of class {}.", UnitInfo.class);
-            JsonArray json = new JsonArray(response.getBody());
-            List<UnitInfo> units = new ArrayList<>(json.size());
-            unitInfoList = new HashMap<>(json.size());
-            for (Object unitJson : json) {
-                if (unitJson instanceof JsonObject) {
-                    UnitInfo multiSensor = UnitInfo.parse((JsonObject)unitJson);
-                    if (multiSensor != null) {
-                        units.add(multiSensor);
-                        unitInfoList.put(multiSensor.getId(), multiSensor);
-                    }
-                }
-            }
-
-            for (UnitInfo multiSensor : units) {
-                List<SensorInfo> sensors = sensors(multiSensor.getId());
-                multiSensor.setSensors(sensors);
-            }
-
-            return units;
-
-        } else {
-            logger.error("Can not get data from the server {}. Error {} {}",
-                    host.getDomain(), response.getStatus(), response.getBody());
-        }
-
-        return Collections.emptyList();
-    }
-
-    public List<SensorInfo> sensors(long unitId) {
-        HostConfig host = config.getSensorServiceHost();
-        logger.debug("Getting last observations from {}.", host.getDomain());
-
-        HttpRequest request = HttpRequest.newBuilder().GET()
-                .url(URLBuilder.newBuilder(host.getDomain(), host.getPath())
-                        .addParam("Operation", "GetSensors")
-                        .addParam("user", config.getUser())
-                        .addParam("unit_id", unitId)
-                        .build())
-                .build();
-        logger.info("Creating a http request to {}.", request);
-
-        HttpResponse response = httpClient.send(request);
-        logger.info("Received a response with a status: {} for the domain {}.", response.getStatus(), host.getDomain());
-
-        if (response.isOk()) {
-            logger.debug("Parsing body of the response to the list of class {}.", SensorInfo.class);
-            JsonArray json = new JsonArray(response.getBody());
-            List<SensorInfo> sensors = new ArrayList<>(json.size());
-            for (Object sensorJson : json) {
-                if (sensorJson instanceof JsonObject) {
-                    SensorInfo sensor = SensorInfo.parse((JsonObject)sensorJson);
-                    if (sensor != null) {
-                        sensors.add(sensor);
-                    }
-                }
-            }
-
-            logger.info("For the multiSensor {} was added {} sensors.", unitId, sensors.size());
-
-            return sensors;
-        } else {
-            logger.error("Can not get data from the server {}. Error {} {}",
-                    host.getDomain(), response.getStatus(), response.getBody());
-
-            return Collections.emptyList();
-        }
-    }
-}

+ 0 - 45
connector-module-senslog1/src/main/java/io/connector/module/senslog1/SensLog1Module.java

@@ -1,45 +0,0 @@
-package io.connector.module.senslog1;
-
-import io.connector.core.ModuleDescriptor;
-import io.connector.core.config.SchedulerConfig;
-import io.connector.core.AbstractModule;
-import io.connector.core.ModuleInfo;
-import io.connector.module.senslog1.gateway.OGCSensorThingsGateway;
-import io.connector.module.senslog1.gateway.SensLog1Gateway;
-import io.vertx.core.json.JsonObject;
-
-public class SensLog1Module extends AbstractModule {
-
-    private final SensLog1HttpClient httpClient;
-    private final SensLog1SQLClient sqlClient;
-
-    protected SensLog1Module(String id, ModuleDescriptor descriptor, SensLog1HttpClient client, SensLog1SQLClient sqlClient) {
-        super(id, descriptor);
-        this.httpClient = client;
-        this.sqlClient = sqlClient;
-    }
-
-    @Override
-    public void run() {
-        registerGateway(new OGCSensorThingsGateway("OGCSensorThings", sqlClient));
-        registerGateway(new SensLog1Gateway("SensLogV1", httpClient));
-    }
-
-    @Override
-    public ModuleInfo info() {
-
-        JsonObject jsonInfo = new JsonObject();
-        if (descriptor().getSchedulerConfig() != null) {
-            SchedulerConfig config = descriptor().getSchedulerConfig();
-            jsonInfo.put("scheduling", new JsonObject()
-                    .put("period", config.getPeriodSecond())
-                    .put("consumer", config.getConsumer())
-                    .put("config", new JsonObject())
-            );
-        }
-
-        jsonInfo.put("config", new JsonObject());
-
-        return new ModuleInfo(id());
-    }
-}

+ 0 - 22
connector-module-senslog1/src/main/java/io/connector/module/senslog1/SensLog1ModuleProvider.java

@@ -1,22 +0,0 @@
-package io.connector.module.senslog1;
-
-import io.connector.core.http.HttpClient;
-import io.connector.core.ModuleDescriptor;
-import io.connector.core.AbstractModule;
-import io.connector.core.ModuleProvider;
-
-public final class SensLog1ModuleProvider implements ModuleProvider {
-
-    @Override
-    public AbstractModule createModule(ModuleDescriptor descriptor) {
-
-        SensLog1Config config = new SensLog1Config(descriptor.getServiceConfig());
-
-        SensLog1HttpClient httpClient = new SensLog1HttpClient(config, HttpClient.newHttpClient());
-        SensLog1SQLClient sqlClient = new SensLog1SQLClient();
-
-        SensLog1Module module = new SensLog1Module("SensLogV1", descriptor, httpClient, sqlClient);
-
-        return module;
-    }
-}

+ 0 - 6
connector-module-senslog1/src/main/java/io/connector/module/senslog1/SensLog1SQLClient.java

@@ -1,6 +0,0 @@
-package io.connector.module.senslog1;
-
-public class SensLog1SQLClient {
-
-
-}

+ 0 - 19
connector-module-senslog1/src/main/java/io/connector/module/senslog1/gateway/OGCSensorThingsGateway.java

@@ -1,19 +0,0 @@
-package io.connector.module.senslog1.gateway;
-
-import io.connector.core.AbstractGateway;
-import io.connector.module.senslog1.SensLog1SQLClient;
-
-public class OGCSensorThingsGateway extends AbstractGateway {
-
-    private final SensLog1SQLClient client;
-
-    public OGCSensorThingsGateway(String id, SensLog1SQLClient client) {
-        super(id);
-        this.client = client;
-    }
-
-    @Override
-    protected void run() {
-
-    }
-}

+ 0 - 188
connector-module-senslog1/src/main/java/io/connector/module/senslog1/gateway/SensLog1Gateway.java

@@ -1,188 +0,0 @@
-package io.connector.module.senslog1.gateway;
-
-import io.connector.core.AbstractGateway;
-import io.connector.core.DataCollection;
-import io.connector.core.Message;
-import io.connector.core.MessageHeader;
-import io.connector.model.senslog1.Unit;
-import io.connector.model.senslog1.UnitData;
-import io.connector.model.senslog1.UnitInfo;
-import io.connector.module.senslog1.SensLog1HttpClient;
-import io.vertx.core.MultiMap;
-import io.vertx.core.buffer.Buffer;
-import io.vertx.core.json.JsonArray;
-import io.vertx.core.json.JsonObject;
-
-import java.time.OffsetDateTime;
-import java.util.*;
-
-import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME;
-
-public class SensLog1Gateway extends AbstractGateway {
-
-    private final SensLog1HttpClient client;
-
-    public SensLog1Gateway(String id, SensLog1HttpClient client) {
-        super(id, true);
-        this.client = client;
-    }
-
-    @Override
-    public void run() {
-
-        event().consume("units", message -> {
-            List<UnitInfo> units = client.units();
-            message.reply(new DataCollection<>(units));
-        });
-
-        event().consume("add-observations", message -> {
-            String resource = message.headers().get(MessageHeader.RESOURCE);
-
-            Iterator<Object> dataIterator;
-            switch (resource) {
-                case MessageHeader.Resource.HTTP_SERVER: {
-                    dataIterator = (((Buffer)message.body()).toJsonArray()).iterator();
-                } break;
-                case MessageHeader.Resource.SCHEDULER: {
-                    dataIterator = ((DataCollection<?>)message.body()).iterator();
-                } break;
-                default: {
-                    message.fail(400, "Unknown resource of data."); return;
-                }
-            }
-
-            List<UnitData> unitData = new ArrayList<>();
-            for (Object data = dataIterator.next(); dataIterator.hasNext();) {
-                if (data instanceof JsonObject) {
-                    unitData.add(UnitData.parse((JsonObject)data));
-                } else if (data instanceof UnitData) {
-                    unitData.add((UnitData)data);
-                }
-            }
-
-            List<UnitData> unsentObservations = client.uploadObservations(unitData);
-            message.reply(new DataCollection<>(unsentObservations));
-        });
-
-        event().consume("observations-with-positions", message -> {
-            MultiMap params = message.headers();
-
-            OffsetDateTime[] timeRange = getTimeRangeFromParam(message);
-            if (timeRange == null) { return; }
-            OffsetDateTime fromDate = timeRange[0], toDate = timeRange[1];
-
-            List<UnitData> positions, observations;
-            if (params.contains("unitId")) {
-                long unitId = Long.parseLong(params.get("unitId"));
-                positions = client.positions(unitId, fromDate, toDate);
-                observations = client.observations(unitId, fromDate, toDate);
-            } else {
-                positions = client.positions(fromDate, toDate);
-                observations = client.observations(fromDate, toDate);
-            }
-
-            List<UnitData> mergedUnitData = mergeUnitDate(positions, observations);
-            message.reply(new DataCollection<>(mergedUnitData));
-        });
-
-        event().consume("positions", message -> {
-            MultiMap params = message.headers();
-
-            OffsetDateTime[] timeRange = getTimeRangeFromParam(message);
-            if (timeRange == null) { return; }
-            OffsetDateTime fromDate = timeRange[0], toDate = timeRange[1];
-
-            List<UnitData> positions;
-            if (params.contains("unitId")) {
-                long unitId = Long.parseLong(params.get("unitId"));
-                positions = client.positions(unitId, fromDate, toDate);
-            } else {
-                positions = client.positions(fromDate, toDate);
-            }
-
-            message.reply(new DataCollection<>(positions));
-        });
-
-        event().consume("observations-with-info", message -> {
-
-            final int hoursInterval = 2;
-
-            if (message.body() != null && message.body() instanceof JsonObject) {
-                JsonObject filter = (JsonObject)message.body();
-                String startDateStr = filter.getString("startDate");
-                OffsetDateTime startDate = startDateStr != null ? OffsetDateTime.parse(startDateStr, ISO_OFFSET_DATE_TIME) : null;
-                if (filter.containsKey("allowedStations")) {
-                    JsonArray allowedStations = filter.getJsonArray("allowedStations");
-                    List<Unit> unitData = new ArrayList<>();
-                    for (int i = 0; i < allowedStations.size(); i++) {
-                        JsonObject station = allowedStations.getJsonObject(i);
-                        long unitId = station.getLong("id");
-                        OffsetDateTime fromDate = OffsetDateTime.parse(station.getString("fromDate"), ISO_OFFSET_DATE_TIME);
-                        fromDate = fromDate.minusMonths(3);
-                        unitData.addAll(client.observationsWithInfo(unitId, fromDate, fromDate.plusHours(hoursInterval)));
-                    }
-                    // TODO filter by sensors
-                    message.reply(new DataCollection<>(unitData));
-                } else if (startDate != null) {
-                    List<Unit> unitData = client.observationsWithInfo(startDate, startDate.plusHours(hoursInterval));
-                    message.reply(new DataCollection<>(unitData));
-                } else {
-                    message.fail(400, "Attribute 'fromDate' is required.");
-                }
-            } else {
-                message.fail(400, "Configuration in body is required.");
-            }
-        });
-
-        event().consumeScheduler("test", message -> {
-            JsonObject filter = message.body() != null && message.body() instanceof JsonObject ? (JsonObject)message.body() : new JsonObject();
-
-            System.out.println(filter.encode());
-
-            message.reply("ok");
-        });
-    }
-
-    private static <T> OffsetDateTime[] getTimeRangeFromParam(Message<T> message) {
-        MultiMap params = message.headers();
-
-        OffsetDateTime fromDate;
-        if (params.contains("fromDate")) {
-            fromDate = OffsetDateTime.parse(params.get("fromDate"), ISO_OFFSET_DATE_TIME);
-        } else {
-            message.fail(400, "Attribute 'fromDate' is required."); return null;
-        }
-
-        OffsetDateTime toDate;
-        if (params.contains("toDate")) {
-            toDate = OffsetDateTime.parse(params.get("toDate"), ISO_OFFSET_DATE_TIME);
-        } else {
-            message.fail(400, "Attribute 'toDate' is required."); return null;
-        }
-
-        return new OffsetDateTime[]{fromDate, toDate};
-    }
-
-    @SafeVarargs
-    private static List<UnitData> mergeUnitDate(List<UnitData> ...unitsToMerge) {
-        int len = unitsToMerge.length;
-        Map<Long, List<UnitData>> units = new HashMap<>();
-        for (List<UnitData> unitDataList : unitsToMerge) {
-            for (UnitData unitData : unitDataList) {
-                units.computeIfAbsent(unitData.getId(), k -> new ArrayList<>(len))
-                        .add(unitData);
-            }
-        }
-        List<UnitData> result = new ArrayList<>();
-
-        for (Map.Entry<Long, List<UnitData>> unitDataEntry : units.entrySet()) {
-            UnitData multiSensor = new UnitData(unitDataEntry.getKey());
-            for (UnitData unitData : unitDataEntry.getValue()) {
-                multiSensor.mergeIn(unitData);
-            }
-            result.add(multiSensor);
-        }
-
-        return result;
-    }
-}

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

@@ -1 +0,0 @@
-io.connector.module.senslog1.SensLog1ModuleProvider