lib/Biblio/ILL/ISO/ForwardNotification.pm

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