| 1 | package RDF::Trine::Store::LDF; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | no warnings 'redefine'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use feature qw(state); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use base qw(RDF::Trine::Store); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use RDF::Trine::Store; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use RDF::Trine::Iterator; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use RDF::LDF; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use RDF::Trine::Error qw(:try); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 16 | 0 | my ($class,%opts) = @_; | |||||||||
| 17 | 0 | my $ref = \%opts; | |||||||||
| 18 | 0 | $ref->{ldf} = RDF::LDF->new( url => $ref->{url}); | |||||||||
| 19 | |||||||||||
| 20 | 0 | ▶ | return undef unless $ref->{ldf}->is_fragment_server; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | |||||||||||
| 22 | 0 | bless $ref , $class; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub _new_with_string { | ||||||||
|
Subroutine
_new_with_string: not called CC=1 SCAR=6.9
| |||||||||||
| 26 | 0 | my ($class, $cfg) = @_; | |||||||||
| 27 | 0 | $class->new(url => $cfg); | |||||||||
| 28 | } | ||||||||||
| 29 | 0 | ▶ | sub _new_with_config { | ||||||||
|
Subroutine
_new_with_config: not called CC=1 SCAR=6.9
| |||||||||||
| 30 | 0 | my ($class,$cfg) = @_; | |||||||||
| 31 | 0 | $class->new(url => $cfg->{url}); | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | sub get_statements { | ||||||||
|
Subroutine
get_statements: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 35 | 0 | my ($self,$subject,$predicate,$object,$context) = @_; | |||||||||
| 36 | |||||||||||
| 37 | 0 | my $sub = $self->{ldf}->get_statements($subject,$predicate,$object); | |||||||||
| 38 | 0 | RDF::Trine::Iterator::Graph->new($sub); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub get_pattern { | ||||||||
|
Subroutine
get_pattern: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | 0 | my ($self,$bgp,$context) = @_; | |||||||||
| 43 | |||||||||||
| 44 | 0 | $self->{ldf}->get_pattern($bgp,$context); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 0 | ▶ | sub get_contexts { | ||||||||
|
Subroutine
get_contexts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | 0 | undef; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 0 | ▶ | sub add_statement { | ||||||||
|
Subroutine
add_statement: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 52 | 0 | throw RDF::Trine::Error::UnimplementedError -text => "LDF add_statement support not implemented"; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | sub remove_statement { | ||||||||
|
Subroutine
remove_statement: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 56 | 0 | throw RDF::Trine::Error::UnimplementedError -text => "LDF remove_statement support not implemented"; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | 0 | ▶ | sub remove_statements { | ||||||||
|
Subroutine
remove_statements: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 60 | 0 | throw RDF::Trine::Error::UnimplementedError -text => "LDF remove_statements support not implemented"; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | sub count_statements { | ||||||||
|
Subroutine
count_statements: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 64 | 0 | my ($self,$subject,$predicate,$object,$context) = @_; | |||||||||
| 65 | |||||||||||
| 66 | 0 | my $it = $self->{ldf}->get_statements($subject,$predicate,$object); | |||||||||
| 67 | |||||||||||
| 68 | 0 | my ($triples,$info) = $it->(); | |||||||||
| 69 | |||||||||||
| 70 | 0 | $info->{hydra_totalItems}; | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | sub size { | ||||||||
|
Subroutine
size: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 74 | 0 | shift->count_statements; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | sub supports { | ||||||||
|
Subroutine
supports: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 78 | 0 | undef; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 1 | 1; | |||||||||
| 82 | |||||||||||
| 83 | =head1 NAME | ||||||||||
| 84 | |||||||||||
| 85 | RDF::Trine::Store::LDF - RDF Store proxy for a Linked Data Fragment endpoint | ||||||||||
| 86 | |||||||||||
| 87 | =head1 SYNOPSIS | ||||||||||
| 88 | |||||||||||
| 89 | use RDF::Trine::Store::LDF; | ||||||||||
| 90 | use RDF::Trine::Store; | ||||||||||
| 91 | |||||||||||
| 92 | my $store = RDF::Trine::Store->new_with_config({ | ||||||||||
| 93 | storetype => 'LDF', | ||||||||||
| 94 | url => $url | ||||||||||
| 95 | }); | ||||||||||
| 96 | |||||||||||
| 97 | my $it = $store->get_statements(); | ||||||||||
| 98 | |||||||||||
| 99 | while (my $st = $it->next) { | ||||||||||
| 100 | # $st is a RDF::Trine::Statement | ||||||||||
| 101 | print "$st\n"; | ||||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | # Or query the store with SPAQRL | ||||||||||
| 105 | |||||||||||
| 106 | use RDF::Query; | ||||||||||
| 107 | my $model = RDF::Trine::Model->new($store); | ||||||||||
| 108 | |||||||||||
| 109 | my $rdf_query = RDF::Query->new(<<EOF); | ||||||||||
| 110 | . | ||||||||||
| 111 | . | ||||||||||
| 112 | SPARQL | ||||||||||
| 113 | . | ||||||||||
| 114 | . | ||||||||||
| 115 | EOF | ||||||||||
| 116 | |||||||||||
| 117 | my $iter = $rdf_query->execute($model); | ||||||||||
| 118 | |||||||||||
| 119 | while (my $s = $iter->next) { | ||||||||||
| 120 | # $s is a RDF::Trine::VariableBinding | ||||||||||
| 121 | print $s->value . "\n"; | ||||||||||
| 122 | } | ||||||||||
| 123 | |||||||||||
| 124 | =head1 DESCRIPTION | ||||||||||
| 125 | |||||||||||
| 126 | RDF::Trine::Store::LDF provides a RDF::Trine::Store API to interact with a remote | ||||||||||
| 127 | Linked Data Fragment endpoint. For details see: <http://linkeddatafragments.org/>. | ||||||||||
| 128 | |||||||||||
| 129 | =head1 METHODS | ||||||||||
| 130 | |||||||||||
| 131 | Beyond the methods documented below, this class inherits methods from the L<RDF::Trine::Store> class. | ||||||||||
| 132 | |||||||||||
| 133 | =over | ||||||||||
| 134 | |||||||||||
| 135 | =item new({ url => url }) | ||||||||||
| 136 | |||||||||||
| 137 | Returns a new RDF::Trine::Store object that will act as a proxy for the Linked Data Fragment | ||||||||||
| 138 | endpoint accessible via the supplied $url. | ||||||||||
| 139 | |||||||||||
| 140 | Expertimental: more than one url as an ARRAY reference can be provided for an federated | ||||||||||
| 141 | query over many LDF endpoints. | ||||||||||
| 142 | |||||||||||
| 143 | =item new_with_config( $hashref ) | ||||||||||
| 144 | |||||||||||
| 145 | Returns a new RDF::Trine::Store object configured by a hashref with the url as required key. | ||||||||||
| 146 | |||||||||||
| 147 | =item get_statements( $subject, $predicate, $object ) | ||||||||||
| 148 | |||||||||||
| 149 | Returns a stream object of all statements matching the specified subject, predicate and objects. | ||||||||||
| 150 | Any of the arguments may be undef to match any value. | ||||||||||
| 151 | |||||||||||
| 152 | =item get_pattern( $bgp ) | ||||||||||
| 153 | |||||||||||
| 154 | Returns an iterator object of all bindings matching the specified graph pattern. | ||||||||||
| 155 | |||||||||||
| 156 | =item get_contexts | ||||||||||
| 157 | |||||||||||
| 158 | Not supported. | ||||||||||
| 159 | |||||||||||
| 160 | =item add_statement ( $statement [, $context] ) | ||||||||||
| 161 | |||||||||||
| 162 | Not supported. | ||||||||||
| 163 | |||||||||||
| 164 | =item remove_statement ( $statement [, $context]) | ||||||||||
| 165 | |||||||||||
| 166 | Not supported. | ||||||||||
| 167 | |||||||||||
| 168 | =item remove_statements ( $subject, $predicate, $object [, $context]) | ||||||||||
| 169 | |||||||||||
| 170 | Not supported. | ||||||||||
| 171 | |||||||||||
| 172 | =item count_statements ( $subject, $predicate, $object ) | ||||||||||
| 173 | |||||||||||
| 174 | Returns a count of all the statements matching the specified subject, predicate and object. | ||||||||||
| 175 | Any of the arguments may be undef to match any value. | ||||||||||
| 176 | |||||||||||
| 177 | =item size | ||||||||||
| 178 | |||||||||||
| 179 | Returns the number of statements in the store. | ||||||||||
| 180 | |||||||||||
| 181 | =item supports ( [ $feature ] ) | ||||||||||
| 182 | |||||||||||
| 183 | Not supported. | ||||||||||
| 184 | |||||||||||
| 185 | =back | ||||||||||
| 186 | |||||||||||
| 187 | =head1 AUTHOR | ||||||||||
| 188 | |||||||||||
| 189 | Patrick Hochstenbach, C<< patrick.hochstenbach at ugent.be >> | ||||||||||
| 190 | |||||||||||
| 191 | =head1 CONTRIBUTORS | ||||||||||
| 192 | |||||||||||
| 193 | Gregory Todd Williams, C<< greg@evilfunhouse.com >> | ||||||||||
| 194 | |||||||||||
| 195 | =head1 LICENSE | ||||||||||
| 196 | |||||||||||
| 197 | This program is free software; you can redistribute it and/or modify it under the terms of either: | ||||||||||
| 198 | the GNU General Public License as published by the Free Software Foundation; or the Artistic License. | ||||||||||
| 199 | |||||||||||
| 200 | See L<http://dev.perl.org/licenses/> for more information. | ||||||||||
| 201 | |||||||||||
| 202 | =encoding utf8 | ||||||||||
| 203 | |||||||||||
| 204 | =cut | ||||||||||