Astrea is a software capable of generate SHACL shapes from one or more given ontologies. It relies on a set of equivalences between the OWL2 constructs and the SHACL constructs, which are exploit by means of a set of SPARQL queries. The idea behind Astrea is to rely on a set of mappings between such specifications, and a list of queries so by just applying the queries over one or more owl files the associated shapes can be generated.
In this repository the software provided imports all the ontologies associated to the construct owl:imports for an input ontology, in addition in its methods counts with the option of importing more than one ontology URL to generate their shapes. Consider that the shapes generated are associated only to the types and properties specified in the ontology, therefore providing more than one URL can be useful if one ontology references elements from another but it does not import it.
The Astrea resources, besides the java library which latest version can be downloaded from the releases tab, include the following elements:
Astrea Demo: Astrea has been integrated as a web service and published online. In addition, the source code of this demo can be found at its GitHub repository
In order to use the Astrea as java library for third-party components there are two approaches: import the library as a jar or install Astrea as a local maven dependency and then use your pom.xml to import it. Following we provide a guide for both options.
Download the last release from our GitHub. Then, import the jar file in a project .
Astrea can be installed as a local dependency. For this purpose download the code from this repository:
git clone https://github.com/oeg-upm/Astrea.git
Then, install the project as a local maven dependency, for which you can run the script that we provide
bash mvn-install.sh
Finally, import in a project the Astrea maven dependency using the following code in your pom.xml:
<dependency>
<groupId>oeg.validation</groupId>
<artifactId>astrea</artifactId>
<version>1.2.1</version>
</dependency>
Alternatively, Astrea can be installed as a local dependency following these steps:
mvn clean package -Dskiptests
mvn install:install-file -Dfile=./target/astrea-1.2.1.jar -DgroupId=oeg.validation -DartifactId=astrea -Dversion=1.2.1 -Dpackaging=jar
Astrea can be used as a java library for third-party java projects, in you code create an instance of our Astrea object as follows:
ShaclFromOwl sharper = new OwlGenerator();
Having this object the shapes, which will be provided as jena Models, can be generated using different methods:
Model shapes = sharper.fromURL("http://iot.linkeddata.es/def/core/ontology.ttl");
List<String> ontologies = new ArrayList<>();
ontologies.add("http://iot.linkeddata.es/def/core/ontology.ttl");
...
Model shapes = sharper.fromURLs(ontologies);
Model shapes = sharper.fromOwl(String owlContent, String format);
Model ontologyModel = ModelFactory.createDefaultModel();
// insert content in the variable ontologyModel
Model shapes = sharper.fromModel(ontologyModel);
Keep in mind that Astrea will automatically include all the ontologies that are specified under the owl:imports statement, and therefore, it will generate their shapes as well.
To check other constructors of the OwlGenerator class read our java doc