Skip to content

Commit c210ae9

Browse files
committed
switch SPARQL ?resource variable to ?this in order to align with SHACL
1 parent dbc3064 commit c210ae9

File tree

19 files changed

+305
-305
lines changed

19 files changed

+305
-305
lines changed

ns/core.ttl

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ rut:Pattern
8585
rut:sparqlWherePattern
8686
a owl:DatatypeProperty ;
8787
rdfs:label "sparqlWherePattern"@en ;
88-
rdfs:comment "The WHERE part of a sparql query with %%parameter%% placeholders. Must bind variables ?resource and ?message (see rut:sparqlWhere)"@en ;
88+
rdfs:comment "The WHERE part of a sparql query with %%parameter%% placeholders. Must bind variables ?this and ?message (see rut:sparqlWhere)"@en ;
8989
rdfs:domain rut:Pattern ;
9090
rdfs:range xsd:string .
9191

@@ -331,7 +331,7 @@ rut:sparqlWhere
331331
rdfs:label "sparqlWhere"@en ;
332332
rdfs:comment
333333
"""The WHERE part of a SPARQL query. Must be enclosed in brackets {} and bind the following variables:
334-
?resource: the instance (URI) where the constraint violation occurs;
334+
?this: the instance (URI) where the constraint violation occurs;
335335
?message: a logging message."""@en ;
336336
rdfs:domain rut:ManualTestCase ;
337337
rdfs:range xsd:string .

rdfunit-core/src/main/java/org/aksw/rdfunit/io/writer/RDFHTMLResultsRlogWriter.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ protected StringBuffer getResultsList(QueryExecutionFactory qef, String testExec
4949
String template = "<tr class=\"%s\"><td>%s</td><td>%s</ts><td><a href=\"%s\">%s</a></td><td>%s</td></tr>";
5050

5151
String sparql = PrefixNSService.getSparqlPrefixDecl() +
52-
" SELECT DISTINCT ?level ?message ?resource ?testcase WHERE {" +
52+
" SELECT DISTINCT ?level ?message ?this ?testcase WHERE {" +
5353
" ?s a rut:RLOGTestCaseResult ; " +
5454
" rlog:level ?level ;" +
5555
" rlog:message ?message ; " +
56-
" rlog:resource ?resource ; " +
56+
" rlog:resource ?this ; " +
5757
" rut:testCase ?testcase ; " +
5858
//" prov:wasGeneratedBy <" + testExecutionURI + "> " +
5959
"} ";
@@ -68,7 +68,7 @@ protected StringBuffer getResultsList(QueryExecutionFactory qef, String testExec
6868
QuerySolution qs = rs.next();
6969
String level = qs.get("level").toString();
7070
String message = qs.get("message").toString();
71-
String resource = qs.get("resource").toString();
71+
String resource = qs.get("this").toString();
7272
String testcase = qs.get("testcase").toString();
7373

7474
String levelShort = PrefixNSService.getLocalName(level, "rlog");

rdfunit-core/src/main/java/org/aksw/rdfunit/io/writer/RDFHTMLResultsShaclWriter.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ protected StringBuffer getResultsList(QueryExecutionFactory qef, String testExec
4949
String template = "<tr class=\"%s\"><td>%s</td><td>%s</ts><td><a href=\"%s\">%s</a></td><td>%s</td></tr>";
5050

5151
String sparql = PrefixNSService.getSparqlPrefixDecl() +
52-
" SELECT DISTINCT ?level ?message ?resource ?testcase WHERE {" +
52+
" SELECT DISTINCT ?level ?message ?this ?testcase WHERE {" +
5353
" ?s a sh:ValidationResult ; " +
5454
" sh:severity ?level ;" +
5555
" sh:message ?message ; " +
56-
" sh:focusNode ?resource ; " +
56+
" sh:focusNode ?this ; " +
5757
" rut:testCase ?testcase ; " +
5858
//" prov:wasGeneratedBy <" + testExecutionURI + "> " +
5959
"} ";
@@ -68,7 +68,7 @@ protected StringBuffer getResultsList(QueryExecutionFactory qef, String testExec
6868
QuerySolution qs = rs.next();
6969
String level = qs.get("level").toString();
7070
String message = qs.get("message").toString();
71-
String resource = qs.get("resource").toString();
71+
String resource = qs.get("this").toString();
7272
String testcase = qs.get("testcase").toString();
7373

7474
String levelShort = PrefixNSService.getLocalName(level, "rlog");

rdfunit-core/src/main/java/org/aksw/rdfunit/tests/TestCaseValidator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ public void validate() {
5050
// check for Resource & message
5151
boolean hasResource = false;
5252
for (String v : vars) {
53-
if ("resource".equals(v)) {
53+
if ("this".equals(v)) {
5454
hasResource = true;
5555
}
5656

5757
}
5858
if (!hasResource) {
59-
// throw new TestCaseInstantiationException("?resource is not included in SELECT for Test: " + testCase.getTestURI());
59+
// throw new TestCaseInstantiationException("?this is not included in SELECT for Test: " + testCase.getTestURI());
6060
}
6161

6262
// Message is allowed to exist either in SELECT or as a result annotation

rdfunit-core/src/main/java/org/aksw/rdfunit/tests/executors/ExtendedTestExecutor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ protected Collection<TestCaseResult> executeSingleTest(TestSource testSource, Te
6060

6161
QuerySolution qs = results.next();
6262

63-
String resource = qs.get("resource").toString();
64-
if (qs.get("resource").isLiteral()) {
63+
String resource = qs.get("this").toString();
64+
if (qs.get("this").isLiteral()) {
6565
resource = StringUtils.getHashFromString(resource);
6666
}
6767
String message = testCase.getResultMessage();

rdfunit-core/src/main/java/org/aksw/rdfunit/tests/executors/RLOGTestExecutor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ protected Collection<TestCaseResult> executeSingleTest(TestSource testSource, Te
5454

5555
QuerySolution qs = results.next();
5656

57-
String resource = qs.get("resource").toString();
58-
if (qs.get("resource").isLiteral()) {
57+
String resource = qs.get("this").toString();
58+
if (qs.get("this").isLiteral()) {
5959
resource = StringUtils.getHashFromString(resource);
6060
}
6161
String message = testCase.getResultMessage();

rdfunit-core/src/main/java/org/aksw/rdfunit/tests/executors/ShaclFullTestExecutor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ protected Collection<TestCaseResult> executeSingleTest(TestSource testSource, Te
5858

5959
QuerySolution qs = results.next();
6060

61-
String resource = qs.get("resource").toString();
62-
if (qs.get("resource").isLiteral()) {
61+
String resource = qs.get("this").toString();
62+
if (qs.get("this").isLiteral()) {
6363
resource = StringUtils.getHashFromString(resource);
6464
}
6565
String message = testCase.getResultMessage();

rdfunit-core/src/main/java/org/aksw/rdfunit/tests/executors/ShaclSimpleTestExecutor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ protected Collection<TestCaseResult> executeSingleTest(TestSource testSource, Te
5454

5555
QuerySolution qs = results.next();
5656

57-
String resource = qs.get("resource").toString();
58-
if (qs.get("resource").isLiteral()) {
57+
String resource = qs.get("this").toString();
58+
if (qs.get("this").isLiteral()) {
5959
resource = StringUtils.getHashFromString(resource);
6060
}
6161
String message = testCase.getResultMessage();

rdfunit-core/src/main/java/org/aksw/rdfunit/tests/query_generation/QueryGenerationCountFactory.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
*/
1515
public class QueryGenerationCountFactory implements QueryGenerationFactory {
1616

17-
private static final String selectClauseSimple = " SELECT (count(DISTINCT ?resource ) AS ?total ) WHERE ";
17+
private static final String selectClauseSimple = " SELECT (count(DISTINCT ?this ) AS ?total ) WHERE ";
1818

19-
private static final String selectClauseGroupStart = " SELECT (count(DISTINCT ?resource ) AS ?total ) WHERE {" +
20-
" SELECT ?resource WHERE ";
19+
private static final String selectClauseGroupStart = " SELECT (count(DISTINCT ?this ) AS ?total ) WHERE {" +
20+
" SELECT ?this WHERE ";
2121
private static final String selectClauseGroupEnd = "}";
2222

2323
/** {@inheritDoc} */

rdfunit-core/src/main/java/org/aksw/rdfunit/tests/query_generation/QueryGenerationExtendedSelectFactory.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@
1111

1212
/**
1313
* Factory that returns select queries and besides
14-
* SELECT ?resource it adds all variable annotations
14+
* SELECT ?this it adds all variable annotations
1515
*
1616
* @author Dimitris Kontokostas
1717
* @since 7/25/14 10:02 PM
1818
* @version $Id: $Id
1919
*/
2020
public class QueryGenerationExtendedSelectFactory implements QueryGenerationFactory {
2121

22-
private static final String selectDistinctResource = " SELECT DISTINCT ?resource ";
22+
private static final String selectDistinctResource = " SELECT DISTINCT ?this ";
2323

24-
private static final String resourceVar = "?resource";
24+
private static final String resourceVar = "?this";
2525

2626
private static final String whereClause = " WHERE ";
2727

28-
private static final String orderByResourceAsc = " ORDER BY ASC(?resource) ";
28+
private static final String orderByResourceAsc = " ORDER BY ASC(?this) ";
2929

3030
/** {@inheritDoc} */
3131
@Override

rdfunit-core/src/main/java/org/aksw/rdfunit/tests/query_generation/QueryGenerationSelectFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
public class QueryGenerationSelectFactory implements QueryGenerationFactory {
1616

17-
private static final String selectClause = " SELECT DISTINCT ?resource WHERE ";
17+
private static final String selectClause = " SELECT DISTINCT ?this WHERE ";
1818

1919
/** {@inheritDoc} */
2020
@Override

rdfunit-core/src/test/java/org/aksw/rdfunit/tests/query_generation/QueryGenerationSelectFactoryTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public class QueryGenerationSelectFactoryTest {
1919

2020
private static final String sparqlPrefix = "";
2121

22-
private static final String sparqlSelect = " SELECT DISTINCT ?resource WHERE ";
22+
private static final String sparqlSelect = " SELECT DISTINCT ?this WHERE ";
2323

24-
private static final String goodSparqlQuery = "{ ?resource ?p ?o }";
24+
private static final String goodSparqlQuery = "{ ?this ?p ?o }";
2525

2626
private QueryGenerationSelectFactory queryGenerationSelectFactory;
2727

rdfunit-manual-tests/src/main/resources/org/aksw/rdfunit/tests/Manual/dbpedia.org/dbpedia.org.tests.Manual.ttl

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ rutt:dbpedia-org-manual-dateofbirthbirthdate
4747
rut:references <http://dbpedia.org/property/dateOfBirth> ;
4848
rut:source <http://dbpedia.org> ;
4949
rut:sparqlWhere """ {
50-
?resource <http://dbpedia.org/property/dateOfBirth> ?v1 .
51-
FILTER NOT EXISTS {?resource <http://dbpedia.org/ontology/birthDate> ?v2}} """ ;
52-
rut:sparqlPrevalence """ SELECT (count(?resource) AS ?total) WHERE {
53-
?resource <http://dbpedia.org/property/dateOfBirth> ?v1 . } """ ;
50+
?this <http://dbpedia.org/property/dateOfBirth> ?v1 .
51+
FILTER NOT EXISTS {?this <http://dbpedia.org/ontology/birthDate> ?v2}} """ ;
52+
rut:sparqlPrevalence """ SELECT (count(?this) AS ?total) WHERE {
53+
?this <http://dbpedia.org/property/dateOfBirth> ?v1 . } """ ;
5454
rut:testCaseLogLevel
5555
rlog:WARN .
5656

rdfunit-manual-tests/src/main/resources/org/aksw/rdfunit/tests/Manual/dbpedia.org/ontology/dbo.tests.Manual.ttl

+6-6
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,16 @@ rutt:dbo-LITRAN-rangeheightperson
133133
rut:source <http://dbpedia.org/ontology/> ;
134134
rut:sparqlWhere """ {
135135
{
136-
?resource a <http://dbpedia.org/ontology/Person> .
137-
?resource <http://dbpedia.org/ontology/height> ?v1 .
136+
?this a <http://dbpedia.org/ontology/Person> .
137+
?this <http://dbpedia.org/ontology/height> ?v1 .
138138
} UNION {
139-
?resource a ?class .
139+
?this a ?class .
140140
?class rdfs:subClassOf+ <http://dbpedia.org/ontology/Person> .
141-
?resource <http://dbpedia.org/ontology/height> ?v1 .
141+
?this <http://dbpedia.org/ontology/height> ?v1 .
142142
}
143143
FILTER ( !(xsd:double(?v1) < 44 || xsd:double(?v1) > 250))} """ ;
144-
rut:sparqlPrevalence """ SELECT (count(?resource) AS ?total) WHERE {
145-
?resource <http://dbpedia.org/ontology/height> ?v1 . } """ ;
144+
rut:sparqlPrevalence """ SELECT (count(?this) AS ?total) WHERE {
145+
?this <http://dbpedia.org/ontology/height> ?v1 . } """ ;
146146
rut:testCaseLogLevel
147147
rlog:WARN ;
148148
rut:resultAnnotation [

0 commit comments

Comments
 (0)