├── .gitignore
├── License.txt
├── README.md
├── configs.json
├── examples
├── citybench
│ ├── AarhusTrafficData182955.stream
│ ├── SensorRepository.n3
│ ├── SensorRepository.ttl
│ └── ssnExtended.ttl
├── influenza
│ ├── catalog-v001.xml
│ ├── influenza.owl
│ ├── observation_example.xml
│ ├── static.owl
│ └── stream.xml
└── sensors
│ ├── input.stream
│ └── query.json
├── figs
└── StreamingMassifPrototypesDemo.png
├── logback.xml
├── pom.xml
├── src
├── main
│ ├── java
│ │ └── idlab
│ │ │ ├── examples
│ │ │ └── generators
│ │ │ │ ├── HTTPGetGenerator.java
│ │ │ │ ├── HTTPPostGenerator.java
│ │ │ │ ├── HTTPPostSinkTest.java
│ │ │ │ ├── SimpleEventSocket.java
│ │ │ │ ├── Test.java
│ │ │ │ ├── WebSocketClientGenerator.java
│ │ │ │ └── WebSocketServerGenerator.java
│ │ │ └── massif
│ │ │ ├── abstraction
│ │ │ └── hermit
│ │ │ │ ├── HermitAbstractionComp.java
│ │ │ │ ├── HermitAbstractionImpl.java
│ │ │ │ └── utils
│ │ │ │ └── DLQueryParser.java
│ │ │ ├── cep
│ │ │ └── esper
│ │ │ │ ├── EsperCEPComp.java
│ │ │ │ └── EsperCEPImpl.java
│ │ │ ├── core
│ │ │ ├── HTTPMonitoringSingleTon.java
│ │ │ ├── PipeLine.java
│ │ │ ├── PipeLineComponent.java
│ │ │ └── PipeLineGraph.java
│ │ │ ├── exceptions
│ │ │ └── QueryRegistrationException.java
│ │ │ ├── filter
│ │ │ └── jena
│ │ │ │ └── JenaFilter.java
│ │ │ ├── functions
│ │ │ ├── FunctionManyParTest.java
│ │ │ └── FunctionTest.java
│ │ │ ├── interfaces
│ │ │ └── core
│ │ │ │ ├── AbstractionInf.java
│ │ │ │ ├── AbstractionListenerInf.java
│ │ │ │ ├── CEPInf.java
│ │ │ │ ├── CEPListener.java
│ │ │ │ ├── FilterInf.java
│ │ │ │ ├── ListenerInf.java
│ │ │ │ ├── MapperInf.java
│ │ │ │ ├── MonitorInf.java
│ │ │ │ ├── PipeLineElement.java
│ │ │ │ ├── SelectionInf.java
│ │ │ │ ├── SelectionListenerInf.java
│ │ │ │ ├── SinkInf.java
│ │ │ │ ├── SourceInf.java
│ │ │ │ └── WindowInf.java
│ │ │ ├── listeners
│ │ │ └── AbstractionListener.java
│ │ │ ├── mapping
│ │ │ ├── JSONMapper.java
│ │ │ └── SimpleMapper.java
│ │ │ ├── run
│ │ │ ├── QueryParser.java
│ │ │ └── Run.java
│ │ │ ├── selection
│ │ │ └── csparql_basic
│ │ │ │ ├── CSparqlSelectionImpl.java
│ │ │ │ ├── DBPediaTest.java
│ │ │ │ ├── JenaReasoner.java
│ │ │ │ ├── JenaReasonerOWL2RL.java
│ │ │ │ ├── StreamingJena.java
│ │ │ │ └── utils
│ │ │ │ ├── EventReader.java
│ │ │ │ ├── GraphEvent.java
│ │ │ │ └── OWLUtils.java
│ │ │ ├── sinks
│ │ │ ├── HTTPGetCombinedSink.java
│ │ │ ├── HTTPGetSink.java
│ │ │ ├── HTTPPostSink.java
│ │ │ ├── PrintSink.java
│ │ │ ├── SparqlEPInsertSink.java
│ │ │ ├── WebSocketClientSink.java
│ │ │ ├── WebSocketServerSink.java
│ │ │ └── utils
│ │ │ │ └── WebSocketOutputStream.java
│ │ │ ├── sources
│ │ │ ├── FileSource.java
│ │ │ ├── HTTPGetSource.java
│ │ │ ├── HTTPPostCombinedSource.java
│ │ │ ├── HTTPPostSource.java
│ │ │ ├── KafkaConsumerSource.java
│ │ │ ├── KafkaSource.java
│ │ │ ├── WebSocketClientSource.java
│ │ │ ├── WebSocketServerSource.java
│ │ │ ├── kafkautils
│ │ │ │ ├── JsonPOJODeserializer.java
│ │ │ │ └── JsonPOJOSerializer.java
│ │ │ └── util
│ │ │ │ └── WebSocketInputStream.java
│ │ │ ├── timeout
│ │ │ ├── KeyedTimeout.java
│ │ │ └── Timeout.java
│ │ │ ├── utils
│ │ │ ├── FormatUtils.java
│ │ │ ├── RDFUtils.java
│ │ │ └── TableUtils.java
│ │ │ └── window
│ │ │ └── esper
│ │ │ └── EsperWindow.java
│ └── resources
│ │ └── web
│ │ ├── icon.png
│ │ ├── index.html
│ │ ├── index_vue.html
│ │ ├── mockup.html
│ │ └── style.css
└── test
│ └── java
│ └── idlab
│ └── massif
│ ├── AppTest.java
│ ├── MASSIFTest.java
│ ├── PipelineTest.java
│ ├── QueryTest.java
│ ├── SinkTest.java
│ ├── SourceTest.java
│ ├── abstraction
│ └── hermit
│ │ └── HermitAbstractionTest.java
│ ├── cep
│ └── esper
│ │ └── EsperCEPTest.java
│ ├── pipeline
│ ├── KafkaTest.java
│ ├── PipeLineTest.java
│ └── StreamingMASSIFTest.java
│ ├── selection
│ └── csparql_basic
│ │ └── CSparqlBasicTest.java
│ ├── timeout
│ └── KeyedTimeoutTest.java
│ └── utils
│ └── TableUtilsTest.java
├── web_old
├── icon.png
├── index.html
└── style.css
└── webfiles
├── .gitignore
└── log4j2.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .classpath
3 | .project
4 | target/*
5 |
6 | # Compiled class file
7 | *.class
8 |
9 | # Log file
10 | *.log
11 |
12 | # BlueJ files
13 | *.ctxt
14 |
15 | # Mobile Tools for Java (J2ME)
16 | .mtj.tmp/
17 |
18 | # Package Files #
19 | *.jar
20 | *.war
21 | *.nar
22 | *.ear
23 | *.zip
24 | *.tar.gz
25 | *.rar
26 |
27 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
28 | hs_err_pid*
29 | /target/
30 | .DS_Store
31 | .settings/
32 | .idea/
33 | /web/
34 |
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016 Ghent University and IMEC vzw with offices at Technologiepark 15, 9052 Ghent, Belgium - Email: info@imec.be.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software for non-commercial educational and research use, including without limitation the rights to use, copy, modify, merge, publish, distribute and/or sublicense copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | 1. The above copyright notice and this permission notice shall be included in all copies of the Software.
6 |
7 | 2. Permission is restricted to non-commercial educational and research use: the use of the Software is allowed for teaching purposes and academic research. Usage by non-academic parties is allowed in a strict research environment only. The use of the results of the research for commercial purposes or inclusion in commercial activities requires the permission of Ghent University and IMEC vzw.
8 |
9 | 3. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # StreamingMASSIF
2 |
3 | This is the implementation of the *StreamingMASSIF* platform, a streaming extension of the MASSIF platform.
4 |
5 | StreamingMASSIF allows to perform cascading reasoning by combining various components. In its standard configuration it allows to filter meaningful events from a datastream through RDF Stream Processing, abstract the selection through DL reasoning and perform Complex Event Processing ontop of these abstraction.
6 |
7 | Check the [wikipage](https://github.com/IBCNServices/StreamingMASSIF/wiki) for a more in depth explanation on how to use Streaming MASSIF!
8 |
9 | How to cite [Streaming MASSIF](https://www.mdpi.com/1424-8220/18/11/3832):
10 | ```
11 | @article{bonte2018streaming,
12 | title={Streaming MASSIF: Cascading Reasoning for Efficient Processing of IoT Data Streams},
13 | author={Bonte, Pieter and Tommasini, Riccardo and Della Valle, Emanuele and De Turck, Filip and Ongenae, Femke},
14 | journal={Sensors},
15 | volume={18},
16 | number={11},
17 | pages={3832},
18 | year={2018},
19 | publisher={Multidisciplinary Digital Publishing Institute}
20 | }
21 | ```
22 |
23 | How to cite [MASSIF](https://link.springer.com/article/10.1007/s10115-016-0969-1):
24 | ```
25 | @article{bonte2017massif,
26 | title={The MASSIF platform: a modular and semantic platform for the development of flexible IoT services},
27 | author={Bonte, Pieter and Ongenae, Femke and De Backere, Femke and Schaballie, Jeroen and Arndt, D{\"o}rthe and Verstichel, Stijn and Mannens, Erik and Van de Walle, Rik and De Turck, Filip},
28 | journal={Knowledge and Information Systems},
29 | volume={51},
30 | number={1},
31 | pages={89--126},
32 | year={2017},
33 | publisher={Springer}
34 | }
35 | ```
36 |
37 | ## Building and running MASSIF
38 |
39 | ### Requirements:
40 |
41 | - Java 9+
42 | - Maven2
43 |
44 | ### Build
45 | To build the MASSIF app, call `mvn` and get the compiled `.jar`.
46 | ```shell
47 | mvn clean compile assembly:single
48 | mv target/massif-jar-with-dependencies.jar .
49 | ```
50 |
51 | To build the MASSIF classes (e.g. for usage in higher level apps), call `mvn` to compile and install the project in the local repository, then add the package to the higher level app dependencies (see `pom.xml` snippet below):
52 | ```shell
53 | mvn install -Dmaven.test.skip=true
54 | ```
55 | ```xml
56 |
57 | be.ugent.idlab
58 | massif
59 | 0.0.1
60 |
61 | ```
62 |
63 | ### Run
64 | To run MASSIF, call the compiled `.jar` from the command line as follows:
65 | ```shell
66 | java -jar -Dlog4j.configurationFile=webfiles/log4j2.xml massif-jar-with-dependencies.jar
67 | ```
68 | Calling this command will return something like this on the CLI:
69 | ```shell
70 | 21:27:32.313 [main] INFO idlab.massif.run.Run - MASSIF STARTING
71 | 21:27:32.403 [main] INFO idlab.massif.run.Run - MASSIF Listening on port 9000
72 | 21:27:32.403 [main] INFO idlab.massif.run.Run - Access the MASSIF GUI on localhost:9000 or register a configuration on localhost:9000/register
73 | 21:27:32.414 [main] INFO idlab.massif.run.Run - MASSIF is ONLINE
74 | ```
75 | Run options:
76 | * `-p` : TCP port on which massif listens, default: `9000`
77 |
78 | GUI:
79 | * The MASSIF GUI is available on http://localhost:9000
80 |
81 | ### REST API
82 | The MASSIF allow for direct management through GET/POST calls.
83 | Here are the most important path:
84 | * `/register`: register a configuration
85 | * `/stop` : stop a certain query
86 | * `/configs` : get all registered configs
87 |
88 | ### REST API call examples with the [cURL](https://linuxize.com/post/curl-post-request/) tool
89 | List of active configs:
90 | ```
91 | curl -X GET --verbose \
92 | --url "http://127.0.0.1:9000/configs"
93 | ```
94 | * Note: returns `{}` if there are no active config.
95 |
96 | Stop a config (pre-requisite: config ID, see previous command):
97 | ```
98 | curl -X POST --verbose \
99 | -H "Content-Type: application/json" \
100 | -d '19' \
101 | --url "http://127.0.0.1:9000/stop"
102 | ```
103 | * Note: returns `ok`
104 |
105 | Send a config:
106 | ```
107 | curl -X POST --verbose \
108 | -H "Content-Type: application/json" \
109 | -d '{"configuration":{"0":[1],"1":[]},"components":{"0":{"type":"Source","impl":"kafkaSource","kafkaServer":"127.0.0.1:9092","kafkaTopic":"backblaze_smart"},"1":{"type":"Sink","impl":"httpGetSinkCombined","path":"1","config":""}}}' \
110 | --url "http://127.0.0.1:9000/register"
111 | ```
112 | * Note: returns the config ID
113 |
114 | Get a component running metrics (pre-requisite: component ID, see previous commands):
115 | ```
116 | curl -X GET --verbose \
117 | --url "http://127.0.0.1:9000/monitor/1"
118 | ```
119 |
120 |
121 |
--------------------------------------------------------------------------------
/configs.json:
--------------------------------------------------------------------------------
1 |
2 |
3 | {
4 | "components": {
5 | "comp1": {
6 | "type": "Sink",
7 | "impl": "PrintSink"
8 | },
9 | "sink2": {
10 | "type": "Sink",
11 | "impl": "HTTPGetSinkCombined",
12 | "path":"sink",
13 | "config":"last"
14 | },
15 | "comp2": {
16 | "type": "window",
17 | "size": 1,
18 | "slide": 1
19 | },
20 | "comp3": {
21 | "type": "Filter",
22 | "queries": ["CONSTRUCT{?obs ?p ?o.} WHERE {?obs ; [ ]. ?obs ?p ?o}"],
23 | "ontology":"http://aaa-master.aaadev.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be:30081/sensors.ttl"
24 | },
25 | "comp4": {
26 | "type": "Abstract",
27 | "expressions": [
28 | {
29 | "head": "http://massif.test/EventA",
30 | "tail": "Observation"
31 | }
32 | ]
33 | },
34 | "comp5": {
35 | "type": "Source",
36 | "impl": "HTTPGetSource",
37 | "url": "http://aaa-master.aaadev.wall2-ilabt-iminds-be.wall2.ilabt.iminds.be:30080/httpgetsink/sink",
38 | "timeout": 1000
39 | }
40 | },
41 | "configuration": {
42 | "comp1": [],
43 | "comp3": [
44 | "comp1"
45 | ],
46 | "comp2": [
47 | "comp3"
48 | ],
49 | "comp5": [
50 | "comp2",
51 | "sink2"
52 | ],
53 | "comp4": [
54 | "comp1"
55 | ]
56 | }
57 | }
58 |
59 | {
60 | "components": {
61 | "print": {
62 | "type": "Sink",
63 | "impl": "PrintSink"
64 | },
65 | "window": {
66 | "type": "window",
67 | "size": 1,
68 | "slide": 1
69 | },
70 | "filter": {
71 | "type": "Filter",
72 | "queries": ["CONSTRUCT{?s ?p ?p.} WHERE {?s ?p ?o}"]
73 | },
74 | "abstract": {
75 | "type": "Abstract",
76 | "expressions": [
77 | {
78 | "head": "http://massif.test/EventA",
79 | "tail": "Observation"
80 | }
81 | ]
82 | },
83 | "kafka": {
84 | "type": "Source",
85 | "impl": "KafkaSource",
86 | "kafkaServer": "kafka-headless.kafka:9092",
87 | "kafkaTopic": "idlab.homelab.semantic"
88 | },
89 | "sink": {
90 | "type": "Sink",
91 | "impl": "HTTPGetSinkCombined",
92 | "path":"sink",
93 | "config":"last"
94 | },
95 | },
96 | "configuration": {
97 | "print": [],
98 | "abstract": [
99 | "print"
100 | ],
101 | "window": [
102 | "filter"
103 | ],
104 | "kafka": [
105 | "sink"
106 | ],
107 | "filter": [
108 | "abstract"
109 | ]
110 | }
111 | }
--------------------------------------------------------------------------------
/examples/influenza/catalog-v001.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/examples/influenza/observation_example.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | 30.0
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 | 37.9
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/examples/sensors/input.stream:
--------------------------------------------------------------------------------
1 | .
2 | .
3 | .
4 | .
5 | .
6 | .
7 | .
8 | "465.92" .
--------------------------------------------------------------------------------
/examples/sensors/query.json:
--------------------------------------------------------------------------------
1 | {
2 | "components": {
3 | "file":{"type":"Source","impl":"FileSource","fileName":"examples/sensors/input.stream","timeout":1000},
4 | "print":{"type":"Sink","impl":"PrintSink"},
5 | "window": {"type": "window","size": 10,"slide": 1},
6 | "filter": {"type": "Filter","queries": ["CONSTRUCT{?s ?p ?p.} WHERE {?s ?p ?o}"]}
7 | },
8 | "configuration": {
9 | "file": ["window"],
10 | "window":["filter"],
11 | "filter":["print"]
12 |
13 | }
14 | }
15 |
16 | {
17 | "components": {
18 | "0":{"type":"Source","impl":"FileSource","fileName":"examples/sensors/input.stream","timeout":1000},
19 | "2": {"type": "window","size": 10,"slide": 1},
20 | "3": {"type": "Filter","queries": ["CONSTRUCT{?s ?p ?p.} WHERE {?s ?p ?o}"]},
21 | "1":{"type":"Sink","impl":"PrintSink"}
22 | },
23 | "configuration": {
24 | "0": ["2"],
25 | "2":["3"],
26 | "3":["1"]
27 |
28 | }
29 | }
--------------------------------------------------------------------------------
/figs/StreamingMassifPrototypesDemo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KNowledgeOnWebScale/StreamingMASSIF/c84fcaf251f8dffbb32bb188821cb2159b1646fd/figs/StreamingMassifPrototypesDemo.png
--------------------------------------------------------------------------------
/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | c:/tmp/output.log
5 |
6 |
7 | %date %level [%thread] %logger{10} [%file:%line] %msg%n
8 |
9 |
10 |
11 |
12 |
13 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
14 |
15 |
16 |
17 |
20 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 | be.ugent.idlab
7 | massif
8 | 0.0.1
9 | jar
10 |
11 | massif
12 | http://maven.apache.org
13 |
14 |
15 | UTF-8
16 | 1.9
17 | 1.9
18 |
19 |
20 |
21 | massif
22 |
23 |
24 | maven-assembly-plugin
25 |
26 |
27 |
28 | idlab.massif.run.Run
29 |
30 |
31 |
32 | jar-with-dependencies
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.apache.jena
43 | jena-arq
44 | 3.16.0
45 |
46 |
47 | com.github.jsonld-java
48 | jsonld-java
49 |
50 |
51 |
52 |
53 |
54 | net.sourceforge.owlapi
55 | org.semanticweb.hermit
56 | 1.4.3.517
57 |
58 |
59 | com.github.jsonld-java
60 | jsonld-java
61 |
62 |
63 |
64 |
65 |
66 | com.github.jsonld-java
67 | jsonld-java
68 | 0.12.5
69 |
70 |
71 |
72 | com.espertech
73 | esper
74 | 7.1.0
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | junit
85 | junit
86 | 4.12
87 | test
88 |
89 |
90 | com.sparkjava
91 | spark-core
92 | 2.9.1
93 |
94 |
95 | org.apache.logging.log4j
96 | log4j-api
97 | 2.11.1
98 |
99 |
100 | org.apache.logging.log4j
101 | log4j-core
102 | 2.11.1
103 |
104 |
105 | org.apache.logging.log4j
106 | log4j-slf4j-impl
107 | 2.11.1
108 |
109 |
110 |
111 | org.json
112 | json
113 | 20200518
114 |
115 |
116 |
117 | org.apache.kafka
118 | kafka-streams
119 | 2.5.0
120 |
121 |
122 | commons-codec
123 | commons-codec
124 | 1.14
125 |
126 |
127 | com.jsoniter
128 | jsoniter
129 | 0.9.19
130 |
131 |
132 | info.picocli
133 | picocli
134 | 4.6.1
135 |
136 |
137 |
138 |
139 |
140 |
--------------------------------------------------------------------------------
/src/main/java/idlab/examples/generators/HTTPGetGenerator.java:
--------------------------------------------------------------------------------
1 | package idlab.examples.generators;
2 |
3 | import spark.Spark;
4 |
5 | public class HTTPGetGenerator {
6 | public static void main(String[] args) {
7 | new HTTPGetGenerator();
8 | }
9 |
10 | public HTTPGetGenerator() {
11 | Spark.get("/test", (req, res) -> ONT_EVENT);
12 |
13 | }
14 | private static String ONT_EVENT="\n" +
15 | "\n" +
23 | " \n" +
24 | " \n" +
25 | " \n" +
26 | " \n" +
27 | "\n" +
28 | "\n" +
29 | " \n" +
36 | "\n" +
37 | " \n" +
38 | "\n" +
39 | "\n" +
40 | " \n" +
41 | "\n" +
42 | " \n" +
43 | " \n" +
44 | " \n" +
45 | " \n" +
46 | "\n" +
47 | "\n" +
48 | " \n" +
49 | "\n" +
50 | " \n" +
51 | " \n" +
52 | " \n" +
53 | " \n" +
54 | "\n" +
55 | "\n" +
56 | " \n" +
57 | "\n" +
58 | " \n" +
59 | " \n" +
60 | " \n" +
61 | " \n" +
62 | "\n" +
63 | "\n" +
64 | " \n" +
65 | "\n" +
66 | " \n" +
67 | " \n" +
68 | " \n" +
69 | " \n" +
70 | "";
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/idlab/examples/generators/HTTPPostGenerator.java:
--------------------------------------------------------------------------------
1 | package idlab.examples.generators;
2 |
3 | import java.io.IOException;
4 | import java.io.UnsupportedEncodingException;
5 |
6 | import org.apache.http.client.methods.CloseableHttpResponse;
7 | import org.apache.http.client.methods.HttpPost;
8 | import org.apache.http.client.methods.HttpPut;
9 | import org.apache.http.entity.StringEntity;
10 | import org.apache.http.impl.client.CloseableHttpClient;
11 | import org.apache.http.impl.client.HttpClients;
12 |
13 | public class HTTPPostGenerator {
14 | public static void main(String[] args) {
15 | new HTTPPostGenerator();
16 | }
17 |
18 | public HTTPPostGenerator() {
19 |
20 |
21 | while(true) {
22 |
23 |
24 | try {
25 |
26 | CloseableHttpClient client = HttpClients.createDefault();
27 | HttpPost httpPost = new HttpPost("http://localhost:8080/test");
28 |
29 | StringEntity entity = new StringEntity(ONT_EVENT);
30 | httpPost.setEntity(entity);
31 |
32 |
33 | CloseableHttpResponse response = client.execute(httpPost);
34 | client.close();
35 | try {
36 | Thread.sleep(1000);
37 | } catch (InterruptedException e) {
38 | // TODO Auto-generated catch block
39 | e.printStackTrace();
40 | }
41 |
42 | } catch (UnsupportedEncodingException e) {
43 | // TODO Auto-generated catch block
44 | e.printStackTrace();
45 | }catch( IOException e) {
46 | e.printStackTrace();
47 | }
48 | }
49 |
50 | }
51 | private static String ONT_EVENT="\n" +
52 | "\n" +
60 | " \n" +
61 | " \n" +
62 | " \n" +
63 | " \n" +
64 | "\n" +
65 | "\n" +
66 | " \n" +
73 | "\n" +
74 | " \n" +
75 | "\n" +
76 | "\n" +
77 | " \n" +
78 | "\n" +
79 | " \n" +
80 | " \n" +
81 | " \n" +
82 | " \n" +
83 | "\n" +
84 | "\n" +
85 | " \n" +
86 | "\n" +
87 | " \n" +
88 | " \n" +
89 | " \n" +
90 | " \n" +
91 | "\n" +
92 | "\n" +
93 | " \n" +
94 | "\n" +
95 | " \n" +
96 | " \n" +
97 | " \n" +
98 | " \n" +
99 | "\n" +
100 | "\n" +
101 | " \n" +
102 | "\n" +
103 | " \n" +
104 | " \n" +
105 | " \n" +
106 | " \n" +
107 | "";
108 | }
109 |
--------------------------------------------------------------------------------
/src/main/java/idlab/examples/generators/HTTPPostSinkTest.java:
--------------------------------------------------------------------------------
1 | package idlab.examples.generators;
2 |
3 | import spark.Spark;
4 |
5 | public class HTTPPostSinkTest {
6 |
7 | public static void main(String[] args) {
8 | // TODO Auto-generated method stub
9 | String path = "test";
10 | Spark.port(9090);
11 | Spark.post("/" + path, (req, res) -> {
12 | System.out.println(req.body());
13 |
14 | return "ok";
15 | });
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/idlab/examples/generators/Test.java:
--------------------------------------------------------------------------------
1 | package idlab.examples.generators;
2 |
3 | import java.io.ByteArrayInputStream;
4 | import java.io.InputStream;
5 | import java.util.ArrayList;
6 | import java.util.HashSet;
7 | import java.util.List;
8 | import java.util.Set;
9 |
10 | import org.apache.jena.query.Query;
11 | import org.apache.jena.query.QueryExecution;
12 | import org.apache.jena.query.QueryExecutionFactory;
13 | import org.apache.jena.query.QueryFactory;
14 | import org.apache.jena.query.QuerySolution;
15 | import org.apache.jena.query.ResultSet;
16 | import org.apache.jena.rdf.model.Model;
17 | import org.apache.jena.rdf.model.ModelFactory;
18 | import org.apache.jena.rdf.model.ResourceFactory;
19 | import org.apache.jena.rdf.model.StmtIterator;
20 |
21 | public class Test {
22 |
23 | public static void main(String[] args) {
24 | System.out.println(ResourceFactory.createResource("http://IBCNServices.github.io/homelab.owl#lightIntensity"));;
25 | }
26 | private static String stripFilterName(String longName) {
27 | if (longName.contains("#")) {
28 | return longName.substring(longName.lastIndexOf('#') + 1);
29 |
30 | } else {
31 | return longName.substring(longName.lastIndexOf('/') + 1);
32 | }
33 | }
34 | private static String ONT_EVENT="\n" +
35 | "\n" +
43 | " \n" +
44 | " \n" +
45 | " \n" +
46 | " \n" +
47 | "\n" +
48 | "\n" +
49 | " \n" +
56 | "\n" +
57 | " \n" +
58 | "\n" +
59 | "\n" +
60 | " \n" +
61 | "\n" +
62 | " \n" +
63 | " \n" +
64 | " \n" +
65 | " \n" +
66 | "\n" +
67 | "\n" +
68 | " \n" +
69 | "\n" +
70 | " \n" +
71 | " \n" +
72 | " \n" +
73 | " \n" +
74 | "\n" +
75 | "\n" +
76 | " \n" +
77 | "\n" +
78 | " \n" +
79 | " \n" +
80 | " \n" +
81 | " \n" +
82 | "\n" +
83 | "\n" +
84 | " \n" +
85 | "\n" +
86 | " \n" +
87 | " \n" +
88 | " \n" +
89 |
90 | " \n" +
91 | " \n" +
92 | "";
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/idlab/examples/generators/WebSocketClientGenerator.java:
--------------------------------------------------------------------------------
1 | package idlab.examples.generators;
2 |
3 | import java.net.URI;
4 | import java.util.concurrent.TimeUnit;
5 |
6 | import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
7 | import org.eclipse.jetty.websocket.client.WebSocketClient;
8 |
9 |
10 | public class WebSocketClientGenerator {
11 | public static void main(String[] args) {
12 | WebSocketClient client = new WebSocketClient();
13 |
14 | SimpleEventSocket socket = new SimpleEventSocket();
15 | try
16 | {
17 | client.start();
18 |
19 | URI echoUri = new URI("ws://localhost:4000/ws");
20 | ClientUpgradeRequest request = new ClientUpgradeRequest();
21 | client.connect(socket,echoUri,request);
22 | System.out.printf("Connecting to : %s%n",echoUri);
23 |
24 | // wait for closed socket connection.
25 | socket.awaitClose(5,TimeUnit.SECONDS);
26 |
27 | }
28 | catch (Throwable t)
29 | {
30 | t.printStackTrace();
31 | }
32 | finally
33 | {
34 | try
35 | {
36 | client.stop();
37 | }
38 | catch (Exception e)
39 | {
40 | e.printStackTrace();
41 | }
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/idlab/examples/generators/WebSocketServerGenerator.java:
--------------------------------------------------------------------------------
1 | package idlab.examples.generators;
2 |
3 | import idlab.massif.sources.util.WebSocketInputStream;
4 | import spark.Spark;
5 |
6 | public class WebSocketServerGenerator {
7 |
8 | public static void main(String[] args) {
9 | Spark.port(4000);
10 | Spark.webSocket("/ws", new SimpleEventSocket());
11 | Spark.init();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/idlab/massif/abstraction/hermit/HermitAbstractionComp.java:
--------------------------------------------------------------------------------
1 | package idlab.massif.abstraction.hermit;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.util.HashMap;
6 | import java.util.HashSet;
7 | import java.util.Map;
8 | import java.util.Map.Entry;
9 | import java.util.Set;
10 | import java.util.stream.Collectors;
11 |
12 | import org.semanticweb.HermiT.Configuration;
13 | import org.semanticweb.HermiT.Reasoner;
14 | import org.semanticweb.owlapi.apibinding.OWLManager;
15 | import org.semanticweb.owlapi.io.StringDocumentSource;
16 | import org.semanticweb.owlapi.io.StringDocumentTarget;
17 | import org.semanticweb.owlapi.model.IRI;
18 | import org.semanticweb.owlapi.model.OWLAxiom;
19 | import org.semanticweb.owlapi.model.OWLClass;
20 | import org.semanticweb.owlapi.model.OWLClassExpression;
21 | import org.semanticweb.owlapi.model.OWLDataFactory;
22 | import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom;
23 | import org.semanticweb.owlapi.model.OWLNamedIndividual;
24 | import org.semanticweb.owlapi.model.OWLOntology;
25 | import org.semanticweb.owlapi.model.OWLOntologyCreationException;
26 | import org.semanticweb.owlapi.model.OWLOntologyManager;
27 | import org.semanticweb.owlapi.model.OWLOntologyStorageException;
28 | import org.semanticweb.owlapi.model.OWLSubClassOfAxiom;
29 | import org.semanticweb.owlapi.reasoner.NodeSet;
30 | import org.slf4j.Logger;
31 | import org.slf4j.LoggerFactory;
32 |
33 | import idlab.massif.abstraction.hermit.utils.DLQueryParser;
34 | import idlab.massif.interfaces.core.AbstractionInf;
35 | import idlab.massif.interfaces.core.AbstractionListenerInf;
36 | import idlab.massif.interfaces.core.ListenerInf;
37 |
38 | public class HermitAbstractionComp implements AbstractionInf {
39 | private OWLOntology ontology;
40 | private OWLOntologyManager manager;
41 | private Reasoner reasoner;
42 | private OWLDataFactory factory;
43 | private static String EVENT_IRI = "http://idlab.massif.be/EVENT";
44 | private static String ONTOLOGY_IRI = "http://idlab.massif.be/abstraction.owl#";
45 |
46 | private ListenerInf listener;
47 | private DLQueryParser parser;
48 | private int queryCounter = 0;
49 | private Map queryIDMapper;
50 | private Set queries;
51 |
52 | private final Logger logger = LoggerFactory.getLogger(this.getClass());
53 |
54 | public HermitAbstractionComp() {
55 | this.queryIDMapper = new HashMap();
56 | this.queries = new HashSet();
57 | }
58 |
59 | public HermitAbstractionComp(OWLOntology ontology) {
60 | this();
61 | setOntology(ontology);
62 | }
63 |
64 | public HermitAbstractionComp(String ontologyIRI) {
65 | // load ontology
66 | this.manager = OWLManager.createOWLOntologyManager();
67 | try {
68 | this.ontology = manager.loadOntologyFromOntologyDocument(IRI.create(ontologyIRI));
69 | } catch (OWLOntologyCreationException e) {
70 | // TODO Auto-generated catch block
71 | e.printStackTrace();
72 | }
73 | initiateReasoner();
74 | }
75 |
76 | private void initiateReasoner() {
77 | // initiate the reasoner
78 | Configuration conf = new Configuration();
79 | conf.ignoreUnsupportedDatatypes = true;
80 | // conf.prepareReasonerInferences = new PrepareReasonerInferences();
81 | // conf.prepareReasonerInferences.realisationRequired = true;
82 | this.reasoner = new Reasoner(conf, this.ontology);
83 | this.factory = manager.getOWLDataFactory();
84 | }
85 |
86 | @Deprecated
87 | public boolean registerDLQuery(String newClass, String classExpression, AbstractionListenerInf listener) {
88 |
89 | return false;
90 | }
91 |
92 | public void addEvent(Set event) {
93 |
94 | System.out.println(event);
95 | Set