File Coverage

blib/lib/Biblio/ILL/ISO/StatusQuery.pm
Criterion Covered Total %
statement 54 77 70.1
branch 14 38 36.8
condition 1 6 16.6
subroutine 11 13 84.6
pod 10 10 100.0
total 90 144 62.5


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::StatusQuery;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::StatusQuery - Perl extension for handling ISO 10161 interlibrary loan Status-Query messages
6              
7             =cut
8              
9 2     2   4471 use Biblio::ILL::ISO::ISO;
  2         7  
  2         85  
10 2     2   14 use Carp;
  2         8  
  2         257  
11              
12             =head1 VERSION
13              
14             Version 0.01
15              
16             =cut
17              
18             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::StatusQuery is a derivation of the abstract
27             Biblio::ILL::ISO::ISO object, and handles the Status-Query 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     2   2694 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ISO ); }
40              
41             =head1 FROM THE ASN DEFINITION
42            
43             Status-Query ::= [APPLICATION 18] 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             note [46] ILL-String OPTIONAL,
57             status-query-extensions [49] IMPLICIT SEQUENCE OF Extension OPTIONAL
58             }
59              
60             =cut
61              
62             =head1 CONSTRUCTORS
63              
64             new()
65              
66             Base constructor for the class. It just returns a completely
67             empty message object, which you'll need to populate with the
68             various set_() methods, or use the read() method to read a
69             Status-Query message from a file (followed by a call to
70             from_asn() to turn the read's returned hash into a proper
71             StatusQuery message.
72              
73             The constructor also initializes the Convert::ASN1 if it
74             hasn't been initialized.
75              
76             =cut
77              
78             #---------------------------------------------------------------
79             #
80             #---------------------------------------------------------------
81             sub new {
82 2     2 1 16 my $class = shift;
83 2         3 my $self = {};
84              
85 2 50       5 Biblio::ILL::ISO::ISO::_init() if (not $Biblio::ILL::ISO::ISO::_asn_initialized);
86 2         4 $self->{"ASN_TYPE"} = "Status-Query";
87              
88 2   33     11 bless($self, ref($class) || $class);
89 2         5 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         11 foreach my $key (sort keys %$self) {
116 7 100       20 if ($key ne "ASN_TYPE") {
117             #print "\n[$key]\n";
118 6         27 $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::StatusQuery;
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_01.request.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          
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             ) {
168 0         0 $self->{$k} = new Biblio::ILL::ISO::SystemId();
169 0         0 $self->{$k}->from_asn($href->{$k});
170              
171             } elsif ($k =~ /^note$/) {
172 0         0 $self->{$k} = new Biblio::ILL::ISO::ILLString();
173 0         0 $self->{$k}->from_asn($href->{$k});
174              
175             } else {
176 0         0 croak "invalid " . ref($self) . " element: [$k]";
177             }
178              
179             }
180 0         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             sub set_protocol_version_num {
197 1     1 1 6 my $self = shift;
198 1         2 my ($parm) = shift;
199              
200 1 50       3 croak "missing protocol-version-num" unless $parm;
201              
202 1         5 $self->{"protocol-version-num"} = new Biblio::ILL::ISO::ProtocolVersionNum($parm);
203              
204 1         5 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             sub set_transaction_id {
225 1     1 1 6 my $self = shift;
226 1         2 my ($parm) = shift;
227              
228 1 50       4 croak "missing transaction-id" unless $parm;
229 1 50       4 croak "invalid transaction-id" unless (ref($parm) eq "Biblio::ILL::ISO::TransactionId");
230              
231 1         3 $self->{"transaction-id"} = $parm;
232              
233 1         3 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             sub set_service_date_time {
255 1     1 1 11 my $self = shift;
256 1         2 my ($sdt) = shift;
257              
258 1 50       4 croak "missing service-date-time" unless $sdt;
259 1 50       4 croak "invalid service-date-time" unless (ref($sdt) eq "Biblio::ILL::ISO::ServiceDateTime");
260              
261 1         2 $self->{"service-date-time"} = $sdt;
262              
263 1         8 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             sub set_requester_id {
284 1     1 1 5 my $self = shift;
285 1         3 my ($parm) = shift;
286              
287 1 50       3 croak "missing requester-id" unless $parm;
288 1 50       4 croak "invalid requester-id" unless (ref($parm) eq "Biblio::ILL::ISO::SystemId");
289              
290 1         2 $self->{"requester-id"} = $parm;
291              
292 1         2 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             sub set_responder_id {
312 1     1 1 5 my $self = shift;
313 1         2 my ($parm) = shift;
314              
315 1 50       3 croak "missing responder-id" unless $parm;
316 1 50       4 croak "invalid responder-id" unless (ref($parm) eq "Biblio::ILL::ISO::SystemId");
317              
318 1         3 $self->{"responder-id"} = $parm;
319              
320 1         3 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             sub set_note {
339 1     1 1 6 my $self = shift;
340 1         3 my ($parm) = shift;
341              
342 1 50       4 croak "missing note" unless $parm;
343 1 50       4 if (ref($parm) eq "Biblio::ILL::ISO::ILLString") {
344 1         3 $self->{"note"} = $parm;
345             } else {
346 0         0 $self->{"note"} = new Biblio::ILL::ISO::ILLString($parm);
347             }
348              
349 1         3 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,
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             1;