lib/Biblio/ILL/ISO/StatusOrErrorReport.pm

filter: Statementstmt 61.3% 62 / 101 Branchbran 30.7% 16 / 52 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 75.0% 12 / 16 Podpod 100% 13 / 13 totaltotal 54.1% 104 / 192 CC 32 SCAR 35.3
CC
32
Cov
50%
from_asn
132.0
as_pretty_string
12.0
set_error_report
12.0
CRAP 34.2
« lib/Biblio/ILL/ISO/ForwardNotification.pm ↑ Summary lib/Biblio/ILL/ISO/Returned.pm »
1 package Biblio::ILL::ISO::StatusOrErrorReport;
2  
3 =head1 NAME
4  
5 Biblio::ILL::ISO::StatusOrErrorReport - Perl extension for handling ISO 10161 interlibrary loan
6 Status-Or-Error-Report 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::StatusOrErrorReport is a derivation of the abstract
28 Biblio::ILL::ISO::ISO object, and handles the Status-Or-Error-Report 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  
40 2 ▶BEGIN{@ISA = qw ( Biblio::ILL::ISO::ISO ); }
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 =head1 FROM THE ASN DEFINITION
43
44 Status-Or-Error-Report ::= [APPLICATION 19] SEQUENCE {
45 protocol-version-num [0] IMPLICIT INTEGER, -- {
46 -- version-1 (1),
47 -- version-2 (2)
48 -- },
49 transaction-id [1] IMPLICIT Transaction-Id,
50 service-date-time [2] IMPLICIT Service-Date-Time,
51 requester-id [3] IMPLICIT System-Id OPTIONAL,
52 -- mandatory when using store-and-forward communications
53 -- optional when using connection-oriented communications
54 responder-id [4] IMPLICIT System-Id OPTIONAL,
55 -- mandatory when using store-and-forward communications
56 -- optional when using connection-oriented communications
57 reason-no-report [43] IMPLICIT Reason-No-Report OPTIONAL,
58 -- mandatory if no report is present;
59 -- not present otherwise
60 status-report [44] IMPLICIT Status-Report OPTIONAL,
61 error-report [45] IMPLICIT Error-Report OPTIONAL,
62 note [46] ILL-String OPTIONAL,
63 status-or-error-report-extensions [49] IMPLICIT SEQUENCE OF Extension OPTIONAL
64 }
65  
66 =cut
67  
68 =head1 CONSTRUCTORS
69  
70 new()
71  
72 Base constructor for the class. It just returns a completely
73 empty message object, which you'll need to populate with the
74 various set_() methods, or use the read() method to read a
75 Status-Or-Error-Report message from a file (followed by a call to
76 from_asn() to turn the read's returned hash into a proper
77 StatusOrErrorReport message.
78  
79 The constructor also initializes the Convert::ASN1 if it
80 hasn't been initialized.
81  
82 =cut
83  
84 #---------------------------------------------------------------
85 #
86 #---------------------------------------------------------------
87 2 ▶sub new {
Subroutine new: called CC=3 SCAR=11.6
Pod documented
88 2 my $class = shift;
89 2 my $self = {};
90  
91 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
92 2 $self->{"ASN_TYPE"} = "Status-Or-Error-Report";
93  
94 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
95 2 return ($self);
96 }
97  
98  
99 #---------------------------------------------------------------
100 #
101 #---------------------------------------------------------------
102 0 ▶sub as_pretty_string {
Subroutine as_pretty_string: not called CC=3 SCAR=24.8
Pod documented
103 0 my $self = shift;
104  
105 0 foreach my $key (sort keys %$self) {
106 0 ▶ if ($key ne "ASN_TYPE") {
Branch: 1 branch
BranchTrueFalseTotal
if ($key ne "ASN_TYPE") 0 0 0
107 0 print "\n[$key]\n";
108 0 print $self->{$key}->as_pretty_string();
109 }
110 }
111 0 return;
112 }
113  
114 #---------------------------------------------------------------
115 # This will return a structure usable by Convert::ASN1
116 #---------------------------------------------------------------
117 1 ▶sub as_asn {
Subroutine as_asn: called CC=3 SCAR=11.0
Pod documented
118 1 my $self = shift;
119  
120 1 my %h = ();
121 1 foreach my $key (sort keys %$self) {
122 8 ▶ if ($key ne "ASN_TYPE") {
Branch: 1 branch
BranchTrueFalseTotal
if ($key ne "ASN_TYPE") 7 1 8
123 #print "\n[$key]\n";
124 7 $h{$key} = $self->{$key}->as_asn();
125 }
126 }
127 1 return \%h;
128 }
129  
130 =head1 METHODS
131  
132 For any example code, assume the following:
133 my $msg = new Biblio::ILL::ISO::StatusOrErrorReport;
134  
135 =cut
136  
137 #---------------------------------------------------------------
138 #
139 #---------------------------------------------------------------
140 =head1
141  
142 =head2 from_asn($href)
143  
144 To read a message from a file, use the following:
145  
146 my $href = $msg->read("msg_18.status-or-error-report.ber");
147 $msg = $msg->from_asn($href);
148  
149 The from_asn() method turns the hash returned from read() into
150 a proper message-type object.
151  
152 =cut
153 0 ▶sub from_asn {
Subroutine from_asn: not called CC=11 SCAR=48.8
Pod documented
154 0 my $self = shift;
155 0 my $href = shift;
156  
157 0 foreach my $k (keys %$href) {
158  
159 0 ▶ if ($k =~ /^protocol-version-num$/) {
Branch: 8 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 =~ /^reason-no-report$/) { } 0 0 0
elsif ($k =~ /^status-report$/) { } 0 0 0
elsif ($k =~ /^error-report$/) { } 0 0 0
elsif ($k =~ /^note$/) { } 0 0 0
160 0 $self->{$k} = new Biblio::ILL::ISO::ProtocolVersionNum();
161 0 $self->{$k}->from_asn($href->{$k});
162  
163 } elsif ($k =~ /^transaction-id$/) {
164 0 $self->{$k} = new Biblio::ILL::ISO::TransactionId();
165 0 $self->{$k}->from_asn($href->{$k});
166  
167 } elsif ($k =~ /^service-date-time$/) {
168 0 $self->{$k} = new Biblio::ILL::ISO::ServiceDateTime();
169 0 $self->{$k}->from_asn($href->{$k});
170  
171 ▶ } 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
172 || ($k =~ /^responder-id$/)
173 ) {
174 0 $self->{$k} = new Biblio::ILL::ISO::SystemId();
175 0 $self->{$k}->from_asn($href->{$k});
176  
177 } elsif ($k =~ /^reason-no-report$/) {
178 0 $self->{$k} = new Biblio::ILL::ISO::ReasonNoReport();
179 0 $self->{$k}->from_asn($href->{$k});
180  
181 } elsif ($k =~ /^status-report$/) {
182 0 $self->{$k} = new Biblio::ILL::ISO::StatusReport();
183 0 $self->{$k}->from_asn($href->{$k});
184  
185 } elsif ($k =~ /^error-report$/) {
186 0 $self->{$k} = new Biblio::ILL::ISO::ErrorReport();
187 0 $self->{$k}->from_asn($href->{$k});
188  
189 } elsif ($k =~ /^note$/) {
190 0 $self->{$k} = new Biblio::ILL::ISO::ILLString();
191 0 $self->{$k}->from_asn($href->{$k});
192  
193 } else {
194 0 croak "invalid " . ref($self) . " element: [$k]";
195 }
196  
197 }
198 0 return $self;
199 }
200  
201 #---------------------------------------------------------------
202 #
203 #---------------------------------------------------------------
204 =head1
205  
206 =head2 set_protocol_version_num($pvn)
207  
208 Sets the protocol version number.
209 Acceptable parameter values are the strings:
210 version-1
211 version-2
212  
213 =cut
214 1 ▶sub set_protocol_version_num {
Subroutine set_protocol_version_num: called CC=2 SCAR=7.0
Pod documented
215 1 my $self = shift;
216 1 my ($parm) = shift;
217  
218 1 ▶ croak "missing protocol-version-num" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
219  
220 1 $self->{"protocol-version-num"} = new Biblio::ILL::ISO::ProtocolVersionNum($parm);
221  
222 1 return;
223 }
224  
225 #---------------------------------------------------------------
226 #
227 #---------------------------------------------------------------
228 =head1
229  
230 =head2 set_transaction_id($tid)
231  
232 Sets the message's transaction-id.
233 Expects a valid Biblio::ILL::ISO::TransactionId.
234  
235 my $tid = new Biblio::ILL::ISO::TransactionId("PLS","001","",
236 new Biblio::ILL::ISO::SystemId("MWPL"));
237 $msg->set_transaction_id($tid);
238  
239 This is a mandatory field.
240  
241 =cut
242 1 ▶sub set_transaction_id {
Subroutine set_transaction_id: called CC=3 SCAR=11.2
Pod documented
243 1 my $self = shift;
244 1 my ($parm) = shift;
245  
246 1 ▶ croak "missing transaction-id" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
247 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
248  
249 1 $self->{"transaction-id"} = $parm;
250  
251 1 return;
252 }
253  
254 #---------------------------------------------------------------
255 #
256 #---------------------------------------------------------------
257 =head1
258  
259 =head2 set_service_date_time($sdt)
260  
261 Sets the message's service-date-time.
262 Expects a valid Biblio::ILL::ISO::ServiceDateTime.
263  
264 my $dt_this = new Biblio::ILL::ISO::DateTime("20030623","114400");
265 my $dt_orig = new Biblio::ILL::ISO::DateTime("20030623","114015")
266 my $sdt = new Biblio::ILL::ISO::ServiceDateTime( $dt_this, $dt_orig);
267 $msg->set_service_date_time($sdt);
268  
269 This is a mandatory field.
270  
271 =cut
272 1 ▶sub set_service_date_time {
Subroutine set_service_date_time: called CC=3 SCAR=11.2
Pod documented
273 1 my $self = shift;
274 1 my ($sdt) = shift;
275  
276 1 ▶ croak "missing service-date-time" unless $sdt;
Branch: 1 branch
BranchTrueFalseTotal
unless $sdt 0 1 1
277 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
278  
279 1 $self->{"service-date-time"} = $sdt;
280  
281 1 return;
282 }
283  
284 #---------------------------------------------------------------
285 #
286 #---------------------------------------------------------------
287 =head1
288  
289 =head2 set_requester_id($reqid)
290  
291 Sets the message's requester-id.
292 Expects a valid Biblio::ILL::ISO::SystemId.
293  
294 my $reqid = new Biblio::ILL::ISO::SystemId();
295 $reqid->set_person_name("David A. Christensen");
296 $msg->set_requester_id($reqid);
297  
298 This is an optional field.
299  
300 =cut
301 1 ▶sub set_requester_id {
Subroutine set_requester_id: called CC=3 SCAR=11.2
Pod documented
302 1 my $self = shift;
303 1 my ($parm) = shift;
304  
305 1 ▶ croak "missing requester-id" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
306 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
307  
308 1 $self->{"requester-id"} = $parm;
309  
310 1 return;
311 }
312  
313 #---------------------------------------------------------------
314 #
315 #---------------------------------------------------------------
316 =head1
317  
318 =head2 set_responder_id($resid)
319  
320 Sets the message's responder-id.
321 Expects a valid Biblio::ILL::ISO::SystemId.
322  
323 my $resid = new Biblio::ILL::ISO::SystemId("MWPL");
324 $msg->set_responder_id($resid);
325  
326 This is an optional field.
327  
328 =cut
329 1 ▶sub set_responder_id {
Subroutine set_responder_id: called CC=3 SCAR=11.2
Pod documented
330 1 my $self = shift;
331 1 my ($parm) = shift;
332  
333 1 ▶ croak "missing responder-id" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
334 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
335  
336 1 $self->{"responder-id"} = $parm;
337  
338 1 return;
339 }
340  
341 #---------------------------------------------------------------
342 #
343 #---------------------------------------------------------------
344 =head1
345  
346 =head2 set_reason_no_report($rnr)
347  
348 Sets the message's reason-no-report.
349 Acceptable parameter values are the strings:
350 temporary
351 permanent
352  
353 This is an optional field.
354  
355 =cut
356 0 ▶sub set_reason_no_report {
Subroutine set_reason_no_report: not called CC=1 SCAR=6.9
Pod documented
357 0 my $self = shift;
358 0 my ($parm) = shift;
359  
360 0 $self->{"reason-no-report"} = new Biblio::ILL::ISO::ReasonNoReport($parm);
361  
362 0 return;
363 }
364  
365 #---------------------------------------------------------------
366 #
367 #---------------------------------------------------------------
368 =head1
369  
370 =head2 set_status_report($sr)
371  
372 Sets the message's status-report.
373 Expects a valid Biblio::ILL::ISO::StatusReport.
374  
375 my $cs = new Biblio::ILL::ISO::CurrentState("sHIPPED");
376 my $hr = new Biblio::ILL::ISO::HistoryReport("20030811",
377 "fORWARD",
378 "20030813",
379 new Biblio::ILL::ISO::SystemId("MBOM"),
380 "20030815",
381 "Anne Author",
382 "A Title",
383 "",
384 "",
385 "loan",
386 new Biblio::ILL::ISO::TransactionResults("will-supply"),
387 "This is a history report."
388 );
389 my $sr = new Biblio::ILL::ISO::StatusReport($hr, $cs);
390 $msg->set_status_report($sr);
391  
392 This is an optional field.
393  
394 =cut
395 1 ▶sub set_status_report {
Subroutine set_status_report: called CC=3 SCAR=11.2
Pod documented
396 1 my $self = shift;
397 1 my ($parm) = shift;
398  
399 1 ▶ croak "missing status-report" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
400 1 ▶ croak "invalid status-report" unless (ref($parm) eq "Biblio::ILL::ISO::StatusReport");
Branch: 1 branch
BranchTrueFalseTotal
unless ref $parm eq "Biblio::ILL::ISO::StatusReport" 0 1 1
401  
402 1 $self->{"status-report"} = $parm;
403  
404 1 return;
405 }
406  
407 #---------------------------------------------------------------
408 #
409 #---------------------------------------------------------------
410 =head1
411  
412 =head2 set_error_report($er)
413  
414 Sets the message's error-report.
415 Expects a valid Biblio::ILL::ISO::ErrorReport.
416  
417 my $tip = new Biblio::ILL::ISO::TransactionIdProblem("duplicate-transaction-id");
418 my $per = new Biblio::ILL::ISO::ProviderErrorReport( $tip );
419 my $er = new Biblio::ILL::ISO::ErrorReport("Some correlation information",
420 "provider",
421 $per,
422 );
423 $msg->set_error_report($er);
424  
425 This is an optional field.
426  
427 =cut
428 0 ▶sub set_error_report {
Subroutine set_error_report: not called CC=3 SCAR=24.8
Pod documented
429 0 my $self = shift;
430 0 my ($parm) = shift;
431  
432 0 ▶ croak "missing error-report" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 0 0
433 0 ▶ croak "invalid error-report" unless (ref($parm) eq "Biblio::ILL::ISO::ErrorReport");
Branch: 1 branch
BranchTrueFalseTotal
unless ref $parm eq "Biblio::ILL::ISO::ErrorReport" 0 0 0
434  
435 0 $self->{"error-report"} = $parm;
436  
437 0 return;
438 }
439  
440 #---------------------------------------------------------------
441 #
442 #---------------------------------------------------------------
443 =head1
444  
445 =head2 set_note($note)
446  
447 Sets the message's note.
448 Expects a valid Biblio::ILL::ISO::ILLString or a simple text string.
449  
450 $msg->set_note("This is a note");
451  
452 This is an optional field.
453  
454 =cut
455 1 ▶sub set_note {
Subroutine set_note: called CC=3 SCAR=11.6
Pod documented
456 1 my $self = shift;
457 1 my ($parm) = shift;
458  
459 1 ▶ croak "missing note" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
460 1 ▶ if (ref($parm) eq "Biblio::ILL::ISO::ILLString") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $parm eq 'Biblio::ILL::ISO::ILLString') { } 1 0 1
461 1 $self->{"note"} = $parm;
462 } else {
463 0 $self->{"note"} = new Biblio::ILL::ISO::ILLString($parm);
464 }
465  
466 1 return;
467 }
468  
469 =head1 RELATED MODULES
470  
471 Biblio::ILL::ISO::ISO
472 Biblio::ILL::ISO::Request
473 Biblio::ILL::ISO::ForwardNotification
474 Biblio::ILL::ISO::Shipped
475 Biblio::ILL::ISO::Answer
476 Biblio::ILL::ISO::ConditionalReply
477 Biblio::ILL::ISO::Cancel
478 Biblio::ILL::ISO::CancelReply
479 Biblio::ILL::ISO::Received
480 Biblio::ILL::ISO::Recall
481 Biblio::ILL::ISO::Returned
482 Biblio::ILL::ISO::CheckedIn
483 Biblio::ILL::ISO::Overdue
484 Biblio::ILL::ISO::Renew
485 Biblio::ILL::ISO::RenewAnswer
486 Biblio::ILL::ISO::Lost
487 Biblio::ILL::ISO::Damaged
488 Biblio::ILL::ISO::Message
489 Biblio::ILL::ISO::StatusQuery
490 Biblio::ILL::ISO::StatusOrErrorReport
491 Biblio::ILL::ISO::Expired
492  
493 =cut
494  
495 =head1 SEE ALSO
496  
497 See the README for system design notes.
498  
499 For more information on Interlibrary Loan standards (ISO 10160/10161),
500 a good place to start is:
501  
502 http://www.nlc-bnc.ca/iso/ill/main.htm
503  
504 =cut
505  
506 =head1 AUTHOR
507  
508 David Christensen, <DChristensenSPAMLESS@westman.wave.ca>
509  
510 =cut
511  
512  
513 =head1 COPYRIGHT AND LICENSE
514  
515 Copyright 2003 by David Christensen
516  
517 This library is free software; you can redistribute it and/or modify it
518 under the same terms as Perl itself.
519  
520 =cut
521  
522 2 1;
« lib/Biblio/ILL/ISO/ForwardNotification.pm ↑ Summary lib/Biblio/ILL/ISO/Returned.pm »