diff --git a/scorpio-broker/AllInOneRunner/.gitignore b/scorpio-broker/AllInOneRunner/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..a1c3ab4d08c0f9f91918f21c730272a4711885e8
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/.gitignore
@@ -0,0 +1,4 @@
+/target/
+/.settings/
+.classpath
+.project
diff --git a/scorpio-broker/AllInOneRunner/hs_err_pid11763.log b/scorpio-broker/AllInOneRunner/hs_err_pid11763.log
new file mode 100644
index 0000000000000000000000000000000000000000..c47d44b227b6cba7557ad9940ab6ebbfed79e27e
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/hs_err_pid11763.log
@@ -0,0 +1,20 @@
+#
+# A fatal error has been detected by the Java Runtime Environment:
+#
+# SIGSEGV (0xb) at pc=0x00007fbc3b5bc401, pid=11763, tid=11779
+#
+# JRE version: OpenJDK Runtime Environment (11.0.6+10) (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
+# Java VM: OpenJDK 64-Bit Server VM (11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
+# Problematic frame:
+# C [libjimage.so+0x2401]
+#
+# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P" (or dumping to /home/bla/ScorpioBroker/AllInOneRunner/core.11763)
+#
+# If you would like to submit a bug report, please visit:
+# https://bugs.launchpad.net/ubuntu/+source/openjdk-lts
+#
+
+--------------- S U M M A R Y ------------
+
+Command Line: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:35417 -Dspring.profiles.active=dev -javaagent:/home/bla/Downloads/eclipse-jee-2019-12-R-linux-gtk-x86_64/eclipse/configuration/org.eclipse.osgi/405/0/.cp/lib/javaagent-shaded.jar -Dfile.encoding=UTF-8 eu.neclab.ngsildbroker.runner.Runner
+
diff --git a/scorpio-broker/AllInOneRunner/hs_err_pid5675.log b/scorpio-broker/AllInOneRunner/hs_err_pid5675.log
new file mode 100644
index 0000000000000000000000000000000000000000..d0531bbc0a584d0dfaaba8b722c22dcac3a7d752
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/hs_err_pid5675.log
@@ -0,0 +1,21 @@
+#
+# A fatal error has been detected by the Java Runtime Environment:
+#
+# SIGSEGV (0xb) at pc=0x00007f89bf5bc401, pid=5675, tid=5691
+#
+# JRE version: OpenJDK Runtime Environment (11.0.6+10) (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
+# Java VM: OpenJDK 64-Bit Server VM (11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
+# Problematic frame:
+# C [libjimage.so+0x2401]
+#
+# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P" (or dumping to /home/bla/ScorpioBroker/AllInOneRunner/core.5675)
+#
+# If you would like to submit a bug report, please visit:
+# https://bugs.launchpad.net/ubuntu/+source/openjdk-lts
+#
+
+--------------- S U M M A R Y ------------
+
+Command Line: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:33055 -Dspring.profiles.active=dev -javaagent:/home/bla/Downloads/eclipse-jee-2019-12-R-linux-gtk-x86_64/eclipse/configuration/org.eclipse.osgi/405/0/.cp/lib/javaagent-shaded.jar -Dfile.encoding=UTF-8 eu.neclab.ngsildbroker.runner.Runner
+
+Host: Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz, 4 cores, 4G,
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/pom.xml b/scorpio-broker/AllInOneRunner/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..cc479f0781197d46e76eac2995e8b9838eb84755
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/pom.xml
@@ -0,0 +1,86 @@
+
+ 4.0.0
+
+ eu.neclab.ngsildbroker
+ BrokerParent
+ 1.0.0-SNAPSHOT
+ ../BrokerParent
+
+ AllInOneRunner
+ 1.0.0-SNAPSHOT
+ jar
+
+
+
+
+
+ skipDefault
+
+
+ docker-aaio
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+
+
+
+
+
+
+
+ eu.neclab.ngsildbroker
+ InfoServer
+ 1.0.0-SNAPSHOT
+
+
+ eu.neclab.ngsildbroker
+ AtContextServer
+ 1.0.0-SNAPSHOT
+
+
+ eu.neclab.ngsildbroker
+ EntityManager
+ 1.0.0-SNAPSHOT
+
+
+ eu.neclab.ngsildbroker
+ HistoryManager
+ 1.0.0-SNAPSHOT
+
+
+ eu.neclab.ngsildbroker
+ QueryManager
+ 1.0.0-SNAPSHOT
+
+
+ eu.neclab.ngsildbroker
+ RegistryManager
+ 1.0.0-SNAPSHOT
+
+
+ eu.neclab.ngsildbroker
+ StorageManager
+ 1.0.0-SNAPSHOT
+
+
+ eu.neclab.ngsildbroker
+ SubscriptionManager
+ 1.0.0-SNAPSHOT
+
+
+
+
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/src/main/java/eu/neclab/ngsildbroker/runner/Runner.java b/scorpio-broker/AllInOneRunner/src/main/java/eu/neclab/ngsildbroker/runner/Runner.java
new file mode 100644
index 0000000000000000000000000000000000000000..a176d72f6ad791baa6e00058b36fb6d37771f0de
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/java/eu/neclab/ngsildbroker/runner/Runner.java
@@ -0,0 +1,20 @@
+package eu.neclab.ngsildbroker.runner;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+
+import org.springframework.context.annotation.FilterType;
+
+@SpringBootApplication
+@ComponentScan(basePackages = {
+ "eu.neclab.ngsildbroker.*" }, excludeFilters = @Filter(type = FilterType.REGEX, pattern = {
+ "eu.neclab.ngsildbroker.commons.*" }))
+//@Import(KafkaConfig.class)
+public class Runner {
+
+ public static void main(String[] args) throws Exception{
+ SpringApplication.run(Runner.class, args);
+ }
+}
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/application-aaio.yml b/scorpio-broker/AllInOneRunner/src/main/resources/application-aaio.yml
new file mode 100644
index 0000000000000000000000000000000000000000..4eaba240583c808ea7a65df22be58e6715117c35
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/application-aaio.yml
@@ -0,0 +1,192 @@
+append:
+ overwrite: noOverwrite
+atcontext:
+ url: http://localhost:9090/ngsi-ld/contextes/
+bootstrap:
+ servers: kafka:9092
+broker:
+ id: FedBroker1
+ parent:
+ location:
+ url: SELF
+
+query:
+ result:
+ topic: QUERY_RESULT
+ topic: QUERY
+
+
+csource:
+ stopListenerIfDbFails: false
+ topic: CONTEXT_SOURCE
+ registry:
+ topic: CONTEXT_REGISTRY
+ source:
+ topic: CONTEXT_SOURCE
+ notification:
+ topic: CONTEXT_SOURCE_NOTIFICATION
+ query:
+ topic: CONTEXT_REGISTRY_QUERY
+ result:
+ topic: CONTEXT_REGISTRY_QUERY_RESULT
+
+csources:
+ registration:
+ topic: CONTEXT_REGISTRY
+defaultLimit: 50
+directDbConnection: false
+entity:
+ append:
+ topic: ENTITY_APPEND
+ create:
+ topic: ENTITY_CREATE
+ delete:
+ topic: ENTITY_DELETE
+ update:
+ topic: ENTITY_UPDATE
+ index:
+ topic: ENTITY_INDEX
+ keyValues:
+ topic: KVENTITY
+ stopListenerIfDbFails: false
+ temporal:
+ stopListenerIfDbFails: false
+ topic: TEMPORALENTITY
+ topic: ENTITY
+ withoutSysAttrs:
+ topic: ENTITY_WITHOUT_SYSATTRS
+
+submanager:
+ subscription:
+ topic: SUBSCRIPTIONS
+
+kafka:
+ replytimeout: 10000
+management:
+ endpoint:
+ restart:
+ enabled: true
+ endpoints:
+ web:
+ exposure:
+ include: "*"
+max:
+ request:
+ size: 104857600
+maxLimit: 500
+ngb:
+ debugmode: false
+
+
+reader:
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP_Reader
+ password: ngb
+ url: jdbc:postgresql://postgres:5432/ngb?ApplicationName=ngb_storagemanager_reader
+ username: ngb
+ enabled: true
+
+server:
+ port: 1025
+ tomcat:
+ max:
+ threads: 200
+spring:
+ cloud:
+ stream:
+ kafka:
+ binder:
+ brokers: kafka:9092
+ bindings:
+ ENTITY_WRITE_CHANNEL:
+ destination: ENTITY
+ contentType: application/json
+ KVENTITY_WRITE_CHANNEL:
+ destination: KVENTITY
+ contentType: application/json
+ ENTITY_WITHOUT_SYSATTRS_WRITE_CHANNEL:
+ destination: ENTITY_WITHOUT_SYSATTRS
+ contentType: application/json
+ CREATE_WRITE_CHANNEL:
+ destination: ENTITY_CREATE
+ contentType: application/json
+ APPEND_WRITE_CHANNEL:
+ destination: ENTITY_APPEND
+ contentType: application/json
+ UPDATE_WRITE_CHANNEL:
+ destination: ENTITY_UPDATE
+ contentType: application/json
+ DELETE_WRITE_CHANNEL:
+ destination: ENTITY_DELETE
+ contentType: application/json
+ CONTEXT_REGISTRY_WRITE_CHANNEL:
+ destination: CONTEXT_REGISTRY
+ contentType: application/json
+ CONTEXT_REGISTRY_UPDATE_CHANNEL:
+ destination: CONTEXT_UPDATE
+ contentType: application/json
+ INDEX_WRITE_CHANNEL:
+ destination: ENTITY_INDEX
+ contentType: application/json
+ ATCONTEXT_WRITE_CHANNEL:
+ destination: ATCONTEXT
+ contentType: application/json
+ TEMPORAL_ENTITY_WRITE_CHANNEL:
+ destination: TEMPORALENTITY
+ contentType: application/json
+ SUBSCRIPTIONS_WRITE_CHANNEL:
+ destination: SUBSCRIPTIONS
+ contentType: application/json
+ CSOURCE_SUBSCRIPTION_WRITE_CHANNEL:
+ destination: CSOURCE_SUBSCRIPTIONS
+ contentType: application/json
+ CSOURCE_REGISTRATION_WRITE_CHANNEL:
+ destination: CONTEXT_SOURCE
+ contentType: application/json
+ CSOURCE_NOTIFICATION_WRITE_CHANNEL:
+ destination: CONTEXT_SOURCE_NOTIFICATION
+ contentType: application/json
+ application.name: aio-runner
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP
+ password: ngb
+ url: jdbc:postgresql://postgres:5432/ngb?ApplicationName=ngb_registrymanager
+ username: ngb
+ flyway:
+ baselineOnMigrate: true
+ kafka:
+ admin:
+ properties:
+ cleanup:
+ policy: compact
+ main:
+ lazy-initialization: true
+ allow-bean-definition-overriding: true
+
+selfhostcorecontext: http://localhost:9090/corecontext
+writer:
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP_Writer
+ password: ngb
+ url: jdbc:postgresql://postgres:5432/ngb?ApplicationName=ngb_storagemanager_writer
+ username: ngb
+ enabled: true
+
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/application-dev.yml b/scorpio-broker/AllInOneRunner/src/main/resources/application-dev.yml
new file mode 100644
index 0000000000000000000000000000000000000000..1c48fc6566c8082a39a8d31181f9ffd6a283b810
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/application-dev.yml
@@ -0,0 +1,290 @@
+append:
+ overwrite: noOverwrite
+atcontext:
+ url: http://localhost:9090/ngsi-ld/contextes/
+bootstrap:
+ servers: localhost:9092
+broker:
+ id: FedBroker1
+ parent:
+ location:
+ url: SELF
+
+query:
+ result:
+ topic: QUERY_RESULT
+ topic: QUERY
+
+csource:
+ stopListenerIfDbFails: false
+ topic: CONTEXT_SOURCE
+ registry:
+ topic: CONTEXT_REGISTRY
+ source:
+ topic: CONTEXT_SOURCE
+ notification:
+ topic: CONTEXT_SOURCE_NOTIFICATION
+ query:
+ topic: CONTEXT_REGISTRY_QUERY
+ result:
+ topic: CONTEXT_REGISTRY_QUERY_RESULT
+
+csources:
+ registration:
+ topic: CONTEXT_REGISTRY
+defaultLimit: 50
+directDbConnection: false
+entity:
+ append:
+ topic: ENTITY_APPEND
+ create:
+ topic: ENTITY_CREATE
+ delete:
+ topic: ENTITY_DELETE
+ update:
+ topic: ENTITY_UPDATE
+ index:
+ topic: ENTITY_INDEX
+ keyValues:
+ topic: KVENTITY
+ stopListenerIfDbFails: false
+ temporal:
+ stopListenerIfDbFails: false
+ topic: TEMPORALENTITY
+ topic: ENTITY
+ withoutSysAttrs:
+ topic: ENTITY_WITHOUT_SYSATTRS
+
+submanager:
+ subscription:
+ topic: SUBSCRIPTIONS
+
+kafka:
+ replytimeout: 10000
+management:
+ endpoint:
+ restart:
+ enabled: true
+ endpoints:
+ web:
+ exposure:
+ include: "*"
+max:
+ request:
+ size: 104857600
+maxLimit: 500
+ngb:
+ debugmode: false
+
+
+reader:
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP_Reader
+ password: ngb
+ url: jdbc:postgresql://localhost:5432/ngb?ApplicationName=ngb_storagemanager_reader
+ username: ngb
+ enabled: true
+
+spring:
+ cloud:
+ stream:
+ kafka:
+ binder:
+ brokers: localhost:9092
+ bindings:
+ ENTITY_WRITE_CHANNEL:
+ destination: ENTITY
+ contentType: application/json
+ KVENTITY_WRITE_CHANNEL:
+ destination: KVENTITY
+ contentType: application/json
+ ENTITY_WITHOUT_SYSATTRS_WRITE_CHANNEL:
+ destination: ENTITY_WITHOUT_SYSATTRS
+ contentType: application/json
+ CREATE_WRITE_CHANNEL:
+ destination: ENTITY_CREATE
+ contentType: application/json
+ APPEND_WRITE_CHANNEL:
+ destination: ENTITY_APPEND
+ contentType: application/json
+ UPDATE_WRITE_CHANNEL:
+ destination: ENTITY_UPDATE
+ contentType: application/json
+ DELETE_WRITE_CHANNEL:
+ destination: ENTITY_DELETE
+ contentType: application/json
+ CONTEXT_REGISTRY_WRITE_CHANNEL:
+ destination: CONTEXT_REGISTRY
+ contentType: application/json
+ CONTEXT_REGISTRY_UPDATE_CHANNEL:
+ destination: CONTEXT_UPDATE
+ contentType: application/json
+ INDEX_WRITE_CHANNEL:
+ destination: ENTITY_INDEX
+ contentType: application/json
+ ATCONTEXT_WRITE_CHANNEL:
+ destination: ATCONTEXT
+ contentType: application/json
+ TEMPORAL_ENTITY_WRITE_CHANNEL:
+ destination: TEMPORALENTITY
+ contentType: application/json
+ SUBSCRIPTIONS_WRITE_CHANNEL:
+ destination: SUBSCRIPTIONS
+ contentType: application/json
+ CSOURCE_SUBSCRIPTION_WRITE_CHANNEL:
+ destination: CSOURCE_SUBSCRIPTIONS
+ contentType: application/json
+ CSOURCE_REGISTRATION_WRITE_CHANNEL:
+ destination: CONTEXT_SOURCE
+ contentType: application/json
+ CSOURCE_NOTIFICATION_WRITE_CHANNEL:
+ destination: CONTEXT_SOURCE_NOTIFICATION
+ contentType: application/json
+ application.name: aio-runner
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP
+ password: ngb
+ url: jdbc:postgresql://localhost:5432/ngb?ApplicationName=ngb_registrymanager
+ username: ngb
+ flyway:
+ baselineOnMigrate: true
+ kafka:
+ admin:
+ properties:
+ cleanup:
+ policy: compact
+ main:
+ lazy-initialization: true
+ allow-bean-definition-overriding: true
+
+
+writer:
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP_Writer
+ password: ngb
+ url: jdbc:postgresql://localhost:5432/ngb?ApplicationName=ngb_storagemanager_writer
+ username: ngb
+ enabled: true
+
+# Increase the Hystrix timeout to 60s (globally)
+hystrix:
+ command:
+ default:
+ execution:
+ isolation:
+ thread:
+ timeoutInMilliseconds: 60000
+
+
+#GET request configuration for QUERY-MANAGER
+ribbon:
+ ReadTimeout: 60000
+ ConnectTimeout: 60000
+
+
+
+query-manager:
+ request-path: /ngsi-ld/v1/entities
+ target-service: aio-runner
+ http-method: GET
+
+
+
+server:
+ port: 27015
+ tomcat:
+ max:
+ threads:200
+
+eureka:
+ client:
+ register-with-eureka: true
+ fetchRegistry: true
+ serviceUrl:
+ defaultZone: http://localhost:8761/eureka/
+
+zuul:
+ ignored-services: '*'
+ semaphore:
+ maxSemaphores: 60000
+ host:
+ connect-timeout-millis: 60000
+ socket-timeout-millis: 60000
+ routes:
+ entity-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/entities/**
+ serviceId: aio-runner
+ stripPrefix: false
+ subscription-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/subscriptions/**
+ serviceId: aio-runner
+ stripPrefix: false
+ context-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/csourceRegistrations/**
+ serviceId: aio-runner
+ stripPrefix: false
+ subforeg:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/csourceSubscriptions/**
+ serviceId: aio-runner
+ stripPrefix: false
+ history-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/temporal/**
+ serviceId: aio-runner
+ stripPrefix: false
+ atcontext-server:
+ sensitiveHeaders:
+ path: /ngsi-ld/contextes/**
+ serviceId: aio-runner
+ stripPrefix: false
+ test-manager:
+ sensitiveHeaders:
+ path: /test/**
+ serviceId: testmanager
+ stripPrefix: false
+selfhostcorecontext: http://localhost:9090/corecontext
+security:
+ active: false
+ oauth2:
+ client:
+ # for keycloak configure
+ #accessTokenUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/token
+ #userAuthorizationUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/auth
+ #clientId: authserver
+ #clientSecret: ae8c99a9-f98d-41e9-8fb2-d348acb987e0
+ # for ketrock configure
+ accessTokenUri: http://172.30.64.120:3000/oauth2/token
+ userAuthorizationUri: http://172.30.64.120:3000/oauth2/authorize
+ clientId: a2034c11-d2a9-4cab-9fac-ff65425bd53f
+ clientSecret: 7364baec-6d6f-4307-8c71-d66e1e6c3afc
+ resource:
+ # for keycloak configure
+ #userInfoUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/userinfo
+ # for keycloak configure
+ userInfoUri: http://172.30.64.120:3000/user
+logging:
+ level:
+ root: ERROR
+
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/application-local.yml b/scorpio-broker/AllInOneRunner/src/main/resources/application-local.yml
new file mode 100644
index 0000000000000000000000000000000000000000..663ecb275ddac9fc1d33ca57b85cb1d235d74526
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/application-local.yml
@@ -0,0 +1,292 @@
+append:
+ overwrite: noOverwrite
+atcontext:
+ url: http://localhost:9090/ngsi-ld/contextes/
+bootstrap:
+ servers: localhost:9092
+broker:
+ id: FedBroker1
+ parent:
+ location:
+ url: SELF
+
+query:
+ result:
+ topic: QUERY_RESULT
+ topic: QUERY
+batchoperations:
+ maxnumber:
+ create: 1000
+ update: 1000
+ upsert: 1000
+ delete: 1000
+
+csource:
+ stopListenerIfDbFails: false
+ topic: CONTEXT_SOURCE
+ registry:
+ topic: CONTEXT_REGISTRY
+ source:
+ topic: CONTEXT_SOURCE
+ notification:
+ topic: CONTEXT_SOURCE_NOTIFICATION
+ query:
+ topic: CONTEXT_REGISTRY_QUERY
+ result:
+ topic: CONTEXT_REGISTRY_QUERY_RESULT
+
+csources:
+ registration:
+ topic: CONTEXT_REGISTRY
+defaultLimit: 50
+directDbConnection: false
+entity:
+ append:
+ topic: ENTITY_APPEND
+ create:
+ topic: ENTITY_CREATE
+ delete:
+ topic: ENTITY_DELETE
+ update:
+ topic: ENTITY_UPDATE
+ index:
+ topic: ENTITY_INDEX
+ keyValues:
+ topic: KVENTITY
+ stopListenerIfDbFails: false
+ temporal:
+ stopListenerIfDbFails: false
+ topic: TEMPORALENTITY
+ topic: ENTITY
+ withoutSysAttrs:
+ topic: ENTITY_WITHOUT_SYSATTRS
+
+submanager:
+ subscription:
+ topic: SUBSCRIPTIONS
+
+kafka:
+ replytimeout: 10000
+management:
+ endpoint:
+ restart:
+ enabled: true
+ endpoints:
+ web:
+ exposure:
+ include: "*"
+max:
+ request:
+ size: 104857600
+maxLimit: 500
+ngb:
+ debugmode: false
+
+
+reader:
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP_Reader
+ password: ngb
+ url: jdbc:postgresql://localhost:5432/ngb?ApplicationName=ngb_storagemanager_reader
+ username: ngb
+ enabled: true
+
+spring:
+ cloud:
+ stream:
+ kafka:
+ binder:
+ brokers: localhost:9092
+ bindings:
+ ENTITY_WRITE_CHANNEL:
+ destination: ENTITY
+ contentType: application/json
+ KVENTITY_WRITE_CHANNEL:
+ destination: KVENTITY
+ contentType: application/json
+ ENTITY_WITHOUT_SYSATTRS_WRITE_CHANNEL:
+ destination: ENTITY_WITHOUT_SYSATTRS
+ contentType: application/json
+ CREATE_WRITE_CHANNEL:
+ destination: ENTITY_CREATE
+ contentType: application/json
+ APPEND_WRITE_CHANNEL:
+ destination: ENTITY_APPEND
+ contentType: application/json
+ UPDATE_WRITE_CHANNEL:
+ destination: ENTITY_UPDATE
+ contentType: application/json
+ DELETE_WRITE_CHANNEL:
+ destination: ENTITY_DELETE
+ contentType: application/json
+ CONTEXT_REGISTRY_WRITE_CHANNEL:
+ destination: CONTEXT_REGISTRY
+ contentType: application/json
+ CONTEXT_REGISTRY_UPDATE_CHANNEL:
+ destination: CONTEXT_UPDATE
+ contentType: application/json
+ INDEX_WRITE_CHANNEL:
+ destination: ENTITY_INDEX
+ contentType: application/json
+ ATCONTEXT_WRITE_CHANNEL:
+ destination: ATCONTEXT
+ contentType: application/json
+ TEMPORAL_ENTITY_WRITE_CHANNEL:
+ destination: TEMPORALENTITY
+ contentType: application/json
+ SUBSCRIPTIONS_WRITE_CHANNEL:
+ destination: SUBSCRIPTIONS
+ contentType: application/json
+ CSOURCE_SUBSCRIPTION_WRITE_CHANNEL:
+ destination: CSOURCE_SUBSCRIPTIONS
+ contentType: application/json
+ CSOURCE_REGISTRATION_WRITE_CHANNEL:
+ destination: CONTEXT_SOURCE
+ contentType: application/json
+ CSOURCE_NOTIFICATION_WRITE_CHANNEL:
+ destination: CONTEXT_SOURCE_NOTIFICATION
+ contentType: application/json
+ application.name: aio-runner
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP
+ password: ngb
+ url: jdbc:postgresql://localhost:5432/ngb?ApplicationName=ngb_registrymanager
+ username: ngb
+ flyway:
+ baselineOnMigrate: true
+ kafka:
+ admin:
+ properties:
+ cleanup:
+ policy: compact
+ main:
+ lazy-initialization: true
+ allow-bean-definition-overriding: true
+
+
+writer:
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP_Writer
+ password: ngb
+ url: jdbc:postgresql://localhost:5432/ngb?ApplicationName=ngb_storagemanager_writer
+ username: ngb
+ enabled: true
+
+# Increase the Hystrix timeout to 60s (globally)
+hystrix:
+ command:
+ default:
+ execution:
+ isolation:
+ thread:
+ timeoutInMilliseconds: 60000
+
+selfhostcorecontext: http://localhost:9090/corecontext
+#GET request configuration for QUERY-MANAGER
+ribbon:
+ ReadTimeout: 60000
+ ConnectTimeout: 60000
+
+
+
+query-manager:
+ request-path: /ngsi-ld/v1/entities
+ target-service: aio-runner
+ http-method: GET
+
+
+
+server:
+ port: 27015
+ tomcat:
+ max:
+ threads:200
+
+eureka:
+ client:
+ register-with-eureka: true
+ fetchRegistry: true
+ serviceUrl:
+ defaultZone: http://localhost:8761/eureka/
+
+zuul:
+ ignored-services: '*'
+ semaphore:
+ maxSemaphores: 60000
+ host:
+ connect-timeout-millis: 60000
+ socket-timeout-millis: 60000
+ routes:
+ entity-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/entities/**
+ serviceId: aio-runner
+ stripPrefix: false
+ subscription-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/subscriptions/**
+ serviceId: aio-runner
+ stripPrefix: false
+ context-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/csourceRegistrations/**
+ serviceId: aio-runner
+ stripPrefix: false
+ subforeg:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/csourceSubscriptions/**
+ serviceId: aio-runner
+ stripPrefix: false
+ history-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/temporal/**
+ serviceId: aio-runner
+ stripPrefix: false
+ atcontext-server:
+ sensitiveHeaders:
+ path: /ngsi-ld/contextes/**
+ serviceId: aio-runner
+ stripPrefix: false
+ test-manager:
+ sensitiveHeaders:
+ path: /test/**
+ serviceId: testmanager
+ stripPrefix: false
+security:
+ active: false
+ oauth2:
+ client:
+ # for keycloak configure
+ #accessTokenUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/token
+ #userAuthorizationUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/auth
+ #clientId: authserver
+ #clientSecret: ae8c99a9-f98d-41e9-8fb2-d348acb987e0
+ # for ketrock configure
+ accessTokenUri: http://172.30.64.120:3000/oauth2/token
+ userAuthorizationUri: http://172.30.64.120:3000/oauth2/authorize
+ clientId: a2034c11-d2a9-4cab-9fac-ff65425bd53f
+ clientSecret: 7364baec-6d6f-4307-8c71-d66e1e6c3afc
+ resource:
+ # for keycloak configure
+ #userInfoUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/userinfo
+ # for keycloak configure
+ userInfoUri: http://172.30.64.120:3000/user
+
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/application.yml b/scorpio-broker/AllInOneRunner/src/main/resources/application.yml
new file mode 100644
index 0000000000000000000000000000000000000000..0703379a4a0f10d97cf2e6af411da8aa1a454d82
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/application.yml
@@ -0,0 +1,292 @@
+append:
+ overwrite: noOverwrite
+atcontext:
+ url: http://localhost:9090/ngsi-ld/contextes/
+bootstrap:
+ servers: kafka:9092
+broker:
+ id: FedBroker1
+ parent:
+ location:
+ url: SELF
+
+query:
+ result:
+ topic: QUERY_RESULT
+ topic: QUERY
+batchoperations:
+ maxnumber:
+ create: 1000
+ update: 1000
+ upsert: 1000
+ delete: 1000
+
+csource:
+ stopListenerIfDbFails: false
+ topic: CONTEXT_SOURCE
+ registry:
+ topic: CONTEXT_REGISTRY
+ source:
+ topic: CONTEXT_SOURCE
+ notification:
+ topic: CONTEXT_SOURCE_NOTIFICATION
+ query:
+ topic: CONTEXT_REGISTRY_QUERY
+ result:
+ topic: CONTEXT_REGISTRY_QUERY_RESULT
+
+csources:
+ registration:
+ topic: CONTEXT_REGISTRY
+defaultLimit: 50
+directDbConnection: false
+entity:
+ append:
+ topic: ENTITY_APPEND
+ create:
+ topic: ENTITY_CREATE
+ delete:
+ topic: ENTITY_DELETE
+ update:
+ topic: ENTITY_UPDATE
+ index:
+ topic: ENTITY_INDEX
+ keyValues:
+ topic: KVENTITY
+ stopListenerIfDbFails: false
+ temporal:
+ stopListenerIfDbFails: false
+ topic: TEMPORALENTITY
+ topic: ENTITY
+ withoutSysAttrs:
+ topic: ENTITY_WITHOUT_SYSATTRS
+
+submanager:
+ subscription:
+ topic: SUBSCRIPTIONS
+
+kafka:
+ replytimeout: 10000
+management:
+ endpoint:
+ restart:
+ enabled: true
+ endpoints:
+ web:
+ exposure:
+ include: "*"
+max:
+ request:
+ size: 104857600
+maxLimit: 500
+ngb:
+ debugmode: false
+
+
+reader:
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP_Reader
+ password: ngb
+ url: jdbc:postgresql://postgres:5432/ngb?ApplicationName=ngb_storagemanager_reader
+ username: ngb
+ enabled: true
+
+spring:
+ cloud:
+ stream:
+ kafka:
+ binder:
+ brokers: kafka:9092
+ bindings:
+ ENTITY_WRITE_CHANNEL:
+ destination: ENTITY
+ contentType: application/json
+ KVENTITY_WRITE_CHANNEL:
+ destination: KVENTITY
+ contentType: application/json
+ ENTITY_WITHOUT_SYSATTRS_WRITE_CHANNEL:
+ destination: ENTITY_WITHOUT_SYSATTRS
+ contentType: application/json
+ CREATE_WRITE_CHANNEL:
+ destination: ENTITY_CREATE
+ contentType: application/json
+ APPEND_WRITE_CHANNEL:
+ destination: ENTITY_APPEND
+ contentType: application/json
+ UPDATE_WRITE_CHANNEL:
+ destination: ENTITY_UPDATE
+ contentType: application/json
+ DELETE_WRITE_CHANNEL:
+ destination: ENTITY_DELETE
+ contentType: application/json
+ CONTEXT_REGISTRY_WRITE_CHANNEL:
+ destination: CONTEXT_REGISTRY
+ contentType: application/json
+ CONTEXT_REGISTRY_UPDATE_CHANNEL:
+ destination: CONTEXT_UPDATE
+ contentType: application/json
+ INDEX_WRITE_CHANNEL:
+ destination: ENTITY_INDEX
+ contentType: application/json
+ ATCONTEXT_WRITE_CHANNEL:
+ destination: ATCONTEXT
+ contentType: application/json
+ TEMPORAL_ENTITY_WRITE_CHANNEL:
+ destination: TEMPORALENTITY
+ contentType: application/json
+ SUBSCRIPTIONS_WRITE_CHANNEL:
+ destination: SUBSCRIPTIONS
+ contentType: application/json
+ CSOURCE_SUBSCRIPTION_WRITE_CHANNEL:
+ destination: CSOURCE_SUBSCRIPTIONS
+ contentType: application/json
+ CSOURCE_REGISTRATION_WRITE_CHANNEL:
+ destination: CONTEXT_SOURCE
+ contentType: application/json
+ CSOURCE_NOTIFICATION_WRITE_CHANNEL:
+ destination: CONTEXT_SOURCE_NOTIFICATION
+ contentType: application/json
+ application.name: aio-runner
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP
+ password: ngb
+ url: jdbc:postgresql://postgres:5432/ngb?ApplicationName=ngb_registrymanager
+ username: ngb
+ flyway:
+ baselineOnMigrate: true
+ kafka:
+ admin:
+ properties:
+ cleanup:
+ policy: compact
+ main:
+ lazy-initialization: true
+ allow-bean-definition-overriding: true
+
+
+writer:
+ datasource:
+ hikari:
+ connectionTimeout: 30000
+ idleTimeout: 30000
+ maxLifetime: 2000000
+ maximumPoolSize: 20
+ minimumIdle: 5
+ poolName: SpringBootHikariCP_Writer
+ password: ngb
+ url: jdbc:postgresql://postgres:5432/ngb?ApplicationName=ngb_storagemanager_writer
+ username: ngb
+ enabled: true
+
+# Increase the Hystrix timeout to 60s (globally)
+hystrix:
+ command:
+ default:
+ execution:
+ isolation:
+ thread:
+ timeoutInMilliseconds: 60000
+
+
+#GET request configuration for QUERY-MANAGER
+ribbon:
+ ReadTimeout: 60000
+ ConnectTimeout: 60000
+
+
+
+query-manager:
+ request-path: /ngsi-ld/v1/entities
+ target-service: aio-runner
+ http-method: GET
+
+
+
+server:
+ port: 27015
+ tomcat:
+ max:
+ threads:200
+
+eureka:
+ client:
+ register-with-eureka: true
+ fetchRegistry: true
+ serviceUrl:
+ defaultZone: http://localhost:8761/eureka/
+
+zuul:
+ ignored-services: '*'
+ semaphore:
+ maxSemaphores: 60000
+ host:
+ connect-timeout-millis: 60000
+ socket-timeout-millis: 60000
+ routes:
+ entity-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/entities/**
+ serviceId: aio-runner
+ stripPrefix: false
+ subscription-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/subscriptions/**
+ serviceId: aio-runner
+ stripPrefix: false
+ context-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/csourceRegistrations/**
+ serviceId: aio-runner
+ stripPrefix: false
+ subforeg:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/csourceSubscriptions/**
+ serviceId: aio-runner
+ stripPrefix: false
+ history-manager:
+ sensitiveHeaders:
+ path: /ngsi-ld/v1/temporal/**
+ serviceId: aio-runner
+ stripPrefix: false
+ atcontext-server:
+ sensitiveHeaders:
+ path: /ngsi-ld/contextes/**
+ serviceId: aio-runner
+ stripPrefix: false
+ test-manager:
+ sensitiveHeaders:
+ path: /test/**
+ serviceId: testmanager
+ stripPrefix: false
+security:
+ active: false
+ oauth2:
+ client:
+ # for keycloak configure
+ #accessTokenUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/token
+ #userAuthorizationUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/auth
+ #clientId: authserver
+ #clientSecret: ae8c99a9-f98d-41e9-8fb2-d348acb987e0
+ # for ketrock configure
+ accessTokenUri: http://172.30.64.120:3000/oauth2/token
+ userAuthorizationUri: http://172.30.64.120:3000/oauth2/authorize
+ clientId: a2034c11-d2a9-4cab-9fac-ff65425bd53f
+ clientSecret: 7364baec-6d6f-4307-8c71-d66e1e6c3afc
+ resource:
+ # for keycloak configure
+ #userInfoUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/userinfo
+ # for keycloak configure
+ userInfoUri: http://172.30.64.120:3000/user
+selfhostcorecontext: http://localhost:9090/corecontext
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/config/c-sources.yml b/scorpio-broker/AllInOneRunner/src/main/resources/config/c-sources.yml
new file mode 100644
index 0000000000000000000000000000000000000000..158dcc0a49b85da02d5fabc2c56caf69abee0597
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/config/c-sources.yml
@@ -0,0 +1,57 @@
+management:
+ security:
+ enabled: false
+
+security:
+ sessions: NEVER
+ oauth2:
+ resource:
+ userInfoUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/userinfo
+# Configure resources
+secEnabled: false
+auth:
+ - api: /*
+ role:
+ - USER_G
+ - USER_PG
+ - USER_PUG
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ GET
+ - api: /*
+ role:
+ - USER_PG
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ POST
+ - api: /*
+ role:
+ - USER_GUD
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ PATCH
+ - api: /*
+ role:
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ DELETE
+ - api: /
+ role:
+ - USER_PG
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ POST
+ - api: /
+ role:
+ - USER_G
+ - USER_PG
+ - USER_PUG
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ GET
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/config/entity-manager.yml b/scorpio-broker/AllInOneRunner/src/main/resources/config/entity-manager.yml
new file mode 100644
index 0000000000000000000000000000000000000000..081df638cbdacb705a84c53495fdc8b1063e0253
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/config/entity-manager.yml
@@ -0,0 +1,52 @@
+management:
+ security:
+ enabled: false
+
+security:
+ sessions: NEVER
+ oauth2:
+ resource:
+ userInfoUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/userinfo
+# Configure resources
+secEnabled: false
+auth:
+ - api: /*
+ role:
+ - USER_PG
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ POST
+ - api: /*
+ role:
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ DELETE
+ - api: /*/attrs
+ role:
+ - USER_PUG
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ PATCH
+ - api: /*/attrs
+ role:
+ - USER_PG
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ POST
+ - api: /*/attrs/*
+ role:
+ - USER_PUG
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ PATCH
+ - api: /*/attrs/*
+ role:
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ DELETE
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/config/history-manager.yml b/scorpio-broker/AllInOneRunner/src/main/resources/config/history-manager.yml
new file mode 100644
index 0000000000000000000000000000000000000000..3a2be36c6024778c8b220f673564ae4ce343ce25
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/config/history-manager.yml
@@ -0,0 +1,68 @@
+management:
+ security:
+ enabled: false
+
+security:
+ sessions: NEVER
+ oauth2:
+ resource:
+ userInfoUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/userinfo
+# Configure resources
+secEnabled: false
+auth:
+ - api: /entities
+ role:
+ - USER_PG
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ POST
+ - api: /entities
+ role:
+ - USER_G
+ - USER_PG
+ - USER_PUG
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ GET
+ - api: /entities/*
+ role:
+ - USER_G
+ - USER_PG
+ - USER_PUG
+ - USER_GUD
+ method:
+ GET
+ - api: /entities/*
+ role:
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ DELETE
+ - api: /entities/*/attrs/
+ role:
+ - USER_PG
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ POST
+ - api: /entities/*/attrs/*
+ role:
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ DELETE
+ - api: /entities/*/attrs/*/*
+ role:
+ - USER_GUD
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ PATCH
+ - api: /entities/*/attrs/*/*
+ role:
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ DELETE
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/config/ngsi-ld-core-context.jsonld b/scorpio-broker/AllInOneRunner/src/main/resources/config/ngsi-ld-core-context.jsonld
new file mode 100644
index 0000000000000000000000000000000000000000..fb43242d5a69cf2b5c0e7f22a45e85c1750f1368
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/config/ngsi-ld-core-context.jsonld
@@ -0,0 +1,158 @@
+{
+ "@context": {
+ "ngsi-ld": "https://uri.etsi.org/ngsi-ld/",
+ "id": "@id",
+ "type": "@type",
+ "value": "https://uri.etsi.org/ngsi-ld/hasValue",
+ "object": {
+ "@id": "https://uri.etsi.org/ngsi-ld/hasObject",
+ "@type":"@id"
+ },
+ "Property": "https://uri.etsi.org/ngsi-ld/Property",
+ "Relationship": "https://uri.etsi.org/ngsi-ld/Relationship",
+ "DateTime": "https://uri.etsi.org/ngsi-ld/DateTime",
+ "Date": "https://uri.etsi.org/ngsi-ld/Date",
+ "Time": "https://uri.etsi.org/ngsi-ld/Time",
+ "createdAt": {
+ "@id": "https://uri.etsi.org/ngsi-ld/createdAt",
+ "@type": "DateTime"
+ },
+ "modifiedAt": {
+ "@id": "https://uri.etsi.org/ngsi-ld/modifiedAt",
+ "@type": "DateTime"
+ },
+ "observedAt": {
+ "@id": "https://uri.etsi.org/ngsi-ld/observedAt",
+ "@type": "DateTime"
+ },
+ "datasetId": {
+ "@id": "https://uri.etsi.org/ngsi-ld/datasetId",
+ "@type": "@id"
+ },
+ "instanceId": {
+ "@id": "https://uri.etsi.org/ngsi-ld/instanceId",
+ "@type": "@id"
+ },
+ "unitCode": "https://uri.etsi.org/ngsi-ld/unitCode",
+ "location": "https://uri.etsi.org/ngsi-ld/location",
+ "observationSpace": "https://uri.etsi.org/ngsi-ld/observationSpace",
+ "operationSpace": "https://uri.etsi.org/ngsi-ld/operationSpace",
+ "GeoProperty": "https://uri.etsi.org/ngsi-ld/GeoProperty",
+ "TemporalProperty": "https://uri.etsi.org/ngsi-ld/TemporalProperty",
+ "ContextSourceRegistration": "https://uri.etsi.org/ngsi-ld/ContextSourceRegistration",
+ "Subscription": "https://uri.etsi.org/ngsi-ld/Subscription",
+ "Notification": "https://uri.etsi.org/ngsi-ld/Notification",
+ "ContextSourceNotification": "https://uri.etsi.org/ngsi-ld/ContextSourceNotification",
+ "title": "https://uri.etsi.org/ngsi-ld/title",
+ "detail": "https://uri.etsi.org/ngsi-ld/detail",
+ "idPattern": "https://uri.etsi.org/ngsi-ld/idPattern",
+ "name": "https://uri.etsi.org/ngsi-ld/name",
+ "description": "https://uri.etsi.org/ngsi-ld/description",
+ "information": "https://uri.etsi.org/ngsi-ld/information",
+ "observationInterval": "https://uri.etsi.org/ngsi-ld/observationInterval",
+ "managementInterval": "https://uri.etsi.org/ngsi-ld/managementInterval",
+ "expires": {
+ "@id": "https://uri.etsi.org/ngsi-ld/expires",
+ "@type": "DateTime"
+ },
+ "endpoint": "https://uri.etsi.org/ngsi-ld/endpoint",
+ "entities": "https://uri.etsi.org/ngsi-ld/entities",
+ "properties": {
+ "@id": "https://uri.etsi.org/ngsi-ld/properties",
+ "@type": "@vocab"
+ },
+ "relationships": {
+ "@id": "https://uri.etsi.org/ngsi-ld/relationships",
+ "@type": "@vocab"
+ },
+ "start": {
+ "@id": "https://uri.etsi.org/ngsi-ld/start",
+ "@type": "DateTime"
+ },
+ "end": {
+ "@id": "https://uri.etsi.org/ngsi-ld/end",
+ "@type": "DateTime"
+ },
+ "watchedAttributes":{
+ "@id": "https://uri.etsi.org/ngsi-ld/watchedAttributes",
+ "@type": "@vocab"
+ },
+ "timeInterval": "https://uri.etsi.org/ngsi-ld/timeInterval",
+ "q": "https://uri.etsi.org/ngsi-ld/q",
+ "geoQ": "https://uri.etsi.org/ngsi-ld/geoQ",
+ "csf": "https://uri.etsi.org/ngsi-ld/csf",
+ "isActive": "https://uri.etsi.org/ngsi-ld/isActive",
+ "notification": "https://uri.etsi.org/ngsi-ld/notification",
+ "status": "https://uri.etsi.org/ngsi-ld/status",
+ "throttling": "https://uri.etsi.org/ngsi-ld/throttling",
+ "temporalQ": "https://uri.etsi.org/ngsi-ld/temporalQ",
+ "geometry": "https://uri.etsi.org/ngsi-ld/geometry",
+ "coordinates": "https://uri.etsi.org/ngsi-ld/coordinates",
+ "georel": "https://uri.etsi.org/ngsi-ld/georel",
+ "geoproperty": "https://uri.etsi.org/ngsi-ld/geoproperty",
+ "attributes": {
+ "@id": "https://uri.etsi.org/ngsi-ld/attributes",
+ "@type": "@vocab"
+ },
+ "format": "https://uri.etsi.org/ngsi-ld/format",
+ "timesSent": "https://uri.etsi.org/ngsi-ld/timesSent",
+ "lastNotification":{
+ "@id": "https://uri.etsi.org/ngsi-ld/lastNotification",
+ "@type": "DateTime"
+ },
+ "lastFailure":{
+ "@id": "https://uri.etsi.org/ngsi-ld/lastFailure",
+ "@type": "DateTime"
+ },
+ "lastSuccess":{
+ "@id": "https://uri.etsi.org/ngsi-ld/lastSuccess",
+ "@type": "DateTime"
+ },
+ "uri": "https://uri.etsi.org/ngsi-ld/uri",
+ "accept": "https://uri.etsi.org/ngsi-ld/accept",
+ "success": {
+ "@id": "https://uri.etsi.org/ngsi-ld/success",
+ "@type": "@id"
+ },
+ "errors": "https://uri.etsi.org/ngsi-ld/errors",
+ "error": "https://uri.etsi.org/ngsi-ld/error",
+ "entityId": {
+ "@id": "https://uri.etsi.org/ngsi-ld/entityId",
+ "@type": "@id"
+ },
+ "updated": "https://uri.etsi.org/ngsi-ld/updated",
+ "unchanged": "https://uri.etsi.org/ngsi-ld/unchanged",
+ "attributeName": "https://uri.etsi.org/ngsi-ld/attributeName",
+ "reason": "https://uri.etsi.org/ngsi-ld/reason",
+ "timerel": "https://uri.etsi.org/ngsi-ld/timerel",
+ "time": {
+ "@id": "https://uri.etsi.org/ngsi-ld/time",
+ "@type": "DateTime"
+ },
+ "endTime": {
+ "@id": "https://uri.etsi.org/ngsi-ld/endTime",
+ "@type": "DateTime"
+ },
+ "timeproperty": "https://uri.etsi.org/ngsi-ld/timeproperty",
+ "subscriptionId": {
+ "@id": "https://uri.etsi.org/ngsi-ld/subscriptionId",
+ "@type": "@id"
+ },
+ "notifiedAt":{
+ "@id": "https://uri.etsi.org/ngsi-ld/notifiedAt",
+ "@type": "DateTime"
+ },
+ "data": "https://uri.etsi.org/ngsi-ld/data",
+ "triggerReason": "https://uri.etsi.org/ngsi-ld/triggerReason",
+ "values":{
+ "@id": "https://uri.etsi.org/ngsi-ld/hasValues",
+ "@container": "@list"
+ },
+ "objects":{
+ "@id": "https://uri.etsi.org/ngsi-ld/hasObjects",
+ "@type": "@id",
+ "@container": "@list"
+ },
+ "@vocab": "https://uri.etsi.org/ngsi-ld/default-context/"
+ }
+}
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/config/query-manager.yml b/scorpio-broker/AllInOneRunner/src/main/resources/config/query-manager.yml
new file mode 100644
index 0000000000000000000000000000000000000000..485eab6e15cdeeb10ecfe8eb49464f856d57271a
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/config/query-manager.yml
@@ -0,0 +1,21 @@
+management:
+ security:
+ enabled: false
+
+security:
+ sessions: NEVER
+ oauth2:
+ resource:
+ userInfoUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/userinfo
+# Configure resources
+secEnabled: false
+auth:
+ - api: /*
+ role:
+ - USER_G
+ - USER_PG
+ - USER_PUG
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ GET
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/config/subscription-manager.yml b/scorpio-broker/AllInOneRunner/src/main/resources/config/subscription-manager.yml
new file mode 100644
index 0000000000000000000000000000000000000000..0ae20cc00530d47fc0c34d9347dd010dd5b0ad37
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/config/subscription-manager.yml
@@ -0,0 +1,50 @@
+management:
+ security:
+ enabled: false
+
+security:
+ sessions: NEVER
+ oauth2:
+ resource:
+ userInfoUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/userinfo
+# Configure resources
+secEnabled: false
+auth:
+ - api: /
+ role:
+ - USER_PG
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ POST
+ - api: /
+ role:
+ - USER_G
+ - USER_PG
+ - USER_GUD
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ GET
+ - api: /*
+ role:
+ - USER_G
+ - USER_PG
+ - USER_GUD
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ GET
+ - api: /*
+ role:
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ DELETE
+ - api: /*
+ role:
+ - USER_GUD
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ PATCH
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/config/testmanager.yml b/scorpio-broker/AllInOneRunner/src/main/resources/config/testmanager.yml
new file mode 100644
index 0000000000000000000000000000000000000000..081df638cbdacb705a84c53495fdc8b1063e0253
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/config/testmanager.yml
@@ -0,0 +1,52 @@
+management:
+ security:
+ enabled: false
+
+security:
+ sessions: NEVER
+ oauth2:
+ resource:
+ userInfoUri: http://10.0.4.33:8080/auth/realms/mykeycloak/protocol/openid-connect/userinfo
+# Configure resources
+secEnabled: false
+auth:
+ - api: /*
+ role:
+ - USER_PG
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ POST
+ - api: /*
+ role:
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ DELETE
+ - api: /*/attrs
+ role:
+ - USER_PUG
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ PATCH
+ - api: /*/attrs
+ role:
+ - USER_PG
+ - USER_PUG
+ - ADMIN_PUGD
+ method:
+ POST
+ - api: /*/attrs/*
+ role:
+ - USER_PUG
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ PATCH
+ - api: /*/attrs/*
+ role:
+ - USER_GUD
+ - ADMIN_PUGD
+ method:
+ DELETE
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190604.1__entity.sql b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190604.1__entity.sql
new file mode 100644
index 0000000000000000000000000000000000000000..a8259f8bf603988add0925c6985b979640cdc13e
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190604.1__entity.sql
@@ -0,0 +1,57 @@
+CREATE EXTENSION IF NOT EXISTS postgis;
+
+CREATE TABLE IF NOT EXISTS Entity (
+ id TEXT NOT NULL,
+ type TEXT,
+ data JSONB NOT NULL,
+ context JSONB,
+ createdAt TIMESTAMP,
+ modifiedAt TIMESTAMP,
+ location GEOMETRY(Geometry, 4326), -- 4326 (WGS84) is the Coordinate System defined in GeoJson spec: https://tools.ietf.org/html/rfc7946#section-4
+ observationSpace GEOMETRY(Geometry, 4326),
+ operationSpace GEOMETRY(Geometry, 4326),
+ PRIMARY KEY (id))
+;
+
+-- trigger to automatically extract pre-defined ngsi-ld members and store them in regular fields (for query performance)
+CREATE OR REPLACE FUNCTION entity_extract_jsonb_fields() RETURNS trigger AS $_$
+ BEGIN
+ -- is any validation needed?
+ NEW.type = NEW.data#>>'{@type,0}';
+ NEW.createdat = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/createdAt,0,@value}')::TIMESTAMP;
+ NEW.modifiedat = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/modifiedAt,0,@value}')::TIMESTAMP;
+
+ IF (NEW.data@>'{"https://uri.etsi.org/ngsi-ld/location": [ {"@type": [ "https://uri.etsi.org/ngsi-ld/GeoProperty" ] } ] }') THEN
+ NEW.location = ST_SetSRID(ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/location,0,https://uri.etsi.org/ngsi-ld/hasValue,0,@value}' ), 4326);
+ ELSE
+ NEW.location = NULL;
+ END IF;
+ IF (NEW.data@>'{"https://uri.etsi.org/ngsi-ld/observationSpace": [ {"@type": [ "https://uri.etsi.org/ngsi-ld/GeoProperty" ] }] }') THEN
+ NEW.observationSpace = ST_SetSRID( ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/observationSpace,0,https://uri.etsi.org/ngsi-ld/hasValue,0,@value}' ), 4326);
+ ELSE
+ NEW.observationSpace = NULL;
+ END IF;
+ IF (NEW.data@>'{"https://uri.etsi.org/ngsi-ld/operationSpace": [ {"@type": [ "https://uri.etsi.org/ngsi-ld/GeoProperty" ] } ] }') THEN
+ NEW.operationSpace = ST_SetSRID( ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/operationSpace,0,https://uri.etsi.org/ngsi-ld/hasValue,0,@value}' ), 4326);
+ ELSE
+ NEW.operationSpace = NULL;
+ END IF;
+
+ RETURN NEW;
+ END;
+$_$ LANGUAGE plpgsql;
+
+CREATE TRIGGER entity_extract_jsonb_fields BEFORE INSERT OR UPDATE ON entity
+ FOR EACH ROW EXECUTE PROCEDURE entity_extract_jsonb_fields();
+
+-- create indexes for performance
+CREATE INDEX i_entity_type ON entity (type);
+CREATE INDEX i_entity_createdat ON entity (createdat);
+CREATE INDEX i_entity_modifiedat ON entity (modifiedat);
+CREATE INDEX i_entity_location ON entity USING GIST (location);
+CREATE INDEX i_entity_observationspace ON entity USING GIST (observationspace);
+CREATE INDEX i_entity_operationspace ON entity USING GIST (operationspace);
+
+-- to check if this index will be used by the database optimizer, or if it should be applied only for for certain keys
+-- check https://www.postgresql.org/docs/current/static/datatype-json.html
+CREATE INDEX i_entity_data ON entity USING GIN (data);
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190604.2__registry.sql b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190604.2__registry.sql
new file mode 100644
index 0000000000000000000000000000000000000000..51d767f1a6ee0368765817ebce039132d1160bd9
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190604.2__registry.sql
@@ -0,0 +1,135 @@
+CREATE EXTENSION IF NOT EXISTS postgis;
+
+CREATE TABLE IF NOT EXISTS csource (
+ id TEXT NOT NULL,
+ data JSONB NOT NULL,
+ type TEXT,
+ name TEXT,
+ description TEXT,
+ timestamp_start TIMESTAMP,
+ timestamp_end TIMESTAMP,
+ location GEOMETRY(Geometry, 4326), -- 4326 (WGS84) is the Coordinate System defined in GeoJson spec: https://tools.ietf.org/html/rfc7946#section-4
+ expires TIMESTAMP,
+ endpoint TEXT,
+ internal boolean default false,
+ has_registrationinfo_with_attrs_only BOOL NOT NULL DEFAULT FALSE,
+ has_registrationinfo_with_entityinfo_only BOOL NOT NULL DEFAULT FALSE,
+ PRIMARY KEY (id))
+;
+
+-- create indexes for performance
+CREATE INDEX i_csource_data ON csource USING GIN (data);
+CREATE INDEX i_csource_name ON csource (name);
+CREATE INDEX i_csource_timestamp_start ON csource (timestamp_start);
+CREATE INDEX i_csource_timestamp_end ON csource (timestamp_end);
+CREATE INDEX i_csource_location ON csource USING GIST (location);
+CREATE INDEX i_csource_expires ON csource (expires);
+CREATE INDEX i_csource_endpoint ON csource (endpoint);
+CREATE INDEX i_csource_internal ON csource (internal);
+
+CREATE TABLE IF NOT EXISTS csourceinformation (
+ id BIGSERIAL,
+ csource_id TEXT NOT NULL REFERENCES csource(id) ON DELETE CASCADE ON UPDATE CASCADE,
+ group_id BIGINT,
+ entity_id TEXT,
+ entity_idpattern TEXT,
+ entity_type TEXT,
+ property_id TEXT,
+ relationship_id TEXT,
+ PRIMARY KEY (id))
+;
+CREATE SEQUENCE csourceinformation_group_id_seq OWNED BY csourceinformation.group_id; -- used by csource trigger
+-- create indexes for performance
+CREATE INDEX i_csourceinformation_csource_id ON csourceinformation (csource_id);
+CREATE INDEX i_csourceinformation_entity_type_id_idpattern ON csourceinformation (entity_type, entity_id, entity_idpattern);
+CREATE INDEX i_csourceinformation_entity_type_id ON csourceinformation (entity_type, entity_id);
+CREATE INDEX i_csourceinformation_entity_type_idpattern ON csourceinformation (entity_type, entity_idpattern);
+CREATE INDEX i_csourceinformation_property_id ON csourceinformation (property_id);
+CREATE INDEX i_csourceinformation_relationship_id ON csourceinformation (relationship_id);
+CREATE INDEX i_csourceinformation_group_property_relationship ON csourceinformation (group_id, property_id, relationship_id);
+
+-- trigger to automatically extract pre-defined ngsi-ld members and store them in regular fields (for query performance)
+CREATE OR REPLACE FUNCTION csource_extract_jsonb_fields() RETURNS trigger AS $_$
+DECLARE
+ l_rec RECORD;
+ l_entityinfo_count INTEGER;
+ l_attributeinfo_count INTEGER;
+BEGIN
+ NEW.type = NEW.data#>>'{@type,0}';
+ NEW.name = NEW.data#>>'{https://uri.etsi.org/ngsi-ld/name,0,@value}';
+ NEW.description = NEW.data#>>'{https://uri.etsi.org/ngsi-ld/description,0,@value}';
+ NEW.timestamp_start = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/timestamp,0,https://uri.etsi.org/ngsi-ld/start,0,@value}')::TIMESTAMP;
+ NEW.timestamp_end = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/timestamp,0,https://uri.etsi.org/ngsi-ld/end,0,@value}')::TIMESTAMP;
+ NEW.location = ST_SetSRID(ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/location,0,@value}' ), 4326);
+ NEW.expires = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/expires,0,@value}')::TIMESTAMP;
+ NEW.endpoint = NEW.data#>>'{https://uri.etsi.org/ngsi-ld/endpoint,0,@value}';
+ NEW.internal = COALESCE((NEW.data#>>'{https://uri.etsi.org/ngsi-ld/internal,0,@value}')::BOOLEAN, FALSE);
+
+ NEW.has_registrationinfo_with_attrs_only = false;
+ NEW.has_registrationinfo_with_entityinfo_only = false;
+
+ FOR l_rec IN SELECT value FROM jsonb_array_elements(NEW.data#>'{https://uri.etsi.org/ngsi-ld/information}')
+ LOOP
+ SELECT INTO l_entityinfo_count count(*) FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/entities}' );
+ SELECT INTO l_attributeinfo_count count(*) FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/properties}' );
+ SELECT INTO l_attributeinfo_count count(*)+l_attributeinfo_count FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/relationships}' );
+
+ IF (NEW.has_registrationinfo_with_attrs_only = false) THEN
+ NEW.has_registrationinfo_with_attrs_only = (l_entityinfo_count = 0 AND l_attributeinfo_count > 0);
+ END IF;
+
+ IF (NEW.has_registrationinfo_with_entityinfo_only = false) THEN
+ NEW.has_registrationinfo_with_entityinfo_only = (l_entityinfo_count > 0 AND l_attributeinfo_count = 0);
+ END IF;
+ END LOOP;
+
+ RETURN NEW;
+END;
+$_$ LANGUAGE plpgsql;
+
+CREATE TRIGGER csource_extract_jsonb_fields BEFORE INSERT OR UPDATE ON csource
+ FOR EACH ROW EXECUTE PROCEDURE csource_extract_jsonb_fields();
+
+-- trigger to automatically extract pre-defined ngsi-ld members and store them in information table
+CREATE OR REPLACE FUNCTION csource_extract_jsonb_fields_to_information_table() RETURNS trigger AS $_$
+DECLARE
+ l_rec RECORD;
+ l_group_id csourceinformation.group_id%TYPE;
+BEGIN
+ IF TG_OP = 'UPDATE' THEN
+ DELETE FROM csourceinformation where csource_id = NEW.id;
+ END IF;
+
+ FOR l_rec IN SELECT value FROM jsonb_array_elements(NEW.data#>'{https://uri.etsi.org/ngsi-ld/information}')
+ LOOP
+ -- RAISE NOTICE '%', rec.value;
+ SELECT nextval('csourceinformation_group_id_seq') INTO l_group_id;
+
+ -- id takes precedence over idPattern. so, only store idPattern if id is empty. this makes queries much easier/faster.
+ INSERT INTO csourceinformation (csource_id, group_id, entity_id, entity_type, entity_idpattern)
+ SELECT NEW.id,
+ l_group_id,
+ value#>>'{@id}',
+ value#>>'{@type,0}',
+ CASE WHEN value#>>'{@id}' IS NULL THEN value#>>'{https://uri.etsi.org/ngsi-ld/idPattern,0,@value}' END
+ FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/entities}');
+
+ INSERT INTO csourceinformation (csource_id, group_id, property_id)
+ SELECT NEW.id,
+ l_group_id,
+ value#>>'{@id}'
+ FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/properties}');
+
+ INSERT INTO csourceinformation (csource_id, group_id, relationship_id)
+ SELECT NEW.id,
+ l_group_id,
+ value#>>'{@id}'
+ FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/relationships}');
+
+ END LOOP;
+ RETURN NEW;
+END;
+$_$ LANGUAGE plpgsql;
+
+CREATE TRIGGER csource_extract_jsonb_fields_to_information_table AFTER INSERT OR UPDATE ON csource
+ FOR EACH ROW EXECUTE PROCEDURE csource_extract_jsonb_fields_to_information_table();
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190604.3__temporal.sql b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190604.3__temporal.sql
new file mode 100644
index 0000000000000000000000000000000000000000..bc9d603a2b3ed51124507c18e77df266bb80c91a
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190604.3__temporal.sql
@@ -0,0 +1,105 @@
+BEGIN;
+
+CREATE EXTENSION IF NOT EXISTS postgis;
+
+CREATE TABLE IF NOT EXISTS temporalentity (
+ id TEXT NOT NULL,
+ type TEXT,
+ createdAt TIMESTAMP,
+ modifiedAt TIMESTAMP,
+ PRIMARY KEY (id))
+;
+
+CREATE TABLE IF NOT EXISTS temporalentityattrinstance (
+ internalid BIGSERIAL,
+ temporalentity_id TEXT NOT NULL REFERENCES temporalentity(id) ON DELETE CASCADE ON UPDATE CASCADE,
+ attributeid TEXT NOT NULL,
+ instanceid TEXT,
+ attributetype TEXT,
+ value TEXT, -- object (relationship) is also stored here
+ geovalue GEOMETRY,
+ createdat TIMESTAMP,
+ modifiedat TIMESTAMP,
+ observedat TIMESTAMP,
+ data JSONB NOT NULL,
+ static BOOL NOT NULL,
+ PRIMARY KEY (internalid))
+;
+CREATE UNIQUE INDEX i_temporalentityattrinstance_entityid_attributeid_instanceid ON temporalentityattrinstance (temporalentity_id, attributeid, instanceid);
+
+-- trigger to automatically extract pre-defined ngsi-ld members and store them in regular fields (for query performance)
+CREATE OR REPLACE FUNCTION temporalentityattrinstance_extract_jsonb_fields() RETURNS trigger AS $_$
+ DECLARE
+ f_internalid temporalentityattrinstance.internalid%TYPE;
+ BEGIN
+ IF TG_OP = 'INSERT' OR NEW.data <> OLD.data THEN -- do not reprocess if it is just an update on other column (e.g. static)
+ NEW.attributetype = NEW.data#>>'{@type,0}';
+
+ NEW.instanceid = NEW.data#>>'{https://uri.etsi.org/ngsi-ld/instanceId,0,@id}';
+
+ NEW.createdat = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/createdAt,0,@value}')::TIMESTAMP;
+ NEW.modifiedat = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/modifiedAt,0,@value}')::TIMESTAMP;
+ NEW.observedat = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/observedAt,0,@value}')::TIMESTAMP;
+
+ IF NEW.attributeid IN ('https://uri.etsi.org/ngsi-ld/createdAt', 'https://uri.etsi.org/ngsi-ld/modifiedAt', 'https://uri.etsi.org/ngsi-ld/observedAt') THEN
+ NEW.value = NEW.data#>'{@value}';
+ ELSE
+ IF (NEW.data?'https://uri.etsi.org/ngsi-ld/hasValue') THEN
+ NEW.value = NEW.data#>'{https://uri.etsi.org/ngsi-ld/hasValue,0,@value}'; -- TODO: confirm if #> or #>>
+ ELSIF (NEW.data?'https://uri.etsi.org/ngsi-ld/hasObject') THEN
+ NEW.value = NEW.data#>'{https://uri.etsi.org/ngsi-ld/hasObject,0,@id}';
+ ELSE
+ NEW.value = NULL;
+ END IF;
+ END IF;
+
+ IF NEW.attributetype = 'https://uri.etsi.org/ngsi-ld/GeoProperty' THEN
+ NEW.geovalue = ST_SetSRID(ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/hasValue,0,@value}' ), 4326);
+ ELSE
+ NEW.geovalue = NULL;
+ END IF;
+ END IF;
+
+ IF TG_OP = 'INSERT' THEN
+ select into f_internalid internalid from temporalentityattrinstance
+ where temporalentity_id = NEW.temporalentity_id and attributeid = NEW.attributeid limit 1;
+ IF FOUND THEN
+ NEW.static = FALSE;
+ UPDATE temporalentityattrinstance SET static = false
+ WHERE internalid = f_internalid and static = true;
+ ELSE
+ NEW.static = TRUE;
+ END IF;
+ END IF;
+
+ RETURN NEW;
+ END;
+$_$ LANGUAGE plpgsql;
+
+CREATE TRIGGER temporalentityattrinstance_extract_jsonb_fields BEFORE INSERT OR UPDATE ON temporalentityattrinstance
+ FOR EACH ROW EXECUTE PROCEDURE temporalentityattrinstance_extract_jsonb_fields();
+
+CREATE OR REPLACE FUNCTION temporalentityattrinstance_update_static() RETURNS trigger AS $_$
+ DECLARE
+ f_internalid temporalentityattrinstance.internalid%TYPE;
+ f_count integer;
+ BEGIN
+ select into f_internalid, f_count min(internalid), count(1) from temporalentityattrinstance
+ where temporalentity_id = OLD.temporalentity_id AND attributeid = OLD.attributeid;
+ IF (f_count = 1) THEN
+ UPDATE temporalentityattrinstance SET static = true WHERE internalid = f_internalid;
+ END IF;
+ RETURN OLD;
+ END;
+$_$ LANGUAGE plpgsql;
+
+CREATE TRIGGER temporalentityattrinstance_update_static AFTER DELETE ON temporalentityattrinstance
+ FOR EACH ROW EXECUTE PROCEDURE temporalentityattrinstance_update_static();
+
+-- create indexes for performance
+
+CREATE INDEX i_temporalentity_type ON temporalentity (type);
+
+CREATE INDEX i_temporalentityattrinstance_data ON temporalentityattrinstance USING GIN (data);
+
+COMMIT;
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190611.1__sysattrs.sql b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190611.1__sysattrs.sql
new file mode 100644
index 0000000000000000000000000000000000000000..3e24ff4111eb19227e14f1b3a2b90a2d863f337e
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190611.1__sysattrs.sql
@@ -0,0 +1,7 @@
+-- entity
+ALTER TABLE entity ALTER data DROP NOT NULL;
+ALTER TABLE entity ADD data_without_sysattrs JSONB;
+
+-- csource
+ALTER TABLE csource ALTER data DROP NOT NULL;
+ALTER TABLE csource ADD data_without_sysattrs JSONB;
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190611.2__extract_functions_optimization.sql b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190611.2__extract_functions_optimization.sql
new file mode 100644
index 0000000000000000000000000000000000000000..4ab6fe3c66556cde740eaf56948e95d4556fa7c9
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190611.2__extract_functions_optimization.sql
@@ -0,0 +1,121 @@
+CREATE OR REPLACE FUNCTION entity_extract_jsonb_fields() RETURNS trigger AS $_$
+ BEGIN
+ IF TG_OP = 'INSERT' OR NEW.data <> OLD.data THEN -- do not reprocess if it is just an update on another column
+ -- is any validation needed?
+ NEW.type = NEW.data#>>'{@type,0}';
+ NEW.createdat = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/createdAt,0,@value}')::TIMESTAMP;
+ NEW.modifiedat = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/modifiedAt,0,@value}')::TIMESTAMP;
+
+ IF (NEW.data@>'{"https://uri.etsi.org/ngsi-ld/location": [ {"@type": [ "https://uri.etsi.org/ngsi-ld/GeoProperty" ] } ] }') THEN
+ NEW.location = ST_SetSRID(ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/location,0,https://uri.etsi.org/ngsi-ld/hasValue,0,@value}' ), 4326);
+ ELSE
+ NEW.location = NULL;
+ END IF;
+ IF (NEW.data@>'{"https://uri.etsi.org/ngsi-ld/observationSpace": [ {"@type": [ "https://uri.etsi.org/ngsi-ld/GeoProperty" ] }] }') THEN
+ NEW.observationSpace = ST_SetSRID( ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/observationSpace,0,https://uri.etsi.org/ngsi-ld/hasValue,0,@value}' ), 4326);
+ ELSE
+ NEW.observationSpace = NULL;
+ END IF;
+ IF (NEW.data@>'{"https://uri.etsi.org/ngsi-ld/operationSpace": [ {"@type": [ "https://uri.etsi.org/ngsi-ld/GeoProperty" ] } ] }') THEN
+ NEW.operationSpace = ST_SetSRID( ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/operationSpace,0,https://uri.etsi.org/ngsi-ld/hasValue,0,@value}' ), 4326);
+ ELSE
+ NEW.operationSpace = NULL;
+ END IF;
+ END IF;
+
+ RETURN NEW;
+ END;
+$_$ LANGUAGE plpgsql;
+
+
+
+
+-- trigger to automatically extract pre-defined ngsi-ld members and store them in regular fields (for query performance)
+CREATE OR REPLACE FUNCTION csource_extract_jsonb_fields() RETURNS trigger AS $_$
+DECLARE
+ l_rec RECORD;
+ l_entityinfo_count INTEGER;
+ l_attributeinfo_count INTEGER;
+BEGIN
+ IF TG_OP = 'INSERT' OR NEW.data <> OLD.data THEN -- do not reprocess if it is just an update on another column
+ NEW.type = NEW.data#>>'{@type,0}';
+ NEW.name = NEW.data#>>'{https://uri.etsi.org/ngsi-ld/name,0,@value}';
+ NEW.description = NEW.data#>>'{https://uri.etsi.org/ngsi-ld/description,0,@value}';
+ NEW.timestamp_start = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/timestamp,0,https://uri.etsi.org/ngsi-ld/start,0,@value}')::TIMESTAMP;
+ NEW.timestamp_end = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/timestamp,0,https://uri.etsi.org/ngsi-ld/end,0,@value}')::TIMESTAMP;
+ NEW.location = ST_SetSRID(ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/location,0,@value}' ), 4326);
+ NEW.expires = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/expires,0,@value}')::TIMESTAMP;
+ NEW.endpoint = NEW.data#>>'{https://uri.etsi.org/ngsi-ld/endpoint,0,@value}';
+ NEW.internal = COALESCE((NEW.data#>>'{https://uri.etsi.org/ngsi-ld/internal,0,@value}')::BOOLEAN, FALSE);
+
+ NEW.has_registrationinfo_with_attrs_only = false;
+ NEW.has_registrationinfo_with_entityinfo_only = false;
+
+ FOR l_rec IN SELECT value FROM jsonb_array_elements(NEW.data#>'{https://uri.etsi.org/ngsi-ld/information}')
+ LOOP
+ SELECT INTO l_entityinfo_count count(*) FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/entities}' );
+ SELECT INTO l_attributeinfo_count count(*) FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/properties}' );
+ SELECT INTO l_attributeinfo_count count(*)+l_attributeinfo_count FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/relationships}' );
+
+ IF (NEW.has_registrationinfo_with_attrs_only = false) THEN
+ NEW.has_registrationinfo_with_attrs_only = (l_entityinfo_count = 0 AND l_attributeinfo_count > 0);
+ END IF;
+
+ IF (NEW.has_registrationinfo_with_entityinfo_only = false) THEN
+ NEW.has_registrationinfo_with_entityinfo_only = (l_entityinfo_count > 0 AND l_attributeinfo_count = 0);
+ END IF;
+ END LOOP;
+ END IF;
+
+ RETURN NEW;
+END;
+$_$ LANGUAGE plpgsql;
+
+
+
+-- trigger to automatically extract pre-defined ngsi-ld members and store them in information table
+CREATE OR REPLACE FUNCTION csource_extract_jsonb_fields_to_information_table() RETURNS trigger AS $_$
+DECLARE
+ l_rec RECORD;
+ l_group_id csourceinformation.group_id%TYPE;
+BEGIN
+
+ IF TG_OP = 'INSERT' OR NEW.data <> OLD.data THEN -- do not reprocess if it is just an update on another column
+
+ IF TG_OP = 'UPDATE' THEN
+ DELETE FROM csourceinformation where csource_id = NEW.id;
+ END IF;
+
+ FOR l_rec IN SELECT value FROM jsonb_array_elements(NEW.data#>'{https://uri.etsi.org/ngsi-ld/information}')
+ LOOP
+ -- RAISE NOTICE '%', rec.value;
+ SELECT nextval('csourceinformation_group_id_seq') INTO l_group_id;
+
+ -- id takes precedence over idPattern. so, only store idPattern if id is empty. this makes queries much easier/faster.
+ INSERT INTO csourceinformation (csource_id, group_id, entity_id, entity_type, entity_idpattern)
+ SELECT NEW.id,
+ l_group_id,
+ value#>>'{@id}',
+ value#>>'{@type,0}',
+ CASE WHEN value#>>'{@id}' IS NULL THEN value#>>'{https://uri.etsi.org/ngsi-ld/idPattern,0,@value}' END
+ FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/entities}');
+
+ INSERT INTO csourceinformation (csource_id, group_id, property_id)
+ SELECT NEW.id,
+ l_group_id,
+ value#>>'{@id}'
+ FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/properties}');
+
+ INSERT INTO csourceinformation (csource_id, group_id, relationship_id)
+ SELECT NEW.id,
+ l_group_id,
+ value#>>'{@id}'
+ FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/relationships}');
+
+ END LOOP;
+
+ END IF;
+
+ RETURN NEW;
+END;
+$_$ LANGUAGE plpgsql;
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190703.1__keyvalues.sql b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190703.1__keyvalues.sql
new file mode 100644
index 0000000000000000000000000000000000000000..fae8d021431fadf39732600f684e69f5aa43447a
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190703.1__keyvalues.sql
@@ -0,0 +1 @@
+ALTER TABLE entity ADD kvdata JSONB;
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190704.1__extract_functions_bugfix.sql b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190704.1__extract_functions_bugfix.sql
new file mode 100644
index 0000000000000000000000000000000000000000..13b2ff5ba21ce08cd58465e6b7b9240c592f6f5c
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/db/migration/V20190704.1__extract_functions_bugfix.sql
@@ -0,0 +1,131 @@
+CREATE OR REPLACE FUNCTION entity_extract_jsonb_fields() RETURNS trigger AS $_$
+ BEGIN
+ -- do not reprocess if it is just an update on another column
+ IF (TG_OP = 'INSERT' AND NEW.data IS NOT NULL) OR
+ (TG_OP = 'UPDATE' AND OLD.data IS NULL AND NEW.data IS NOT NULL) OR
+ (TG_OP = 'UPDATE' AND OLD.data IS NOT NULL AND NEW.data IS NULL) OR
+ (TG_OP = 'UPDATE' AND OLD.data IS NOT NULL AND NEW.data IS NOT NULL AND OLD.data <> NEW.data) THEN
+ -- is any validation needed?
+ NEW.type = NEW.data#>>'{@type,0}';
+ NEW.createdat = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/createdAt,0,@value}')::TIMESTAMP;
+ NEW.modifiedat = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/modifiedAt,0,@value}')::TIMESTAMP;
+
+ IF (NEW.data@>'{"https://uri.etsi.org/ngsi-ld/location": [ {"@type": [ "https://uri.etsi.org/ngsi-ld/GeoProperty" ] } ] }') THEN
+ NEW.location = ST_SetSRID(ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/location,0,https://uri.etsi.org/ngsi-ld/hasValue,0,@value}' ), 4326);
+ ELSE
+ NEW.location = NULL;
+ END IF;
+ IF (NEW.data@>'{"https://uri.etsi.org/ngsi-ld/observationSpace": [ {"@type": [ "https://uri.etsi.org/ngsi-ld/GeoProperty" ] }] }') THEN
+ NEW.observationSpace = ST_SetSRID( ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/observationSpace,0,https://uri.etsi.org/ngsi-ld/hasValue,0,@value}' ), 4326);
+ ELSE
+ NEW.observationSpace = NULL;
+ END IF;
+ IF (NEW.data@>'{"https://uri.etsi.org/ngsi-ld/operationSpace": [ {"@type": [ "https://uri.etsi.org/ngsi-ld/GeoProperty" ] } ] }') THEN
+ NEW.operationSpace = ST_SetSRID( ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/operationSpace,0,https://uri.etsi.org/ngsi-ld/hasValue,0,@value}' ), 4326);
+ ELSE
+ NEW.operationSpace = NULL;
+ END IF;
+ END IF;
+
+ RETURN NEW;
+ END;
+$_$ LANGUAGE plpgsql;
+
+
+
+
+-- trigger to automatically extract pre-defined ngsi-ld members and store them in regular fields (for query performance)
+CREATE OR REPLACE FUNCTION csource_extract_jsonb_fields() RETURNS trigger AS $_$
+DECLARE
+ l_rec RECORD;
+ l_entityinfo_count INTEGER;
+ l_attributeinfo_count INTEGER;
+BEGIN
+ IF (TG_OP = 'INSERT' AND NEW.data IS NOT NULL) OR
+ (TG_OP = 'UPDATE' AND OLD.data IS NULL AND NEW.data IS NOT NULL) OR
+ (TG_OP = 'UPDATE' AND OLD.data IS NOT NULL AND NEW.data IS NULL) OR
+ (TG_OP = 'UPDATE' AND OLD.data IS NOT NULL AND NEW.data IS NOT NULL AND OLD.data <> NEW.data) THEN
+ NEW.type = NEW.data#>>'{@type,0}';
+ NEW.name = NEW.data#>>'{https://uri.etsi.org/ngsi-ld/name,0,@value}';
+ NEW.description = NEW.data#>>'{https://uri.etsi.org/ngsi-ld/description,0,@value}';
+ NEW.timestamp_start = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/timestamp,0,https://uri.etsi.org/ngsi-ld/start,0,@value}')::TIMESTAMP;
+ NEW.timestamp_end = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/timestamp,0,https://uri.etsi.org/ngsi-ld/end,0,@value}')::TIMESTAMP;
+ NEW.location = ST_SetSRID(ST_GeomFromGeoJSON( NEW.data#>>'{https://uri.etsi.org/ngsi-ld/location,0,@value}' ), 4326);
+ NEW.expires = (NEW.data#>>'{https://uri.etsi.org/ngsi-ld/expires,0,@value}')::TIMESTAMP;
+ NEW.endpoint = NEW.data#>>'{https://uri.etsi.org/ngsi-ld/endpoint,0,@value}';
+ NEW.internal = COALESCE((NEW.data#>>'{https://uri.etsi.org/ngsi-ld/internal,0,@value}')::BOOLEAN, FALSE);
+
+ NEW.has_registrationinfo_with_attrs_only = false;
+ NEW.has_registrationinfo_with_entityinfo_only = false;
+
+ FOR l_rec IN SELECT value FROM jsonb_array_elements(NEW.data#>'{https://uri.etsi.org/ngsi-ld/information}')
+ LOOP
+ SELECT INTO l_entityinfo_count count(*) FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/entities}' );
+ SELECT INTO l_attributeinfo_count count(*) FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/properties}' );
+ SELECT INTO l_attributeinfo_count count(*)+l_attributeinfo_count FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/relationships}' );
+
+ IF (NEW.has_registrationinfo_with_attrs_only = false) THEN
+ NEW.has_registrationinfo_with_attrs_only = (l_entityinfo_count = 0 AND l_attributeinfo_count > 0);
+ END IF;
+
+ IF (NEW.has_registrationinfo_with_entityinfo_only = false) THEN
+ NEW.has_registrationinfo_with_entityinfo_only = (l_entityinfo_count > 0 AND l_attributeinfo_count = 0);
+ END IF;
+ END LOOP;
+ END IF;
+
+ RETURN NEW;
+END;
+$_$ LANGUAGE plpgsql;
+
+
+
+-- trigger to automatically extract pre-defined ngsi-ld members and store them in information table
+CREATE OR REPLACE FUNCTION csource_extract_jsonb_fields_to_information_table() RETURNS trigger AS $_$
+DECLARE
+ l_rec RECORD;
+ l_group_id csourceinformation.group_id%TYPE;
+BEGIN
+
+ IF (TG_OP = 'INSERT' AND NEW.data IS NOT NULL) OR
+ (TG_OP = 'UPDATE' AND OLD.data IS NULL AND NEW.data IS NOT NULL) OR
+ (TG_OP = 'UPDATE' AND OLD.data IS NOT NULL AND NEW.data IS NULL) OR
+ (TG_OP = 'UPDATE' AND OLD.data IS NOT NULL AND NEW.data IS NOT NULL AND OLD.data <> NEW.data) THEN
+
+ IF TG_OP = 'UPDATE' THEN
+ DELETE FROM csourceinformation where csource_id = NEW.id;
+ END IF;
+
+ FOR l_rec IN SELECT value FROM jsonb_array_elements(NEW.data#>'{https://uri.etsi.org/ngsi-ld/information}')
+ LOOP
+ -- RAISE NOTICE '%', rec.value;
+ SELECT nextval('csourceinformation_group_id_seq') INTO l_group_id;
+
+ -- id takes precedence over idPattern. so, only store idPattern if id is empty. this makes queries much easier/faster.
+ INSERT INTO csourceinformation (csource_id, group_id, entity_id, entity_type, entity_idpattern)
+ SELECT NEW.id,
+ l_group_id,
+ value#>>'{@id}',
+ value#>>'{@type,0}',
+ CASE WHEN value#>>'{@id}' IS NULL THEN value#>>'{https://uri.etsi.org/ngsi-ld/idPattern,0,@value}' END
+ FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/entities}');
+
+ INSERT INTO csourceinformation (csource_id, group_id, property_id)
+ SELECT NEW.id,
+ l_group_id,
+ value#>>'{@id}'
+ FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/properties}');
+
+ INSERT INTO csourceinformation (csource_id, group_id, relationship_id)
+ SELECT NEW.id,
+ l_group_id,
+ value#>>'{@id}'
+ FROM jsonb_array_elements( l_rec.value#>'{https://uri.etsi.org/ngsi-ld/relationships}');
+
+ END LOOP;
+
+ END IF;
+
+ RETURN NEW;
+END;
+$_$ LANGUAGE plpgsql;
\ No newline at end of file
diff --git a/scorpio-broker/AllInOneRunner/src/main/resources/ngsi-ld-core-context.jsonld b/scorpio-broker/AllInOneRunner/src/main/resources/ngsi-ld-core-context.jsonld
new file mode 100644
index 0000000000000000000000000000000000000000..fb43242d5a69cf2b5c0e7f22a45e85c1750f1368
--- /dev/null
+++ b/scorpio-broker/AllInOneRunner/src/main/resources/ngsi-ld-core-context.jsonld
@@ -0,0 +1,158 @@
+{
+ "@context": {
+ "ngsi-ld": "https://uri.etsi.org/ngsi-ld/",
+ "id": "@id",
+ "type": "@type",
+ "value": "https://uri.etsi.org/ngsi-ld/hasValue",
+ "object": {
+ "@id": "https://uri.etsi.org/ngsi-ld/hasObject",
+ "@type":"@id"
+ },
+ "Property": "https://uri.etsi.org/ngsi-ld/Property",
+ "Relationship": "https://uri.etsi.org/ngsi-ld/Relationship",
+ "DateTime": "https://uri.etsi.org/ngsi-ld/DateTime",
+ "Date": "https://uri.etsi.org/ngsi-ld/Date",
+ "Time": "https://uri.etsi.org/ngsi-ld/Time",
+ "createdAt": {
+ "@id": "https://uri.etsi.org/ngsi-ld/createdAt",
+ "@type": "DateTime"
+ },
+ "modifiedAt": {
+ "@id": "https://uri.etsi.org/ngsi-ld/modifiedAt",
+ "@type": "DateTime"
+ },
+ "observedAt": {
+ "@id": "https://uri.etsi.org/ngsi-ld/observedAt",
+ "@type": "DateTime"
+ },
+ "datasetId": {
+ "@id": "https://uri.etsi.org/ngsi-ld/datasetId",
+ "@type": "@id"
+ },
+ "instanceId": {
+ "@id": "https://uri.etsi.org/ngsi-ld/instanceId",
+ "@type": "@id"
+ },
+ "unitCode": "https://uri.etsi.org/ngsi-ld/unitCode",
+ "location": "https://uri.etsi.org/ngsi-ld/location",
+ "observationSpace": "https://uri.etsi.org/ngsi-ld/observationSpace",
+ "operationSpace": "https://uri.etsi.org/ngsi-ld/operationSpace",
+ "GeoProperty": "https://uri.etsi.org/ngsi-ld/GeoProperty",
+ "TemporalProperty": "https://uri.etsi.org/ngsi-ld/TemporalProperty",
+ "ContextSourceRegistration": "https://uri.etsi.org/ngsi-ld/ContextSourceRegistration",
+ "Subscription": "https://uri.etsi.org/ngsi-ld/Subscription",
+ "Notification": "https://uri.etsi.org/ngsi-ld/Notification",
+ "ContextSourceNotification": "https://uri.etsi.org/ngsi-ld/ContextSourceNotification",
+ "title": "https://uri.etsi.org/ngsi-ld/title",
+ "detail": "https://uri.etsi.org/ngsi-ld/detail",
+ "idPattern": "https://uri.etsi.org/ngsi-ld/idPattern",
+ "name": "https://uri.etsi.org/ngsi-ld/name",
+ "description": "https://uri.etsi.org/ngsi-ld/description",
+ "information": "https://uri.etsi.org/ngsi-ld/information",
+ "observationInterval": "https://uri.etsi.org/ngsi-ld/observationInterval",
+ "managementInterval": "https://uri.etsi.org/ngsi-ld/managementInterval",
+ "expires": {
+ "@id": "https://uri.etsi.org/ngsi-ld/expires",
+ "@type": "DateTime"
+ },
+ "endpoint": "https://uri.etsi.org/ngsi-ld/endpoint",
+ "entities": "https://uri.etsi.org/ngsi-ld/entities",
+ "properties": {
+ "@id": "https://uri.etsi.org/ngsi-ld/properties",
+ "@type": "@vocab"
+ },
+ "relationships": {
+ "@id": "https://uri.etsi.org/ngsi-ld/relationships",
+ "@type": "@vocab"
+ },
+ "start": {
+ "@id": "https://uri.etsi.org/ngsi-ld/start",
+ "@type": "DateTime"
+ },
+ "end": {
+ "@id": "https://uri.etsi.org/ngsi-ld/end",
+ "@type": "DateTime"
+ },
+ "watchedAttributes":{
+ "@id": "https://uri.etsi.org/ngsi-ld/watchedAttributes",
+ "@type": "@vocab"
+ },
+ "timeInterval": "https://uri.etsi.org/ngsi-ld/timeInterval",
+ "q": "https://uri.etsi.org/ngsi-ld/q",
+ "geoQ": "https://uri.etsi.org/ngsi-ld/geoQ",
+ "csf": "https://uri.etsi.org/ngsi-ld/csf",
+ "isActive": "https://uri.etsi.org/ngsi-ld/isActive",
+ "notification": "https://uri.etsi.org/ngsi-ld/notification",
+ "status": "https://uri.etsi.org/ngsi-ld/status",
+ "throttling": "https://uri.etsi.org/ngsi-ld/throttling",
+ "temporalQ": "https://uri.etsi.org/ngsi-ld/temporalQ",
+ "geometry": "https://uri.etsi.org/ngsi-ld/geometry",
+ "coordinates": "https://uri.etsi.org/ngsi-ld/coordinates",
+ "georel": "https://uri.etsi.org/ngsi-ld/georel",
+ "geoproperty": "https://uri.etsi.org/ngsi-ld/geoproperty",
+ "attributes": {
+ "@id": "https://uri.etsi.org/ngsi-ld/attributes",
+ "@type": "@vocab"
+ },
+ "format": "https://uri.etsi.org/ngsi-ld/format",
+ "timesSent": "https://uri.etsi.org/ngsi-ld/timesSent",
+ "lastNotification":{
+ "@id": "https://uri.etsi.org/ngsi-ld/lastNotification",
+ "@type": "DateTime"
+ },
+ "lastFailure":{
+ "@id": "https://uri.etsi.org/ngsi-ld/lastFailure",
+ "@type": "DateTime"
+ },
+ "lastSuccess":{
+ "@id": "https://uri.etsi.org/ngsi-ld/lastSuccess",
+ "@type": "DateTime"
+ },
+ "uri": "https://uri.etsi.org/ngsi-ld/uri",
+ "accept": "https://uri.etsi.org/ngsi-ld/accept",
+ "success": {
+ "@id": "https://uri.etsi.org/ngsi-ld/success",
+ "@type": "@id"
+ },
+ "errors": "https://uri.etsi.org/ngsi-ld/errors",
+ "error": "https://uri.etsi.org/ngsi-ld/error",
+ "entityId": {
+ "@id": "https://uri.etsi.org/ngsi-ld/entityId",
+ "@type": "@id"
+ },
+ "updated": "https://uri.etsi.org/ngsi-ld/updated",
+ "unchanged": "https://uri.etsi.org/ngsi-ld/unchanged",
+ "attributeName": "https://uri.etsi.org/ngsi-ld/attributeName",
+ "reason": "https://uri.etsi.org/ngsi-ld/reason",
+ "timerel": "https://uri.etsi.org/ngsi-ld/timerel",
+ "time": {
+ "@id": "https://uri.etsi.org/ngsi-ld/time",
+ "@type": "DateTime"
+ },
+ "endTime": {
+ "@id": "https://uri.etsi.org/ngsi-ld/endTime",
+ "@type": "DateTime"
+ },
+ "timeproperty": "https://uri.etsi.org/ngsi-ld/timeproperty",
+ "subscriptionId": {
+ "@id": "https://uri.etsi.org/ngsi-ld/subscriptionId",
+ "@type": "@id"
+ },
+ "notifiedAt":{
+ "@id": "https://uri.etsi.org/ngsi-ld/notifiedAt",
+ "@type": "DateTime"
+ },
+ "data": "https://uri.etsi.org/ngsi-ld/data",
+ "triggerReason": "https://uri.etsi.org/ngsi-ld/triggerReason",
+ "values":{
+ "@id": "https://uri.etsi.org/ngsi-ld/hasValues",
+ "@container": "@list"
+ },
+ "objects":{
+ "@id": "https://uri.etsi.org/ngsi-ld/hasObjects",
+ "@type": "@id",
+ "@container": "@list"
+ },
+ "@vocab": "https://uri.etsi.org/ngsi-ld/default-context/"
+ }
+}
diff --git a/scorpio-broker/BrokerParent/.gitignore b/scorpio-broker/BrokerParent/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..a1c3ab4d08c0f9f91918f21c730272a4711885e8
--- /dev/null
+++ b/scorpio-broker/BrokerParent/.gitignore
@@ -0,0 +1,4 @@
+/target/
+/.settings/
+.classpath
+.project
diff --git a/scorpio-broker/BrokerParent/pom.xml b/scorpio-broker/BrokerParent/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..671bff752c305b8caaa21e14ff579d5cd98c1f5b
--- /dev/null
+++ b/scorpio-broker/BrokerParent/pom.xml
@@ -0,0 +1,64 @@
+
+ 4.0.0
+
+ BrokerParent
+ pom
+
+ eu.neclab.ngsildbroker
+ OverallParent
+ 1.0.0-SNAPSHOT
+ ../OverallParent
+
+
+
+
+
+
+
+ eu.neclab.ngsildbroker
+ Commons
+ 1.0.0-SNAPSHOT
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
+
+ com.thoughtworks.xstream
+ xstream
+ 1.4.19
+
+
+
+
+
+ default
+
+
+ !skipDefault
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+
+
+
+
+
+
+
+
diff --git a/scorpio-broker/CONTRIBUTING.ja.md b/scorpio-broker/CONTRIBUTING.ja.md
new file mode 100644
index 0000000000000000000000000000000000000000..86ea0e1cdcbc5f64e82efaa81ae3d66fdbc59633
--- /dev/null
+++ b/scorpio-broker/CONTRIBUTING.ja.md
@@ -0,0 +1,9 @@
+## Scorpio Broker ã¸ã®è²¢çŒ®
+
+### Contributor License Agreement ã«ã‚µã‚¤ãƒ³ã‚¢ãƒƒãƒ—
+
+Scorpio Broker ã«è²¢çŒ®ã™ã‚‹ã“ã¨ã«èˆˆå‘³ãŒã‚ã‚‹å ´åˆã¯ã€ä»¥ä¸‹ã«ãƒªã‚¹ãƒˆã•れã¦ã„ã‚‹ Contributor License Agreement をダウンãƒãƒ¼ãƒ‰ã—ã€
+ç½²åã•れãŸå¥‘ç´„ã‚’é›»åメール scorpio-support@listserv.neclab.eu å®›ã«é€ä¿¡ã—ã¦ãã ã•ã„。
+
+- [ScorpioBroker Entity Contributor License Agreement](https://github.com/scorpiobroker/scorpiobroker/blob/development/ScorpioBroker-Entity.pdf)
+- [ScorpioBroker Individual Contributor License Agreement](https://github.com/scorpiobroker/scorpiobroker/blob/development/ScorpioBroker-Individual.pdf)
diff --git a/scorpio-broker/CONTRIBUTING.md b/scorpio-broker/CONTRIBUTING.md
new file mode 100644
index 0000000000000000000000000000000000000000..3210b3ae3851159f9b8a4f30ff85f6181e52b5d4
--- /dev/null
+++ b/scorpio-broker/CONTRIBUTING.md
@@ -0,0 +1,12 @@
+## Contributing to the ScorpioBroker
+
+
+### sign up your contributor agreement license
+
+If you are interested to make any contribution to the ScorpioBroker, please download the contributor license agreement listed below and send us you signed agreement via email scorpio-support@listserv.neclab.eu
+
+
+[ScorpioBroker Entity Contributor License Agreement](https://github.com/scorpiobroker/scorpiobroker/blob/development/ScorpioBroker-Entity.pdf)
+
+
+[ScorpioBroker Individual Contributor License Agreement](https://github.com/scorpiobroker/scorpiobroker/blob/development/ScorpioBroker-Individual.pdf)
diff --git a/scorpio-broker/CREDITS b/scorpio-broker/CREDITS
new file mode 100644
index 0000000000000000000000000000000000000000..264bd7fdf5ebf2a306eb28b951d9ee43bc662c8c
--- /dev/null
+++ b/scorpio-broker/CREDITS
@@ -0,0 +1,12 @@
+# Contributors in no specific order
+
+The scorpio development team:
+Benjamin Hebgen, Parwinder Singh, Everton LuÃs Berz, Martin Bauer, Naveen Singh Bisht, Mohd Adeeb Khan, Kailash Adhikari, Amit Kumar Raghav, Arpit Tayal
+Benjamin Hebgen
+Martin Bauer
+Naveen Singh Bisht
+Amit Kumar Raghav
+Arpit Tayal
+Pawan Kumar
+Michael Schulz
+Jason Fox
diff --git a/scorpio-broker/Commons/.gitignore b/scorpio-broker/Commons/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..a1c3ab4d08c0f9f91918f21c730272a4711885e8
--- /dev/null
+++ b/scorpio-broker/Commons/.gitignore
@@ -0,0 +1,4 @@
+/target/
+/.settings/
+.classpath
+.project
diff --git a/scorpio-broker/Commons/pom.xml b/scorpio-broker/Commons/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..eefc800e233011ad59a6534a6b092c902644d372
--- /dev/null
+++ b/scorpio-broker/Commons/pom.xml
@@ -0,0 +1,74 @@
+
+ 4.0.0
+
+ eu.neclab.ngsildbroker
+ OverallParent
+ 1.0.0-SNAPSHOT
+ ../OverallParent
+
+ Commons
+ 1.0.0-SNAPSHOT
+ jar
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+ org.apache.httpcomponents
+ httpcore
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
+
+
+
+ com.google.code.gson
+ gson
+
+
+ com.github.jsonld-java
+ jsonld-java
+ 0.13.0
+
+
+
+ com.google.guava
+ guava
+ 25.1-jre
+
+
+ org.springframework.cloud
+ spring-cloud-starter-oauth2
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+ org.springframework
+ spring-jdbc
+
+
+
+ com.github.filosganga
+ geogson-core
+ 1.2.21
+
+
+ com.github.filosganga
+ geogson-jts
+ 1.2.21
+
+
+
+
\ No newline at end of file
diff --git a/scorpio-broker/Commons/resources/application.yml b/scorpio-broker/Commons/resources/application.yml
new file mode 100644
index 0000000000000000000000000000000000000000..acf7b8225f67c2435032e5648bfd3ec5fe81607a
--- /dev/null
+++ b/scorpio-broker/Commons/resources/application.yml
@@ -0,0 +1,3 @@
+context:
+ default:
+ url: https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld
\ No newline at end of file
diff --git a/scorpio-broker/Commons/resources/log4j2-spring.xml b/scorpio-broker/Commons/resources/log4j2-spring.xml
new file mode 100644
index 0000000000000000000000000000000000000000..50ea7ce9ef24ae626ac20a7947b5301d38b7066d
--- /dev/null
+++ b/scorpio-broker/Commons/resources/log4j2-spring.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+ %d %p %C{1.} [%t] %m%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/AppConstants.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/AppConstants.java
new file mode 100644
index 0000000000000000000000000000000000000000..c39d8f3bd8f9c26e8f1b85558afc13a38d96a7c9
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/AppConstants.java
@@ -0,0 +1,48 @@
+package eu.neclab.ngsildbroker.commons.constants;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @version 1.0
+ * @date 12-Jul-2018
+ */
+
+public class AppConstants {
+
+ // entities URL for
+ public final static String ENTITES_URL = "/ngsi-ld/v1/entities/";
+ public final static int ENTITIES_URL_ID = 0;
+ // csource URL
+ public final static String CSOURCE_URL = "/ngsi-ld/v1/csourceRegistrations/";
+ public final static int CSOURCE_URL_ID = 1;
+ //history
+ public final static String HISTORY_URL="/ngsi-ld/v1/temporal/entities/";
+ public final static int HISTORY_URL_ID = 2;
+ //subscriptions
+ public final static String SUBSCRIPTIONS_URL="/ngsi-ld/v1/subscriptions/";
+ public final static int SUBSCRIPTIONS_URL_ID = 3;
+ public static final int BATCH_URL_ID = 4;
+ public final static int INTERNAL_CALL_ID = 5;
+
+ public final static String NGB_APPLICATION_JSON="application/json";
+ public final static String NGB_APPLICATION_NQUADS="application/n-quads";
+ public final static String NGB_APPLICATION_JSONLD="application/ld+json";
+ public final static String NGB_APPLICATION_GENERIC ="application/*";
+ public final static String NGB_GENERIC_GENERIC ="*/*";
+
+ //allowed geometry types in queries params.
+ public final static List NGB_ALLOWED_GEOM_LIST=new ArrayList(Arrays.asList("POINT","POLYGON"));
+
+
+ public final static byte[] NULL_BYTES = "null".getBytes();
+ public static final String CORE_CONTEXT_URL_SUFFIX = "ngsi-ld-core-context";
+
+ //constants for swagger
+ public final static String SWAGGER_WEBSITE_LINK = "https://github.com/ScorpioBroker/ScorpioBroker";
+ public final static String SWAGGER_CONTACT_LINK = "https://github.com/ScorpioBroker/ScorpioBroker";
+
+
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/DBConstants.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/DBConstants.java
new file mode 100644
index 0000000000000000000000000000000000000000..977110326d33daf52147363d3449fa58d7374a3d
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/DBConstants.java
@@ -0,0 +1,95 @@
+package eu.neclab.ngsildbroker.commons.constants;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+public class DBConstants {
+
+ public final static String DBTABLE_ENTITY = "entity";
+ public final static String DBTABLE_CSOURCE = "csource";
+ public final static String DBTABLE_CSOURCE_INFO = "csourceinformation";
+ public final static String DBTABLE_TEMPORALENTITY = "temporalentity";
+ public final static String DBTABLE_TEMPORALENTITY_ATTRIBUTEINSTANCE= "temporalentityattrinstance";
+
+ public final static String DBCOLUMN_DATA = "data";
+ public final static String DBCOLUMN_KVDATA = "kvdata";
+ public final static String DBCOLUMN_DATA_WITHOUT_SYSATTRS = "data_without_sysattrs";
+ public final static String DBCOLUMN_ID = "id";
+ public final static String DBCOLUMN_TYPE = "type";
+ public final static String DBCOLUMN_CREATED_AT = "createdat";
+ public final static String DBCOLUMN_MODIFIED_AT = "modifiedat";
+ public final static String DBCOLUMN_OBSERVED_AT = "observedat";
+ public final static String DBCOLUMN_LOCATION = "location";
+ public final static String DBCOLUMN_OBSERVATION_SPACE = "observationspace";
+ public final static String DBCOLUMN_OPERATION_SPACE = "operationspace";
+
+ public final static Map NGSILD_TO_SQL_RESERVED_PROPERTIES_MAPPING = initNgsildToSqlReservedPropertiesMapping();
+
+ public static Map initNgsildToSqlReservedPropertiesMapping() {
+ Map map = new HashMap<>();
+ map.put(NGSIConstants.JSON_LD_ID, DBCOLUMN_ID);
+ map.put(NGSIConstants.JSON_LD_TYPE, DBCOLUMN_TYPE);
+ map.put(NGSIConstants.NGSI_LD_CREATED_AT, DBCOLUMN_CREATED_AT);
+ map.put(NGSIConstants.NGSI_LD_MODIFIED_AT, DBCOLUMN_MODIFIED_AT);
+ // the type conversion (from geometry to geojson text) changes the format (i.e.
+ // remove spaces in geojson), so it is better to use the original data
+// map.put(NGSIConstants.NGSI_LD_LOCATION, DBCOLUMN_LOCATION);
+// map.put(NGSIConstants.NGSI_LD_OBSERVATION_SPACE, DBCOLUMN_OBSERVATION_SPACE);
+// map.put(NGSIConstants.NGSI_LD_OPERATION_SPACE, DBCOLUMN_OPERATION_SPACE);
+ return Collections.unmodifiableMap(map);
+ }
+
+ public final static Map NGSILD_TO_SQL_RESERVED_PROPERTIES_MAPPING_GEO = initNgsildToSqlReservedPropertiesMappingGeo();
+
+ public static Map initNgsildToSqlReservedPropertiesMappingGeo() {
+ Map map = new HashMap<>();
+ map.put(NGSIConstants.NGSI_LD_LOCATION, DBCOLUMN_LOCATION);
+ map.put(NGSIConstants.NGSI_LD_OBSERVATION_SPACE, DBCOLUMN_OBSERVATION_SPACE);
+ map.put(NGSIConstants.NGSI_LD_OPERATION_SPACE, DBCOLUMN_OPERATION_SPACE);
+ return Collections.unmodifiableMap(map);
+ }
+
+ public final static String SQLQUERY_EQUAL = "=";
+ public final static String SQLQUERY_UNEQUAL = "<>";
+ public final static String SQLQUERY_GREATEREQ = ">=";
+ public final static String SQLQUERY_GREATER = ">";
+ public final static String SQLQUERY_LESSEQ = "<=";
+ public final static String SQLQUERY_LESS = "<";
+
+ public final static Map NGSILD_TO_SQL_OPERATORS_MAPPING = initNgsildToSqlOperatorsMapping();
+
+ public static Map initNgsildToSqlOperatorsMapping() {
+ Map map = new HashMap<>();
+ map.put(NGSIConstants.QUERY_EQUAL, SQLQUERY_EQUAL);
+ map.put(NGSIConstants.QUERY_UNEQUAL, SQLQUERY_UNEQUAL);
+ map.put(NGSIConstants.QUERY_GREATEREQ, SQLQUERY_GREATEREQ);
+ map.put(NGSIConstants.QUERY_GREATER, SQLQUERY_GREATER);
+ map.put(NGSIConstants.QUERY_LESSEQ, SQLQUERY_LESSEQ);
+ map.put(NGSIConstants.QUERY_LESS, SQLQUERY_LESS);
+ return Collections.unmodifiableMap(map);
+ }
+
+ public final static String POSTGIS_NEAR = "ST_DWithin";
+ public final static String POSTGIS_WITHIN = "ST_Within";
+ public final static String POSTGIS_CONTAINS = "ST_Contains";
+ public final static String POSTGIS_OVERLAPS = "ST_Overlaps";
+ public final static String POSTGIS_INTERSECTS = "ST_Intersects";
+ public final static String POSTGIS_EQUALS = "ST_Equals";
+ public final static String POSTGIS_DISJOINT = "ST_Disjoint";
+
+ public final static Map NGSILD_TO_POSTGIS_GEO_OPERATORS_MAPPING = initNgsildToPostgisGeoOperatorsMapping();
+
+ public static Map initNgsildToPostgisGeoOperatorsMapping() {
+ Map map = new HashMap<>();
+ map.put(NGSIConstants.GEO_REL_NEAR, POSTGIS_NEAR);
+ map.put(NGSIConstants.GEO_REL_WITHIN, POSTGIS_WITHIN);
+ map.put(NGSIConstants.GEO_REL_CONTAINS, POSTGIS_CONTAINS);
+ map.put(NGSIConstants.GEO_REL_OVERLAPS, POSTGIS_OVERLAPS);
+ map.put(NGSIConstants.GEO_REL_INTERSECTS, POSTGIS_INTERSECTS);
+ map.put(NGSIConstants.GEO_REL_EQUALS, POSTGIS_EQUALS);
+ map.put(NGSIConstants.GEO_REL_DISJOINT, POSTGIS_DISJOINT);
+ return Collections.unmodifiableMap(map);
+ }
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/KafkaConstants.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/KafkaConstants.java
new file mode 100644
index 0000000000000000000000000000000000000000..43f7dc179f8f4cea45e030950fb2d015c1cacf0c
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/KafkaConstants.java
@@ -0,0 +1,20 @@
+package eu.neclab.ngsildbroker.commons.constants;
+
+public interface KafkaConstants {
+
+ public static final String ENTITY_TOPIC = "ENTITY";
+ public static final String QUERY_TOPIC = "QUERY";
+ public static final String QUERY_RESULT_TOPIC = "QUERYRESULT";
+ public static final String CREATE_TOPIC = "CREATE";
+ public static final String UPDATE_TOPIC = "UPDATE";
+ public static final String APPEND_TOPIC = "APPEND";
+ public static final String DELETE_TOPIC = "DELETE";
+ public static final String SUBSCRIPTIONS_TOPIC = "SUBSCRIPTIONS";
+ public static final String CSOURCE_SUBSCRIPTIONS_TOPIC = "CSOURCE_SUBSCRIPTIONS";
+ public static final String ATCONTEXT_TOPIC = "ATCONTEXT";
+ public static final String PAGINATION_TOPIC = "PAGINATION";
+
+
+
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/NGSIConstants.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/NGSIConstants.java
new file mode 100644
index 0000000000000000000000000000000000000000..b2c9f3a4489c28a431cc4e5600621657361e7a9e
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/constants/NGSIConstants.java
@@ -0,0 +1,218 @@
+package eu.neclab.ngsildbroker.commons.constants;
+
+import java.util.HashMap;
+import java.util.List;
+
+import java.util.Arrays;
+
+public interface NGSIConstants {
+ public final static String GEO_REL_TYPE = "type";
+ public final static String GEO_REL_REL = "rel";
+ public final static String GEO_REL_NEAR = "near";
+ public final static String GEO_REL_WITHIN = "within";
+ public final static String GEO_REL_CONTAINS = "contains";
+ public final static String GEO_REL_INTERSECTS = "intersects";
+ public final static String GEO_REL_EQUALS = "equals";
+ public final static String GEO_REL_DISJOINT = "disjoint";
+ public final static String GEO_REL_OVERLAPS = "overlaps";
+ public final static String GEO_REL_MAX_DISTANCE = "maxDistance";
+ public final static String GEO_REL_MIN_DISTANCE = "minDistance";
+
+ public final static String GEO_TYPE_POINT = "Point";
+ public final static String GEO_TYPE_POLYGON = "Polygon";
+ public final static String GEO_TYPE_LINESTRING = "LineString";
+ public final static String GEO_TYPE_MULTI_POLYGON = "MultiPolygon";
+
+ public final static String TIME_REL_BEFORE = "before";
+ public final static String TIME_REL_AFTER = "after";
+ public final static String TIME_REL_BETWEEN = "between";
+
+ public final static String CSOURCE_INFORMATION = "information";
+ public final static String CSOURCE_DESCRIPTION = "description";
+ public final static String CSOURCE_ENDPOINT = "endpoint";
+ public final static String CSOURCE_EXPIRES = "expires";
+ public final static String CSOURCE_NAME = "name";
+ public final static String CSOURCE_TYPE = "type";
+ public final static String CSOURCE_TIMESTAMP = "timestamp";
+ public final static String CSOURCE_COORDINATES = "coordinates";
+
+ public final static String OBJECT = "object";
+ public final static String JSON_LD_ID = "@id";
+ public final static String JSON_LD_TYPE = "@type";
+ public final static String JSON_LD_VALUE = "@value";
+ public final static String JSON_LD_CONTEXT = "@context";
+ public final static String NGSI_LD_DEFAULT_PREFIX = "https://uri.etsi.org/ngsi-ld/default-context/";
+ public final static String NGSI_LD_RELATIONSHIP = "https://uri.etsi.org/ngsi-ld/Relationship";
+ public final static String NGSI_LD_PROPERTY = "https://uri.etsi.org/ngsi-ld/Property";
+ public final static String NGSI_LD_HAS_VALUE = "https://uri.etsi.org/ngsi-ld/hasValue";
+ public final static String NGSI_LD_HAS_OBJECT = "https://uri.etsi.org/ngsi-ld/hasObject";
+ public final static String NGSI_LD_COORDINATES = "https://uri.etsi.org/ngsi-ld/coordinates";
+ public final static String NGSI_LD_GEOPROPERTY = "https://uri.etsi.org/ngsi-ld/GeoProperty";
+ public final static String NGSI_LD_GEOPROPERTY_SHORT = "GeoProperty";
+ public final static String NGSI_LD_LOCATION = "https://uri.etsi.org/ngsi-ld/location";
+ public final static String NGSI_LD_LOCATION_SHORT = "location";
+ public final static String NGSI_LD_CREATED_AT = "https://uri.etsi.org/ngsi-ld/createdAt";
+ public final static String NGSI_LD_MODIFIED_AT = "https://uri.etsi.org/ngsi-ld/modifiedAt";
+ public final static String NGSI_LD_OBSERVED_AT = "https://uri.etsi.org/ngsi-ld/observedAt";
+ public final static String NGSI_LD_OBSERVATION_SPACE = "https://uri.etsi.org/ngsi-ld/observationSpace";
+ public final static String NGSI_LD_OPERATION_SPACE = "https://uri.etsi.org/ngsi-ld/operationSpace";
+ public final static String NGSI_LD_ATTRIBUTES = "https://uri.etsi.org/ngsi-ld/attributes";
+ public final static String NGSI_LD_DATE_TIME = "https://uri.etsi.org/ngsi-ld/DateTime";
+ public final static String NGSI_LD_DATE = "https://uri.etsi.org/ngsi-ld/Date";
+ public final static String NGSI_LD_TIME = "https://uri.etsi.org/ngsi-ld/Time";
+ public final static String NGSI_LD_INFORMATION = "https://uri.etsi.org/ngsi-ld/information";
+ public final static String NGSI_LD_RELATIONSHIPS = "https://uri.etsi.org/ngsi-ld/relationships";
+ public final static String NGSI_LD_PROPERTIES = "https://uri.etsi.org/ngsi-ld/properties";
+ public final static String NGSI_LD_INSTANCE_ID = "https://uri.etsi.org/ngsi-ld/instanceId";
+
+ public final static String NGSI_LD_ID_PATTERN = "https://uri.etsi.org/ngsi-ld/idPattern";
+ public final static String NGSI_LD_ENTITIES = "https://uri.etsi.org/ngsi-ld/entities";
+ public final static String NGSI_LD_GEOMETRY = "https://uri.etsi.org/ngsi-ld/geometry";
+ public final static String NGSI_LD_GEO_QUERY = "https://uri.etsi.org/ngsi-ld/geoQ";
+ public final static String NGSI_LD_ACCEPT = "https://uri.etsi.org/ngsi-ld/accept";
+ public final static String NGSI_LD_URI = "https://uri.etsi.org/ngsi-ld/uri";
+ public final static String NGSI_LD_ENDPOINT = "https://uri.etsi.org/ngsi-ld/endpoint";
+ public final static String NGSI_LD_FORMAT = "https://uri.etsi.org/ngsi-ld/format";
+ public final static String NGSI_LD_NOTIFICATION = "https://uri.etsi.org/ngsi-ld/notification";
+ public final static String NGSI_LD_QUERY = "https://uri.etsi.org/ngsi-ld/q";
+ public final static String NGSI_LD_WATCHED_ATTRIBUTES = "https://uri.etsi.org/ngsi-ld/watchedAttributes";
+ public final static String NGSI_LD_WATCHED_ATTRIBUTES_SHORT = "watchedAttributes";
+ public final static String NGSI_LD_ENTITIES_SHORT = "entities";
+ public final static String NGSI_LD_ATTRIBUTES_SHORT = "attributes";
+ public final static String NGSI_LD_NAME = "https://uri.etsi.org/ngsi-ld/name";
+ public final static String NGSI_LD_THROTTLING = "https://uri.etsi.org/ngsi-ld/throttling";
+ public final static String NGSI_LD_TIME_INTERVAL = "https://uri.etsi.org/ngsi-ld/timeInterval";
+ public final static String NGSI_LD_EXPIRES = "https://uri.etsi.org/ngsi-ld/expires";
+ public final static String NGSI_LD_STATUS = "https://uri.etsi.org/ngsi-ld/status";
+ public final static String NGSI_LD_DESCRIPTION = "https://uri.etsi.org/ngsi-ld/description";
+ public final static String NGSI_LD_GEO_REL = "https://uri.etsi.org/ngsi-ld/georel";
+ public final static String NGSI_LD_TIME_STAMP = "https://uri.etsi.org/ngsi-ld/default-context/timestamp";
+ public final static String NGSI_LD_TIMESTAMP_START = "https://uri.etsi.org/ngsi-ld/start";
+ public final static String NGSI_LD_TIMESTAMP_END = "https://uri.etsi.org/ngsi-ld/end";
+ public final static String NGSI_LD_POLYOGN = "https://uri.etsi.org/ngsi-ld/Polygon";
+ public final static String NGSI_LD_POINT = "https://uri.etsi.org/ngsi-ld/Point";
+ public final static String NGSI_LD_LINESTRING = "https://uri.etsi.org/ngsi-ld/LineString";
+ public final static String NGSI_LD_SUBSCRIPTION_ID = "https://uri.etsi.org/ngsi-ld/subscriptionId";
+ public final static String NGSI_LD_NOTIFIED_AT = "https://uri.etsi.org/ngsi-ld/notifiedAt";
+ public final static String NGSI_LD_DATA = "https://uri.etsi.org/ngsi-ld/data";
+ public final static String NGSI_LD_INTERNAL = "https://uri.etsi.org/ngsi-ld/internal";
+ public final static String NGSI_LD_CSOURCE_REGISTRATION = "https://uri.etsi.org/ngsi-ld/ContextSourceRegistration";
+ public final static String NGSI_LD_CSOURCE_REGISTRATION_SHORT = "ContextSourceRegistration";
+ public final static String NGSI_LD_SUBSCRIPTION = "https://uri.etsi.org/ngsi-ld/Subscription";
+ public final static String NGSI_LD_SUBSCRIPTION_SHORT = "Subscription";
+ public final static String NGSI_LD_LAST_NOTIFICATION = "https://uri.etsi.org/ngsi-ld/lastNotification";
+ public final static String NGSI_LD_LAST_FAILURE = "https://uri.etsi.org/ngsi-ld/lastFailure ";
+ public final static String NGSI_LD_LAST_SUCCESS = "https://uri.etsi.org/ngsi-ld/lastSuccess";
+ public final static String NGSI_LD_TIMES_SEND = "https://uri.etsi.org/ngsi-ld/timesSent";
+ public final static String NGSI_LD_UNIT_CODE = "https://uri.etsi.org/ngsi-ld/unitCode";
+ public final static String NGSI_LD_DATA_SET_ID = "https://uri.etsi.org/ngsi-ld/datasetId";
+ public final static String NGSI_LD_IS_ACTIVE = "https://uri.etsi.org/ngsi-ld/isActive";
+ // IMPORTANT! DO NOT MESS UP THIS ORDER!!! ONLY APPEND ON THE END NEW STUFF
+ public final static String[] NGSI_LD_PAYLOAD_KEYS = { JSON_LD_ID, JSON_LD_TYPE, JSON_LD_CONTEXT,
+ NGSI_LD_DEFAULT_PREFIX, NGSI_LD_HAS_VALUE, NGSI_LD_HAS_OBJECT, JSON_LD_VALUE, NGSI_LD_LOCATION,
+ NGSI_LD_CREATED_AT, NGSI_LD_MODIFIED_AT, NGSI_LD_OBSERVED_AT, NGSI_LD_OBSERVATION_SPACE,
+ NGSI_LD_OPERATION_SPACE, NGSI_LD_ATTRIBUTES, NGSI_LD_INFORMATION, NGSI_LD_INSTANCE_ID, NGSI_LD_COORDINATES,
+ NGSI_LD_ID_PATTERN, NGSI_LD_ENTITIES, NGSI_LD_GEOMETRY, NGSI_LD_GEO_QUERY, NGSI_LD_ACCEPT, NGSI_LD_URI,
+ NGSI_LD_ENDPOINT, NGSI_LD_FORMAT, NGSI_LD_NOTIFICATION, NGSI_LD_QUERY, NGSI_LD_WATCHED_ATTRIBUTES,
+ NGSI_LD_NAME, NGSI_LD_THROTTLING, NGSI_LD_TIME_INTERVAL, NGSI_LD_EXPIRES, NGSI_LD_STATUS,
+ NGSI_LD_DESCRIPTION, NGSI_LD_GEO_REL, NGSI_LD_TIME_STAMP, NGSI_LD_TIMESTAMP_START, NGSI_LD_TIMESTAMP_END,
+ NGSI_LD_SUBSCRIPTION_ID, NGSI_LD_NOTIFIED_AT, NGSI_LD_DATA, NGSI_LD_INTERNAL, NGSI_LD_LAST_NOTIFICATION,
+ NGSI_LD_LAST_FAILURE, NGSI_LD_LAST_SUCCESS, NGSI_LD_TIMES_SEND, NGSI_LD_UNIT_CODE, NGSI_LD_DATA_SET_ID };
+
+ public final static String[] NGSI_LD_SUBSCRIPTON_PAYLOAD_KEYS = { JSON_LD_ID, JSON_LD_TYPE, JSON_LD_CONTEXT,
+ NGSI_LD_ENTITIES, NGSI_LD_ID_PATTERN, NGSI_LD_GEO_QUERY, NGSI_LD_NOTIFICATION, NGSI_LD_ATTRIBUTES,
+ NGSI_LD_ENDPOINT, NGSI_LD_ACCEPT, NGSI_LD_URI, NGSI_LD_FORMAT, NGSI_LD_QUERY, NGSI_LD_WATCHED_ATTRIBUTES,
+ NGSI_LD_TIMES_SEND, NGSI_LD_THROTTLING, NGSI_LD_TIME_INTERVAL, NGSI_LD_EXPIRES, NGSI_LD_STATUS,
+ NGSI_LD_DESCRIPTION, NGSI_LD_IS_ACTIVE, NGSI_LD_TIMESTAMP_END, NGSI_LD_TIMESTAMP_START };
+
+ public final static String GEO_JSON_COORDINATES = "coordinates";
+ public final static String GEO_JSON_TYPE = "type";
+
+ public final static String VALUE = "value";
+
+ // Entity validation attribute types
+ public final static String VALID_NGSI_ATTRIBUTE_TYPES = "Relationship,Property,DateTime";
+
+ // url decode format
+ public final static String ENCODE_FORMAT = "UTF-8";
+ // query parameter url
+ public final static String QUERY_URL = "entities/?";
+
+ // query parameter
+ public final static String QUERY_PARAMETER_TYPE = "type";
+ public final static String QUERY_PARAMETER_ID = "id";
+ public final static String QUERY_PARAMETER_IDPATTERN = "idPattern";
+ public final static String QUERY_PARAMETER_ATTRS = "attrs";
+ public final static String QUERY_PARAMETER_QUERY = "q";
+ public final static String QUERY_PARAMETER_GEOREL = "georel";
+ public final static String QUERY_PARAMETER_GEOMETRY = "geometry";
+ public final static String QUERY_PARAMETER_COORDINATES = "coordinates";
+ public final static String QUERY_PARAMETER_GEOPROPERTY = "geoproperty";
+ public final static String QUERY_PARAMETER_TIMEREL = "timerel";
+ public final static String QUERY_PARAMETER_OFFSET = "offset";
+ public final static String QUERY_PARAMETER_LIMIT = "limit";
+ public final static String QUERY_PARAMETER_QTOKEN = "qtoken";
+ public final static String QUERY_PARAMETER_TIME = "time";
+ public final static String QUERY_PARAMETER_ENDTIME = "endTime";
+ public final static String QUERY_PARAMETER_TIMEPROPERTY = "timeproperty";
+ public final static String QUERY_PARAMETER_LOCATION = "location";
+ public final static String QUERY_PARAMETER_CREATED_AT = "createdAt";
+ public final static String QUERY_PARAMETER_MODIFIED_AT = "modifiedAt";
+ public final static String QUERY_PARAMETER_OBSERVED_AT = "observedAt";
+ public final static String QUERY_PARAMETER_UNIT_CODE = "unitCode";
+ public final static String QUERY_PARAMETER_DATA_SET_ID = "datasetId";
+ public final static String QUERY_PARAMETER_OBSERVATION_SPACE = "observationspace";
+ public final static String QUERY_PARAMETER_OPERATION_SPACE = "operationspace";
+ public final static String QUERY_PARAMETER_GEOREL_DISTANCE = "distance";
+ public final static String QUERY_PARAMETER_DEFAULT_GEOPROPERTY = NGSIConstants.NGSI_LD_LOCATION;
+ public final static String QUERY_PARAMETER_DEFAULT_TIMEPROPERTY = NGSIConstants.NGSI_LD_OBSERVED_AT;
+ public final static String QUERY_PARAMETER_OPTIONS = "options";
+ public final static String QUERY_PARAMETER_OPTIONS_SYSATTRS = "sysAttrs";
+ public final static String QUERY_PARAMETER_OPTIONS_KEYVALUES = "keyValues";
+ public final static String QUERY_PARAMETER_OPTIONS_COMPRESS = "compress";
+ public final static String QUERY_PARAMETER_OPTIONS_TEMPORALVALUES = "temporalValues";
+
+ public final static String QUERY_EQUAL = "==";
+ public final static String QUERY_UNEQUAL = "!=";
+ public final static String QUERY_GREATEREQ = ">=";
+ public final static String QUERY_GREATER = ">";
+ public final static String QUERY_LESSEQ = "<=";
+ public final static String QUERY_LESS = "<";
+ public final static String QUERY_PATTERNOP = "~=";
+ public final static String QUERY_NOTPATTERNOP = "!~=";
+ // public final static String CHECK_QUERY_STRING_URI = "/";
+
+ public static final String ALLOWED_IN_DEFAULT_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss[.SSSSSS][.SSSSS][.SSSS][.SSS][.SS][.S]'Z'";
+ public static final String ALLOWED_OUT_DEFAULT_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss[.SSSSSS]'Z'";
+ public static final String DEFAULT_FORGIVING_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
+ public static final String HEADER_REL_LDCONTEXT = "http://www.w3.org/ns/json-ld#context";
+
+ public static final HashMap HTTP_CODE_2_NGSI_ERROR = new HashMap();
+ public static final List ALLOWED_GEOMETRIES = Arrays.asList("Point", "MultiPoint", "LineString",
+ "MultiLineString", "Polygon", "MultiPolygon");
+ public static final List ALLOWED_GEOREL = Arrays.asList("near", "equals", "disjoint", "intersects",
+ "within", "contains", "overlaps");
+ public static final List SPECIAL_PROPERTIES = Arrays.asList(NGSI_LD_CREATED_AT, NGSI_LD_OBSERVED_AT,
+ NGSI_LD_MODIFIED_AT, NGSI_LD_DATA_SET_ID, NGSI_LD_UNIT_CODE);
+ public static final String MQTT_QOS = "mqtt_qos";
+ public static final String MQTT_VERSION = "mqtt_version";
+ public static final String DEFAULT_DATA_SET_ID = "https://uri.etsi.org/ngsi-ld/default-data-set-id";
+ public static final String NGSI_LD_ENDPOINT_REGEX = ".*\\\"https\\:\\/\\/uri\\.etsi\\.org\\/ngsi-ld\\/endpoint\\\"\\W*\\:\\W*\\[\\W*\\{\\W*\\@value\\\"\\:\\W*\\\"(http(s)*\\:\\/\\/\\S*)\\\".*";
+ public static final String NGSI_LD_FORBIDDEN_KEY_CHARS_REGEX = "([\\<\\\"\\'\\=\\;\\(\\)\\>\\?\\*])";
+ public static final String NGSI_LD_FORBIDDEN_KEY_CHARS = "<,\",',=,;,(,),>,?,*";
+ public static final String[] VALID_SUB_ENDPOINT_SCHEMAS = { "http", "https", "mqtt", "mqtts" };
+ public final static String QUERY_PARAMETER_DELETE_ALL = "deleteAll";
+ public static final String NGSI_LD_NOTIFIERINFO = "https://uri.etsi.org/ngsi-ld/default-context/notifierinfo";
+ public static final String NGSI_LD_MQTT_QOS = "https://uri.etsi.org/ngsi-ld/default-context/qos";
+ public static final String NGSI_LD_MQTT_VERSION = "https://uri.etsi.org/ngsi-ld/default-context/version";
+ public static final Integer DEFAULT_MQTT_QOS = 0;
+ public static final String DEFAULT_MQTT_VERSION = "mqtt5.0";
+ public static final String CONTENT_TYPE = "contentType";
+ public static final String ACCEPTED_LINK = "link";
+ public static final String METADATA = "metadata";
+ public static final String BODY = "body";
+ public static final String MQTT_VERSION_5 = "mqtt5.0";
+ public static final String MQTT_VERSION_3 = "mqtt3.1.1";
+ public static final String[] VALID_MQTT_VERSION = { "mqtt5.0", "mqtt3.1.1" };
+ public static final Integer[] VALID_QOS = { 0, 1, 2 };
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Append.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Append.java
new file mode 100644
index 0000000000000000000000000000000000000000..50d0f8c39dd51352b14ae42371b1a43b521efd9a
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Append.java
@@ -0,0 +1,24 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class Append extends BaseEntityModificationOperation {
+
+
+
+ public Append(Map customFlags, List data, URI id, LDContext ldContext) {
+ super(customFlags, data, id, ldContext);
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/AppendResult.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/AppendResult.java
new file mode 100644
index 0000000000000000000000000000000000000000..10b35877daae30ea0a09de61cde8e3ec15691dec
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/AppendResult.java
@@ -0,0 +1,72 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+public class AppendResult {
+
+ private JsonNode jsonToAppend;
+ private JsonNode appendedJsonFields;// = new ArrayList();
+ private JsonNode finalNode;
+ private boolean status=false;
+ private byte[] json;
+ private byte[] jsonWithoutSysAttrs;
+
+ public boolean getAppendResult() {
+ return jsonToAppend.size()==appendedJsonFields.size();
+ }
+
+ public AppendResult(JsonNode jsonToAppend,JsonNode appendedJsonFields) {
+ super();
+ this.jsonToAppend = jsonToAppend;
+ this.appendedJsonFields=appendedJsonFields;
+ }
+
+ public JsonNode getFinalNode() {
+ return finalNode;
+ }
+
+ public void setFinalNode(JsonNode finalNode) {
+ this.finalNode = finalNode;
+ }
+
+ public JsonNode getJsonToAppend() {
+ return jsonToAppend;
+ }
+
+ public void setJsonToAppend(JsonNode jsonToAppend) {
+ this.jsonToAppend = jsonToAppend;
+ }
+
+ public JsonNode getAppendedJsonFields() {
+ return appendedJsonFields;
+ }
+
+ public void setAppendedJsonFields(JsonNode appendedJsonFields) {
+ this.appendedJsonFields = appendedJsonFields;
+ }
+
+ public boolean getStatus() {
+ return status;
+ }
+
+ public void setStatus(boolean status) {
+ this.status = status;
+ }
+
+ public byte[] getJson() {
+ return json;
+ }
+
+ public void setJson(byte[] json) {
+ this.json = json;
+ }
+
+ public byte[] getJsonWithoutSysAttrs() {
+ return jsonWithoutSysAttrs;
+ }
+
+ public void setJsonWithoutSysAttrs(byte[] jsonWithoutSysAttrs) {
+ this.jsonWithoutSysAttrs = jsonWithoutSysAttrs;
+ }
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseEntityModificationOperation.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseEntityModificationOperation.java
new file mode 100644
index 0000000000000000000000000000000000000000..90b9e2cad9d9a206a3eef314620252f8d43b5b40
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseEntityModificationOperation.java
@@ -0,0 +1,72 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class BaseEntityModificationOperation extends BaseOperation {
+
+ private List data;
+ private URI id;
+ private LDContext ldContext;
+
+
+
+ public BaseEntityModificationOperation(Map customFlags, List data, URI id,
+ LDContext ldContext) {
+ super(customFlags);
+ this.data = data;
+ this.id = id;
+ this.ldContext = ldContext;
+ }
+
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+
+
+ public List getData() {
+ return data;
+ }
+
+
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+
+
+ public URI getId() {
+ return id;
+ }
+
+
+
+ public void setId(URI id) {
+ this.id = id;
+ }
+
+
+
+ public LDContext getLdContext() {
+ return ldContext;
+ }
+
+
+
+ public void setLdContext(LDContext ldContext) {
+ this.ldContext = ldContext;
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseEntry.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseEntry.java
new file mode 100644
index 0000000000000000000000000000000000000000..85c81c4bbead1f114de1fa213e6ab4bb0fade796
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseEntry.java
@@ -0,0 +1,122 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.List;
+import java.util.UUID;
+
+import eu.neclab.ngsildbroker.commons.constants.NGSIConstants;
+
+public abstract class BaseEntry {
+ protected String name;
+ protected Long observedAt = -1l;
+ protected List properties;
+ private Object refToAccessControl;
+ protected List relationships;
+ protected int timeSeriesId;
+ protected String type;
+ private Long createdAt = -1l;
+ private Long modifiedAt = -1l;
+ protected String dataSetId;
+
+ public BaseEntry(String dataSetId) {
+ this.dataSetId = dataSetId;
+ if (this.dataSetId == null || this.dataSetId.trim().isEmpty()) {
+ this.dataSetId = NGSIConstants.DEFAULT_DATA_SET_ID;
+ }
+ }
+
+ public String getDataSetId() {
+ return dataSetId;
+ }
+
+ public void setDataSetId(String dataSetId) {
+ this.dataSetId = dataSetId;
+ if (this.dataSetId == null || this.dataSetId.trim().isEmpty()) {
+ this.dataSetId = UUID.randomUUID().toString();
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public long getObservedAt() {
+ return observedAt;
+ }
+
+ public void setObservedAt(Long observedAt) {
+ if (observedAt == null) {
+ this.observedAt = -1l;
+ } else {
+ this.observedAt = observedAt;
+ }
+ }
+
+ public List getProperties() {
+ return properties;
+ }
+
+ public void setProperties(List properties) {
+ this.properties = properties;
+ }
+
+ public Object getRefToAccessControl() {
+ return refToAccessControl;
+ }
+
+ public void setRefToAccessControl(Object refToAccessControl) {
+ this.refToAccessControl = refToAccessControl;
+ }
+
+ public List getRelationships() {
+ return relationships;
+ }
+
+ public void setRelationships(List relationships) {
+ this.relationships = relationships;
+ }
+
+ public int getTimeSeriesId() {
+ return timeSeriesId;
+ }
+
+ public void setTimeSeriesId(int timeSeriesId) {
+ this.timeSeriesId = timeSeriesId;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public long getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Long createdAt) {
+ if (createdAt == null) {
+ this.createdAt = -1l;
+ } else {
+ this.createdAt = createdAt;
+ }
+ }
+
+ public long getModifiedAt() {
+ return modifiedAt;
+ }
+
+ public void setModifiedAt(Long modifiedAt) {
+ if (createdAt == null) {
+ this.modifiedAt = -1l;
+ } else {
+ this.modifiedAt = modifiedAt;
+ }
+ }
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseOperation.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseOperation.java
new file mode 100644
index 0000000000000000000000000000000000000000..68f366cd99c99273c8f0bfcf7a3d16b3485b1f7d
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseOperation.java
@@ -0,0 +1,38 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.Map;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class BaseOperation {
+
+ protected Map customFlags;
+
+ public BaseOperation() {
+
+ }
+
+ public BaseOperation(Map customFlags){
+ this.customFlags = customFlags;
+
+ }
+
+
+ public Map getCustomFlags() {
+ return customFlags;
+ }
+
+
+ public void setCustomFlags(Map customFlags) {
+ this.customFlags = customFlags;
+ }
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseProperty.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseProperty.java
new file mode 100644
index 0000000000000000000000000000000000000000..c86f9bc796fcb54e18e94cc66d84cb21a4e98faa
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseProperty.java
@@ -0,0 +1,84 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public abstract class BaseProperty {
+
+ protected URI id;
+ protected String type;
+
+ public BaseProperty(){
+
+ }
+
+
+ abstract public boolean isMultiValue();
+
+ public URI getId() {
+ return id;
+ }
+ public String getIdString() {
+ return id.toString();
+ }
+
+ public void setId(URI id) {
+ this.id = id;
+ }
+
+
+ public String getType() {
+ return type;
+ }
+
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public abstract HashMap getEntries();
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ BaseProperty other = (BaseProperty) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ return true;
+ }
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseResult.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseResult.java
new file mode 100644
index 0000000000000000000000000000000000000000..16c6a4062b6e94ce2b4901bce80207b35bc330f4
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BaseResult.java
@@ -0,0 +1,91 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import eu.neclab.ngsildbroker.commons.enums.ErrorType;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class BaseResult {
+
+ protected String errorMsg;
+ protected ErrorType errorType;
+ protected int shortErrorMsg;
+ protected boolean success;
+
+
+
+
+ public BaseResult(String errorMsg, ErrorType errorType, int shortErrorMsg, boolean success) {
+ super();
+ this.errorMsg = errorMsg;
+ this.errorType = errorType;
+ this.shortErrorMsg = shortErrorMsg;
+ this.success = success;
+ }
+
+
+
+
+ public String getErrorMsg() {
+ return errorMsg;
+ }
+
+
+
+
+ public void setErrorMsg(String errorMsg) {
+ this.errorMsg = errorMsg;
+ }
+
+
+
+
+ public ErrorType getErrorType() {
+ return errorType;
+ }
+
+
+
+
+ public void setErrorType(ErrorType errorType) {
+ this.errorType = errorType;
+ }
+
+
+
+
+ public int getShortErrorMsg() {
+ return shortErrorMsg;
+ }
+
+
+
+
+ public void setShortErrorMsg(int shortErrorMsg) {
+ this.shortErrorMsg = shortErrorMsg;
+ }
+
+
+
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+
+
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BatchFailure.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BatchFailure.java
new file mode 100644
index 0000000000000000000000000000000000000000..05954a717cb0c830f9d1d6d4e8dca3f4924bdd2f
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BatchFailure.java
@@ -0,0 +1,29 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+public class BatchFailure {
+ private String entityId;
+ private RestResponse ProblemDetails;
+
+
+ public BatchFailure(String entityId, RestResponse details) {
+ super();
+ this.entityId = entityId;
+ this.ProblemDetails = details;
+ }
+ public String getEntityId() {
+ return entityId;
+ }
+ public void setEntityId(String entityId) {
+ this.entityId = entityId;
+ }
+ public RestResponse getDetails() {
+ return ProblemDetails;
+ }
+ public void setDetails(RestResponse details) {
+ this.ProblemDetails = details;
+ }
+
+
+
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BatchResult.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BatchResult.java
new file mode 100644
index 0000000000000000000000000000000000000000..7da799525d3a85f4c7ecf36932e1e9a85feeb773
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/BatchResult.java
@@ -0,0 +1,31 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.ArrayList;
+
+public class BatchResult {
+
+ private ArrayList success = new ArrayList();
+ private ArrayList fails = new ArrayList();
+
+ public void addSuccess(String entityId) {
+ success.add(entityId);
+ }
+
+ public void addFail(BatchFailure fail) {
+ fails.add(fail);
+ }
+
+ public ArrayList getSuccess() {
+ return success;
+ }
+ public ArrayList getFails() {
+ return fails;
+ }
+
+
+
+
+
+
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceNotification.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceNotification.java
new file mode 100644
index 0000000000000000000000000000000000000000..c0a75b2e8da0f8f09011878c90468cb76729e9e3
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceNotification.java
@@ -0,0 +1,144 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.util.Date;
+import java.util.List;
+
+import eu.neclab.ngsildbroker.commons.enums.ErrorType;
+import eu.neclab.ngsildbroker.commons.enums.TriggerReason;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class CSourceNotification extends CSourceQueryResult {
+
+
+ private URI id;
+ private Date notifiedAt;
+ private TriggerReason triggerReason;
+ private String type = "ContextSource Notfication";
+ private URI subscriptionId;
+
+
+ public CSourceNotification(URI id, URI subscriptionId, Date notifiedAt, TriggerReason triggerReason, List data, String errorMsg, ErrorType errorType, int shortErrorMsg,
+ boolean success) {
+ super(data, errorMsg, errorType, shortErrorMsg, success);
+ this.id = id;
+ this.notifiedAt = notifiedAt;
+ this.triggerReason = triggerReason;
+ this.subscriptionId = subscriptionId;
+ }
+
+
+
+
+
+
+
+ public URI getSubscriptionId() {
+ return subscriptionId;
+ }
+
+
+
+
+
+
+
+ public void setSubscriptionId(URI subscriptionId) {
+ this.subscriptionId = subscriptionId;
+ }
+
+
+
+
+
+
+
+ public URI getId() {
+ return id;
+ }
+
+
+
+
+
+
+
+ public void setId(URI id) {
+ this.id = id;
+ }
+
+
+
+
+
+
+
+ public Date getNotifiedAt() {
+ return notifiedAt;
+ }
+
+
+
+
+
+
+
+ public void setNotifiedAt(Date notifiedAt) {
+ this.notifiedAt = notifiedAt;
+ }
+
+
+
+
+
+
+
+ public TriggerReason getTriggerReason() {
+ return triggerReason;
+ }
+
+
+
+
+
+
+
+ public void setTriggerReason(TriggerReason triggerReason) {
+ this.triggerReason = triggerReason;
+ }
+
+
+
+
+
+
+
+ public String getType() {
+ return type;
+ }
+
+
+
+
+
+
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+
+
+
+
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceQuery.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceQuery.java
new file mode 100644
index 0000000000000000000000000000000000000000..a2f3bd18ba19a663181936feffc9767d93e369f7
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceQuery.java
@@ -0,0 +1,27 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class CSourceQuery extends Query {
+
+
+
+ public CSourceQuery(Map customFlags, List attributeNames, List entities,
+ String ldContext, LDGeoQuery ldGeoQuery, String ldQuery, LDTemporalQuery ldTempQuery,
+ List requestorList) {
+ super(customFlags, attributeNames, entities, ldContext, ldGeoQuery, ldQuery, ldTempQuery, requestorList);
+ // TODO Auto-generated constructor stub
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceQueryResult.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceQueryResult.java
new file mode 100644
index 0000000000000000000000000000000000000000..d7b80efd864fcd76ba5940ae81bc05838f1c43fd
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceQueryResult.java
@@ -0,0 +1,41 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.List;
+
+import eu.neclab.ngsildbroker.commons.enums.ErrorType;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class CSourceQueryResult extends BaseResult {
+
+ public CSourceQueryResult(List data, String errorMsg, ErrorType errorType, int shortErrorMsg, boolean success) {
+ super(errorMsg, errorType, shortErrorMsg, success);
+ this.data = data;
+ }
+
+
+
+ public List getData() {
+ return data;
+ }
+
+
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+
+
+ private List data;
+
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceRegistration.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceRegistration.java
new file mode 100644
index 0000000000000000000000000000000000000000..2416aac0d648b22422dde9633ae2fbe4b13e99e7
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CSourceRegistration.java
@@ -0,0 +1,236 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.util.Date;
+import java.util.List;
+import com.github.filosganga.geogson.model.Geometry;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class CSourceRegistration {
+
+ private String description;
+ private URI endpoint;
+ private Long expires;
+ private URI id;
+
+ private List information;
+ //private GeoProperty location;
+ private Geometry> location; // csource location is not the same as entity location. entity location is a GeoProperty, csource location is just a geojson value (string)
+ private String name;
+ private TimeInterval timestamp;
+ private boolean isInternal = false;
+
+ /**
+ * a
+ */
+ private String type = "CSourceRegistration";
+
+ public CSourceRegistration() {
+
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+ public CSourceRegistration update(CSourceRegistration updateBean) throws Exception {
+ if (updateBean == null) {
+ throw new Exception("null update payload.");
+ }
+ if (updateBean.getDescription() != null) {
+ this.setDescription(updateBean.getDescription());
+ }
+ if (updateBean.getEndpoint() != null) {
+ this.setEndpoint(updateBean.getEndpoint());
+ }
+ if (updateBean.getExpires() != null) {
+ this.setExpires(updateBean.getExpires());
+ }
+ if (updateBean.getId() != null) {
+ this.setId(updateBean.getId());
+ }
+ if (updateBean.getInformation() != null) {
+ // TODO : support for updating nested element i.e EntityInfo.
+ // this.getInformation().addAll(updateBean.getInformation());
+ this.setInformation(updateBean.getInformation());
+ }
+ if (updateBean.getLocation() != null) {
+ this.setLocation(updateBean.getLocation());
+ }
+ if (updateBean.getName() != null) {
+ this.setName(updateBean.getName());
+ }
+ if (updateBean.getTimestamp() != null) {
+ this.setTimestamp(updateBean.getTimestamp());
+ }
+
+ return this;
+ }
+
+
+
+ public boolean isInternal() {
+ return isInternal;
+ }
+
+ public void setInternal(boolean isInternal) {
+ this.isInternal = isInternal;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public URI getEndpoint() {
+ return endpoint;
+ }
+
+ public void setEndpoint(URI endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public Long getExpires() {
+ return expires;
+ }
+
+ public void setExpires(Long expires) {
+ this.expires = expires;
+ }
+
+ public URI getId() {
+ return id;
+ }
+
+ public void setId(URI id) {
+ this.id = id;
+ }
+
+ public List getInformation() {
+ return information;
+ }
+
+ public void setInformation(List information) {
+ this.information = information;
+ }
+
+ public Geometry> getLocation() {
+ return location;
+ }
+
+ public void setLocation(Geometry> location) {
+ this.location = location;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public TimeInterval getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(TimeInterval timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ @Override
+ public String toString() {
+ return "CSourceRegistration [description=" + description + ", endpoint=" + endpoint + ", expires=" + expires
+ + ", id=" + id + ", information=" + information + ", location=" + location + ", name=" + name
+ + ", timestamp=" + timestamp + ", type=" + type + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((endpoint == null) ? 0 : endpoint.hashCode());
+ result = prime * result + ((expires == null) ? 0 : expires.hashCode());
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((information == null) ? 0 : information.hashCode());
+ result = prime * result + ((location == null) ? 0 : location.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((timestamp == null) ? 0 : timestamp.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CSourceRegistration other = (CSourceRegistration) obj;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (endpoint == null) {
+ if (other.endpoint != null)
+ return false;
+ } else if (!endpoint.equals(other.endpoint))
+ return false;
+ if (expires == null) {
+ if (other.expires != null)
+ return false;
+ } else if (!expires.equals(other.expires))
+ return false;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ if (information == null) {
+ if (other.information != null)
+ return false;
+ } else if (!information.equals(other.information))
+ return false;
+ if (location == null) {
+ if (other.location != null)
+ return false;
+ } else if (!location.equals(other.location))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (timestamp == null) {
+ if (other.timestamp != null)
+ return false;
+ } else if (!timestamp.equals(other.timestamp))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ return true;
+ }
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Create.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Create.java
new file mode 100644
index 0000000000000000000000000000000000000000..8a4baebed40adba0ed28bd60d0a48503ab61de1d
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Create.java
@@ -0,0 +1,52 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.Map;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class Create extends BaseOperation {
+
+ private Entity data;
+ private LDContext ldContext;
+
+
+
+
+
+
+
+ public Create(Map customFlags, Entity data, LDContext ldContext) {
+ super(customFlags);
+ this.data = data;
+ this.ldContext = ldContext;
+ }
+
+
+ public Entity getData() {
+ return data;
+ }
+
+
+ public void setData(Entity data) {
+ this.data = data;
+ }
+
+
+ public LDContext getLdContext() {
+ return ldContext;
+ }
+
+
+ public void setLdContext(LDContext ldContext) {
+ this.ldContext = ldContext;
+ }
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CreateResult.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CreateResult.java
new file mode 100644
index 0000000000000000000000000000000000000000..772f0953544519db7389eeabe0723c27a8be732c
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/CreateResult.java
@@ -0,0 +1,39 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import eu.neclab.ngsildbroker.commons.enums.ErrorType;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class CreateResult extends BaseResult {
+
+ private Entity data;
+
+
+
+ public CreateResult(Entity data, String errorMsg, ErrorType errorType, int shortErrorMsg, boolean success) {
+ super(errorMsg, errorType, shortErrorMsg, success);
+ this.data = data;
+ }
+
+
+
+ public Entity getData() {
+ return data;
+ }
+
+
+
+ public void setData(Entity data) {
+ this.data = data;
+ }
+
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Delete.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Delete.java
new file mode 100644
index 0000000000000000000000000000000000000000..3bb5492e40ac7210156c1b851a51411f31a9dd82
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Delete.java
@@ -0,0 +1,25 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class Delete extends BaseEntityModificationOperation {
+
+
+
+ public Delete(Map customFlags, List data, URI id, LDContext ldContext) {
+ super(customFlags, data, id, ldContext);
+
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/DeleteResult.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/DeleteResult.java
new file mode 100644
index 0000000000000000000000000000000000000000..3865c179e1b9dde5871d212a8a8041f94d69e582
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/DeleteResult.java
@@ -0,0 +1,40 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import eu.neclab.ngsildbroker.commons.enums.ErrorType;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class DeleteResult extends BaseResult {
+
+ public DeleteResult(Entity data, String errorMsg, ErrorType errorType, int shortErrorMsg, boolean success) {
+ super(errorMsg, errorType, shortErrorMsg, success);
+ this.data = data;
+
+ }
+
+
+
+ private Entity data;
+
+
+
+ public Entity getData() {
+ return data;
+ }
+
+
+
+ public void setData(Entity data) {
+ this.data = data;
+ }
+
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/EndPoint.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/EndPoint.java
new file mode 100644
index 0000000000000000000000000000000000000000..7dfaa47ee785e332d09d804af785489f390f6e74
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/EndPoint.java
@@ -0,0 +1,49 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.util.Map;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class EndPoint {
+
+ private String accept;
+ private URI uri;
+ private MapnotifierInfo;
+
+ public EndPoint(){
+
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+ public String getAccept() {
+ return accept;
+ }
+
+ public void setAccept(String accept) {
+ this.accept = accept;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+
+ public Map getNotifierInfo() {
+ return notifierInfo;
+ }
+
+ public void setNotifierInfo(Map notifierInfo) {
+ this.notifierInfo = notifierInfo;
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Entity.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Entity.java
new file mode 100644
index 0000000000000000000000000000000000000000..1ca06229d1678d3889ae3c0f039ebb280c3dbe63
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Entity.java
@@ -0,0 +1,282 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import eu.neclab.ngsildbroker.commons.constants.NGSIConstants;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:32:45
+ */
+public class Entity {
+
+ private URI id;
+ private GeoProperty location;
+ private GeoProperty observationSpace;
+ private GeoProperty operationSpace;
+ private List properties;
+ private Object refToAccessControl;
+ private List relationships;
+ private List geoProperties;
+ private String type;
+ private Long createdAt;
+ private Long modifiedAt;
+ private Long observedAt;
+ private String name;
+ private List allBaseProperties = new ArrayList();
+ private Property createdAtProp = new Property();
+ private Property modifiedAtProp = new Property();
+ private Property observedAtProp = new Property();
+
+ public Entity(URI id, String type, List baseProps, Object refToAccessControl) {
+ this.id = id;
+ this.type = type;
+ this.refToAccessControl = refToAccessControl;
+ this.allBaseProperties = baseProps;
+ relationships = new ArrayList();
+ properties = new ArrayList();
+ geoProperties = new ArrayList();
+ for (BaseProperty baseProp : baseProps) {
+ if (baseProp instanceof GeoProperty) {
+ if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_LOCATION)) {
+ this.location = (GeoProperty) baseProp;
+ } else if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_OBSERVATION_SPACE)) {
+ this.observationSpace = (GeoProperty) baseProp;
+ } else if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_OPERATION_SPACE)) {
+ this.operationSpace = (GeoProperty) baseProp;
+ } else {
+ this.geoProperties.add((GeoProperty) baseProp);
+ }
+ } else if (baseProp instanceof Relationship) {
+ this.relationships.add((Relationship) baseProp);
+ } else if (baseProp instanceof Property) {
+ if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_CREATED_AT)) {
+ if (((Property) baseProp).getEntries() != null) {
+ createdAtProp = (Property) baseProp;
+ createdAt = (Long) createdAtProp.getEntries().values().iterator().next().getValue();
+ }
+
+ } else if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_MODIFIED_AT)) {
+ if (((Property) baseProp).getEntries() != null) {
+ modifiedAtProp = (Property) baseProp;
+ modifiedAt = (Long) modifiedAtProp.getEntries().values().iterator().next().getValue();
+ }
+
+ } else if (baseProp.id.toString().equals(NGSIConstants.NGSI_LD_OBSERVED_AT)) {
+ if (((Property) baseProp).getEntries() != null) {
+ observedAtProp = (Property) baseProp;
+ observedAt = (Long) observedAtProp.getEntries().values().iterator().next().getValue();
+ }
+ } else {
+ this.properties.add((Property) baseProp);
+ }
+
+ }
+ }
+ }
+
+ public Entity(URI id, GeoProperty location, GeoProperty observationSpace, GeoProperty operationSpace,
+ List properties, Object refToAccessControl, List relationships, String type,
+ List geoProperties) {
+ super();
+ this.id = id;
+ this.location = location;
+ this.observationSpace = observationSpace;
+ this.operationSpace = operationSpace;
+ this.properties = properties;
+ this.refToAccessControl = refToAccessControl;
+ this.relationships = relationships;
+ this.geoProperties = geoProperties;
+ this.type = type;
+ try {
+ createdAtProp.setId(new URI(NGSIConstants.NGSI_LD_CREATED_AT));
+ modifiedAtProp.setId(new URI(NGSIConstants.NGSI_LD_MODIFIED_AT));
+ observedAtProp.setId(new URI(NGSIConstants.NGSI_LD_OBSERVED_AT));
+ createdAtProp.setEntries(null);
+ modifiedAtProp.setEntries(null);
+ observedAtProp.setEntries(null);
+ allBaseProperties.add(createdAtProp);
+ allBaseProperties.add(modifiedAtProp);
+ allBaseProperties.add(observedAtProp);
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ }
+ if (properties != null) {
+ allBaseProperties.addAll(properties);
+ }
+ if (relationships != null) {
+ allBaseProperties.addAll(relationships);
+ }
+ if (geoProperties != null) {
+ allBaseProperties.addAll(geoProperties);
+ }
+ if (location != null) {
+ allBaseProperties.add(location);
+ }
+ if (observationSpace != null) {
+ allBaseProperties.add(observationSpace);
+ }
+ if (operationSpace != null) {
+ allBaseProperties.add(operationSpace);
+ }
+
+ }
+
+ public Long getObservedAt() {
+ return observedAt;
+ }
+
+ public void setObservedAt(Long observedAt) {
+ this.observedAt = observedAt;
+ observedAtProp.setSingleEntry(new PropertyEntry("observedAt", observedAt));
+ }
+
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public URI getId() {
+ return id;
+ }
+
+ public void setId(URI id) {
+ this.id = id;
+ }
+
+ public GeoProperty getLocation() {
+ return location;
+ }
+
+ public void setLocation(GeoProperty location) {
+ if (this.location != null) {
+ allBaseProperties.remove(this.location);
+ }
+ allBaseProperties.add(location);
+ this.location = location;
+ }
+
+ public GeoProperty getObservationSpace() {
+ return observationSpace;
+ }
+
+ public void setObservationSpace(GeoProperty observationSpace) {
+ if (this.observationSpace != null) {
+ allBaseProperties.remove(this.observationSpace);
+ }
+ allBaseProperties.add(observationSpace);
+ this.observationSpace = observationSpace;
+ }
+
+ public GeoProperty getOperationSpace() {
+ return operationSpace;
+ }
+
+ public void setOperationSpace(GeoProperty operationSpace) {
+ if (this.operationSpace != null) {
+ allBaseProperties.remove(this.operationSpace);
+ }
+ allBaseProperties.add(operationSpace);
+ this.operationSpace = operationSpace;
+ }
+
+ public List getProperties() {
+ return properties;
+ }
+
+ public void setProperties(List properties) {
+ if (this.properties != null) {
+ allBaseProperties.removeAll(this.properties);
+ }
+ allBaseProperties.addAll(properties);
+
+ this.properties = properties;
+ }
+
+ public Object getRefToAccessControl() {
+ return refToAccessControl;
+ }
+
+ public void setRefToAccessControl(Object refToAccessControl) {
+ this.refToAccessControl = refToAccessControl;
+ }
+
+ public List getRelationships() {
+ return relationships;
+ }
+
+ public void setRelationships(List relationships) {
+ if (this.relationships != null) {
+ allBaseProperties.removeAll(this.relationships);
+ }
+ if (relationships != null) {
+ allBaseProperties.addAll(relationships);
+ }
+ this.relationships = relationships;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+ public Long getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Long createdAt) {
+ createdAtProp.setSingleEntry(new PropertyEntry("createdAt", createdAt));
+ this.createdAt = createdAt;
+ }
+
+ public Long getModifiedAt() {
+ return modifiedAt;
+ }
+
+ public void setModifiedAt(Long modifiedAt) {
+ modifiedAtProp.setSingleEntry(new PropertyEntry("modifiedAt", modifiedAt));
+ this.modifiedAt = modifiedAt;
+ }
+
+ public List getAllBaseProperties() {
+ return allBaseProperties;
+ }
+
+ public List getGeoProperties() {
+ return geoProperties;
+ }
+
+ public void setGeoProperties(List geoProperties) {
+ if (this.geoProperties != null) {
+ allBaseProperties.removeAll(this.geoProperties);
+ }
+ if (geoProperties != null) {
+ allBaseProperties.addAll(geoProperties);
+ }
+ this.geoProperties = geoProperties;
+ }
+
+ @Override
+ public String toString() {
+ return "Entity [id=" + id + ", location=" + location + ", observationSpace=" + observationSpace
+ + ", operationSpace=" + operationSpace + ", properties=" + properties + ", refToAccessControl="
+ + refToAccessControl + ", relationships=" + relationships + ", type=" + type + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/EntityDetails.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/EntityDetails.java
new file mode 100644
index 0000000000000000000000000000000000000000..4d782b63f6fb4facedec0d3bd37d280d3cda91db
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/EntityDetails.java
@@ -0,0 +1,81 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+public class EntityDetails {
+
+ private String key;
+ private int partition;
+ private long offset;
+
+ public EntityDetails() {}
+
+
+ public EntityDetails(String key, int partition, long offset) {
+ super();
+ this.key = key;
+ this.partition = partition;
+ this.offset = offset;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public int getPartition() {
+ return partition;
+ }
+
+ public void setPartition(int partition) {
+ this.partition = partition;
+ }
+
+ public long getOffset() {
+ return offset;
+ }
+
+ public void setOffset(long offset) {
+ this.offset = offset;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((key == null) ? 0 : key.hashCode());
+ result = prime * result + (int) (offset ^ (offset >>> 32));
+ result = prime * result + partition;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ EntityDetails other = (EntityDetails) obj;
+ if (key == null) {
+ if (other.key != null)
+ return false;
+ } else if (!key.equals(other.key))
+ return false;
+ if (offset != other.offset)
+ return false;
+ if (partition != other.partition)
+ return false;
+ return true;
+ }
+
+
+ @Override
+ public String toString() {
+ return "EntityTopicDetails [key=" + key + ", partition=" + partition + ", offset=" + offset + "]";
+ }
+
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/EntityInfo.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/EntityInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..16d32949218889585f13416fde2fdd9f76d54f03
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/EntityInfo.java
@@ -0,0 +1,74 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:34:28
+ */
+public class EntityInfo {
+
+ private URI id;
+ private String idPattern;
+ private String type;
+
+ public EntityInfo() {
+
+ }
+
+ public EntityInfo(URI id, String idPattern, String type) {
+ super();
+ this.id = id;
+ this.idPattern = idPattern;
+ this.type = type;
+ }
+
+
+
+ public URI getId() {
+ return id;
+ }
+
+
+
+ public void setId(URI id) {
+ this.id = id;
+ }
+
+
+
+ public String getIdPattern() {
+ return idPattern;
+ }
+
+
+
+ public void setIdPattern(String idPattern) {
+ this.idPattern = idPattern;
+ }
+
+
+
+ public String getType() {
+ return type;
+ }
+
+
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+ @Override
+ public String toString() {
+ return "EntityInfo [id=" + id + ", idPattern=" + idPattern + ", type=" + type + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoProperty.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoProperty.java
new file mode 100644
index 0000000000000000000000000000000000000000..12dedc4dcd3d6be1b3e934326176b22fdf33fc1c
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoProperty.java
@@ -0,0 +1,69 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.HashMap;
+
+import com.github.filosganga.geogson.model.Geometry;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class GeoProperty extends BaseProperty {
+
+
+ HashMap entries = new HashMap();
+
+ public GeoProperty(){
+// this.type = "GeoProperty";
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+
+
+
+ public HashMap getEntries() {
+ return entries;
+ }
+
+ public void setEntries(HashMap entries) {
+ this.entries = entries;
+ }
+
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ GeoProperty other = (GeoProperty) obj;
+ if (entries == null) {
+ if (other.entries != null)
+ return false;
+ } else if (!entries.equals(other.entries))
+ return false;
+ return true;
+ }
+
+ @Override
+ public boolean isMultiValue() {
+ return entries.size() != 1;
+ }
+
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoPropertyEntry.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoPropertyEntry.java
new file mode 100644
index 0000000000000000000000000000000000000000..1c016ee52ec647931f3b3394d48e695ce66f374f
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoPropertyEntry.java
@@ -0,0 +1,35 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import com.github.filosganga.geogson.model.Geometry;
+
+import eu.neclab.ngsildbroker.commons.constants.NGSIConstants;
+
+public class GeoPropertyEntry extends BaseEntry {
+ public GeoPropertyEntry(String dataSetId, String value, Geometry> geoValue) {
+ super(dataSetId);
+ this.value = value;
+ this.geoValue = geoValue;
+ this.type = NGSIConstants.NGSI_LD_GEOPROPERTY;
+ }
+
+ private String value;
+
+ private Geometry> geoValue;
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String string) {
+ this.value = string;
+ }
+
+ public Geometry> getGeoValue() {
+ return geoValue;
+ }
+
+ public void setGeoValue(Geometry> geoValue) {
+ this.geoValue = geoValue;
+ }
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoRelation.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoRelation.java
new file mode 100644
index 0000000000000000000000000000000000000000..908cbabd4bc501facf11d29db4b655774f847d05
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoRelation.java
@@ -0,0 +1,86 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class GeoRelation {
+
+ private Object maxDistance;
+ private Double maxDistanceAsDouble;
+ private Object minDistance;
+ private Double minDistanceAsDouble;
+ private String relation;
+
+ public GeoRelation() {
+
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+ public Object getMaxDistance() {
+ return maxDistance;
+ }
+
+
+ public Double getMaxDistanceAsDouble() {
+ return maxDistanceAsDouble;
+ }
+
+ public Double getMinDistanceAsDouble() {
+ return minDistanceAsDouble;
+ }
+
+ public void setMaxDistance(Object maxDistance) {
+ this.maxDistance = maxDistance;
+ if (maxDistance instanceof Integer) {
+ maxDistanceAsDouble = ((Integer) maxDistance).doubleValue();
+ } else {
+ maxDistanceAsDouble = (Double) maxDistance;
+ }
+ }
+
+ public Object getMinDistance() {
+ return minDistance;
+ }
+
+ public void setMinDistance(Object minDistance) {
+ this.minDistance = minDistance;
+ if (minDistance instanceof Integer) {
+ minDistanceAsDouble = ((Integer) minDistance).doubleValue();
+ } else {
+ minDistanceAsDouble = (Double) minDistance;
+ }
+ }
+
+ public String getRelation() {
+ return relation;
+ }
+
+ public void setRelation(String relation) {
+ this.relation = relation;
+ }
+
+ public String getABNFString() {
+ StringBuilder result = new StringBuilder();
+ result.append(relation);
+ if (maxDistance != null) {
+ result.append(";");
+ result.append("maxDistance");
+ result.append("==");
+ result.append(maxDistance);
+ }
+ if (minDistance != null) {
+ result.append(";");
+ result.append("minDistance");
+ result.append("==");
+ result.append(minDistance);
+ }
+ return result.toString();
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoValue.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoValue.java
new file mode 100644
index 0000000000000000000000000000000000000000..e7196b06ed8868e7d5636c4ab00b1126d2f94690
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoValue.java
@@ -0,0 +1,53 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.List;
+
+public class GeoValue {
+
+ String type;
+ List coordinates;
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public List getCoordinates() {
+ return coordinates;
+ }
+ public void setCoordinates(List coordinates) {
+ this.coordinates = coordinates;
+ }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((coordinates == null) ? 0 : coordinates.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ GeoValue other = (GeoValue) obj;
+ if (coordinates == null) {
+ if (other.coordinates != null)
+ return false;
+ } else if (!coordinates.equals(other.coordinates))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ return true;
+ }
+
+
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoqueryRel.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoqueryRel.java
new file mode 100644
index 0000000000000000000000000000000000000000..6ea9ebb5da685104d31aeff9b2d5649b89c0f3f8
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/GeoqueryRel.java
@@ -0,0 +1,49 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import eu.neclab.ngsildbroker.commons.constants.NGSIConstants;
+
+public class GeoqueryRel {
+ private String georelOp = null;
+ private String distanceType = null;
+ private String distanceValue = null;
+
+
+ public GeoqueryRel() {
+ super();
+ }
+
+
+ public GeoqueryRel(GeoRelation georel) {
+ super();
+ this.georelOp = georel.getRelation();
+ if(georel.getMaxDistance() != null && georel.getMaxDistanceAsDouble() > 0) {
+ this.distanceType = NGSIConstants.GEO_REL_MAX_DISTANCE;
+ this.distanceValue = "" + georel.getMaxDistance();
+ }else if(georel.getMinDistance() != null && georel.getMinDistanceAsDouble() > 0) {
+ this.distanceType = NGSIConstants.GEO_REL_MIN_DISTANCE;
+ this.distanceValue = "" + georel.getMinDistance();
+ }
+ }
+
+
+ public String getGeorelOp() {
+ return georelOp;
+ }
+ public void setGeorelOp(String georelOp) {
+ this.georelOp = georelOp;
+ }
+ public String getDistanceType() {
+ return distanceType;
+ }
+ public void setDistanceType(String distanceType) {
+ this.distanceType = distanceType;
+ }
+ public String getDistanceValue() {
+ return distanceValue;
+ }
+ public void setDistanceValue(String distanceValue) {
+ this.distanceValue = distanceValue;
+ }
+
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Information.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Information.java
new file mode 100644
index 0000000000000000000000000000000000000000..cb93ce19a644e97fa732a38472d4dd0dea7cc429
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Information.java
@@ -0,0 +1,86 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class Information {
+
+ private List entities;
+ private Set properties;
+ private Set relationships;
+
+ public Information() {
+ this.entities=new ArrayList();
+ this.properties=new HashSet();
+ this.relationships=new HashSet();
+ }
+ public List getEntities() {
+ return entities;
+ }
+
+ public void setEntities(List entities) {
+ this.entities = entities;
+ }
+
+ public Set getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Set properties) {
+ this.properties = properties;
+ }
+
+ public Set getRelationships() {
+ return relationships;
+ }
+
+ public void setRelationships(Set relationships) {
+ this.relationships = relationships;
+ }
+
+ @Override
+ public String toString() {
+ return "Information [entities=" + entities + ", properties=" + properties + ", relationships=" + relationships
+ + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((entities == null) ? 0 : entities.hashCode());
+ result = prime * result + ((properties == null) ? 0 : properties.hashCode());
+ result = prime * result + ((relationships == null) ? 0 : relationships.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Information other = (Information) obj;
+ if (entities == null) {
+ if (other.entities != null)
+ return false;
+ } else if (!entities.equals(other.entities))
+ return false;
+ if (properties == null) {
+ if (other.properties != null)
+ return false;
+ } else if (!properties.equals(other.properties))
+ return false;
+ if (relationships == null) {
+ if (other.relationships != null)
+ return false;
+ } else if (!relationships.equals(other.relationships))
+ return false;
+ return true;
+ }
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDContext.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDContext.java
new file mode 100644
index 0000000000000000000000000000000000000000..e501a303f274edf8af1fc41671174cd0e6607fd6
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDContext.java
@@ -0,0 +1,19 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class LDContext {
+
+ public LDContext(){
+
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDGeoQuery.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDGeoQuery.java
new file mode 100644
index 0000000000000000000000000000000000000000..859c1ecb6476ae191813f9cfebbc559fe9e50513
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDGeoQuery.java
@@ -0,0 +1,88 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.List;
+
+import eu.neclab.ngsildbroker.commons.enums.Geometry;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class LDGeoQuery {
+
+ private List coordinates;
+ private Geometry geometry;
+ private String geoProperty = "location";
+ private GeoRelation geoRelation;
+// private boolean nextAnd = true;
+// private LDGeoQuery next;
+
+ public LDGeoQuery(){
+
+ }
+
+
+
+// public boolean isNextAnd() {
+// return nextAnd;
+// }
+//
+//
+//
+// public void setNextAnd(boolean nextAnd) {
+// this.nextAnd = nextAnd;
+// }
+//
+//
+//
+// public LDGeoQuery getNext() {
+// return next;
+// }
+//
+//
+//
+// public void setNext(LDGeoQuery next) {
+// this.next = next;
+// }
+
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+ public List getCoordinates() {
+ return coordinates;
+ }
+
+ public void setCoordinates(List coordinates) {
+ this.coordinates = coordinates;
+ }
+
+ public Geometry getGeometry() {
+ return geometry;
+ }
+
+ public void setGeometry(Geometry geometry) {
+ this.geometry = geometry;
+ }
+
+ public String getGeoProperty() {
+ return geoProperty;
+ }
+
+ public void setGeoProperty(String geoProperty) {
+ this.geoProperty = geoProperty;
+ }
+
+ public GeoRelation getGeoRelation() {
+ return geoRelation;
+ }
+
+ public void setGeoRelation(GeoRelation geoRelation) {
+ this.geoRelation = geoRelation;
+ }
+
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDQuery.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDQuery.java
new file mode 100644
index 0000000000000000000000000000000000000000..8b018844d35fbc18232d7976d588b642c09dc87c
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDQuery.java
@@ -0,0 +1,19 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class LDQuery {
+
+ public LDQuery(){
+
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDTemporalQuery.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDTemporalQuery.java
new file mode 100644
index 0000000000000000000000000000000000000000..22328c159385a1c0b05e5424850ee7f667802d8a
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/LDTemporalQuery.java
@@ -0,0 +1,60 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.Date;
+
+import eu.neclab.ngsildbroker.commons.enums.TemporalRelation;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class LDTemporalQuery {
+
+ private Date endTime;
+ private TemporalRelation temprel;
+ private Date time;
+ private String timeProperty = "observedAt";
+
+ public LDTemporalQuery(){
+
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+ public Date getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(Date endTime) {
+ this.endTime = endTime;
+ }
+
+ public TemporalRelation getTemprel() {
+ return temprel;
+ }
+
+ public void setTemprel(TemporalRelation temprel) {
+ this.temprel = temprel;
+ }
+
+ public Date getTime() {
+ return time;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ public String getTimeProperty() {
+ return timeProperty;
+ }
+
+ public void setTimeProperty(String timeProperty) {
+ this.timeProperty = timeProperty;
+ }
+
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Location.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Location.java
new file mode 100644
index 0000000000000000000000000000000000000000..66892e9318f8cadf14a8121661dab29ef3dd757a
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Location.java
@@ -0,0 +1,39 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class Location {
+
+ private double latitude;
+ private double longitude;
+
+ public Location(){
+
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Notification.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Notification.java
new file mode 100644
index 0000000000000000000000000000000000000000..3ffad2b9532e3892baf9ac612c76d46c33ebba1c
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Notification.java
@@ -0,0 +1,99 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.util.Date;
+import java.util.List;
+
+import eu.neclab.ngsildbroker.commons.enums.ErrorType;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class Notification extends QueryResult {
+
+
+ public Notification(URI id, Long notifiedAt, URI subscriptionId, List data) {
+ super(null, null, null, -1, true);
+ this.id = id;
+ this.notifiedAt = notifiedAt;
+ this.subscriptionId = subscriptionId;
+ this.data = data;
+ }
+
+
+
+ public Notification(URI id, Long notifiedAt, URI subscriptionId, List data, String errorMsg, ErrorType errorType, int shortErrorMsg, boolean success) {
+ super(null, errorMsg, errorType, shortErrorMsg, success);
+ this.id = id;
+ this.notifiedAt = notifiedAt;
+ this.subscriptionId = subscriptionId;
+ this.data = data;
+ }
+
+
+
+ private URI id;
+ private Long notifiedAt;
+ private URI subscriptionId;
+ private List data;
+ private final String type = "Notification";
+
+
+
+ public URI getId() {
+ return id;
+ }
+
+
+
+ public void setId(URI id) {
+ this.id = id;
+ }
+
+
+
+ public Long getNotifiedAt() {
+ return notifiedAt;
+ }
+
+
+
+ public void setNotifiedAt(Long notifiedAt) {
+ this.notifiedAt = notifiedAt;
+ }
+
+
+
+ public URI getSubscriptionId() {
+ return subscriptionId;
+ }
+
+
+
+ public void setSubscriptionId(URI subscriptionId) {
+ this.subscriptionId = subscriptionId;
+ }
+
+
+
+ public String getType() {
+ return type;
+ }
+
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/NotificationParam.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/NotificationParam.java
new file mode 100644
index 0000000000000000000000000000000000000000..1791964d7927fa324af654392ed2bf484fe61ac5
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/NotificationParam.java
@@ -0,0 +1,120 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.Date;
+import java.util.List;
+
+import eu.neclab.ngsildbroker.commons.enums.Format;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class NotificationParam {
+
+ private List attributeNames;
+ private EndPoint endPoint;
+ private Format format;
+
+ private int timesSent = 0;
+ private Date lastNotification;
+ private Date lastSuccessfulNotification;
+ private Date lastFailedNotification;
+
+
+
+
+ public NotificationParam(){
+
+ }
+
+
+
+ public int getTimesSent() {
+ return timesSent;
+ }
+
+
+
+
+
+
+ public Date getLastNotification() {
+ return lastNotification;
+ }
+
+ public void setTimesSent(int timeSent) {
+ this.timesSent = timeSent;
+ }
+
+ public void setLastNotification(Date lastNotification) {
+ this.timesSent++;
+ this.lastNotification = lastNotification;
+ }
+
+
+
+ public Date getLastSuccessfulNotification() {
+ return lastSuccessfulNotification;
+ }
+
+
+
+ public void setLastSuccessfulNotification(Date lastSuccessfulNotification) {
+ this.lastSuccessfulNotification = lastSuccessfulNotification;
+ }
+
+
+
+ public Date getLastFailedNotification() {
+ return lastFailedNotification;
+ }
+
+
+
+ public void setLastFailedNotification(Date lastFailedNotification) {
+ this.lastFailedNotification = lastFailedNotification;
+ }
+
+
+
+ public void finalize() throws Throwable {
+
+ }
+
+ public List getAttributeNames() {
+ return attributeNames;
+ }
+
+ public void setAttributeNames(List attributeNames) {
+ this.attributeNames = attributeNames;
+ }
+
+ public EndPoint getEndPoint() {
+ return endPoint;
+ }
+
+ public void setEndPoint(EndPoint endPoint) {
+ this.endPoint = endPoint;
+ }
+
+ public Format getFormat() {
+ return format;
+ }
+
+ public void setFormat(Format format) {
+ this.format = format;
+ }
+
+
+
+ @Override
+ public String toString() {
+ return "NotificationParam [attributeNames=" + attributeNames + ", endPoint=" + endPoint + ", format=" + format
+ + ", timesSent=" + timesSent + ", lastNotification=" + lastNotification
+ + ", lastSuccessfulNotification=" + lastSuccessfulNotification + ", lastFailedNotification="
+ + lastFailedNotification + "]";
+ }
+
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Property.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Property.java
new file mode 100644
index 0000000000000000000000000000000000000000..1e2ee640f63c432b08f9f9b1e493c322327af054
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Property.java
@@ -0,0 +1,76 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class Property extends BaseProperty {
+
+
+
+
+ private HashMap dataSetId2value;
+ public Property(){
+ type = "Property";
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+ public void setSingleEntry(PropertyEntry value) {
+ HashMap temp = new HashMap();
+ temp.put(value.getDataSetId(), value);
+ setEntries(temp);
+ }
+
+ public HashMap getEntries() {
+ return dataSetId2value;
+ }
+
+ public void setEntries(HashMap value) {
+ this.dataSetId2value = value;
+ }
+
+
+
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((dataSetId2value == null) ? 0 : dataSetId2value.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Property other = (Property) obj;
+ if (dataSetId2value == null) {
+ if (other.dataSetId2value != null)
+ return false;
+ } else if (!dataSetId2value.equals(other.dataSetId2value))
+ return false;
+ return true;
+ }
+
+ @Override
+ public boolean isMultiValue() {
+ return dataSetId2value.size() != 1;
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/PropertyEntry.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/PropertyEntry.java
new file mode 100644
index 0000000000000000000000000000000000000000..11a8d4b72c82b4003ebe2c697ac7137685259b79
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/PropertyEntry.java
@@ -0,0 +1,36 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.UUID;
+
+import eu.neclab.ngsildbroker.commons.constants.NGSIConstants;
+
+public class PropertyEntry extends BaseEntry{
+
+ private Object value;
+ private String unitCode;
+
+
+ public PropertyEntry(String dataSetId, Object value) {
+ super(dataSetId);
+ this.value = value;
+ this.type = NGSIConstants.NGSI_LD_PROPERTY;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+ public void setValue(Object value) {
+ this.value = value;
+ }
+ public String getUnitCode() {
+ return unitCode;
+ }
+
+ public void setUnitCode(String unitCode) {
+ this.unitCode = unitCode;
+ }
+
+
+
+
+}
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Query.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Query.java
new file mode 100644
index 0000000000000000000000000000000000000000..ad27163fa041419d9e3ebd6fa3510569260f4b09
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/Query.java
@@ -0,0 +1,141 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class Query extends BaseOperation {
+
+
+ public Query() {
+ super();
+ }
+
+ public Query(Map customFlags, List attributeNames, List entities,
+ String ldContext, LDGeoQuery ldGeoQuery, String ldQuery, LDTemporalQuery ldTempQuery,
+ List requestorList) {
+ super(customFlags);
+ this.attributeNames = attributeNames;
+ if(this.attributeNames == null) {
+ this.attributeNames = new ArrayList();
+ }
+
+ this.entities = entities;
+ this.ldContext = ldContext;
+ this.ldGeoQuery = ldGeoQuery;
+ this.ldQuery = ldQuery;
+ this.ldTempQuery = ldTempQuery;
+ this.requestorList = requestorList;
+ }
+
+
+ protected List attributeNames;
+ protected List entities = new ArrayList();
+ protected String ldContext;
+ protected LDGeoQuery ldGeoQuery;
+ protected String ldQuery;
+ protected LDTemporalQuery ldTempQuery;
+ protected List requestorList;
+
+
+
+ public List getAttributeNames() {
+ return attributeNames;
+ }
+
+
+
+ public void setAttributeNames(List attributeNames) {
+ this.attributeNames = attributeNames;
+ }
+
+
+
+ public List getEntities() {
+ return entities;
+ }
+
+
+
+ public void setEntities(List entities) {
+ this.entities = entities;
+ }
+
+
+
+ public String getLdContext() {
+ return ldContext;
+ }
+
+
+
+ public void setLdContext(String ldContext) {
+ this.ldContext = ldContext;
+ }
+
+
+
+ public LDGeoQuery getLdGeoQuery() {
+ return ldGeoQuery;
+ }
+
+
+
+ public void setLdGeoQuery(LDGeoQuery ldGeoQuery) {
+ this.ldGeoQuery = ldGeoQuery;
+ }
+
+
+
+ public String getLdQuery() {
+ return ldQuery;
+ }
+
+
+
+ public void setLdQuery(String ldQuery) {
+ this.ldQuery = ldQuery;
+ }
+
+
+
+ public LDTemporalQuery getLdTempQuery() {
+ return ldTempQuery;
+ }
+
+
+
+ public void setLdTempQuery(LDTemporalQuery ldTempQuery) {
+ this.ldTempQuery = ldTempQuery;
+ }
+
+
+
+ public List getRequestorList() {
+ return requestorList;
+ }
+
+
+
+ public void setRequestorList(List requestorList) {
+ this.requestorList = requestorList;
+ }
+
+ public void addEntityInfo(EntityInfo entity) {
+ this.entities.add(entity);
+ }
+ public void removeEntityInfo(EntityInfo entity) {
+ this.entities.remove(entity);
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryParams.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryParams.java
new file mode 100644
index 0000000000000000000000000000000000000000..f59e2b8055b7376bd51536699d69839012f8b736
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryParams.java
@@ -0,0 +1,314 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+public class QueryParams {
+
+ @SerializedName("id")
+ @Expose
+ private String id;
+ @SerializedName("type")
+ @Expose
+ private String type;
+ @SerializedName("attrs")
+ @Expose
+ private String attrs;
+ @SerializedName("instanceId")
+ @Expose
+ private String instanceId;
+ @SerializedName("idPattern")
+ @Expose
+ private String idPattern;
+ @SerializedName("q")
+ @Expose
+ private String q;
+ @SerializedName("georel")
+ @Expose
+ private GeoqueryRel georel;
+ @SerializedName("geometry")
+ @Expose
+ private String geometry;
+ @SerializedName("coordinates")
+ @Expose
+ private String coordinates;
+ @SerializedName("geoproperty")
+ @Expose
+ private String geoproperty;
+ @SerializedName("timerel")
+ @Expose
+ private String timerel;
+ @SerializedName("time")
+ @Expose
+ private String time;
+ @SerializedName("endTime")
+ @Expose
+ private String endTime;
+ @SerializedName("timeproperty")
+ @Expose
+ private String timeproperty;
+ @SerializedName("includeSysAttrs")
+ @Expose
+ private boolean includeSysAttrs;
+ @SerializedName("keyValues")
+ @Expose
+ private boolean keyValues;
+ @SerializedName("temporalValues")
+ @Expose
+ private boolean temporalValues;
+
+ @SerializedName("limit")
+ @Expose
+ private int limit = -1;
+
+ @SerializedName("offSet")
+ @Expose
+ private int offSet = -1;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public QueryParams withId(String id) {
+ this.id = id;
+ return this;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public QueryParams withType(String type) {
+ this.type = type;
+ return this;
+ }
+
+ public String getAttrs() {
+ return attrs;
+ }
+
+ public void setAttrs(String attrs) {
+ this.attrs = attrs;
+ }
+
+ public QueryParams withAttrs(String attrs) {
+ this.attrs = attrs;
+ return this;
+ }
+
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ public QueryParams withInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ return this;
+ }
+
+ public String getIdPattern() {
+ return idPattern;
+ }
+
+ public void setIdPattern(String idPattern) {
+ this.idPattern = idPattern;
+ }
+
+ public QueryParams withIdPattern(String idPattern) {
+ this.idPattern = idPattern;
+ return this;
+ }
+
+ public String getQ() {
+ return q;
+ }
+
+ public void setQ(String q) {
+ this.q = q;
+ }
+
+ public QueryParams withQ(String q) {
+ this.q = q;
+ return this;
+ }
+
+ public GeoqueryRel getGeorel() {
+ return georel;
+ }
+
+ public void setGeorel(GeoqueryRel georel) {
+ this.georel = georel;
+ }
+
+ public QueryParams withGeorel(GeoqueryRel georel) {
+ this.georel = georel;
+ return this;
+ }
+
+ public String getGeometry() {
+ return geometry;
+ }
+
+ public void setGeometry(String geometry) {
+ this.geometry = geometry;
+ }
+
+ public QueryParams withGeometry(String geometry) {
+ this.geometry = geometry;
+ return this;
+ }
+
+ public String getCoordinates() {
+ return coordinates;
+ }
+
+ public void setCoordinates(String coordinates) {
+ this.coordinates = coordinates;
+ }
+
+ public QueryParams withCoordinates(String coordinates) {
+ this.coordinates = coordinates;
+ return this;
+ }
+
+ public String getGeoproperty() {
+ return geoproperty;
+ }
+
+ public void setGeoproperty(String geoproperty) {
+ this.geoproperty = geoproperty;
+ }
+
+ public QueryParams withGeoproperty(String geoproperty) {
+ this.geoproperty = geoproperty;
+ return this;
+ }
+
+ public String getTimerel() {
+ return timerel;
+ }
+
+ public void setTimerel(String timerel) {
+ this.timerel = timerel;
+ }
+
+ public QueryParams withTimerel(String timerel) {
+ this.timerel = timerel;
+ return this;
+ }
+
+ public String getTime() {
+ return time;
+ }
+
+ public void setTime(String time) {
+ this.time = time;
+ }
+
+ public QueryParams withTime(String time) {
+ this.time = time;
+ return this;
+ }
+
+ public String getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(String endTime) {
+ this.endTime = endTime;
+ }
+
+ public QueryParams withEndTime(String endTime) {
+ this.endTime = endTime;
+ return this;
+ }
+
+ public String getTimeproperty() {
+ return timeproperty;
+ }
+
+ public void setTimeproperty(String timeproperty) {
+ this.timeproperty = timeproperty;
+ }
+
+ public QueryParams withTimeproperty(String timeproperty) {
+ this.timeproperty = timeproperty;
+ return this;
+ }
+
+ public boolean getIncludeSysAttrs() {
+ return includeSysAttrs;
+ }
+
+ public void setIncludeSysAttrs(boolean includeSysAttrs) {
+ this.includeSysAttrs = includeSysAttrs;
+ }
+
+ public QueryParams withIncludeSysAttrs(boolean includeSysAttrs) {
+ this.includeSysAttrs = includeSysAttrs;
+ return this;
+ }
+
+ public boolean getKeyValues() {
+ return keyValues;
+ }
+
+ public void setKeyValues(boolean keyValues) {
+ this.keyValues = keyValues;
+ }
+
+ public QueryParams withKeyValues(boolean keyValues) {
+ this.keyValues = keyValues;
+ return this;
+ }
+
+ public boolean getTemporalValues() {
+ return temporalValues;
+ }
+
+ public void setTemporalValues(boolean temporalValues) {
+ this.temporalValues = temporalValues;
+ }
+
+ public QueryParams withTemporalValues(boolean temporalValues) {
+ this.temporalValues = temporalValues;
+ return this;
+ }
+
+ public int getLimit() {
+ return limit;
+ }
+
+ public void setLimit(int limit) {
+ this.limit = limit;
+ }
+
+ public int getOffSet() {
+ return offSet;
+ }
+
+ public void setOffSet(int offSet) {
+ this.offSet = offSet;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("id", id).append("type", type).append("attrs", attrs)
+ .append("idPattern", idPattern).append("q", q).append("georel", georel).append("geometry", geometry)
+ .append("coordinates", coordinates).append("geoproperty", geoproperty).append("timerel", timerel)
+ .append("time", time).append("endTime", endTime).append("timeproperty", timeproperty).toString();
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryParams.schema.json b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryParams.schema.json
new file mode 100644
index 0000000000000000000000000000000000000000..6fcbefb5d8af17ec97298fe7dfbeadca665de809
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryParams.schema.json
@@ -0,0 +1,45 @@
+{
+ "type":"object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ },
+ "attrs": {
+ "type": "string"
+ },
+ "idPattern": {
+ "type": "string"
+ },
+ "q": {
+ "type": "string"
+ },
+ "georel": {
+ "type": "object",
+ "javaType" : "GeoqueryRel",
+ },
+ "geometry": {
+ "type": "string"
+ },
+ "coordinates": {
+ "type": "string"
+ },
+ "geoproperty": {
+ "type": "string"
+ },
+ "timerel": {
+ "type": "string"
+ },
+ "time": {
+ "type": "string"
+ },
+ "endTime": {
+ "type": "string"
+ },
+ "timeproperty": {
+ "type": "string"
+ }
+ }
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryResult.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryResult.java
new file mode 100644
index 0000000000000000000000000000000000000000..84d310e3273d8902f2a6e791cf39fd8b77babc7d
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryResult.java
@@ -0,0 +1,101 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.util.List;
+
+import eu.neclab.ngsildbroker.commons.enums.ErrorType;
+
+/**
+ * @author hebgen
+ * @version 1.0
+ * @created 11-Jun-2018 11:13:22
+ */
+public class QueryResult extends BaseResult {
+
+ public QueryResult(List dataString, String errorMsg, ErrorType errorType, int shortErrorMsg, boolean success) {
+ super(errorMsg, errorType, shortErrorMsg, success);
+ this.dataString = dataString;
+ }
+
+
+ private String qToken;
+ private Integer limit;
+ private Integer offset;
+ private Integer resultsLeftAfter;
+ private Integer resultsLeftBefore;
+
+ private List dataString;
+
+
+
+ public Integer getResultsLeftBefore() {
+ return resultsLeftBefore;
+ }
+
+
+
+ public void setResultsLeftBefore(Integer resultsLeftBefore) {
+ this.resultsLeftBefore = resultsLeftBefore;
+ }
+
+
+
+ public Integer getResultsLeftAfter() {
+ return resultsLeftAfter;
+ }
+
+
+
+ public void setResultsLeftAfter(Integer resultsLeft) {
+ this.resultsLeftAfter = resultsLeft;
+ }
+
+
+
+ public String getqToken() {
+ return qToken;
+ }
+
+
+
+ public void setqToken(String qToken) {
+ this.qToken = qToken;
+ }
+
+
+
+ public Integer getLimit() {
+ return limit;
+ }
+
+
+
+ public void setLimit(Integer limit) {
+ this.limit = limit;
+ }
+
+
+
+ public Integer getOffset() {
+ return offset;
+ }
+
+
+
+ public void setOffset(Integer offset) {
+ this.offset = offset;
+ }
+
+
+ public List getDataString() {
+ return dataString;
+ }
+
+ public void setDataString(List dataString) {
+ this.dataString = dataString;
+ }
+
+ public void finalize() throws Throwable {
+
+ }
+
+}
\ No newline at end of file
diff --git a/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryTerm.java b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryTerm.java
new file mode 100644
index 0000000000000000000000000000000000000000..70f221c99ad24b5c4495b2891d844e6b82be8577
--- /dev/null
+++ b/scorpio-broker/Commons/src/main/java/eu/neclab/ngsildbroker/commons/datatypes/QueryTerm.java
@@ -0,0 +1,1243 @@
+package eu.neclab.ngsildbroker.commons.datatypes;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import eu.neclab.ngsildbroker.commons.constants.DBConstants;
+import eu.neclab.ngsildbroker.commons.constants.NGSIConstants;
+import eu.neclab.ngsildbroker.commons.enums.ErrorType;
+import eu.neclab.ngsildbroker.commons.exceptions.BadRequestException;
+import eu.neclab.ngsildbroker.commons.exceptions.ResponseException;
+import eu.neclab.ngsildbroker.commons.ngsiqueries.ParamsResolver;
+import eu.neclab.ngsildbroker.commons.tools.SerializationTools;
+
+public class QueryTerm {
+
+ private static final String RANGE = ".+\\.\\..+";
+ private static final String LIST = ".+(,.+)+";
+ private static final String URI = "\\w+:(\\/?\\/?)[^\\s^;]+";
+ private static final String DATETIME = "\\d\\d\\d\\d-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d(,\\d\\d\\d\\d\\d\\d)?Z";
+ private static final String DATE = "\\d\\d\\d\\d-\\d\\d-\\d\\d";
+ private static final String TIME = "\\d\\d:\\d\\d:\\d\\d(,\\d\\d\\d\\d\\d\\d)?Z";
+
+ private static final List TIME_PROPS = Arrays.asList(NGSIConstants.NGSI_LD_OBSERVED_AT,
+ NGSIConstants.NGSI_LD_CREATED_AT, NGSIConstants.NGSI_LD_MODIFIED_AT);
+ private List