Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
digibib
ls.ext
Commits
a39b5736
Commit
a39b5736
authored
Oct 25, 2018
by
Petter Goksøyr Åsen
Browse files
Revert "DEICH-1599: Specifying graph in SPARQL queries (to fix tests)."
This reverts commit
f615629e
.
parent
88178ec5
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
redef/services/src/main/java/no/deichman/services/entity/repository/InMemoryRepository.java
View file @
a39b5736
...
...
@@ -6,14 +6,11 @@ import org.apache.jena.query.Query;
import
org.apache.jena.query.QueryExecution
;
import
org.apache.jena.query.QueryExecutionFactory
;
import
org.apache.jena.rdf.model.Model
;
import
org.apache.jena.rdf.model.ModelFactory
;
import
org.apache.jena.update.UpdateAction
;
import
org.apache.jena.update.UpdateRequest
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
static
no
.
deichman
.
services
.
entity
.
repository
.
SPARQLQueryBuilder
.
DEFAULT_GRAPH
;
/**
* Responsibility: Implement an in-memory RDF-repository.
*/
...
...
@@ -28,16 +25,15 @@ public final class InMemoryRepository extends RDFRepositoryBase {
private
InMemoryRepository
(
SPARQLQueryBuilder
sqb
,
UniqueURIGenerator
uriGenerator
)
{
super
(
sqb
,
uriGenerator
);
model
=
DatasetFactory
.
create
();
model
.
addNamedModel
(
DEFAULT_GRAPH
,
ModelFactory
.
createDefaultModel
());
LOG
.
info
(
"In-memory repository started."
);
}
public
void
addData
(
Model
newData
){
model
.
get
NamedModel
(
DEFAULT_GRAPH
).
add
(
newData
);
model
.
get
DefaultModel
(
).
add
(
newData
);
}
public
Model
getModel
()
{
return
model
.
get
NamedModel
(
DEFAULT_GRAPH
);
return
model
.
get
DefaultModel
(
);
}
@Override
...
...
redef/services/src/main/java/no/deichman/services/entity/repository/SPARQLQueryBuilder.java
View file @
a39b5736
This diff is collapsed.
Click to expand it.
redef/services/src/test/java/no/deichman/services/entity/repository/SPARQLQueryBuilderTest.java
View file @
a39b5736
...
...
@@ -51,7 +51,7 @@ public class SPARQLQueryBuilderTest {
public
void
get_resource_by_id
(){
SPARQLQueryBuilder
sqb
=
new
SPARQLQueryBuilder
();
Query
query
=
sqb
.
getGetResourceByIdQuery
(
"http://example.com/a"
);
String
expected
=
"DESCRIBE <http://example.com/a>
\nFROM <https://data.deichman.no>
"
;
String
expected
=
"DESCRIBE <http://example.com/a>"
;
assertEquals
(
expected
,
query
.
toString
().
trim
());
}
...
...
@@ -136,7 +136,7 @@ public class SPARQLQueryBuilderTest {
@Test
public
void
test_resource_existence_query
()
throws
Exception
{
XURI
uri
=
new
XURI
(
"http://deichman.no/work/w123"
);
String
test
=
"ASK
WHERE { GRAPH <https://data.deichman.no> {
<"
+
uri
.
getUri
()
+
"> ?p ?o}
}
"
;
String
test
=
"ASK
{
<"
+
uri
.
getUri
()
+
"> ?p ?o}"
;
Query
expected
=
QueryFactory
.
create
(
test
);
SPARQLQueryBuilder
sqb
=
new
SPARQLQueryBuilder
();
assertEquals
(
expected
,
sqb
.
checkIfResourceExists
(
uri
));
...
...
@@ -146,7 +146,7 @@ public class SPARQLQueryBuilderTest {
public
void
test_statement_exists
()
throws
UnsupportedEncodingException
{
Statement
s
=
getTestStatement
();
SPARQLQueryBuilder
sqb
=
new
SPARQLQueryBuilder
();
String
test
=
"ASK
WHERE { GRAPH <https://data.deichman.no> {
<"
+
s
.
getSubject
().
getURI
()
+
"> <"
+
s
.
getPredicate
().
getURI
()
+
"> <"
+
s
.
getObject
().
toString
()
+
"> .
}
}"
;
String
test
=
"ASK
{
<"
+
s
.
getSubject
().
getURI
()
+
"> <"
+
s
.
getPredicate
().
getURI
()
+
"> <"
+
s
.
getObject
().
toString
()
+
"> . }"
;
Query
expected
=
QueryFactory
.
create
(
test
);
assertEquals
(
expected
,
sqb
.
checkIfStatementExists
(
s
));
}
...
...
@@ -339,12 +339,10 @@ public class SPARQLQueryBuilderTest {
String
personId
=
"n12345"
;
String
expected
=
"SELECT ?uri\n"
+
"WHERE\n"
+
" { GRAPH <https://data.deichman.no>\n"
+
" { ?uri <http://data.deichman.no/duo#bibliofilPersonId> \""
+
personId
+
"\" }\n }\n"
;
+
" { ?uri <http://data.deichman.no/duo#bibliofilPersonId> \""
+
personId
+
"\" }\n"
;
SPARQLQueryBuilder
sqb
=
new
SPARQLQueryBuilder
();
String
actual
=
sqb
.
getBibliofilPersonResource
(
personId
).
toString
();
assertEquals
(
"Bibliofil person resource query did not match"
,
expected
,
actual
);
assertEquals
(
"Bibliofil person resource query did not match"
,
expected
,
sqb
.
getBibliofilPersonResource
(
personId
).
toString
());
}
@Test
...
...
@@ -352,8 +350,7 @@ public class SPARQLQueryBuilderTest {
String
placeId
=
"n12345"
;
String
expected
=
"SELECT ?uri\n"
+
"WHERE\n"
+
" { GRAPH <https://data.deichman.no>\n"
+
" { ?uri <http://data.deichman.no/duo#bibliofilPlaceId> \""
+
placeId
+
"\" }\n }\n"
;
+
" { ?uri <http://data.deichman.no/duo#bibliofilPlaceId> \""
+
placeId
+
"\" }\n"
;
SPARQLQueryBuilder
sqb
=
new
SPARQLQueryBuilder
();
assertEquals
(
"Bibliofil place of publication resource query did not match"
,
expected
,
sqb
.
getBibliofilPlaceResource
(
placeId
).
toString
());
}
...
...
@@ -362,11 +359,10 @@ public class SPARQLQueryBuilderTest {
public
void
test_describe_publications_query
()
throws
Exception
{
XURI
xuri
=
new
XURI
(
"http://deichman.no/work/w123123"
);
String
test
=
"PREFIX deichman: <"
+
BaseURI
.
ontology
()
+
">\n"
+
"DESCRIBE ?publication WHERE {\n"
+
" GRAPH <https://data.deichman.no> {\n"
+
" ?publication deichman:publicationOf <"
+
xuri
.
getUri
()
+
">\n"
+
" }\n"
+
"}"
;
+
"DESCRIBE ?publication WHERE \n"
+
" {\n"
+
" ?publication deichman:publicationOf <"
+
xuri
.
getUri
()
+
">\n"
+
" }"
;
SPARQLQueryBuilder
sqb
=
new
SPARQLQueryBuilder
();
Query
query
=
sqb
.
describeLinkedPublications
(
xuri
);
Query
expected
=
QueryFactory
.
create
(
test
);
...
...
@@ -380,10 +376,8 @@ public class SPARQLQueryBuilderTest {
Query
query
=
sqb
.
getRecordIdsByWork
(
xuri
);
String
expected
=
"SELECT ?recordId\n"
+
"WHERE\n"
+
" { GRAPH <https://data.deichman.no>\n"
+
" { ?p <http://data.deichman.no/ontology#publicationOf> <"
+
xuri
.
getUri
()
+
"> ;\n"
+
" <http://data.deichman.no/ontology#recordId> ?recordId\n"
+
" }\n"
+
" { ?p <http://data.deichman.no/ontology#publicationOf> <"
+
xuri
.
getUri
()
+
"> ;\n"
+
" <http://data.deichman.no/ontology#recordId> ?recordId\n"
+
" }\n"
;
assertEquals
(
expected
,
query
.
toString
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment