@@ -, +, @@ Koha::RDF --- Koha/RDF.pm | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) --- a/Koha/RDF.pm +++ a/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; --