lib/Biblio/ILL/ISO/Lost.pm

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