File Coverage

blib/lib/Biblio/ILL/ISO/ForwardNotification.pm
Criterion Covered Total %
statement 66 91 72.5
branch 18 50 36.0
condition 1 9 11.1
subroutine 13 15 86.6
pod 12 12 100.0
total 110 177 62.1


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::ForwardNotification;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::ForwardNotification - Perl extension for handling ISO 10161
6             interlibrary loan Forward-Notification messages
7              
8             =cut
9              
10 2     2   7365 use Biblio::ILL::ISO::ISO;
  2         7  
  2         67  
11 2     2   15 use Carp;
  2         4  
  2         260  
12              
13             =head1 VERSION
14              
15             Version 0.01
16              
17             =cut
18              
19             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::ForwardNotification is a derivation of the abstract
28             Biblio::ILL::ISO::ISO object, and handles the ForwardNotification 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 2     2   3726 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ISO ); }
40              
41             =head1 FROM THE ASN DEFINITION
42            
43             Forward-Notification ::= [APPLICATION 2] 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,
54             -- mandatory in this APDU
55             responder-address [24] IMPLICIT System-Address OPTIONAL,
56             intermediary-id [25] IMPLICIT System-Id,
57             notification-note [48] ILL-String OPTIONAL,
58             forward-notification-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             Forward-Notification message from a file (followed by a call to
71             from_asn() to turn the read's returned hash into a proper
72             ForwardNotification message.
73              
74             The constructor also initializes the Convert::ASN1 if it
75             hasn't been initialized.
76              
77             =cut
78             #---------------------------------------------------------------
79             #
80             #---------------------------------------------------------------
81             sub new {
82 2     2 1 19 my $class = shift;
83 2         3 my $self = {};
84              
85 2 50       6 Biblio::ILL::ISO::ISO::_init() if (not $Biblio::ILL::ISO::ISO::_asn_initialized);
86 2         22 $self->{"ASN_TYPE"} = "Forward-Notification";
87              
88 2   33     12 bless($self, ref($class) || $class);
89 2         6 return ($self);
90             }
91              
92              
93             #---------------------------------------------------------------
94             #
95             #---------------------------------------------------------------
96             sub as_pretty_string {
97 0     0 1 0 my $self = shift;
98              
99 0         0 foreach my $key (sort keys %$self) {
100 0 0       0 if ($key ne "ASN_TYPE") {
101 0         0 print "\n[$key]\n";
102 0         0 print $self->{$key}->as_pretty_string();
103             }
104             }
105 0         0 return;
106             }
107              
108             #---------------------------------------------------------------
109             # This will return a structure usable by Convert::ASN1
110             #---------------------------------------------------------------
111             sub as_asn {
112 1     1 1 4 my $self = shift;
113              
114 1         3 my %h = ();
115 1         13 foreach my $key (sort keys %$self) {
116 9 100       25 if ($key ne "ASN_TYPE") {
117             #print "\n[$key]\n";
118 8         30 $h{$key} = $self->{$key}->as_asn();
119             }
120             }
121 1         4 return \%h;
122             }
123              
124             =head1 METHODS
125              
126             For any example code, assume the following:
127             my $msg = new Biblio::ILL::ISO::ForwardNotification;
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_02.forward-notification.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             sub from_asn {
148 0     0 1 0 my $self = shift;
149 0         0 my $href = shift;
150              
151 0         0 foreach my $k (keys %$href) {
152              
153 0 0 0     0 if ($k =~ /^protocol-version-num$/) {
    0 0        
    0          
    0          
    0          
    0          
    0          
154 0         0 $self->{$k} = new Biblio::ILL::ISO::ProtocolVersionNum();
155 0         0 $self->{$k}->from_asn($href->{$k});
156              
157             } elsif ($k =~ /^transaction-id$/) {
158 0         0 $self->{$k} = new Biblio::ILL::ISO::TransactionId();
159 0         0 $self->{$k}->from_asn($href->{$k});
160              
161             } elsif ($k =~ /^service-date-time$/) {
162 0         0 $self->{$k} = new Biblio::ILL::ISO::ServiceDateTime();
163 0         0 $self->{$k}->from_asn($href->{$k});
164              
165             } elsif (($k =~ /^requester-id$/)
166             || ($k =~ /^responder-id$/)
167             || ($k =~ /^intermediary-id$/)
168             ) {
169 0         0 $self->{$k} = new Biblio::ILL::ISO::SystemId();
170 0         0 $self->{$k}->from_asn($href->{$k});
171              
172             } elsif ($k =~ /^responder-address$/) {
173 0         0 $self->{$k} = new Biblio::ILL::ISO::SystemAddress();
174 0         0 $self->{$k}->from_asn($href->{$k});
175              
176             } elsif ($k =~ /^notification-note$/) {
177 0         0 $self->{$k} = new Biblio::ILL::ISO::ILLString();
178 0         0 $self->{$k}->from_asn($href->{$k});
179              
180             } elsif ($k =~ /^forward-notification-extensions$/) {
181             #$self->{$k} = new Biblio::ILL::ISO::Extension();
182             #$self->{$k}->from_asn($href->{$k});
183              
184             } else {
185 0         0 croak "invalid " . ref($self) . " element: [$k]";
186             }
187              
188             }
189 0         0 return $self;
190             }
191              
192             #---------------------------------------------------------------
193             #
194             #---------------------------------------------------------------
195             =head1
196              
197             =head2 set_protocol_version_num($pvn)
198              
199             Sets the protocol version number.
200             Acceptable parameter values are the strings:
201             version-1
202             version-2
203              
204             =cut
205             sub set_protocol_version_num {
206 1     1 1 7 my $self = shift;
207 1         2 my ($parm) = shift;
208              
209 1 50       30 croak "missing protocol-version-num" unless $parm;
210              
211 1         6 $self->{"protocol-version-num"} = new Biblio::ILL::ISO::ProtocolVersionNum($parm);
212              
213 1         2 return;
214             }
215              
216             #---------------------------------------------------------------
217             #
218             #---------------------------------------------------------------
219             =head1
220              
221             =head2 set_transaction_id($tid)
222              
223             Sets the message's transaction-id.
224             Expects a valid Biblio::ILL::ISO::TransactionId.
225              
226             my $tid = new Biblio::ILL::ISO::TransactionId("PLS","001","",
227             new Biblio::ILL::ISO::SystemId("MWPL"));
228             $msg->set_transaction_id($tid);
229              
230             This is a mandatory field.
231              
232             =cut
233             sub set_transaction_id {
234 1     1 1 6 my $self = shift;
235 1         2 my ($parm) = shift;
236              
237 1 50       4 croak "missing transaction-id" unless $parm;
238 1 50       4 croak "invalid transaction-id" unless (ref($parm) eq "Biblio::ILL::ISO::TransactionId");
239              
240 1         3 $self->{"transaction-id"} = $parm;
241              
242 1         3 return;
243             }
244              
245             #---------------------------------------------------------------
246             #
247             #---------------------------------------------------------------
248             =head1
249              
250             =head2 set_service_date_time($sdt)
251              
252             Sets the message's service-date-time.
253             Expects a valid Biblio::ILL::ISO::ServiceDateTime.
254              
255             my $dt_this = new Biblio::ILL::ISO::DateTime("20030623","114400");
256             my $dt_orig = new Biblio::ILL::ISO::DateTime("20030623","114015")
257             my $sdt = new Biblio::ILL::ISO::ServiceDateTime( $dt_this, $dt_orig);
258             $msg->set_service_date_time($sdt);
259              
260             This is a mandatory field.
261              
262             =cut
263             sub set_service_date_time {
264 1     1 1 4 my $self = shift;
265 1         3 my ($sdt) = shift;
266              
267 1 50       4 croak "missing service-date-time" unless $sdt;
268 1 50       3 croak "invalid service-date-time" unless (ref($sdt) eq "Biblio::ILL::ISO::ServiceDateTime");
269              
270 1         2 $self->{"service-date-time"} = $sdt;
271              
272 1         2 return;
273             }
274              
275             #---------------------------------------------------------------
276             #
277             #---------------------------------------------------------------
278             =head1
279              
280             =head2 set_requester_id($reqid)
281              
282             Sets the message's requester-id.
283             Expects a valid Biblio::ILL::ISO::SystemId.
284              
285             my $reqid = new Biblio::ILL::ISO::SystemId();
286             $reqid->set_person_name("David A. Christensen");
287             $msg->set_requester_id($reqid);
288              
289             This is an optional field.
290              
291             =cut
292             sub set_requester_id {
293 1     1 1 4 my $self = shift;
294 1         2 my ($parm) = shift;
295              
296 1 50       3 croak "missing requester-id" unless $parm;
297 1 50       4 croak "invalid requester-id" unless (ref($parm) eq "Biblio::ILL::ISO::SystemId");
298              
299 1         2 $self->{"requester-id"} = $parm;
300              
301 1         3 return;
302             }
303              
304             #---------------------------------------------------------------
305             #
306             #---------------------------------------------------------------
307             =head1
308              
309             =head2 set_responder_id($resid)
310              
311             Sets the message's responder-id.
312             Expects a valid Biblio::ILL::ISO::SystemId.
313              
314             my $resid = new Biblio::ILL::ISO::SystemId("MWPL");
315             $msg->set_responder_id($resid);
316              
317             This is a mandatory field.
318              
319             =cut
320             sub set_responder_id {
321 1     1 1 5 my $self = shift;
322 1         2 my ($parm) = shift;
323              
324 1 50       9 croak "missing responder-id" unless $parm;
325 1 50       8 croak "invalid responder-id" unless (ref($parm) eq "Biblio::ILL::ISO::SystemId");
326              
327 1         2 $self->{"responder-id"} = $parm;
328              
329 1         2 return;
330             }
331              
332             #---------------------------------------------------------------
333             #
334             #---------------------------------------------------------------
335             =head1
336              
337             =head2 set_responder_address($rad)
338              
339             Sets the message's responder-address.
340             Expects a valid Biblio::ILL::ISO::SystemAddress.
341              
342             my $rad = new Biblio::ILL::ISO::SystemAddress("SMTP","pls\@gov.mb.ca");
343             $msg->set_responder_address($rad);
344              
345             This is an optional field.
346              
347             =cut
348             sub set_responder_address {
349 1     1 1 4 my $self = shift;
350 1         3 my ($parm) = shift;
351              
352 1 50       3 croak "missing responder-address" unless $parm;
353 1 50       4 croak "invalid responder-address" unless (ref($parm) eq "Biblio::ILL::ISO::SystemAddress");
354              
355 1         2 $self->{"responder-address"} = $parm;
356              
357 1         3 return;
358             }
359              
360             #---------------------------------------------------------------
361             #
362             #---------------------------------------------------------------
363             =head1
364              
365             =head2 set_intermediary_id($iid)
366              
367             Sets the message's intermediary-id.
368             Expects a valid Biblio::ILL::ISO::SystemAddress.
369              
370             my $iid = new Biblio::ILL::ISO::SystemId();
371             $iid->set_institution_name("The Great Library of Alexandria");
372             $msg->set_intermediary_id($iid);
373              
374             This is a mandatory field.
375              
376             =cut
377             sub set_intermediary_id {
378 1     1 1 4 my $self = shift;
379 1         2 my ($parm) = shift;
380              
381 1 50       3 croak "missing intermediary-id" unless $parm;
382 1 50       3 croak "invalid intermediary-id" unless (ref($parm) eq "Biblio::ILL::ISO::SystemId");
383              
384 1         4 $self->{"intermediary-id"} = $parm;
385              
386 1         2 return;
387             }
388              
389             #---------------------------------------------------------------
390             #
391             #---------------------------------------------------------------
392             =head1
393              
394             =head2 set_notification_note($note)
395              
396             Sets the message's notification-note.
397             Expects a simple text string.
398              
399             $msg->set_notification_note("This is a notification note");
400              
401             This is an optional field.
402              
403             =cut
404             sub set_notification_note {
405 1     1 1 4 my $self = shift;
406 1         2 my ($parm) = shift;
407              
408 1 50       13 croak "missing notification-note" unless $parm;
409 1 50       5 if (ref($parm) eq "Biblio::ILL::ISO::ILLString") {
410 1         14 $self->{"notification-note"} = $parm;
411             } else {
412 0         0 $self->{"notification-note"} = new Biblio::ILL::ISO::ILLString( $parm );
413             }
414              
415 1         9 return;
416             }
417              
418             =head1 RELATED MODULES
419              
420             Biblio::ILL::ISO::ISO
421             Biblio::ILL::ISO::Request
422             Biblio::ILL::ISO::ForwardNotification
423             Biblio::ILL::ISO::Shipped
424             Biblio::ILL::ISO::Answer
425             Biblio::ILL::ISO::ConditionalReply
426             Biblio::ILL::ISO::Cancel
427             Biblio::ILL::ISO::CancelReply
428             Biblio::ILL::ISO::Received
429             Biblio::ILL::ISO::Recall
430             Biblio::ILL::ISO::Returned
431             Biblio::ILL::ISO::CheckedIn
432             Biblio::ILL::ISO::Overdue
433             Biblio::ILL::ISO::Renew
434             Biblio::ILL::ISO::RenewAnswer
435             Biblio::ILL::ISO::Lost
436             Biblio::ILL::ISO::Damaged
437             Biblio::ILL::ISO::Message
438             Biblio::ILL::ISO::StatusQuery
439             Biblio::ILL::ISO::StatusOrErrorReport
440             Biblio::ILL::ISO::Expired
441              
442             =cut
443              
444             =head1 SEE ALSO
445              
446             See the README for system design notes.
447              
448             For more information on Interlibrary Loan standards (ISO 10160/10161),
449             a good place to start is:
450              
451             http://www.nlc-bnc.ca/iso/ill/main.htm
452              
453             =cut
454              
455             =head1 AUTHOR
456              
457             David Christensen,
458              
459             =cut
460              
461              
462             =head1 COPYRIGHT AND LICENSE
463              
464             Copyright 2003 by David Christensen
465              
466             This library is free software; you can redistribute it and/or modify it
467             under the same terms as Perl itself.
468              
469             =cut
470              
471             1;