Skip to content

pericles-project/SPIN-rule-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SPIN-rule-engine

A RESTFUL web API built on top of the existing TopQuadrant SPIN API ( http://topbraid.org/spin/api/) that executes SPIN rule inference on provided models. The engine supports a specialised API for the DEM models that can extract and execute the rules included in DEM policies, and reports the changes back to models using the PERSIST API.

The SPIN engine uses the SPIN API to run inference on the model.

Installation and execution

Commandline

Download the latest release here: https://github.com/pericles-project/SPIN-rule-engine/releases/download/1.1/spinengine.zip
extract, move to folder and run from shell:
`java -jar spinengine.jar`

Web service

The project is based on Maven, in order to direclty run the web service (port 8080 by default):
1. - install Maven
2. - clone or download the repository
3. - go to the folder and run `mvn jetty:run`
4. - open the browser at the local address:
http://127.0.0.1:8080/spinengine/runInferencesGet?baseURI=http://topbraid.org/examples/kennedysSPIN

WAR file install

Follow steps 1-2 and then package the war file using the standard MVN command: 3 - go to the folder and run `mvn war:war`

The API: 🐝


DEM Specific API is described in the project documentation
The complete API documentation - automatically generated - with different language clients is included here: https://pericles-project.github.io/SPIN-rule-engine/apidocs/ Currently the API is implemented as a restful service that can be invoked usign both GET and POST methods. The following methods are implemented and can be executed via simple web call:
* `runInferencesGet`
* `runInferencesPost`
* `runConstraintsGet`
* `runConstraintsPost`

All the methods use the following 4 parameters (1st parameter is necessary, the other 3 optionals):
* `baseURI`: the URI for the base document
* `document`: (optional) the document contents
* `SPINURI`: (optional) The URI for the SPIN document (to be merged with the base document)
* `SPINdocument`: the SPIN document contents
* `outFormat`: the format for output serialisation. Can be one any of the apache Jena ones: https://jena.apache.org/documentation/io/rdf-output.html
The Constraints checking method support one further parameter, that asks the engine to execute the inference before checking the constraints: * `doInference` (optional): true or false (default false)

Output

The output includes the follwing elements, as simple JSON strings: * `constraints`: the constraints inference out model * `model`: the updated model * `newTriplets`: the new triples * `consoleLog`: console output or errors

When the output format is specified to be json, the models are written instead to the following:

  • jsonModel: the updated model
  • jsonNewTriplets: the new triples
  • jsonConstraints: the constraints inference out model

An example

This example is executed running the engine for constraint checking with inference:
http://127.0.0.1:8080/spinengine/runConstraintsGet?baseURI=http://topbraid.org/examples/kennedysSPIN&doInference=true