Bugzilla – Attachment 63908 Details for
Bug 18713
Add support for named graphs and rfds:seeAlso to Koha::RDF
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18713 - Add support for named graphs and rfds:seeAlso to Koha::RDF
Bug-18713---Add-support-for-named-graphs-and-rfdss.patch (text/plain), 2.32 KB, created by
David Cook
on 2017-06-02 06:17:14 UTC
(
hide
)
Description:
Bug 18713 - Add support for named graphs and rfds:seeAlso to Koha::RDF
Filename:
MIME Type:
Creator:
David Cook
Created:
2017-06-02 06:17:14 UTC
Size:
2.32 KB
patch
obsolete
>From 653a4e7352b8d359a2b404d10e8d028f89b27f69 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Thu, 1 Jun 2017 16:17:30 +1000 >Subject: [PATCH] Bug 18713 - Add support for named graphs and rfds:seeAlso to > Koha::RDF > >This patch adds methods to Koha::RDF that creates or deletes a named >graph by removing/adding RDF quads from/to a triplestore. > >This patch also can create a rdfs:seeAlso relationship between >two RDF entities. > >This patch includes unit tests for both of these changes. > >_TEST PLAN_ >1) Run "prove t/Koha/RDF.t" >2) Note that all tests have run successfully. >--- > Koha/RDF.pm | 43 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > >diff --git a/Koha/RDF.pm b/Koha/RDF.pm >index def6dfddcb..c9a635e7f1 100644 >--- a/Koha/RDF.pm >+++ b/Koha/RDF.pm >@@ -47,4 +47,47 @@ sub mint_uri { > return $new_uri; > } > >+sub DelNamedGraph { >+ my ($self, $args) = @_; >+ my $model = $args->{model}; >+ my $context = $args->{context}; >+ if ($model && $context){ >+ #Create a statement including variables to match everything with a given context (ie within a named graph), so that we can delete all these statements >+ my $s = RDF::Trine::Node::Variable->new("s"); >+ my $p = RDF::Trine::Node::Variable->new("p"); >+ my $o = RDF::Trine::Node::Variable->new("o"); >+ my $quad = RDF::Trine::Statement::Quad->new($s, $p, $o, $context); >+ >+ #Perform operations >+ $model->remove_statements($quad); >+ } >+} >+ >+sub AddNamedGraph { >+ my ($self, $args) = @_; >+ my $model = $args->{model}; >+ my $context = $args->{context}; >+ my $iterator = $args->{iterator}; >+ >+ while (my $st = $iterator->next){ >+ #Set the context (in order to populate the named graph) >+ $st->context($context); >+ >+ $model->add_statement($st); >+ #NOTE: This method returns undef on success. >+ } >+} >+ >+sub AddSeeAlso { >+ my ($self, $args) = @_; >+ my $model = $args->{model}; >+ my $subject = $args->{subject}; >+ my $predicate = RDF::Trine::Node::Resource->new("http://www.w3.org/2000/01/rdf-schema#seeAlso"); >+ my $object = $args->{object}; >+ if ($model && $subject && $predicate && $object){ >+ my $statement = RDF::Trine::Statement->new($subject,$predicate,$object); >+ $model->add_statement($statement); >+ } >+} >+ > 1; >-- >2.12.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18713
:
63894
|
63908
|
63909
|
64020
|
69633
|
83612