crowd Implementation

1 SPARQL-DL Engine

The SPARQL-DL query is available under the LGPLv3 License in the following URL https://github.com/protegeproject/SPARQL-DL-api.git, its main page is http://derivo.de/en/resources/SPARQL-DL-api/ and details are uploaded at the W3C Semantic Web page.

1.1 Compiling

Compiling and generating an executable Jar file can be achieved by using an IDE. The code can be downloaded from a github repository at https://github.com/cnngimenez/sparql-dl-api.

A generated Jar file can be downloaded from https://crowd.fi.uncoma.edu.ar/reasoners/sparqldl.jar.

1.1.1 Using Netbeans

By using Netbeans with JDK and open the repository and requesting the IDE for building.

It executes the following:

cd /home/christian/docs/facu/sparql-dl-api-german
export JAVA_HOME=/home/christian/jdk1.8.0_161
/home/christian/netbeans-8.2/java/maven/bin/mvn -f /home/christian/docs/facu/sparql-dl-api-german/pom.xml -DskipTests=true --fail-at-end 

Dependencies are downloaded and stored in the project directory.

For creating an executable JAR file select the project in the "Projects" tab, then activate the "Show lifecycle bound goals" button and select the "jar jar" goal, right click and "Execute goal".

The main class is selected according to the current "Project configuration", it should be in "Consult" for using the class de.derivo.sparqldlapi.examples.Consult.

The command executed by Netbeans for creating the Jar is:

cd /home/christian/Documentos/facu/crowd/visual-query/sparql-dl-api
export JAVA_HOME=/home/christian/jdk1.8.0_161
/home/christian/netbeans-8.2/java/maven/bin/mvn org.apache.maven.plugins:maven-jar-plugin:2.3.2:jar

A video that shows this process can be founded at the crowd Wiki "Visual Query" page.

Warning: At the current date (<2018-04-11 Wed>), this methods generates a Jar file with another main class setted. This bug is still under revision.

1.1.2 Using Eclipse

In Eclipse, the project should be imported as a "Maven project". Once loaded, it can be exported as a Jar file using the Export option under the File menu.

A video that shows the export process can be founded at the crowd Wiki "Visual Query" page.

1.2 Modifications of the Derivo's SPARQL-DL

The original java code provides a simple main file with hard-coded queries for testing purposes. However, we need to provide the ontology and the queries as input instead as of a static implementation.

According to this, we create a new main class in Java based on the previous example that allows to select the ontology as an input file, the name of the output file and the query as parameter.

These modifications are hosted in a github repository under the following URL: https://github.com/cnngimenez/sparql-dl-api and https://github.com/germanbraun/sparql-dl-api.

1.3 Running the SPARQL-DL Engine   ATTACH

For running the SPARQL-DL engine we need two inputs: the ontology and the query.

The ontology must be stored in a file in OWL 2/XML syntax. The second, is a string that can be passed as argument.

Suppose we want to process the Pizza.owl ontology available for download at this page and search for all classes. The command for executing the query is as follows:

java -jar sparqldl.jar pizza.owl output.json 'SELECT * WHERE {Class(?a)}'

The Jar file is the compiled SPARQL-DL engine that accepts three parameters: the input ontology file, the output file where the results will be stored, the query as the third parameters.

In the following example, the terminal execution is displayed with the output of the program for an ASK query in the pizza ontology.

An execution with a SELECT query is showed next.

$ java -jar sparqldl.jar pizza.owl.xml out.json 'SELECT ?c WHERE {DirectSubClassOf(?c, <http://www.co-ode.org/ontologies/pizza/pizza.owl#FishTopping>)} LIMIT 5'
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

SELECT ?c WHERE {DirectSubClassOf(?c, <http://www.co-ode.org/ontologies/pizza/pizza.owl#FishTopping>)} LIMIT 5
<?xml version="1.0" encoding="UTF-8"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#"><head xmlns=""><variable name="c" /></head><results xmlns=""><result><binding name="c"><uri>http://www.co-ode.org/ontologies/pizza/pizza.owl#PrawnsTopping</uri></binding></result><result><binding name="c"><uri>http://www.co-ode.org/ontologies/pizza/pizza.owl#AnchoviesTopping</uri></binding></result><result><binding name="c"><uri>http://www.co-ode.org/ontologies/pizza/pizza.owl#MixedSeafoodTopping</uri></binding></result></results></sparql>

        "head": {
                "vars": [
        "results": {
                "bindings": [
                                "c": {
                                        "type": "uri",
                                        "value": "http://www.co-ode.org/ontologies/pizza/pizza.owl#PrawnsTopping"
                                "c": {
                                        "type": "uri",
                                        "value": "http://www.co-ode.org/ontologies/pizza/pizza.owl#AnchoviesTopping"
                                "c": {
                                        "type": "uri",
                                        "value": "http://www.co-ode.org/ontologies/pizza/pizza.owl#MixedSeafoodTopping"
Size of result set: 3
Finished in 0.054s

1.3.1 TODO Other OWL syntax Supported by the Reasoner

Has the OWL 2 with RDF/XML or RDF/turttle syntax been tested?

2 Client Implementation

The client should support the following features:

  • Design the query in a UML class diagram.
  • Import the ontology in OWL 2 which the user want to use the query with.
  • Show the resulting SPARQL-DL query for the user debugging.
  • Or, create the ontology in crowd and use it instead of importing.

The first feature is already implemented in crowd in the current version because it allows the user to design UML class diagrams. However, the second feature requires the creation of a dialog with a text area widget for typing or pasting the OWL 2 text. The third feature requires another dialog for displaying the result to the user making the possibility to use the query or return to the design screen.

The fourth feature requires a more complex modification to the interface. First, we need to implement a button and the code for switch between the query and the ontology diagram. Second, we should translate both diagrams into JSON for storing temporary or for sending to the back-end. The codification into OWL 2 of the ontology model is made by the server, using the explained strategies in the server part of this tecnical report, once it recieves the JSON representing the class diagram.

At the first stage of the development, we focus at the first, second and third features. The fourth feature can be achieved manually by creating a UML model, requesting the OWL 2 translation to the server and copying it into the text area above mentioned once implemented. Altogether, the user should be able to request a query result using an OWL 2 ontology created by another tool.

3 Server Implementation

The server should be able to translate the class diagram into a SPARQL-DL query, executing the reasoner and feed it with the query and the OWL 2 onthology. In this section, we explain the implementation according to these three steps.

3.1 UML Codification Into SPARQL-DL

Following the translation previously proposed, we design the server for processing the JSON representation of the UML diagram into the SPARQL-DL result.

We start to expand the Translation Module explained in the server part of this tech report by creating a new "Concrete Strategy" called SPARQLDLStrategy. Also, we need new classes for the Builder pattern: SPARQLDLDocument, SPARQLDLBuilder. The resulting design is showed in diagram diag:codif-uml.


Figure 1: Translation Strategy for Codifying UML into SPARQL-DL. diag:codif-uml

3.2 Querying the SPARQL-DL Reasoner

The request for a SPARQL-DL query must be satisfied by running a reasoner instance and providing the ontology and the query.

For that purpose, we make modifications on the SPARQL-DL reasoner for running it with three parameters:

  • The ontology file name.
  • The JSON output file name.
  • The query string.

For this purpose, the SparqlDL Connector must store the ontology in a temporary file. After that, it must execute the reasoner program passing as argument all these three parameters.


Figure 2: The connection design for a SPARQL-DL reasoner. fig:runner-sparqldl

4 References