| 1 | package WQS::SPARQL::Result; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 4 | ▶ | use Class::Utils qw(set_params); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 4 | ▶ | use Error::Pure qw(err); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 4 | ▶ | use URI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 4 | our $VERSION = 0.01; | |||||||||
| 11 | |||||||||||
| 12 | sub new { | ||||||||||
| 13 | 3 | ▶ | my ($class, @params) = @_; | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | |||||||||||
| 15 | # Create object. | ||||||||||
| 16 | 3 | my $self = bless {}, $class; | |||||||||
| 17 | |||||||||||
| 18 | # Process parameters. | ||||||||||
| 19 | 3 | set_params($self, @params); | |||||||||
| 20 | |||||||||||
| 21 | 3 | return $self; | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | sub result { | ||||||||||
| 25 | 2 | ▶ | my ($self, $result_hr, $vars_ar) = @_; | ||||||||
|
Subroutine
result: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||
| 26 | |||||||||||
| 27 | 2 | ▶ | if (! defined $vars_ar) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 2 | $vars_ar = $result_hr->{'head'}->{'vars'}; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 2 | my @res; | |||||||||
| 32 | 2 | ▶ | if (exists $result_hr->{'results'}->{'bindings'}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 2 | my @items = @{$result_hr->{'results'}->{'bindings'}}; | |||||||||
| 34 | 2 | foreach my $item_hr (@items) { | |||||||||
| 35 | 2 | my $result_hr; | |||||||||
| 36 | 2 | foreach my $var (@{$vars_ar}) { | |||||||||
| 37 | |||||||||||
| 38 | # TODO Implement other values | ||||||||||
| 39 | |||||||||||
| 40 | # QID. | ||||||||||
| 41 | # TODO Check real QID, could be another uri. | ||||||||||
| 42 | 2 | ▶ | if ($item_hr->{$var}->{'type'} eq 'uri') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 2 | my $qid_uri = URI->new($item_hr->{$var}->{'value'}); | |||||||||
| 44 | 2 | my @segs = $qid_uri->path_segments; | |||||||||
| 45 | 2 | $result_hr->{$var} = $segs[-1]; | |||||||||
| 46 | } | ||||||||||
| 47 | } | ||||||||||
| 48 | 2 | push @res, $result_hr; | |||||||||
| 49 | } | ||||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 2 | return @res; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 4 | 1; | |||||||||
| 56 | |||||||||||
| 57 | __END__ | ||||||||||