lib/Biblio/ILL/ISO/Recall.pm

filter: Statementstmt 71.7% 56 / 78 Branchbran 36.8% 14 / 38 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 84.6% 11 / 13 Podpod 100% 10 / 10 totaltotal 61.7% 92 / 149 CC 25 SCAR 29.2
CC
25
Cov
58%
from_asn
72.0
as_pretty_string
12.0
new
3.2
CRAP 18.5
« lib/Biblio/ILL/ISO/Cancel.pm ↑ Summary lib/Biblio/ILL/ISO/ServiceDateTime.pm »
1 package Biblio::ILL::ISO::Recall;
2  
3 =head1 NAME
4  
5 Biblio::ILL::ISO::Recall - Perl extension for handling ISO 10161 interlibrary loan Recall messages
6  
7 =cut
8  
9 2 ▶use Biblio::ILL::ISO::ISO;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =head1 VERSION
13  
14 Version 0.01
15  
16 =cut
17  
18 2 our $VERSION = '0.01';
19 #---------------------------------------------------------------------------
20 # Mods
21 # 0.01 - 2003.08.11 - original version
22 #---------------------------------------------------------------------------
23  
24 =head1 DESCRIPTION
25  
26 Biblio::ILL::ISO::Recall is a derivation of the abstract
27 Biblio::ILL::ISO::ISO object, and handles the Recall message type.
28  
29 =head1 EXPORT
30  
31 None.
32  
33 =head1 ERROR HANDLING
34  
35 Each of the set_() methods will croak on missing or invalid parameters.
36  
37 =cut
38  
39 2 ▶BEGIN{@ISA = qw ( Biblio::ILL::ISO::ISO ); }
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 =head1 FROM THE ASN DEFINITION
42
43 Recall ::= [APPLICATION 9] SEQUENCE {
44 protocol-version-num [0] IMPLICIT INTEGER, -- {
45 -- version-1 (1),
46 -- version-2 (2)
47 -- },
48 transaction-id [1] IMPLICIT Transaction-Id,
49 service-date-time [2] IMPLICIT Service-Date-Time,
50 requester-id [3] IMPLICIT System-Id OPTIONAL,
51 -- mandatory when using store-and-forward communications
52 -- optional when using connection-oriented communications
53 responder-id [4] IMPLICIT System-Id OPTIONAL,
54 -- mandatory when using store-and-forward communications
55 -- optional when using connection-oriented communications
56 responder-note [46] ILL-String OPTIONAL,
57 recall-extensions [49] IMPLICIT SEQUENCE OF Extension OPTIONAL
58 }
59  
60 =cut
61  
62 =head1 CONSTRUCTORS
63  
64 new()
65  
66 Base constructor for the class. It just returns a completely
67 empty message object, which you'll need to populate with the
68 various set_() methods, or use the read() method to read an
69 Recall message from a file (followed by a call to
70 from_asn() to turn the read's returned hash into a proper
71 Recall message.
72  
73 The constructor also initializes the Convert::ASN1 if it
74 hasn't been initialized.
75  
76 =cut
77 #---------------------------------------------------------------
78 #
79 #---------------------------------------------------------------
80 2 ▶sub new {
Subroutine new: called CC=3 SCAR=11.6
Pod documented
81 2 my $class = shift;
82 2 my $self = {};
83  
84 2 ▶ Biblio::ILL::ISO::ISO::_init() if (not $Biblio::ILL::ISO::ISO::_asn_initialized);
Branch: 1 branch
BranchTrueFalseTotal
unless $Biblio::ILL::ISO::ISO::_asn_initialized 0 2 2
85 2 $self->{"ASN_TYPE"} = "Recall";
86  
87 2 ▶ bless($self, ref($class) || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
88 2 return ($self);
89 }
90  
91  
92 #---------------------------------------------------------------
93 #
94 #---------------------------------------------------------------
95 0 ▶sub as_pretty_string {
Subroutine as_pretty_string: not called CC=3 SCAR=24.8
Pod documented
96 0 my $self = shift;
97  
98 0 foreach my $key (sort keys %$self) {
99 0 ▶ if ($key ne "ASN_TYPE") {
Branch: 1 branch
BranchTrueFalseTotal
if ($key ne "ASN_TYPE") 0 0 0
100 0 print "\n[$key]\n";
101 0 print $self->{$key}->as_pretty_string();
102 }
103 }
104 0 return;
105 }
106  
107 #---------------------------------------------------------------
108 # This will return a structure usable by Convert::ASN1
109 #---------------------------------------------------------------
110 1 ▶sub as_asn {
Subroutine as_asn: called CC=3 SCAR=11.0
Pod documented
111 1 my $self = shift;
112  
113 1 my %h = ();
114 1 foreach my $key (sort keys %$self) {
115 7 ▶ if ($key ne "ASN_TYPE") {
Branch: 1 branch
BranchTrueFalseTotal
if ($key ne "ASN_TYPE") 6 1 7
116 #print "\n[$key]\n";
117 6 $h{$key} = $self->{$key}->as_asn();
118 }
119 }
120 1 return \%h;
121 }
122  
123 =head1 METHODS
124  
125 For any example code, assume the following:
126 my $msg = new Biblio::ILL::ISO::Recall;
127  
128 =cut
129  
130 #---------------------------------------------------------------
131 #
132 #---------------------------------------------------------------
133 =head1
134  
135 =head2 from_asn($href)
136  
137 To read a message from a file, use the following:
138  
139 my $href = $msg->read("msg_09.recall.ber");
140 $msg = $msg->from_asn($href);
141  
142 The from_asn() method turns the hash returned from read() into
143 a proper message-type object.
144  
145 =cut
146 0 ▶sub from_asn {
Subroutine from_asn: not called CC=8 SCAR=42.8
Pod documented
147 0 my $self = shift;
148 0 my $href = shift;
149  
150 0 foreach my $k (keys %$href) {
151  
152 0 ▶ if ($k =~ /^protocol-version-num$/) {
Branch: 5 branches
BranchTrueFalseTotal
if ($k =~ /^protocol-version-num$/) { } 0 0 0
elsif ($k =~ /^transaction-id$/) { } 0 0 0
elsif ($k =~ /^service-date-time$/) { } 0 0 0
elsif ($k =~ /^requester-id$/ or $k =~ /^responder-id$/) { } 0 0 0
elsif ($k =~ /^responder-note$/) { } 0 0 0
153 0 $self->{$k} = new Biblio::ILL::ISO::ProtocolVersionNum();
154 0 $self->{$k}->from_asn($href->{$k});
155  
156 } elsif ($k =~ /^transaction-id$/) {
157 0 $self->{$k} = new Biblio::ILL::ISO::TransactionId();
158 0 $self->{$k}->from_asn($href->{$k});
159  
160 } elsif ($k =~ /^service-date-time$/) {
161 0 $self->{$k} = new Biblio::ILL::ISO::ServiceDateTime();
162 0 $self->{$k}->from_asn($href->{$k});
163  
164 ▶ } elsif (($k =~ /^requester-id$/)
Condition0%0/3
$k =~ /^requester-id$/ or $k =~ /^responder-id$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$k =~ /^requester-id$/ or $k =~ /^responder-id$/
$k =~ /^requester-id$/ $k =~ /^responder-id$/
Truth table0%0/3
A or B
A= $k =~ /^requester-id$/B= $k =~ /^responder-id$/
ABresult
1X1
011
000
165 || ($k =~ /^responder-id$/)
166 ) {
167 0 $self->{$k} = new Biblio::ILL::ISO::SystemId();
168 0 $self->{$k}->from_asn($href->{$k});
169  
170 } elsif ($k =~ /^responder-note$/) {
171 0 $self->{$k} = new Biblio::ILL::ISO::ILLString();
172 0 $self->{$k}->from_asn($href->{$k});
173  
174 } else {
175 0 croak "invalid " . ref($self) . " element: [$k]";
176 }
177  
178 }
179 0 return $self;
180 }
181  
182 #---------------------------------------------------------------
183 #
184 #---------------------------------------------------------------
185 =head1
186  
187 =head2 set_protocol_version_num($pvn)
188  
189 Sets the protocol version number.
190 Acceptable parameter values are the strings:
191 version-1
192 version-2
193  
194 =cut
195 1 ▶sub set_protocol_version_num {
Subroutine set_protocol_version_num: called CC=2 SCAR=7.0
Pod documented
196 1 my $self = shift;
197 1 my ($parm) = shift;
198  
199 1 ▶ croak "missing protocol-version-num" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
200  
201 1 $self->{"protocol-version-num"} = new Biblio::ILL::ISO::ProtocolVersionNum($parm);
202  
203 1 return;
204 }
205  
206 #---------------------------------------------------------------
207 #
208 #---------------------------------------------------------------
209 =head1
210  
211 =head2 set_transaction_id($tid)
212  
213 Sets the message's transaction-id.
214 Expects a valid Biblio::ILL::ISO::TransactionId.
215  
216 my $tid = new Biblio::ILL::ISO::TransactionId("PLS","001","",
217 new Biblio::ILL::ISO::SystemId("MWPL"));
218 $msg->set_transaction_id($tid);
219  
220 This is a mandatory field.
221  
222 =cut
223 1 ▶sub set_transaction_id {
Subroutine set_transaction_id: called CC=3 SCAR=11.2
Pod documented
224 1 my $self = shift;
225 1 my ($parm) = shift;
226  
227 1 ▶ croak "missing transaction-id" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
228 1 ▶ croak "invalid transaction-id" unless (ref($parm) eq "Biblio::ILL::ISO::TransactionId");
Branch: 1 branch
BranchTrueFalseTotal
unless ref $parm eq "Biblio::ILL::ISO::TransactionId" 0 1 1
229  
230 1 $self->{"transaction-id"} = $parm;
231  
232 1 return;
233 }
234  
235 #---------------------------------------------------------------
236 #
237 #---------------------------------------------------------------
238 =head1
239  
240 =head2 set_service_date_time($sdt)
241  
242 Sets the message's service-date-time.
243 Expects a valid Biblio::ILL::ISO::ServiceDateTime.
244  
245 my $dt_this = new Biblio::ILL::ISO::DateTime("20030623","114400");
246 my $dt_orig = new Biblio::ILL::ISO::DateTime("20030623","114015")
247 my $sdt = new Biblio::ILL::ISO::ServiceDateTime( $dt_this, $dt_orig);
248 $msg->set_service_date_time($sdt);
249  
250 This is a mandatory field.
251  
252 =cut
253 1 ▶sub set_service_date_time {
Subroutine set_service_date_time: called CC=3 SCAR=11.2
Pod documented
254 1 my $self = shift;
255 1 my ($sdt) = shift;
256  
257 1 ▶ croak "missing service-date-time" unless $sdt;
Branch: 1 branch
BranchTrueFalseTotal
unless $sdt 0 1 1
258 1 ▶ croak "invalid service-date-time" unless (ref($sdt) eq "Biblio::ILL::ISO::ServiceDateTime");
Branch: 1 branch
BranchTrueFalseTotal
unless ref $sdt eq "Biblio::ILL::ISO::ServiceDateTime" 0 1 1
259  
260 1 $self->{"service-date-time"} = $sdt;
261  
262 1 return;
263 }
264  
265 #---------------------------------------------------------------
266 #
267 #---------------------------------------------------------------
268 =head1
269  
270 =head2 set_requester_id($reqid)
271  
272 Sets the message's requester-id.
273 Expects a valid Biblio::ILL::ISO::SystemId.
274  
275 my $reqid = new Biblio::ILL::ISO::SystemId();
276 $reqid->set_person_name("David A. Christensen");
277 $msg->set_requester_id($reqid);
278  
279 This is an optional field.
280  
281 =cut
282 1 ▶sub set_requester_id {
Subroutine set_requester_id: called CC=3 SCAR=11.2
Pod documented
283 1 my $self = shift;
284 1 my ($parm) = shift;
285  
286 1 ▶ croak "missing requester-id" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
287 1 ▶ croak "invalid requester-id" unless (ref($parm) eq "Biblio::ILL::ISO::SystemId");
Branch: 1 branch
BranchTrueFalseTotal
unless ref $parm eq "Biblio::ILL::ISO::SystemId" 0 1 1
288  
289 1 $self->{"requester-id"} = $parm;
290  
291 1 return;
292 }
293  
294 #---------------------------------------------------------------
295 #
296 #---------------------------------------------------------------
297 =head1
298  
299 =head2 set_responder_id($resid)
300  
301 Sets the message's responder-id.
302 Expects a valid Biblio::ILL::ISO::SystemId.
303  
304 my $resid = new Biblio::ILL::ISO::SystemId("MWPL");
305 $msg->set_responder_id($resid);
306  
307 This is an optional field.
308  
309 =cut
310 1 ▶sub set_responder_id {
Subroutine set_responder_id: called CC=3 SCAR=11.2
Pod documented
311 1 my $self = shift;
312 1 my ($parm) = shift;
313  
314 1 ▶ croak "missing responder-id" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
315 1 ▶ croak "invalid responder-id" unless (ref($parm) eq "Biblio::ILL::ISO::SystemId");
Branch: 1 branch
BranchTrueFalseTotal
unless ref $parm eq "Biblio::ILL::ISO::SystemId" 0 1 1
316  
317 1 $self->{"responder-id"} = $parm;
318  
319 1 return;
320 }
321  
322 #---------------------------------------------------------------
323 #
324 #---------------------------------------------------------------
325 =head1
326  
327 =head2 set_responder_note($note)
328  
329 Sets the message's responder-note.
330 Expects a simple text string.
331  
332 $msg->set_responder_note("This is a responder note");
333  
334 This is an optional field.
335  
336 =cut
337 1 ▶sub set_responder_note {
Subroutine set_responder_note: called CC=3 SCAR=11.2
Pod documented
338 1 my $self = shift;
339 1 my ($parm) = shift;
340  
341 1 ▶ croak "missing responder-note" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
342 1 ▶ croak "invalid responder-note" unless (ref($parm) eq "Biblio::ILL::ISO::ILLString");
Branch: 1 branch
BranchTrueFalseTotal
unless ref $parm eq "Biblio::ILL::ISO::ILLString" 0 1 1
343  
344 1 $self->{"responder-note"} = $parm;
345  
346 1 return;
347 }
348  
349 =head1 RELATED MODULES
350  
351 Biblio::ILL::ISO::ISO
352 Biblio::ILL::ISO::Request
353 Biblio::ILL::ISO::ForwardNotification
354 Biblio::ILL::ISO::Shipped
355 Biblio::ILL::ISO::Answer
356 Biblio::ILL::ISO::ConditionalReply
357 Biblio::ILL::ISO::Cancel
358 Biblio::ILL::ISO::CancelReply
359 Biblio::ILL::ISO::Received
360 Biblio::ILL::ISO::Recall
361 Biblio::ILL::ISO::Returned
362 Biblio::ILL::ISO::CheckedIn
363 Biblio::ILL::ISO::Overdue
364 Biblio::ILL::ISO::Renew
365 Biblio::ILL::ISO::RenewAnswer
366 Biblio::ILL::ISO::Lost
367 Biblio::ILL::ISO::Damaged
368 Biblio::ILL::ISO::Message
369 Biblio::ILL::ISO::StatusQuery
370 Biblio::ILL::ISO::StatusOrErrorReport
371 Biblio::ILL::ISO::Expired
372  
373 =cut
374  
375 =head1 SEE ALSO
376  
377 See the README for system design notes.
378  
379 For more information on Interlibrary Loan standards (ISO 10160/10161),
380 a good place to start is:
381  
382 http://www.nlc-bnc.ca/iso/ill/main.htm
383  
384 =cut
385  
386 =head1 AUTHOR
387  
388 David Christensen, <DChristensenSPAMLESS@westman.wave.ca>
389  
390 =cut
391  
392  
393 =head1 COPYRIGHT AND LICENSE
394  
395 Copyright 2003 by David Christensen
396  
397 This library is free software; you can redistribute it and/or modify it
398 under the same terms as Perl itself.
399  
400 =cut
401  
402 2 1;
« lib/Biblio/ILL/ISO/Cancel.pm ↑ Summary lib/Biblio/ILL/ISO/ServiceDateTime.pm »