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