line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OAI::GetRecord; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
89
|
use strict; |
|
17
|
|
|
|
|
31
|
|
|
17
|
|
|
|
|
430
|
|
4
|
17
|
|
|
17
|
|
81
|
use warnings; |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
543
|
|
5
|
17
|
|
|
17
|
|
87
|
use base qw( XML::SAX::Base Net::OAI::Base ); |
|
17
|
|
|
|
|
33
|
|
|
17
|
|
|
|
|
1835
|
|
6
|
17
|
|
|
17
|
|
153
|
use Net::OAI::Record::Header; |
|
17
|
|
|
|
|
39
|
|
|
17
|
|
|
|
|
14147
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::OAI::GetRecord - The results of a GetRecord OAI-PMH verb. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 METHODS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 new() |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
9
|
|
|
9
|
1
|
80
|
my ( $class, %opts ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
9
|
|
|
|
|
22
|
my $package; |
26
|
9
|
100
|
|
|
|
74
|
if ( $package = $opts{ recordHandler } ) { |
|
|
100
|
|
|
|
|
|
27
|
3
|
50
|
|
|
|
18
|
$opts{ metadataHandler } and croak( "you may pass either a recordHandler or a metadataHandler to getRecord()" ); |
28
|
3
|
|
|
|
|
10
|
delete $opts { metadataHandler }; |
29
|
|
|
|
|
|
|
} elsif ( $package = $opts{ metadataHandler } ) { |
30
|
4
|
|
|
|
|
16
|
delete $opts{ recordHandler }; |
31
|
|
|
|
|
|
|
} else { |
32
|
2
|
|
|
|
|
7
|
delete $opts{ recordHandler }; |
33
|
2
|
|
|
|
|
7
|
$package = $opts{ metadataHandler } = 'Net::OAI::Record::OAI_DC'; |
34
|
|
|
|
|
|
|
} |
35
|
9
|
|
|
|
|
57
|
Net::OAI::Harvester::_verifyHandler( $package ); |
36
|
|
|
|
|
|
|
|
37
|
9
|
|
33
|
|
|
98
|
my $self = bless \%opts, ref( $class ) || $class; |
38
|
9
|
|
|
|
|
76
|
$self->{ header } = undef; |
39
|
9
|
|
|
|
|
39
|
$self->{ _prefixmap } = {}; |
40
|
9
|
|
|
|
|
151
|
return( $self ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 record() |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return the result as Net::OAI::Record. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub record { |
50
|
5
|
|
|
5
|
1
|
2421
|
my $self = shift; |
51
|
5
|
|
|
|
|
19
|
return $self->{ record }; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 header() |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Shortcut to the C |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub header { |
61
|
7
|
|
|
7
|
1
|
888
|
my $self = shift; |
62
|
7
|
|
|
|
|
45
|
return $self->{ record }->header; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 metadata() |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Shortcut to the C method of the L fetched. |
68
|
|
|
|
|
|
|
The return value may be undefined in case of deleted records or if no |
69
|
|
|
|
|
|
|
metadataHandler was provided. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub metadata { |
74
|
6
|
|
|
6
|
1
|
2931
|
my $self = shift; |
75
|
6
|
50
|
|
|
|
27
|
return undef unless $self->{ record }; |
76
|
6
|
100
|
|
|
|
42
|
return $self->{ metadataHandler } ? $self->{ record }->metadata() : undef; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 recorddata() |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Shortcut to the C method of the L fetched. |
83
|
|
|
|
|
|
|
The return value may be undefined in case of deleted records or if no |
84
|
|
|
|
|
|
|
metadataHandler was provided. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub recorddata { |
89
|
5
|
|
|
5
|
1
|
11
|
my $self = shift; |
90
|
5
|
50
|
|
|
|
20
|
return undef unless $self->{ record }; |
91
|
5
|
100
|
|
|
|
32
|
return $self->{ recordHandler } ? $self->{ record }->recorddata() : undef; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
## SAX Handlers doing about the same as those of ListRecords.pm |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub start_prefix_mapping { |
98
|
42
|
|
|
42
|
1
|
430
|
my ($self, $mapping) = @_; |
99
|
42
|
100
|
|
|
|
156
|
if ( $self->get_handler() ) { |
100
|
24
|
|
|
|
|
225
|
return $self->SUPER::start_prefix_mapping( $mapping )}; |
101
|
18
|
|
|
|
|
300
|
$self->{ _prefixmap }->{$mapping->{ Prefix }} = $mapping; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub end_prefix_mapping { |
105
|
42
|
|
|
42
|
1
|
1332
|
my ($self, $mapping) = @_; |
106
|
42
|
100
|
|
|
|
125
|
if ( $self->get_handler() ) { |
107
|
24
|
|
|
|
|
246
|
return $self->SUPER::end_prefix_mapping( $mapping )}; |
108
|
18
|
|
|
|
|
187
|
delete $self->{ _prefixmap }->{$mapping->{ Prefix }}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub start_element { |
112
|
206
|
|
|
206
|
1
|
1487
|
my ( $self, $element ) = @_; |
113
|
206
|
100
|
|
|
|
1690
|
return $self->SUPER::start_element($element) unless $element->{NamespaceURI} eq Net::OAI::Harvester::XMLNS_OAI; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
## if we are at the start of a new record then we need an empty |
116
|
|
|
|
|
|
|
## metadata object to fill up |
117
|
70
|
100
|
|
|
|
263
|
if ( ($element->{ LocalName } eq 'record') ) { |
118
|
|
|
|
|
|
|
## we store existing downstream handler so we can replace |
119
|
|
|
|
|
|
|
## it after we are done retrieving the metadata record |
120
|
9
|
|
|
|
|
50
|
$self->{ OLD_Handler } = $self->get_handler(); |
121
|
|
|
|
|
|
|
my $header = $self->{ recordHandler } |
122
|
|
|
|
|
|
|
? Net::OAI::Record::Header->new( |
123
|
|
|
|
|
|
|
Handler => (ref($self->{ recordHandler }) ? $self->{ recordHandler } : $self->{ recordHandler }->new()), |
124
|
|
|
|
|
|
|
fwdAll => 1, |
125
|
|
|
|
|
|
|
) |
126
|
|
|
|
|
|
|
: Net::OAI::Record::Header->new( |
127
|
9
|
100
|
|
|
|
230
|
Handler => (ref($self->{ metadataHandler }) ? $self->{ metadataHandler } : $self->{ metadataHandler }->new()), |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
128
|
|
|
|
|
|
|
($Net::OAI::Harvester::OLDmetadataHandler ? (fwdAll => 1) : ()), |
129
|
|
|
|
|
|
|
); |
130
|
9
|
|
|
|
|
61
|
$self->set_handler( $header ); |
131
|
9
|
|
|
|
|
204
|
foreach my $mapping ( values %{$self->{_prefixmap}} ) { |
|
9
|
|
|
|
|
41
|
|
132
|
18
|
|
|
|
|
422
|
$self->SUPER::start_prefix_mapping($mapping)}; |
133
|
|
|
|
|
|
|
} |
134
|
70
|
|
|
|
|
331
|
return $self->SUPER::start_element( $element ); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub end_element { |
138
|
206
|
|
|
206
|
1
|
1437
|
my ( $self, $element ) = @_; |
139
|
|
|
|
|
|
|
|
140
|
206
|
|
|
|
|
571
|
$self->SUPER::end_element( $element ); |
141
|
206
|
100
|
|
|
|
1291
|
return unless $element->{NamespaceURI} eq Net::OAI::Harvester::XMLNS_OAI; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
## if we've got to the end of the record we need finish up |
144
|
|
|
|
|
|
|
## the object |
145
|
70
|
100
|
|
|
|
338
|
if ( $element->{ LocalName } eq 'record' ) { |
146
|
9
|
|
|
|
|
37
|
my $header = $self->get_handler(); |
147
|
9
|
|
|
|
|
79
|
my $data = $header->get_handler(); |
148
|
9
|
|
|
|
|
89
|
$header->set_handler( undef ); ## remove reference to $metadata |
149
|
9
|
|
|
|
|
173
|
my $record; |
150
|
9
|
100
|
|
|
|
30
|
if ( $self->{ recordHandler } ) { |
151
|
3
|
|
|
|
|
77
|
$record = Net::OAI::Record->new(header => $header, recorddata => $data) |
152
|
|
|
|
|
|
|
} else { |
153
|
6
|
|
|
|
|
58
|
$record = Net::OAI::Record->new(header => $header, metadata => $data) |
154
|
|
|
|
|
|
|
}; |
155
|
9
|
|
|
|
|
119
|
$self->{ record } = $record; |
156
|
|
|
|
|
|
|
## set handler to what is was before we started processing |
157
|
|
|
|
|
|
|
## the record |
158
|
9
|
|
|
|
|
36
|
$self->set_handler( $self->{ OLD_Handler } ); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |
163
|
|
|
|
|
|
|
|