-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into retrieve-prefix
- Loading branch information
Showing
25 changed files
with
686 additions
and
39 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,74 @@ | ||
# RDF4J update example | ||
|
||
RDF4J update example explains how to update RDF4J repository. | ||
|
||
## Introduction | ||
|
||
This example explains script [rdf4j-update.sms.ttl](./rdf4j-update.sms.ttl]) that contain one pipeline. It creates RDF4J repository and performs update query. For more details about script construction and execution you can see [hello-world-example](../hello-world/hello-world.md). | ||
|
||
## Script structure | ||
|
||
Script performs following steps: | ||
1) Creates RDF4J repository using `kbss:rdf4j-create-repository` module. Repository is specified by parameters `rdf4j:p-rdf4j-server-url` and `rdf4j:p-rdf4j-repository-name`. Parameter `rdf4j:p-rdf4j-ignore-if-exists` defines behavior of the module in case when defined repository already exists: | ||
in case if it is set to be "true", module will not do anything if repository with given ID already exists on the server. | ||
|
||
|
||
``` | ||
:create-repository | ||
a kbss:rdf4j-create-repository ; | ||
rdf4j:p-rdf4j-server-url "http://localhost:8080/rdf4j-server/" ; | ||
rdf4j:p-rdf4j-repository-name "test-update" ; | ||
rdf4j:p-rdf4j-ignore-if-exists "true" ; | ||
sm:next :update ; | ||
. | ||
``` | ||
|
||
2) Perform an update on repository using `kbss:rdf4j-update` module. Repository is defined in the same way as in `:create-repository`. Update query is set by string in `sp:text` section. | ||
|
||
``` | ||
:update-repository | ||
a kbss:rdf4j-update ; | ||
sm:next :update-repository_Return ; | ||
sml:updateQuery [ | ||
a sp:Update ; | ||
sp:text """ | ||
PREFIX ex-people: <http://example.org/people/> | ||
DELETE { | ||
ex-people:john ex-people:age ?oldAge . | ||
} | ||
INSERT { | ||
ex-people:john ex-people:age ?newAge . | ||
} WHERE { | ||
OPTIONAL { | ||
ex-people:john ex-people:age ?oldAge . | ||
} | ||
BIND(COALESCE(?oldAge+1, 1) as ?newAge) | ||
} | ||
""" ; | ||
]; | ||
rdf4j:p-rdf4j-server-url "http://localhost:8080/rdf4j-server/" ; | ||
rdf4j:p-rdf4j-repository-name "test-update" ; | ||
. | ||
``` | ||
|
||
## Script execution | ||
|
||
Let's assume that SPipes web application is running at `http://localhost:8080/s-pipes`. We can call the *pipeline* with: | ||
|
||
http://localhost:8080/s-pipes/service?_pId=update-repository | ||
|
||
Note, that rdf4j server should be running on the URL that is specified in script (`http://localhost:8080/rdf4j-server/` for example). | ||
You can see following logs while execution: | ||
|
||
[http-nio-8080-exec-7] INFO c.c.s.e.ExecutionEngineImpl - ##### create-repository | ||
... | ||
[http-nio-8080-exec-1] INFO c.c.s.m.Rdf4jUpdateModule - Server url: http://localhost:8080/rdf4j-server/, Repsitory name: test-update, Ignore if repository exist: true | ||
[http-nio-8080-exec-6] INFO c.c.s.m.Rdf4jUpdateModule - Repository "test-update" already exists | ||
... | ||
[http-nio-8080-exec-7] INFO c.c.s.e.ExecutionEngineImpl - ##### Make insert update | ||
... | ||
[http-nio-8080-exec-7] DEBUG c.c.s.m.Rdf4jUpdateModule - Connected to test-update | ||
[http-nio-8080-exec-7] DEBUG c.c.s.m.Rdf4jUpdateModule - Update successful | ||
|
||
This log will occur when Ignore flag is set to true and repository already exists: | ||
`[http-nio-8080-exec-6] INFO c.c.s.m.Rdf4jUpdateModule - Repository "test-update" already exists` |
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,69 @@ | ||
# baseURI: http://onto.fel.cvut.cz/ontologies/s-pipes/rdf-update-example | ||
# imports: http://onto.fel.cvut.cz/ontologies/s-pipes-lib | ||
|
||
@prefix : <http://onto.fel.cvut.cz/ontologies/s-pipes/rdf-update-example/> . | ||
@prefix doc: <http://onto.fel.cvut.cz/ontologies/documentation/> . | ||
@prefix kbss: <http://onto.fel.cvut.cz/ontologies/lib/module/> . | ||
@prefix km-sesame: <http://onto.fel.cvut.cz/ontologies/lib/module/sesame/> . | ||
@prefix owl: <http://www.w3.org/2002/07/owl#> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix sm: <http://topbraid.org/sparqlmotion#> . | ||
@prefix sml: <http://topbraid.org/sparqlmotionlib#> . | ||
@prefix sp: <http://spinrdf.org/sp#> . | ||
@prefix spif: <http://spinrdf.org/spif#> . | ||
@prefix spin: <http://spinrdf.org/spin#> . | ||
@prefix spl: <http://spinrdf.org/spl#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix rdf4j: <http://onto.fel.cvut.cz/ontologies/lib/module/rdf4j/> . | ||
|
||
<http://onto.fel.cvut.cz/ontologies/s-pipes/rdf-update-example> | ||
a owl:Ontology ; | ||
owl:imports <http://onto.fel.cvut.cz/ontologies/s-pipes-lib> ; | ||
. | ||
|
||
:create-repository | ||
a kbss:rdf4j-create-repository ; | ||
rdf4j:p-rdf4j-server-url "http://localhost:8080/rdf4j-server/" ; | ||
rdf4j:p-rdf4j-repository-name "test-update" ; | ||
rdf4j:p-rdf4j-ignore-if-exists "true" ; | ||
sm:next :update-repository ; | ||
. | ||
|
||
:update-repository | ||
a kbss:rdf4j-update ; | ||
sm:next :update-repository_Return ; | ||
sml:updateQuery [ | ||
a sp:Update ; | ||
sp:text """ | ||
PREFIX ex-people: <http://example.org/people/> | ||
DELETE { | ||
ex-people:john ex-people:age ?oldAge . | ||
} | ||
INSERT { | ||
ex-people:john ex-people:age ?newAge . | ||
} WHERE { | ||
OPTIONAL { | ||
ex-people:john ex-people:age ?oldAge . | ||
} | ||
BIND(COALESCE(?oldAge+1, 1) as ?newAge) | ||
} | ||
""" ; | ||
]; | ||
kbss:has-max-iteration-count 5 ; | ||
kbss:only-if-triple-count-changes false; | ||
rdf4j:p-rdf4j-server-url "http://localhost:8080/rdf4j-server/" ; | ||
rdf4j:p-rdf4j-repository-name "test-update" ; | ||
. | ||
|
||
:update-repository_Return | ||
a sml:ReturnRDF ; | ||
sml:serialization sml:JSONLD ; | ||
rdfs:label "Update repository" ; | ||
. | ||
|
||
:update-repository | ||
a sm:Function ; | ||
sm:returnModule :update-repository_Return ; | ||
rdfs:subClassOf sm:Functions ; | ||
. |
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
2 changes: 1 addition & 1 deletion
2
s-pipes-core/src/main/java/cz/cvut/spipes/exception/ContextNotFoundException.java
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
11 changes: 11 additions & 0 deletions
11
...core/src/main/java/cz/cvut/spipes/exception/ModuleConfigurationInconsistentException.java
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,11 @@ | ||
package cz.cvut.spipes.exception; | ||
|
||
/** | ||
* Indicate that SPipes Module was incorrectly configured. | ||
*/ | ||
public class ModuleConfigurationInconsistentException extends SPipesException { | ||
|
||
public ModuleConfigurationInconsistentException(String message) { | ||
super(message); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
s-pipes-core/src/main/java/cz/cvut/spipes/exception/ParseException.java
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
23 changes: 23 additions & 0 deletions
23
s-pipes-core/src/main/java/cz/cvut/spipes/exception/SPipesException.java
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,23 @@ | ||
package cz.cvut.spipes.exception; | ||
|
||
/** | ||
* Runtime exception that should be extended by any specific SPipes exception. | ||
*/ | ||
public class SPipesException extends RuntimeException { | ||
|
||
public SPipesException(String message) { | ||
super(message); | ||
} | ||
|
||
public SPipesException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public SPipesException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
public SPipesException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { | ||
super(message, cause, enableSuppression, writableStackTrace); | ||
} | ||
} |
7 changes: 4 additions & 3 deletions
7
...exception/ValidationConstraintFailed.java → .../ValidationConstraintFailedException.java
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
10 changes: 10 additions & 0 deletions
10
...dules/module-rdf4j/src/main/java/cz/cvut/spipes/exceptions/RepositoryAccessException.java
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,10 @@ | ||
package cz.cvut.spipes.exceptions; | ||
|
||
import cz.cvut.spipes.exception.SPipesException; | ||
|
||
public class RepositoryAccessException extends SPipesException { | ||
|
||
public RepositoryAccessException(String repositoryName, Throwable cause) { | ||
super("Cannot connect to repository " + repositoryName + ".", cause); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...odule-rdf4j/src/main/java/cz/cvut/spipes/exceptions/RepositoryAlreadyExistsException.java
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,11 @@ | ||
package cz.cvut.spipes.exceptions; | ||
|
||
import cz.cvut.spipes.exception.SPipesException; | ||
|
||
public class RepositoryAlreadyExistsException extends SPipesException { | ||
|
||
public RepositoryAlreadyExistsException(String repositoryName) { | ||
super("Repository " + repositoryName + " already exists."); | ||
} | ||
|
||
} |
Oops, something went wrong.