-
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.
Created new module sparql, externalized related classes and tests fro…
…m module basil. See #5
- Loading branch information
Showing
50 changed files
with
478 additions
and
10 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
41 changes: 41 additions & 0 deletions
41
basil/src/test/java/io/github/basilapi/basil/TestUtils.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,41 @@ | ||
package io.github.basilapi.basil; | ||
|
||
import io.github.basilapi.basil.sparql.QueryParameter; | ||
import io.github.basilapi.basil.sparql.Specification; | ||
import io.github.basilapi.basil.sparql.SpecificationFactory; | ||
import io.github.basilapi.basil.sparql.UnknownQueryTypeException; | ||
import org.apache.commons.io.IOUtils; | ||
|
||
import java.io.IOException; | ||
|
||
public class TestUtils { | ||
// | ||
public static String loadQueryString(String qname) throws IOException { | ||
return IOUtils.toString(TestUtils.class.getClassLoader().getResourceAsStream("./sparql/" + qname + ".txt"), | ||
"UTF-8"); | ||
} | ||
// | ||
public static String endpoint(String qname) { | ||
int pos = qname.indexOf("X-Basil-Endpoint:"); | ||
int len = ("X-Basil-Endpoint:").length(); | ||
int eol = qname.indexOf('\n', pos); | ||
return qname.substring(pos + len, eol).trim(); | ||
} | ||
// | ||
public static Specification loadQuery(String fileName) throws IOException { | ||
String sparql = loadQueryString(fileName); | ||
String endpoint = endpoint(sparql); | ||
// System.out.println(endpoint); | ||
try { | ||
return SpecificationFactory.create(endpoint, sparql); | ||
} catch (UnknownQueryTypeException e) { | ||
throw new IOException(e); | ||
} | ||
} | ||
|
||
|
||
public static String loadTemplate(String type, String qname) throws IOException { | ||
return IOUtils.toString( | ||
TestUtils.class.getClassLoader().getResourceAsStream("./" + type + "/" + qname + ".tmpl"), "UTF-8"); | ||
} | ||
} |
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
basil/src/test/java/io/github/basilapi/basil/test/ConfigTest.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
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,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>reactor</artifactId> | ||
<groupId>io.github.basilapi</groupId> | ||
<version>0.8.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>sparql</artifactId> | ||
<name>BASIL :: SPARQL</name> | ||
|
||
|
||
<dependencies> | ||
|
||
<!-- Logging --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
|
||
<!-- Test --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>org.apache.jena</groupId> | ||
<artifactId>jena-core</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.jena</groupId> | ||
<artifactId>jena-arq</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
</project> |
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 @@ | ||
# X-Basil-Endpoint: http://data.open.ac.uk/sparql | ||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | ||
PREFIX mlo: <http://purl.org/net/mlo/> | ||
PREFIX aiiso: <http://purl.org/vocab/aiiso/schema#> | ||
|
||
# Eg value for ?_geoid 2328926 | ||
ASK { | ||
BIND(iri(CONCAT('http://sws.geonames.org/',?_geoid,'/')) as ?location) . | ||
?course mlo:location ?location . ?course a aiiso:Module | ||
} |
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,12 @@ | ||
# X-Basil-Endpoint: http://data.open.ac.uk/sparql | ||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | ||
PREFIX mlo: <http://purl.org/net/mlo/> | ||
PREFIX aiiso: <http://purl.org/vocab/aiiso/schema#> | ||
|
||
# Eg value for ?_geoid 2328926 | ||
CONSTRUCT { | ||
?course mlo:location ?location . ?course a aiiso:Module | ||
}WHERE{ | ||
BIND(iri(CONCAT('http://sws.geonames.org/',?_geoid,'/')) as ?location) . | ||
?course mlo:location ?location . ?course a aiiso:Module | ||
} |
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,7 @@ | ||
PREFIX dc: <http://purl.org/dc/elements/1.1/> | ||
|
||
DELETE DATA | ||
{ | ||
<http://example/book2> dc:title ?_title ; | ||
dc:creator ?_creator . | ||
} |
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 @@ | ||
PREFIX dc: <http://purl.org/dc/elements/1.1/> | ||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | ||
|
||
DELETE | ||
{ ?book ?p ?v } | ||
WHERE | ||
{ ?book dc:date ?date . | ||
FILTER ( ?date > ?_date_dateTime ) | ||
?book ?p ?v | ||
} |
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,5 @@ | ||
PREFIX foaf: <http://xmlns.com/foaf/0.1/> | ||
|
||
WITH <http://example/addresses> | ||
DELETE { ?person ?property ?value } | ||
WHERE { ?person ?property ?value ; foaf:givenName ?_givenName ; rdfs:label "$This $is ?not a ?_variable" } |
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,7 @@ | ||
PREFIX dc: <http://purl.org/dc/elements/1.1/> | ||
DELETE DATA | ||
{ GRAPH <http://example/bookStore> { <http://example/book1> dc:title ?_delete } } ; | ||
|
||
PREFIX dc: <http://purl.org/dc/elements/1.1/> | ||
INSERT DATA | ||
{ GRAPH <http://example/bookStore> { <http://example/book1> dc:title ?_insert } } |
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,7 @@ | ||
PREFIX foaf: <http://xmlns.com/foaf/0.1/> | ||
|
||
WITH <http://example/addresses> | ||
DELETE { ?person foaf:givenName ?_delete } | ||
INSERT { ?person foaf:givenName ?_insert } | ||
WHERE | ||
{ ?person foaf:givenName ?_delete } |
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,3 @@ | ||
# X-Basil-Endpoint: http://data.open.ac.uk/sparql | ||
PREFIX dc: <http://purl.org/dc/elements/1.1/> | ||
INSERT { <http://example/egbook> dc:title ?_title } WHERE {} |
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,6 @@ | ||
PREFIX dc: <http://purl.org/dc/elements/1.1/> | ||
INSERT DATA | ||
{ | ||
<http://example/book1> dc:title ?_title_string ; | ||
dc:creator ?_creator . | ||
} |
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,4 @@ | ||
PREFIX dc: <http://purl.org/dc/elements/1.1/> | ||
PREFIX ns: <http://example.org/ns#> | ||
INSERT DATA | ||
{ GRAPH <http://example/bookStore> { <http://example/book1> ns:price ?_price_number } } |
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 @@ | ||
PREFIX dc: <http://purl.org/dc/elements/1.1/> | ||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | ||
|
||
INSERT | ||
{ GRAPH ?_target_iri { ?book ?p ?v } } | ||
WHERE | ||
{ GRAPH <http://example/bookStore> | ||
{ ?book dc:date ?date . | ||
FILTER ( ?date > ?_date_dateTime ) | ||
?book ?p ?v | ||
} } |
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 @@ | ||
# X-Basil-Endpoint: http://data.open.ac.uk/sparql | ||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | ||
PREFIX mlo: <http://purl.org/net/mlo/> | ||
PREFIX aiiso: <http://purl.org/vocab/aiiso/schema#> | ||
|
||
# Eg value for ?_geoid 2328926 | ||
SELECT ?course FROM <http://data.open.ac.uk/context/course> | ||
WHERE { | ||
BIND(iri(CONCAT('http://sws.geonames.org/',?_geoid,'/')) as ?location) . | ||
?course mlo:location ?location . ?course a aiiso:Module | ||
} |
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 @@ | ||
# X-Basil-Endpoint: http://dbpedia.org/sparql | ||
|
||
PREFIX some: <http://www.example.com/insert#> . | ||
|
||
select ?subject ?label ?nationality where { | ||
?subject a <http://dbpedia.org/ontology/Person> ; | ||
<http://www.w3.org/2000/01/rdf-schema#label> ?label ; | ||
<http://dbpedia.org/property/dateOfBirth> ?_year_number ; | ||
<http://dbpedia.org/ontology/nationality> ?nationality . | ||
filter(lang(?label)="en") | ||
} |
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,15 @@ | ||
# X-Basil-Endpoint: http://dbpedia.org/sparql | ||
|
||
# a DELETE command should be considered in a comment | ||
|
||
select | ||
|
||
?insert ?subject ?label ?nationality where { # insert a comment here | ||
|
||
|
||
?subject a <http://dbpedia.org/ontology/Person> ; | ||
<http://www.w3.org/2000/01/rdf-schema#label> ?label ; | ||
<http://dbpedia.org/property/dateOfBirth> ?_year_number ; | ||
<http://dbpedia.org/ontology/nationality> ?nationality . | ||
filter(lang(?label)="en") | ||
} |
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,9 @@ | ||
# X-Basil-Endpoint: http://dbpedia.org/sparql | ||
select ?subject ?label ?nationality where { | ||
?subject a <http://dbpedia.org/ontology/Person> ; | ||
<http://www.w3.org/2000/01/rdf-schema#label> ?label ; | ||
<http://dbpedia.org/property/dateOfBirth> 1964 ; | ||
<http://dbpedia.org/ontology/nationality> ?nationality . | ||
filter(lang(?label)="en") | ||
} | ||
LIMIT ?_limit_number |
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 @@ | ||
# X-Basil-Endpoint: http://dbpedia.org/sparql | ||
select ?subject ?label ?nationality where { | ||
?subject a <http://dbpedia.org/ontology/Person> ; | ||
<http://www.w3.org/2000/01/rdf-schema#label> ?label ; | ||
<http://dbpedia.org/property/dateOfBirth> 1964 ; | ||
<http://dbpedia.org/ontology/nationality> ?nationality . | ||
filter(lang(?label)="en") | ||
} | ||
LIMIT ?_limit_number | ||
OFFSET ?_offset_number |
Oops, something went wrong.