Scaseco / r2rml-api-jena

A modular R2RML suite built on Apache Jena. Featuring a complete domain API built on Jena's polymorphism system, SHACL validation, an R2RML processor with 100% standard conformance based an Jena's ARQ plus common tooling every R2RML project needs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Jena-based (R2)RML API

A modular R2RML suite built on Apache Jena. Featuring a complete domain API built on Jena's polymorphism system, SHACL validation, an R2RML processor with 100% standard conformance based an Jena's ARQ plus common tooling every R2RML project needs.

Example

The following Java snippet demonstrates usage of the API:

public class R2rmlApiExample {
	public static void main(String[] args) {
		Model model = ModelFactory.createDefaultModel();
		model.setNsPrefix("rdfs", RDFS.uri);
		model.setNsPrefix("rr", RR.uri);
		
		TriplesMap triplesMap = model.createResource().as(TriplesMap.class); 
		triplesMap
			.setSubjectIri("urn:s")
			.addNewPredicateObjectMap()
				.addPredicate("urn:p")
				.addNewObjectMap()
					.setColumn("labels")
					.setLanguage("en");
		
		// All domain classes of the R2RML API *ARE* Jena Resources.
		// Hence, any information - such as types or custom attributes - can be freely attached:
		triplesMap
			.addProperty(RDF.type, RR.TriplesMap)
			.addProperty(RDFS.label, "My R2RML Mapping");
		
		RDFDataMgr.write(System.out, model, RDFFormat.TURTLE_PRETTY);
	}
}

The output in turtle syntax is shown below. Note, that any of the many serialization formats supported by Jena could be used instead.

@prefix rr:    <http://www.w3.org/ns/r2rml#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

[ a                      rr:TriplesMap ;
  rdfs:label             "My R2RML Mapping" ;
  rr:predicateObjectMap  [ rr:objectMap  [ rr:column    "labels" ;
                                           rr:language  "en"
                                         ] ;
                           rr:predicate  <urn:p>
                         ] ;
  rr:subject             <urn:s>
] .

Jena Compatibility

r2rml-api jena
0.9.0 3.17.0
0.9.1 4.4.0
0.9.2 4.4.0
0.9.3 4.5.0
4.8.0-X 4.8.0

Starting with Jena 4.8.0 we aligned the version of this project with Jena to make it easier to determine the compatibility. For example, r2rml-jena-api version 4.8.0-2 indicates the second release developed against Jena 4.8.0.

Usage with Maven

Just include

<dependency>
  <groupId>org.aksw.r2rml</groupId>
  <artifactId>r2rml-jena-plugin</artifactId>
  <version><!-- Check the link below --></version>
</dependency>

List versions published on Maven Central

Usage of the CLI Tool

Conversion of RML to SPARQL Construct Queries

rmltk rml to sparql mapping.rml.ttl > mapping.raw.rq
rmltk optimize workload mapping.raw.rq --no-order > mapping.rq

How to Execute the Mapping

The RDF processing toolkit (RPT) supports execution of the generated mapping. RPT uses this repository.

Using the single threaded Jena engine:

rpt integrate mapping.rq

Using RPT's parallel Spark-based executor:

rpt sansa query mapping.rq

Modules

License

The source code and shacl specification of this repo is published under the Apache License Version 2.0.

About

A modular R2RML suite built on Apache Jena. Featuring a complete domain API built on Jena's polymorphism system, SHACL validation, an R2RML processor with 100% standard conformance based an Jena's ARQ plus common tooling every R2RML project needs.

License:Other


Languages

Language:Java 99.5%Language:Shell 0.2%Language:Makefile 0.2%