Commit 7c958754f81d50f2d3fcba11453f05b9f1013cc2
1 parent
604b5243
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
virtuoso: adjust object term format on triple update
Showing
1 changed file
with
9 additions
and
3 deletions
Show diff stats
plugins/virtuoso/lib/virtuoso_plugin/triples_management.rb
@@ -18,15 +18,21 @@ class VirtuosoPlugin::TriplesManagement | @@ -18,15 +18,21 @@ class VirtuosoPlugin::TriplesManagement | ||
18 | def update_triple(graph_uri, from_triple, to_triple) | 18 | def update_triple(graph_uri, from_triple, to_triple) |
19 | from_subject = from_triple[:subject] | 19 | from_subject = from_triple[:subject] |
20 | from_predicate = from_triple[:predicate] | 20 | from_predicate = from_triple[:predicate] |
21 | - from_object = from_triple[:object] | 21 | + from_object = format_triple_term(from_triple[:object]) |
22 | 22 | ||
23 | to_subject = to_triple[:subject] | 23 | to_subject = to_triple[:subject] |
24 | to_predicate = to_triple[:predicate] | 24 | to_predicate = to_triple[:predicate] |
25 | - to_object = to_triple[:object] | 25 | + to_object = format_triple_term(to_triple[:object]) |
26 | 26 | ||
27 | - query = "WITH <#{graph_uri}> DELETE { <#{from_subject}> <#{from_predicate}> '#{from_object}' } INSERT { <#{to_subject}> <#{to_predicate}> '#{to_object}' }" | 27 | + query = "WITH <#{graph_uri}> DELETE { <#{from_subject}> <#{from_predicate}> #{from_object} } INSERT { <#{to_subject}> <#{to_predicate}> #{to_object} }" |
28 | 28 | ||
29 | plugin.virtuoso_client.query(query) | 29 | plugin.virtuoso_client.query(query) |
30 | end | 30 | end |
31 | 31 | ||
32 | + protected | ||
33 | + | ||
34 | + def format_triple_term(term) | ||
35 | + term =~ /^(http|https):\/\// ? "<#{term}>" : "'#{term}'" | ||
36 | + end | ||
37 | + | ||
32 | end | 38 | end |