lib/Biblio/ILL/ISO/Damaged.pm

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