line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Catmandu::FedoraCommons::Model::findObjects - Perl model for the Fedora 'findObjects' and 'resumeFindObjects' REST call |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Catmandu::FedoraCommons; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $fedora = Catmandu::FedoraCommons->new('http://localhost:8080/fedora','fedoraAdmin','fedoraAdmin'); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $obj = $fedora->findObjects(terms=>'*')->parse_content; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
'token' => '92b0ae4028f9459ce7cd0600f562adb2' , |
15
|
|
|
|
|
|
|
'cursor' => 0, |
16
|
|
|
|
|
|
|
'expirationDate' => '2013-02-08T09:37:55.860Z', |
17
|
|
|
|
|
|
|
'results' => [ |
18
|
|
|
|
|
|
|
{ |
19
|
|
|
|
|
|
|
'pid' => 'demo:29' , |
20
|
|
|
|
|
|
|
'label' => 'Data Object for Image Manipulation Demo' , |
21
|
|
|
|
|
|
|
'state' => 'I' , |
22
|
|
|
|
|
|
|
'ownerId' => 'fedoraAdmin' , |
23
|
|
|
|
|
|
|
'cDate' => '2008-07-02T05:09:42.015Z' , |
24
|
|
|
|
|
|
|
'mDate' => '2013-02-07T19:57:27.140Z' , |
25
|
|
|
|
|
|
|
'dcmDate' => '2008-07-02T05:09:43.234Z' , |
26
|
|
|
|
|
|
|
'title' => [ 'Coliseum in Rome' ] , |
27
|
|
|
|
|
|
|
'creator' => [ 'Thornton Staples' ] , |
28
|
|
|
|
|
|
|
'subject' => [ 'Architecture, Roman' ] , |
29
|
|
|
|
|
|
|
'description' => [ 'Image of Coliseum in Rome' ] , |
30
|
|
|
|
|
|
|
'publisher' => [ 'University of Virginia Library' ] , |
31
|
|
|
|
|
|
|
'format' => [ 'image/jpeg' ] , |
32
|
|
|
|
|
|
|
'identifier' => [ 'demo:29' ], |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
] , |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SEE ALSO |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
L<Catmandu::FedoraCommons> |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
package Catmandu::FedoraCommons::Model::findObjects; |
43
|
|
|
|
|
|
|
|
44
|
11
|
|
|
11
|
|
60692
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our %SCALAR_TYPES = (pid => 1 , label => 1 , state => 1 , ownerId => 1 , cDate => 1 , mDate => 1 , dcmDate => 1); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub parse { |
49
|
|
|
|
|
|
|
my ($class,$xml) = @_; |
50
|
|
|
|
|
|
|
my $dom = XML::LibXML->load_xml(string => $xml); |
51
|
|
|
|
|
|
|
$dom->getDocumentElement()->setNamespace('http://www.fedora.info/definitions/1/0/types/','t'); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $result = { results => [] }; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my @nodes; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
@nodes = $dom->findnodes("/t:result/t:listSession/*"); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
for my $node (@nodes) { |
60
|
|
|
|
|
|
|
my $name = $node->nodeName; |
61
|
|
|
|
|
|
|
my $value = $node->textContent; |
62
|
|
|
|
|
|
|
$result->{$name} = $value; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
@nodes = $dom->findnodes("/t:result/t:resultList/t:objectFields"); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
for my $node (@nodes) { |
68
|
|
|
|
|
|
|
my @vals = $node->findnodes("./*"); |
69
|
|
|
|
|
|
|
my $rec = {}; |
70
|
|
|
|
|
|
|
foreach my $val (@vals) { |
71
|
|
|
|
|
|
|
my $name = $val->nodeName; |
72
|
|
|
|
|
|
|
my $value = $val->textContent; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
if (exists $SCALAR_TYPES{$name}) { |
75
|
|
|
|
|
|
|
$rec->{$name} = $value; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
|
|
|
|
|
|
push @{ $rec->{$name} } , $value; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
push @{$result->{results}}, $rec; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
return $result; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |