Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat(api-v2): Add an RDF processing façade (DSP-1020) (#1754)
- Loading branch information
Benjamin Geer
committed
Nov 17, 2020
1 parent
f31c075
commit 9170419
Showing
165 changed files
with
9,390 additions
and
3,462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<!--- | ||
Copyright © 2015-2019 the contributors (see Contributors.md). | ||
This file is part of Knora. | ||
Knora is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Knora is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public | ||
License along with Knora. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
|
||
# RDF Processing API | ||
|
||
Knora provides an API for parsing and formatting RDF data and | ||
for working with RDF graphs. This allows Knora developers to use a single, | ||
idiomatic Scala API as a façade for a Java RDF library. | ||
By using a feature toggle, you can choose either | ||
[Jena](https://jena.apache.org/tutorials/rdf_api.html) | ||
or | ||
[RDF4J](https://rdf4j.org/documentation/programming/) | ||
as the underlying implementation. | ||
|
||
|
||
## Overview | ||
|
||
The API is in the package `org.knora.webapi.messages.util.rdf`. It includes: | ||
|
||
- `RdfModel`, which represents a set of RDF graphs (a default graph and/or one or more named graphs). | ||
A model can be constructed from scratch, modified, and searched. | ||
|
||
- `RdfNode` and its subclasses, which represent RDF nodes (IRIs, blank nodes, and literals). | ||
|
||
- `Statement`, which represents a triple or quad. | ||
|
||
- `RdfNodeFactory`, which creates nodes and statements. | ||
|
||
- `RdfModelFactory`, which creates empty RDF models. | ||
|
||
- `RdfFormatUtil`, which parses and formats RDF models. | ||
|
||
- `JsonLDUtil`, which provides specialised functionality for working | ||
with RDF in JSON-LD format, and for converting between RDF models | ||
and JSON-LD documents. `RdfFormatUtil` uses `JsonLDUtil` when appropriate. | ||
|
||
To work with RDF models, start with `RdfFeatureFactory`, which returns instances | ||
of `RdfNodeFactory`, `RdfModelFactory`, and `RdfFormatUtil`, using feature toggle | ||
configuration. | ||
|
||
`JsonLDUtil` does not need a feature factory. | ||
|
||
|
||
## Implementations | ||
|
||
- The Jena-based implementation, in package `org.knora.webapi.messages.util.rdf.jenaimpl`. | ||
|
||
- The RDF4J-based implementation, in package `org.knora.webapi.messages.util.rdf.rdf4jimpl`. | ||
|
||
|
||
## Feature toggle | ||
|
||
For an overview of feature toggles, see [Feature Toggles](feature-toggles.md). | ||
|
||
The RDF API uses the feature toggle `jena-rdf-library`: | ||
|
||
- `on`: use the Jena implementation. | ||
|
||
- `off` (the default): use the RDF4J implementation. | ||
|
||
|
||
The default setting is used on startup, e.g. to read ontologies from the | ||
repository. After startup, the per-request setting is used. | ||
|
||
|
||
## What still uses RDF4J directly | ||
|
||
Before this API was added, Knora mainly used the RDF4J API directly, and still does | ||
in some places: | ||
|
||
- Code that uses RDF4J's streaming API to process large amounts of data, especially to | ||
avoid constructing a large string in TriG format: | ||
|
||
- `ProjectsResponderADM.projectDataGetRequestADM` | ||
|
||
- `HttpTriplestoreConnector.turtleToTrig` | ||
|
||
- `RepositoryUpdater` | ||
|
||
- The repository update plugin tests, which use SPARQL. | ||
|
||
- `TEIHeader`: uses XSLT that depends on the exact format of the RDF/XML generated by RDF4J. | ||
The XSLT would need to be improved to handle `rdf:Description`. | ||
|
||
- `GravsearchParser`: uses RDF4J's SPARQL parser. This is probably | ||
not worth changing. | ||
|
||
|
||
## TODO | ||
|
||
- SHACL validation. | ||
|
||
- SPARQL querying. | ||
|
||
- A streaming parsing/formatting API for processing large graphs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters