본문으로 건너뛰기

3.7. SWRL rule generator API

This document describes the method and setting information for deploying SWRL Rule Generator API.

3.7.1. Overview

SWRL Rule Generator API is a Java Maven project, developed using Java Spring Boot. The project can be imported and executed in compatible java IDE such as Eclipse and IntelliJ. Following are the dependencies required for deployment.

3.7.1.1. Dependencies

  • Minimum version of Java Required: 1.5.

  • Maven Dependencies: These are listed under <dependencies> tab in “pom.xml”, in main project directory.

    • apache-jena-libs (version: 3.9.0)
    • owlapi-distribution (version: 3.4.9.2-ansell)
    • pellet-owlapiv3 (version: 2.3.3)
    • mysql-connector-java (version 8.0.18)
    • json-simple (version 1.1.1)
    • gson (version 2.8.6)
    • jackson-dataformat-csv (version)
    • hibernate-core (version 5.5.8.Final)
    • hibernate-jpa-2.0-api (1.0.1.Final)
    • lombok (version 1.16.6)
    • commons-lang3 (version 3.0)
  • External Jar Files: These files are not available in maven repository and may need to add in the build path manually. These can be found in project/lib/

    • virt_jena3.jar
    • virtjdbc4.jar
  • Connection with Virtuoso Triple Store: Three parameters are required to connect to the virtuoso: API base URI, prefix URI and SWRL prefix.

3.7.1.2. APIConfiguration

  • The file is located at project/src/main/java/semantics/cityhub/keti/APIConfiguration.java.
    • The parameters are described as follows:
PropertySampleDescription
API_BASE_URIapi/axiom-generator/v1Parameter to set API base URL. This is required for the SWRL Labeling Tool. It can be changed based on specific preferences
PREFIX_URIhttp://www.city-hub.kr/swrl/2021/1Default prefix URI to be used in defining SWRL concepts. It can be changed based on specific preferences.
SWRL_PREFIXhttp://swrl.stanford.edu/ontologies/3.3/swrla.owlDefault SWRL prefix to be used for SWRL concept definitions.

3.7.1.3. Important File Directories

  • Following are the important directories for Semantic Validator.
    • Project java code files : project/src/main/java/semantics/cityhub/keti
      • API Data Access Object (DAO): project/src/main/java/semantics/cityhub/keti/SWRLRuleDAO.java
      • Java code to define SWRL Entity Models: project/src/main/java/semantics/cityhub/keti/model
      • Reasoner java code files: project/src/main/java/semantics/cityhub/keti/reasoner
      • Additional Utility code files: project/src/main/java/semantics/cityhub/keti/utils
    • External Jar files : project/lib
    • Maven Dependencies : project/pom.xml

3.7.2. Deployment Steps

NOTE: the installation instructions are based on Eclipse IDE in Windows, so it may vary for different IDEs and platforms.

3.7.2.1. Download Project

Download the project from github and choose "SWRLRuleGeneratorAPI2021"

3.7.2.2. Import Project in IDE

  • In Eclipse, Go to File>Import>Maven>Existing Maven Projects
  • Locate the downloaded project and import.

3.7.2.3. Add external Jar dependencies

  • The external jars to be added are located in the project at project/lib. If they are not already added, then must be added manually.
  • In Eclipse, right click on project folder, go to Build Path > Configure Build Path > Java Build Path. Then go under the Libraries tab, which shows the current jars added to the build path.
  • On the right side click “Add External Jars”.
  • Locate the lib directory and select the files inside.
  • Click “Apply and Close”

3.7.2.4. Application Deployment

NOTE: The TDB and ACP Server must be running prior to the execution of this Application.

After all the required dependencies have been installed, the application can be executed using ServerApplication.java class located at project/src/main/java/semantics/cityhub/keti/SwrlRuleGeneratorApiApplication.java:

  • Right click on SwrlRuleGeneratorApiApplication.java, select "Run As", select either "Java Application" or "Spring Boot App".
  • Upon execution, standard Spring Boot execution can be seen on the Eclipse Console.
  • After the information is displayed: "...Started ServerApplication in ..... seconds ...", the console will stop displaying further information and the API is online to provide RESTful services.

3.7.3. Usage Examples

Follow figure shows the HTTP POST example to INSERT new rule data in the database. Here in the request body, the “id” is the identifier for the new rule data. The “dataProperties” and “variables” define the list of OWL Data Properties and variables used in the given rule. This will be used by the API to parse the elements from the rule string and then define it in the OWL Ontology Model. On successful execution, it returns 201 response.

Follow figure shows the HTTP GET request and its corresponding response to get the store rule data from the dataset.

Follow figure shows the POST request to generate the labels using the example stored rule defined in figure 8. The example CSV file for this case can be observed in figure 6 (in the Reasoner section). This defines the backend usage example for the Labeling User Interface.