FIESTA-IoT Prototype Developer Documentation To set up, run, understand the FIESTA-IoT Prototype project

This is the documentation to set up the prototype aiming to share ideas and vision of the project within the consortium. The real FIESTA-IoT platform is available (https://platform.fiesta-iot.eu/).

Do not be afraid by the size of this documentation, we added a lot of screenshot like in tutorials to ease the task to set up this project. By experience, it takes less than one day to set up the project with this documentation.

14 Partners

Powered by

Status Work in progress We are working on the implementation and the integration work. FIESTA-IoT project: 2015-2018 Creator This prototype has been built to share idea within the FIESTA-IoT consortium Dr. Amélie Gyrard is a post-doc researcher at Insight Center for Data Analytics, National University of Galway, Ireland within the IoT unit lead by Dr. Martin Serrano.

Do not hesitate to ask for help or give us feedback, advices to improve our tools or documentations, fix bugs and make them more user-friendly and convenient:

Contributors  Joao Bosco Jares (Insight Center for Data Analytics, National University of Galway, Ireland )  Rachit Agarwal (INRIA Paris)  FIESTA-IoT consortium Code Ask access to Gitlab:  https://gitlab.fiesta-iot.eu/users/sign_in  https://gitlab.fiesta-iot.eu/

Documentation http://fiesta-iot- URL tools.appspot.com/documentation/FIESTA_Prototype_Developer_Documentation.pdf

There is also the documentation to use the web services if required: http://fiesta-iot-tools.appspot.com/documentation/DemoUserGuideTutorial.pdf

Last updated  November 2016 After 1 year and half of research and development, this project really needs a refactoring (even if I have done it frequently), and even maybe to be re-think from scratch. Anyway, this is the documentation to reuse, set up and understand the FIESTA-IoT prototype project. Goal  This documentation guides developers to set up and run this prototype project.  Understanding the project code (description of packages)  Understanding the technologies used in the project Requirements 1.7, Eclipse Kepler, App Engine SDK 1.9, Jena framework 2.11. Technologies  Java 1.7 is required to use Google App Engine used  We used Eclipse Kepler to develop the FIESTA-IoT prototype  Jena: a framework to build semantic web applications  Google App engine (App Engine SDK 1.9) to host the web site online (we do not need to have our own server and domain name)  Java Data Objects (JDO) to store data (e.g., semantic sensor data) on the google app engine datastore  RESTful Java, Jersey (JAX-RS) to develop Java web services  User interface: HTML, CSS, Bootstrap, JavaScript, System Windows 7, 64 bits Status Work in progress Time estimated 1 day to set up the project

Part I : Technologies used in FIESTA-IoT prototype...... 6 I. Jena ...... 7 II. Google App Engine ...... 7 III. RESTful implementation for JAVA: JAX-RS ...... 7 Part II : Set up the FIESAT-IoT prototype project ...... 8 IV. Get the code and everything available on Google Drive to follow this tutorial ...... 8 V. The FIESTA_IoT_Tutorial_Set_up_Prototype directory ...... 9 VI. Install Java and JRE 1.7 ...... 11 VII. Install Eclipse Kepler ...... 11 1. Import and open the project within Eclipse ...... 13 2. Result expected: Check that you can see the project ...... 13 VIII. (Optional) Install the Google Plugin for Eclipse ...... 14 Part III : Running the project on localhost ...... 17 I. Discover the project and run it ...... 17 II. Integrating all Jars requires (Solve Java Build Path Problems) ...... 20 III. (Optional) Install Jena inside Eclipse ...... 25 IV. Check that you have the Java Compiler 1.7 within Eclipse ...... 25 V. Run the project on localhost ...... 26 Part IV : Deploying the project on the Web (Optional) ...... 29 VI. Error App engine when deploying ...... 35 Part V : Understanding the project ...... 36 I. FIESTA-IoT Prototype overview...... 36 II. Libraries (Jars) required ...... 38 III. Descriptions of packages ...... 38 1. insight.web.service ...... 39 IV. The WAR directory ...... 40 1. WAR/CSS ...... 40 2. WAR/dataset ...... 40 3. WAR/documentation ...... 40 4. WAR/html ...... 40 5. WAR/images ...... 40 6. WAR/ ...... 41 7. WAR/ONTOLOGIES...... 41 8. WAR/RULES ...... 41 9. WAR/SPARQL ...... 41 Part VI : Understanding web services ...... 42 Part VII : Gitlab for the FIESTA-IoT consortium code ...... 43

FIGURE 1. TECHNOLOGIES USED IS THIS PROJECT ...... 7 FIGURE 2. REPOSITORY ON GOOGLE DRIVE TO SET UP THE CODE WITH EXACTLY THE SAME ENVIRONMENT ...... 8 FIGURE 3 THE CODE OF THE PROTOTYPE ...... 8 FIGURE 4. THE CODE CORRESPONDS TO THIS PROTOTYPE...... 9 FIGURE 2. FIESTA_IOT_TUTORIAL_SET_UP_PROTOTYPE DIRECTORY ...... 10 FIGURE 8. APP ENGINE SDK 1.9 ALREADY IN THE ECLIPSE THAT WE PROVIDED ...... 10 FIGURE 9. JARS REQUIRED IN THE PROJECT ARE PROVIDED IN THE JAR DIRECTORY ...... 11 FIGURE 10. INSTALL ECLIPSE KEPLER THAT WE PROVIDED ...... 12 FIGURE 11. JAVA 1.7 IS REQUIRED WITH THE GOOGLE PLUGIN FOR ECLIPSE ...... 12 FIGURE 12. THE ECLIPSE WORKSPACE IS EMPTY ...... 13 FIGURE 13. THE PROJECT IN THE ECLIPSE WORKSPACE ...... 14 FIGURE 14. GOOGLE APP ENGINE SETTINGS ...... 15 FIGURE 15. CHECK THAT THE DATANUCLEUS JPP/JPA IS V1 ...... 16 FIGURE 16. OPEN THE FIESTA-IOT PROTOTYPE PROJECT ...... 17 FIGURE 20. FILE -> IMPORT A NEW PROJECT ...... 17 FIGURE 21. IMPORT A NEW PROJECT WITHIN ECLIPSE ...... 18 FIGURE 22. IMPORT CODE WITHIN ECLIPSE ...... 19 FIGURE 23. FIX ISSUES TO RUN THE PROJECT ...... 20 FIGURE 24. MODIFY THE BUILD PATHS TO REFERENCE THE JARS REQUIRED ...... 21 FIGURE 25. ADD THE JARS REQUIRED ...... 21 FIGURE 26. IMPORT THE JENA LIBRARY ...... 22 FIGURE 27. IMPORT THE JENA LIBRARY WITH ALL JAR FILES ...... 23 FIGURE 28. IMPORT THE JERSEY (JAX-RS) LIBRARY...... 24 FIGURE 29. IMPORT THE JERSEY (JAX-RS) LIBRARY WITH ALL JAR FILES ...... 24 FIGURE 31. CHECK THAT YOU SET UP THE JDK 1.7 ...... 25 FIGURE 32. CHECK THE JAVA COMPILER IT SHOULD BE 1.7 ...... 26 FIGURE 33. RIGHT RIGHT CLICK ON THE “FIESTA_IOT_TOOLS”PROJECT ...... 27 FIGURE 34. SELECT RUN AS AND THEN ...... 28 FIGURE 35. GET THE LOCALHOST ADDRESS ...... 28 FIGURE 36. THE PROTOTYPE IS RUNNING ON LOCALHOST, IT WORKS! ...... 29 FIGURE 37. CHECK GOOGLE APP SETTINGS ...... 30 FIGURE 38. INDICATE THE NAME OF THE APPLICATION WHERE IT WILL BE DEPLOYED ON THE WEB ...... 31 FIGURE 39. DEPLOY THE PROJECT ON THE WEB ...... 32 FIGURE 40. CONFIRM THAT YOU DEPLOY THE PROJECT ON THE WEB ...... 33 FIGURE 41. WAIT THE PROJECT IS BEING DEPLOYING ON THE WEB ...... 33 FIGURE 42. AUTHENTICATE YOURSELF WITH GOOGLE APP ENGINE ...... 34 FIGURE 43. ACCEPT THE AUTHENTICATION ON GOOGLE APP ENGINE ...... 34 FIGURE 44. FIESTA-IOT PROTOTYPE DEPLOYED ON THE WEB ...... 35 FIGURE 45. FIESTA-IOT JAVA LIBRARIES ...... 36 FIGURE 46. FIESTA-IOT WAR DIRECTORY CONTENT ...... 37 FIGURE 47. CREATE A NEW ACCOUNT ON GITLAB ...... 43 FIGURE 48. FIESTA-IOT NUIG PROTOTYPE ON GITLAB ...... 44

We employed the following technologies as displayed in Figure 1:  Jena 2.11 framework [Erreur ! Source du renvoi introuvable.] is used to build semantic web applications. Jena includes the Jena reasoning engine to interpret IoT data and Jena/ARQ to execute SPARQL queries on the knowledge base. Jena was the easier Semantic to learn, it was well-documented and had tutorials. Integrating Jena to our application was simple thanks to the JAR file. A light version of Jena is available for constrained devices too.  RDF, RDFS and OWL are used to design ontologies and datasets.  SPARQL is used to query knowledge base designed with RDF, RDFS and OWL [Erreur ! Source du renvoi introuvable.] .  Java 1.7 is used to implement the entire framework  Jersey (JAX-RS) is used to design JAVA RESTful web services.  (GWT) and Google App Engine (GAE) are used to develop the framework and host the entire web site online. We do not have to maintain a server or taking care of security issues, it is easy to deploy and maintain applications online.  Java Data Object (JDO) is used to store data in a .  HTML5, CSS3, JavaScript are used to design the Graphical User Interface (GUI)  AJAX technologies are used query web services. Then, the result returned by web serviced is parsed with JavaScript.

Finally, the designing phase has been achieved by using extreme programming [Erreur ! Source du renvoi introuvable.] and Scrum-like methodologies.

Figure 1. Technologies used is this project

We used Jena1, a framework to build semantic web applications.

To host the prototype web site on the web, we used Google App Engine. It provides a server and the domain name (http://fiesta-iot-tools.appspot.com/). “.appspot.com” means that the web site is hosted on Google, we do not need to pay for a domain name. Further, Google App Engine provides us a server, so we do not need to maintain it, and take care of security issues.

To build RESTful web services in Java, we use the Jersey Java library2.

1 https://jena.apache.org/ 2 https://jersey.java.net/

We created this repository on Google Drive to set up the code with exactly the same environment. You have access to the directory which comprises:  Eclipse Kepler  All JAR required  The JDK and JRE 1.7  Code of the project (e.g., FIESTA-IoT-TOOLS_XXX.zip)  Download and unzip!

Figure 2. Repository on Google Drive to set up the code with exactly the same environment

Figure 3 The code of the prototype

All the code corresponds to the web site online: http://fiesta-iot-tools.appspot.com/

Figure 4. The code corresponds to this prototype

Requirements  Java 1.7  Eclipse Kepler  Plugin Google App Engine SDK App engine 1.9  Jena  Jars required

To avoid any incompatibility issues, we provide all tools with the good version: The FIESTA_IoT_Tutorial_Set_up_Prototype directory comprises:  Eclipse Kepler  All jar required to run the project  JDK Java 1.7

Figure 5. FIESTA_IoT_Tutorial_Set_up_Prototype directory

In the Eclipse directory you already have the plugin for App Engine SDK 1.9. This enables to add the App engine plugins in eclipse in case you already have eclipse on your machine, copy paste this directory.

Figure 6. App Engine SDK 1.9 already in the Eclipse that we provided

I shared all the JAR that I have in my machine, some of them might be useless.

Figure 7. JARs required in the project are provided in the JAR directory

In our case: jdk-7u51-windows-x64 Because of Google App Engine, we cannot use anymore Java 1.6.

If you have Java 1.6, you should uninstall it, restart the machines, to avoid issues. (if it does not compromise the other projects running on your machine).

Double click on the JDK and install it.

In our case: eclipse-jee-kepler-SR1-win32-x86_64

Figure 8. Install Eclipse Kepler that we provided

Figure 9. Java 1.7 is required with the Google Plugin for Eclipse

 Click ok (This is why we set up Java 1.7)

Figure 10. The eclipse workspace is empty

Eclipse installed by default a workspace: E:\Workspace.

You should have the following screenshot:

Figure 11. The project in the Eclipse workspace

In case you encounter some issues, you can follow this tutorial: https://cloud.google.com/appengine/docs/java/tools/eclipse

We do not remember why, but we have to change the default setting of Google: FIESTA-IOT_TOOLS project -> Right Click -> Google -> App Engine Settings  Choose DataNucleus JPO/JPA version v1

Figure 12. Google App Engine settings

Figure 13. Check that the Datanucleus JPP/JPA is V1

Figure 14. Open the FIESTA-IoT prototype project

In case, it does not appear:

Figure 15. File -> Import a new project

Figure 16. Import a new project within Eclipse

Figure 17. Import code within Eclipse

We have to fix the following issues:

Figure 18. Fix issues to run the project

Fixing Google App Engine Problem (Java Build Path Problems)

Two solutions: 1) Copy/Paste the JAR directory that we provided in the project 2) or Modify the Build Path

Modify the build path:

Figure 19. Modify the build paths to reference the JARs required

Modify the build path of all jar libraries:

Figure 20. Add the JARs required

Add all jars required, that are available in the JAR directory.

Figure 21. Import the jena library

Figure 22. Import the jena library with all jar files

Figure 23. Import the Jersey (JAX-RS) library

Figure 24. Import the Jersey (JAX-RS) library with all jar files

In case you encounter some issues, you can follow the following tutorial: http://www.iandickinson.me.uk/articles/jena-eclipse-helloworld/

In case you encounter some trouble to run the project, check that you have the right Java compiler 1.7 as follows.

Did your run the JDK 1.7 that I provided in the FIESTA_IoT_Tutoroial_Set_up_Prototype. If not double click on it, and follow the instructions.

Figure 25. Check that you set up the JDK 1.7

Check that you are using the Compiler Java 1.7 within Eclipse as follows:

Figure 26. Check the Java compiler it should be 1.7

Figure 27. Right right click on the “FIESTA_IoT_TOOLS”project

Figure 28. Select Run as and then Web Application

Figure 29. Get the localhost address

Copy paste the URL in red with the localhost address on the Browser (e.g., Chrome).

Figure 30. The prototype is running on localhost, it works!

Right click on the FIESTA_IOT_TOOLS project on Eclipse:  Select Google  Select App Engine Settings

Figure 31. Check Google App Settings

 You will have the following screen. In the Application ID enter fiesta-iot-tools, this is the web site to try it. For this, we need to give you access rights in case you are collaborating on this project.  Otherwise, you can create your own hostname. Please follow the documentation to deploy you app engine with Google3.  Click OK

3 https://developers.google.com/eclipse/docs/appengine_deploy

Figure 32. Indicate the name of the application where it will be deployed on the Web

Then right click on FIESTA_IOT_TOOLS project again:  Select Google  Select Deploy to App Engine

Figure 33. Deploy the project on the web

Figure 34. Confirm that you deploy the project on the web

Figure 35. Wait the project is being deploying on the web

Google will ask you to authenticate, you need to be authenticated on the project.

Figure 36. Authenticate yourself with Google App Engine

 Click on the button Accept:

Figure 37. Accept the authentication on Google App Engine

Check that it works:

Figure 38. FIESTA-IoT prototype deployed on the web

Error when you want to deploy your application on app engine: Another transaction by user … is already in progress for this app and major version

Figure 39. FIESTA-IoT Java libraries

Figure 40. FIESTA-IoT WAR directory content

 WAR/CSS  WAR/dataset  WAR/html  WAR/images  WAR/javascript  WAR/ont: all ontologies  WAR/publication  WAR/RULES: ruleM3NewType.txt is used in the M3 Converter to add the right sensor, measurement, unit or domain type o LinkedOpenRules*.txt: M3 rules implemented according to the Jena syntax compliant with the Jena reasoned, they are classified by domains (e.g., weather,, environment, health, Home) o ruleM3NewType.txt used by the M3 converter to convert SenML4 sensor data in RDF m3 sensor data o WAR/RULES/OTHER: files are from domain experts and just shared in the ontologie.html web page  WAR/SPARQL all SPARQL queries  WAR/WEB-INF

4 http://www.ietf.org/archive/id/draft-jennings-senml-10.txt

To run the project, you will need the following libraries:  JRE System library, should be the Java 1.7  App engine SDK [App engine - 1.9.0] used to host our project online.  ALL_JAR_NEEDED is comprised of o Jersey 1.14 to develop RESTful web services in JAVA. These web services are then called in HTML web pages through AJAX and Javascript. o Jena 2.11, a framework uses to build semantic web applications. In the project, more specifically, semantic web of things applications. We use the jena reasoner, the sparql engine, etc.  JUnit4 to develop java unit tests

The project comprises packages:

This is the most important package! Since it contains all web services that are used by the use interface developed with HTML and Javascript.

The WAR directory to build web applications.

All CSS file for the web application user interface.

All datasets such as sensor data, sensor data semantically annotated with M3, domain knowledge bases, etc.

All documentation to understand the project or use the tools.

All HTML web pages used for the user interface.

All images used in the projects.

The HTML web pages will send AJAX queries to web services and get the results. The result is parsed in JavaScript and displayed on HTML web pages.

You will find in this directory all the interoperable rules that we designed. This is the Sensor-based Linked Open Rules (S-LOR) tool. The SWoT generator has predefined-templates to build semantic-based IoT application. The templates will referenced these pre-defined set of rules classified by domains.

You will find in this directory all SPARQL queries.

There is also the documentation to use the web services if required: http://fiesta-iot-tools.appspot.com/documentation/DemoUserGuideTutorial.pdf

At the beginning, the project was running on Tomcat. The structure of the project needs to be refactored to run on Tomcat again. For sure, it is feasible.

URL: https://gitlab.fiesta-iot.eu/users/sign_in URL: https://gitlab.fiesta-iot.eu/

Figure 41. Create a new account on Gitlab

Figure 42. FIESTA-IoT NUIG prototype on Gitlab