-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated SPARQL, added unit test to remove objects
- Loading branch information
1 parent
396fddb
commit 7076d08
Showing
3 changed files
with
74 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
PREFIX schema: <http://schema.org/> | ||
PREFIX schemaHttps: <https://schema.org/> | ||
|
||
DELETE { | ||
?subject ?predicate ?object . | ||
?s ?p ?o . | ||
} | ||
WHERE { | ||
?subject ?predicate ?object . | ||
?subject a <http://schema.org/SiteNavigationElement> . | ||
?s ?p ?o . | ||
?s a ?type . | ||
VALUES ?type { schema:SiteNavigationElement schemaHttps:SiteNavigationElement } | ||
} |
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,46 @@ | ||
{ | ||
"@context": "http://schema.org", | ||
"@graph": [ | ||
{ | ||
"@id": "https://example.com/temporary/unique-id-1", | ||
"@type": [ | ||
"https://schema.org/SiteNavigationElement" | ||
], | ||
"http://www.w3.org/ns/prov#wasDerivedFrom": [ | ||
{ | ||
"@id": "https://example.com/source-page-1" | ||
} | ||
] | ||
}, | ||
{ | ||
"@id": "https://example.com/temporary/unique-id-2", | ||
"@type": [ | ||
"http://schema.org/SiteNavigationElement" | ||
], | ||
"http://schema.org/name": [ | ||
{ | ||
"@value": "Example Name 1" | ||
}, | ||
{ | ||
"@value": "Example Name 2" | ||
} | ||
], | ||
"http://schema.org/url": [ | ||
{ | ||
"@id": "https://example.com/page-1" | ||
}, | ||
{ | ||
"@id": "https://example.com/page-2" | ||
}, | ||
{ | ||
"@id": "https://example.com/login-page" | ||
} | ||
], | ||
"http://www.w3.org/ns.prov#wasDerivedFrom": [ | ||
{ | ||
"@id": "https://example.com/source-page-1" | ||
} | ||
] | ||
} | ||
] | ||
} |
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,21 @@ | ||
require 'minitest/autorun' | ||
require 'linkeddata' | ||
|
||
class RemoveObjectTest < Minitest::Test | ||
def setup | ||
@remove_object_sparql_file = "./sparql/remove_objects.sparql" | ||
end | ||
|
||
def test_remove_object | ||
sparql = SPARQL.parse(File.read(@remove_object_sparql_file), update: true) | ||
graph = RDF::Graph.load("./tests/fixtures/test_remove_object.jsonld") | ||
|
||
# puts "before: #{graph.dump(:jsonld)}" | ||
graph.query(sparql) | ||
|
||
# puts "after: #{graph.dump(:jsonld)}" | ||
assert_equal(0, graph.count, "The graph should have no objects after the SPARQL update.") | ||
end | ||
|
||
|
||
end |