lib/Biblio/ILL/ISO/Expired.pm

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