lib/Biblio/ILL/ISO/CancelReply.pm

filter: Statementstmt 71.7% 61 / 85 Branchbran 35.7% 15 / 42 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 85.7% 12 / 14 Podpod 100% 11 / 11 totaltotal 61.7% 100 / 162 CC 27 SCAR 31.4
CC
27
Cov
58%
from_asn
90.0
as_pretty_string
12.0
new
3.2
CRAP 23.0
« lib/Biblio/ILL/ISO/CheckedIn.pm ↑ Summary lib/Biblio/ILL/ISO/ConditionalReply.pm »
1 package Biblio::ILL::ISO::CancelReply;
2  
3 =head1 NAME
4  
5 Biblio::ILL::ISO::CancelReply - Perl extension for handling ISO 10161 interlibrary loan Cancel-Reply 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::CancelReply is a derivation of the abstract
27 Biblio::ILL::ISO::ISO object, and handles the Cancel-Reply 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 Cancel-Reply ::= [APPLICATION 7] 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 answer [35] IMPLICIT BOOLEAN,
57 responder-note [46] ILL-String OPTIONAL,
58 cancel-reply-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 an
70 Cancel-Reply message from a file (followed by a call to
71 from_asn() to turn the read's returned hash into a proper
72 CancelReply 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"} = "Cancel-Reply";
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 8 ▶ if ($key ne "ASN_TYPE") {
Branch: 1 branch
BranchTrueFalseTotal
if ($key ne "ASN_TYPE") 7 1 8
117 #print "\n[$key]\n";
118 7 $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::CancelReply;
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_07.cancel-reply.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=9 SCAR=45.0
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: 6 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 =~ /^answer$/) { } 0 0 0
elsif ($k =~ /^responder-note$/) { } 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/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
166 || ($k =~ /^responder-id$/)
167 ) {
168 0 $self->{$k} = new Biblio::ILL::ISO::SystemId();
169 0 $self->{$k}->from_asn($href->{$k});
170  
171 } elsif ($k =~ /^answer$/) {
172 0 $self->{$k} = new Biblio::ILL::ISO::Flag();
173 0 $self->{$k}->from_asn($href->{$k});
174  
175 } elsif ($k =~ /^responder-note$/) {
176 0 $self->{$k} = new Biblio::ILL::ISO::ILLString();
177 0 $self->{$k}->from_asn($href->{$k});
178  
179 } else {
180 0 croak "invalid " . ref($self) . " element: [$k]";
181 }
182  
183 }
184 0 return $self;
185 }
186  
187 #---------------------------------------------------------------
188 #
189 #---------------------------------------------------------------
190 =head1
191  
192 =head2 set_protocol_version_num($pvn)
193  
194 Sets the protocol version number.
195 Acceptable parameter values are the strings:
196 version-1
197 version-2
198  
199 =cut
200 1 ▶sub set_protocol_version_num {
Subroutine set_protocol_version_num: called CC=2 SCAR=7.0
Pod documented
201 1 my $self = shift;
202 1 my ($parm) = shift;
203  
204 1 ▶ croak "missing protocol-version-num" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
205  
206 1 $self->{"protocol-version-num"} = new Biblio::ILL::ISO::ProtocolVersionNum($parm);
207  
208 1 return;
209 }
210  
211 #---------------------------------------------------------------
212 #
213 #---------------------------------------------------------------
214 =head1
215  
216 =head2 set_transaction_id($tid)
217  
218 Sets the message's transaction-id.
219 Expects a valid Biblio::ILL::ISO::TransactionId.
220  
221 my $tid = new Biblio::ILL::ISO::TransactionId("PLS","001","",
222 new Biblio::ILL::ISO::SystemId("MWPL"));
223 $msg->set_transaction_id($tid);
224  
225 This is a mandatory field.
226  
227 =cut
228 1 ▶sub set_transaction_id {
Subroutine set_transaction_id: called CC=3 SCAR=11.2
Pod documented
229 1 my $self = shift;
230 1 my ($parm) = shift;
231  
232 1 ▶ croak "missing transaction-id" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
233 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
234  
235 1 $self->{"transaction-id"} = $parm;
236  
237 1 return;
238 }
239  
240 #---------------------------------------------------------------
241 #
242 #---------------------------------------------------------------
243 =head1
244  
245 =head2 set_service_date_time($sdt)
246  
247 Sets the message's service-date-time.
248 Expects a valid Biblio::ILL::ISO::ServiceDateTime.
249  
250 my $dt_this = new Biblio::ILL::ISO::DateTime("20030623","114400");
251 my $dt_orig = new Biblio::ILL::ISO::DateTime("20030623","114015")
252 my $sdt = new Biblio::ILL::ISO::ServiceDateTime( $dt_this, $dt_orig);
253 $msg->set_service_date_time($sdt);
254  
255 This is a mandatory field.
256  
257 =cut
258 1 ▶sub set_service_date_time {
Subroutine set_service_date_time: called CC=3 SCAR=11.2
Pod documented
259 1 my $self = shift;
260 1 my ($sdt) = shift;
261  
262 1 ▶ croak "missing service-date-time" unless $sdt;
Branch: 1 branch
BranchTrueFalseTotal
unless $sdt 0 1 1
263 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
264  
265 1 $self->{"service-date-time"} = $sdt;
266  
267 1 return;
268 }
269  
270 #---------------------------------------------------------------
271 #
272 #---------------------------------------------------------------
273 =head1
274  
275 =head2 set_requester_id($reqid)
276  
277 Sets the message's requester-id.
278 Expects a valid Biblio::ILL::ISO::SystemId.
279  
280 my $reqid = new Biblio::ILL::ISO::SystemId();
281 $reqid->set_person_name("David A. Christensen");
282 $msg->set_requester_id($reqid);
283  
284 This is a mandatory field.
285  
286 =cut
287 1 ▶sub set_requester_id {
Subroutine set_requester_id: called CC=3 SCAR=11.2
Pod documented
288 1 my $self = shift;
289 1 my ($parm) = shift;
290  
291 1 ▶ croak "missing requester-id" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
292 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
293  
294 1 $self->{"requester-id"} = $parm;
295  
296 1 return;
297 }
298  
299 #---------------------------------------------------------------
300 #
301 #---------------------------------------------------------------
302 =head1
303  
304 =head2 set_responder_id($resid)
305  
306 Sets the message's responder-id.
307 Expects a valid Biblio::ILL::ISO::SystemId.
308  
309 my $resid = new Biblio::ILL::ISO::SystemId("MWPL");
310 $msg->set_responder_id($resid);
311  
312 This is an optional field.
313  
314 =cut
315 1 ▶sub set_responder_id {
Subroutine set_responder_id: called CC=3 SCAR=11.2
Pod documented
316 1 my $self = shift;
317 1 my ($parm) = shift;
318  
319 1 ▶ croak "missing responder-id" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
320 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
321  
322 1 $self->{"responder-id"} = $parm;
323  
324 1 return;
325 }
326  
327 #---------------------------------------------------------------
328 #
329 #---------------------------------------------------------------
330 =head1
331  
332 =head2 set_answer($flag)
333  
334 Sets the message's answer flag.
335 Acceptable parameter values are the strings:
336 true
337 false
338  
339 This is a mandatory field.
340  
341 =cut
342 1 ▶sub set_answer {
Subroutine set_answer: called CC=2 SCAR=7.0
Pod documented
343 1 my $self = shift;
344 1 my ($parm) = shift;
345  
346 1 ▶ croak "missing answer flag" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
347 1 $self->{"answer"} = new Biblio::ILL::ISO::Flag($parm);
348  
349 1 return;
350 }
351  
352 #---------------------------------------------------------------
353 #
354 #---------------------------------------------------------------
355 =head1
356  
357 =head2 set_responder_note($note)
358  
359 Sets the message's responder-note.
360 Expects a simple text string.
361  
362 $msg->set_responder_note("This is a responder note");
363  
364 This is an optional field.
365  
366 =cut
367 1 ▶sub set_responder_note {
Subroutine set_responder_note: called CC=3 SCAR=11.2
Pod documented
368 1 my $self = shift;
369 1 my ($parm) = shift;
370  
371 1 ▶ croak "missing responder-note" unless $parm;
Branch: 1 branch
BranchTrueFalseTotal
unless $parm 0 1 1
372 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
373  
374 1 $self->{"responder-note"} = $parm;
375  
376 1 return;
377 }
378  
379 =head1 RELATED MODULES
380  
381 Biblio::ILL::ISO::ISO
382 Biblio::ILL::ISO::Request
383 Biblio::ILL::ISO::ForwardNotification
384 Biblio::ILL::ISO::Shipped
385 Biblio::ILL::ISO::Answer
386 Biblio::ILL::ISO::ConditionalReply
387 Biblio::ILL::ISO::Cancel
388 Biblio::ILL::ISO::CancelReply
389 Biblio::ILL::ISO::Received
390 Biblio::ILL::ISO::Recall
391 Biblio::ILL::ISO::Returned
392 Biblio::ILL::ISO::CheckedIn
393 Biblio::ILL::ISO::Overdue
394 Biblio::ILL::ISO::Renew
395 Biblio::ILL::ISO::RenewAnswer
396 Biblio::ILL::ISO::Lost
397 Biblio::ILL::ISO::Damaged
398 Biblio::ILL::ISO::Message
399 Biblio::ILL::ISO::StatusQuery
400 Biblio::ILL::ISO::StatusOrErrorReport
401 Biblio::ILL::ISO::Expired
402  
403 =cut
404  
405 =head1 SEE ALSO
406  
407 See the README for system design notes.
408  
409 For more information on Interlibrary Loan standards (ISO 10160/10161),
410 a good place to start is:
411  
412 http://www.nlc-bnc.ca/iso/ill/main.htm
413  
414 =cut
415  
416 =head1 AUTHOR
417  
418 David Christensen, <DChristensenSPAMLESS@westman.wave.ca>
419  
420 =cut
421  
422  
423 =head1 COPYRIGHT AND LICENSE
424  
425 Copyright 2003 by David Christensen
426  
427 This library is free software; you can redistribute it and/or modify it
428 under the same terms as Perl itself.
429  
430 =cut
431  
432 2 1;
« lib/Biblio/ILL/ISO/CheckedIn.pm ↑ Summary lib/Biblio/ILL/ISO/ConditionalReply.pm »