NAME
RDF::Server::Role::Resource - expectations of a resource object
SYNOPSIS
package My::Resource
use Moose;
with 'RDF::Server::Role::Resource';
sub update { ... }
sub fetch { ... }
sub purge { ... }
DESCRIPTION
CONFIGURATION
REQUIRED METHODS
- update ($rdfxml)
-
Given an RDF document, this should add to the triple store all statements that can be built from the document. Special care should be taken with RDF containers.
- fetch : Str
-
This should return an RDF document describing all of the triples associated with this resource. References to other resources should be referenced only and not followed.
- purge : Bool
-
Given an RDF document, this should remove from the triple store all statements that can be built from the document.
TODO: Security to make sure we don't stray into another resource.
PROVIDED METHODS
- uri : Str
-
The URI of a resource defaults to the namespace of the model concatenated with the
id
of the resource. - add_triple ($s, $p, $o)
-
This will add the triple to the resource's model. If the subject is undefined, the resource's URI is substituted.
- has_triple ($s, $p, $o)
-
This will query the resource's model on the existance of the given triple. If the subject is undefined, the resource's URI is substituted.
- get_value ($namespace, $localname)
-
Given the namespace and localname of a predicate, this returns the value associated with the predicate and the given resource.
- data : HashRef
-
The Perl data structure representing the content of the resource is based on the RDF returned by the
fetch
method with some optimizations for RDF containers. Namespaces are expanded.For example, if the following is the RDF for the resource:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:x="http://www.example.com/ns/"> <rdf:Description> <x:foo>bar</x:foo> <x:stuff> <rdf:Description> <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag" /> <rdf:_1>Red</rdf:_1> <rdf:_3>Blue</rdf:_3> <rdf:_1>Green</rdf:_1> </rdf:Description> </x:stuff> </rdf:Description> </rdf:RDF>
then the Perl data structure would be:
{ '{http://www.example.com/ns/}foo' => 'bar', '{http://www.example.com/ns/}stuff' => { '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Bag' => [ 'Red', 'Green', 'Blue' ] } }
AUTHOR
James Smith, <jsmith@cpan.org>
LICENSE
Copyright (c) 2008 Texas A&M University.
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.