File Coverage

blib/lib/Biblio/ILL/ISO/HistoryReport.pm
Criterion Covered Total %
statement 62 142 43.6
branch 22 106 20.7
condition 1 21 4.7
subroutine 10 12 83.3
pod 3 3 100.0
total 98 284 34.5


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::HistoryReport;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::HistoryReport
6              
7             =cut
8              
9 4     4   656 use Biblio::ILL::ISO::ILLASNtype;
  4         9  
  4         105  
10 4     4   24 use Biblio::ILL::ISO::ILLString;
  4         10  
  4         89  
11 4     4   26 use Biblio::ILL::ISO::ISODate;
  4         8  
  4         88  
12 4     4   41 use Biblio::ILL::ISO::MostRecentService;
  4         13  
  4         95  
13 4     4   25 use Biblio::ILL::ISO::SystemId;
  4         9  
  4         121  
14 4     4   23 use Biblio::ILL::ISO::ShippedServiceType;
  4         8  
  4         90  
15 4     4   21 use Biblio::ILL::ISO::TransactionResults;
  4         8  
  4         103  
16 4     4   21 use Carp;
  4         14  
  4         394  
17              
18             =head1 VERSION
19              
20             Version 0.02
21              
22             =cut
23              
24             our $VERSION = '0.02';
25             #---------------------------------------------------------------------------
26             # Mods
27             # 0.02 - 2003.08.13 - allow passing in of text ShippedServiceType
28             # 0.01 - 2003.08.11 - original version
29             #---------------------------------------------------------------------------
30              
31             =head1 DESCRIPTION
32              
33             Biblio::ILL::ISO::HistoryReport is a derivation of Biblio::ILL::ISO::ILLASNtype.
34              
35             =head1 USES
36              
37             Biblio::ILL::ISO::ILLString
38             Biblio::ILL::ISO::ISODate
39             Biblio::ILL::ISO::MostRecentService
40             Biblio::ILL::ISO::SystemId
41             Biblio::ILL::ISO::ShippedServiceType
42             Biblio::ILL::ISO::TransactionResults
43              
44             =head1 USED IN
45              
46             Biblio::ILL::ISO::StatusReport
47              
48             =cut
49              
50 4     4   7711 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
51              
52             =head1 FROM THE ASN DEFINITION
53            
54             History-Report ::= EXPLICIT SEQUENCE {
55             date-requested [0] IMPLICIT ISO-Date OPTIONAL,
56             author [1] ILL-String OPTIONAL,
57             title [2] ILL-String OPTIONAL,
58             author-of-article [3] ILL-String OPTIONAL,
59             title-of-article [4] ILL-String OPTIONAL,
60             date-of-last-transition [5] IMPLICIT ISO-Date,
61             most-recent-service [6] IMPLICIT ENUMERATED {
62             iLL-REQUEST (1),
63             fORWARD (21),
64             fORWARD-NOTIFICATION (2),
65             sHIPPED (3),
66             iLL-ANSWER (4),
67             cONDITIONAL-REPLY (5),
68             cANCEL (6),
69             cANCEL-REPLY (7),
70             rECEIVED (8),
71             rECALL (9),
72             rETURNED (10),
73             cHECKED-IN (11),
74             rENEW-ANSWER (14),
75             lOST (15),
76             dAMAGED (16),
77             mESSAGE (17),
78             sTATUS-QUERY (18),
79             sTATUS-OR-ERROR-REPORT (19),
80             eXPIRED (20)
81             }
82             date-of-most-recent-service [7] IMPLICIT ISO-Date,
83             initiator-of-most-recent-service [8] IMPLICIT System-Id,
84             shipped-service-type [9] IMPLICIT Shipped-Service-Type OPTIONAL,
85             -- If the information is available, i.e. if a SHIPPED or
86             -- RECEIVED APDU has been sent or received, then the
87             -- value in this parameter shall be supplied.
88             -- Value must contain the most current information, e.g. if a
89             -- requester has received a SHIPPED APDU and then
90             -- invokes a RECEIVED.request, then the value from the
91             -- RECEIVED.request is used
92             transaction-results [10] IMPLICIT Transaction-Results OPTIONAL,
93             -- If the information is available, i.e. if an ILL-ANWSER
94             -- APDU has been sent or received, then the value in this
95             -- parameter shall be supplied.
96             most-recent-service-note [11] ILL-String OPTIONAL
97             -- If the information is available, i.e. if a note has been
98             -- supplied in the most recent service primitive, then the
99             -- value in this parameter shall be supplied.
100             }
101              
102             =cut
103              
104             =head1 METHODS
105              
106             =cut
107             #---------------------------------------------------------------
108             #
109             #---------------------------------------------------------------
110             =head1
111              
112             =head2 new( [...a whole bunch of parameters...] )
113              
114             Creates a new HistoryReport object.
115             Expects either no parameters, or
116             date-of-last-transition (Biblio::ILL::ISO::ISODate or text string (YYYYMMDD)),
117             most-recent-service (Biblio::ILL::ISO::MostRecentService),
118             date-of-most-recent-service (Biblio::ILL::ISO::ISODate or text string (YYYYMMDD)),
119             initiator-of-most-recent-service (Biblio::ILL::ISO::SystemId),
120             (optionally) date-requested (Biblio::ILL::ISO::ISODate or text string (YYYYMMDD)),
121             (optionally) author (Biblio::ILL::ISO::ILLString or text string),
122             (optionally) title (Biblio::ILL::ISO::ILLString or text string),
123             (optionally) author-of-article (Biblio::ILL::ISO::ILLString or text string),
124             (optionally) title-of-article (Biblio::ILL::ISO::ILLString or text string),
125             (optionally) shipped-service-type (Biblio::ILL::ISO::ShippedServiceType),
126             (optionally) transaction-results (Biblio::ILL::ISO::TransactionResults), and
127             (optionally) most-recent-service-note (Biblio::ILL::ISO::ILLString or text string)
128              
129             Pass empty strings ("") as placeholders.
130              
131             =cut
132             sub new {
133 2     2 1 13 my $class = shift;
134 2         4 my $self = {};
135              
136 2 50       7 if (@_) {
137 2         8 my ($dolt, $mrsvc, $date_of_mrsvc, $init_of_mrsvc,
138             $date_req, $author, $title, $author_of_article, $title_of_article,
139             $sst, $trans_res, $mrsvc_note) = @_;
140              
141 2 50       7 croak "missing date-of-last-transition" unless ($dolt);
142 2 50       7 if (ref($dolt) eq "Biblio::ILL::ISO::ISODate") {
143 0         0 $self->{"date-of-last-transition"} = $dolt;
144             } else {
145             # Huh. Must be in text format - ISODate will let us know if it's not....
146 2         8 $self->{"date-of-last-transition"} = new Biblio::ILL::ISO::ISODate($dolt);
147             }
148              
149 2 50       7 croak "missing most-recent-service" unless ($mrsvc);
150 2 50       7 if (ref($mrsvc) eq "Biblio::ILL::ISO::MostRecentService") {
151 0         0 $self->{"most-recent-service"} = $mrsvc;
152             } else {
153             # Huh. Must be in text format - MostRecentService will let us know if it's not....
154 2         12 $self->{"most-recent-service"} = new Biblio::ILL::ISO::MostRecentService($mrsvc);
155             }
156              
157 2 50       7 croak "missing date-of-most-recent-service" unless ($date_of_mrsvc);
158 2 50       5 if (ref($date_of_mrsvc) eq "Biblio::ILL::ISO::ISODate") {
159 0         0 $self->{"date-of-most-recent-service"} = $date_of_mrsvc;
160             } else {
161             # Huh. Must be in text format - ISODate will let us know if it's not....
162 2         7 $self->{"date-of-most-recent-service"} = new Biblio::ILL::ISO::ISODate($date_of_mrsvc);
163             }
164              
165 2 50       6 croak "missing initiator-of-most-recent-service" unless ($init_of_mrsvc);
166 2 50       6 croak "invalid initiator-of-most-recent-service" unless (ref($init_of_mrsvc) eq "Biblio::ILL::ISO::SystemId");
167 2         5 $self->{"initiator-of-most-recent-service"} = $init_of_mrsvc;
168              
169 2 50       5 if ($date_req) {
170 2 50       7 if (ref($date_req) eq "Biblio::ILL::ISO::ISODate") {
171 0         0 $self->{"date-requested"} = $date_req;
172             } else {
173             # Huh. Must be in text format - ISODate will let us know if it's not....
174 2         6 $self->{"date-requested"} = new Biblio::ILL::ISO::ISODate($date_req);
175             }
176             }
177              
178 2 50       6 if ($author) {
179 2 50       11 if (ref($author) eq "Biblio::ILL::ISO::ILLString") {
180 0         0 $self->{"author"} = $author;
181             } else {
182 2         6 $self->{"author"} = new Biblio::ILL::ISO::ILLString($author);
183             }
184             }
185              
186 2 50       6 if ($title) {
187 2 50       4 if (ref($title) eq "Biblio::ILL::ISO::ILLString") {
188 0         0 $self->{"title"} = $title;
189             } else {
190 2         7 $self->{"title"} = new Biblio::ILL::ISO::ILLString($title);
191             }
192             }
193              
194 2 50       7 if ($author_of_article) {
195 0 0       0 if (ref($author_of_article) eq "Biblio::ILL::ISO::ILLString") {
196 0         0 $self->{"author-of-article"} = $author_of_article;
197             } else {
198 0         0 $self->{"author-of-article"} = new Biblio::ILL::ISO::ILLString($author_of_article);
199             }
200             }
201              
202 2 50       12 if ($title_of_article) {
203 0 0       0 if (ref($title_of_article) eq "Biblio::ILL::ISO::ILLString") {
204 0         0 $self->{"title-of-article"} = $title_of_article;
205             } else {
206 0         0 $self->{"title-of-article"} = new Biblio::ILL::ISO::ILLString($title_of_article);
207             }
208             }
209              
210 2 50       6 if ($sst) {
211 2 50       11 if (ref($sst) eq "Biblio::ILL::ISO::ShippedServiceType") {
212 0         0 $self->{"shipped-service-type"} = $sst;
213             } else {
214             # Huh. Must be in text format - ShippedServiceType will let us know if it's not....
215 2         12 $self->{"shipped-service-type"} = new Biblio::ILL::ISO::ShippedServiceType($sst);
216             }
217             }
218              
219 2 50       7 croak "invalid transaction-results" unless (ref($trans_res) eq "Biblio::ILL::ISO::TransactionResults");
220 2         5 $self->{"transaction-results"} = $trans_res;
221              
222 2 50       11 if ($mrsvc_note) {
223 2 50       5 if (ref($mrsvc_note) eq "Biblio::ILL::ISO::ILLString") {
224 0         0 $self->{"most-recent-service-note"} = $mrsvc_note;
225             } else {
226             # Huh. Must be in text format - ILLString will let us know if it's not....
227 2         11 $self->{"most-recent-service-note"} = new Biblio::ILL::ISO::ILLString($mrsvc_note);
228             }
229             }
230              
231             }
232              
233 2   33     12 bless($self, ref($class) || $class);
234 2         15 return ($self);
235             }
236              
237              
238             #---------------------------------------------------------------
239             #
240             #---------------------------------------------------------------
241             =head1
242              
243             =head2 set( [...a whole bunch of parameters...] )
244              
245             Sets the object's date-of-last-transition (Biblio::ILL::ISO::ISODate or text string (YYYYMMDD)),
246             most-recent-service (Biblio::ILL::ISO::MostRecentService),
247             date-of-most-recent-service (Biblio::ILL::ISO::ISODate or text string (YYYYMMDD)),
248             initiator-of-most-recent-service (Biblio::ILL::ISO::SystemId),
249             (optionally) date-requested (Biblio::ILL::ISO::ISODate or text string (YYYYMMDD)),
250             (optionally) author (Biblio::ILL::ISO::ILLString or text string),
251             (optionally) title (Biblio::ILL::ISO::ILLString or text string),
252             (optionally) author-of-article (Biblio::ILL::ISO::ILLString or text string),
253             (optionally) title-of-article (Biblio::ILL::ISO::ILLString or text string),
254             (optionally) shipped-service-type (Biblio::ILL::ISO::ShippedServiceType),
255             (optionally) transaction-results (Biblio::ILL::ISO::TransactionResults), and
256             (optionally) most-recent-service-note (Biblio::ILL::ISO::ILLString or text string)
257              
258             Pass empty strings ("") as placeholders.
259              
260             =cut
261             sub set {
262 0     0 1   my $self = shift;
263              
264 0           my ($dolt, $mrsvc, $date_of_mrsvc, $init_of_mrsvc,
265             $date_req, $author, $title, $author_of_article, $title_of_article,
266             $sst, $trans_res, $mrsvc_note) = @_;
267            
268 0 0         croak "missing date-of-last-transition" unless ($dolt);
269 0 0         if (ref($dolt) eq "Biblio::ILL::ISO::ISODate") {
270 0           $self->{"date-of-last-transition"} = $dolt;
271             } else {
272             # Huh. Must be in text format - ISODate will let us know if it's not....
273 0           $self->{"date-of-last-transition"} = new Biblio::ILL::ISO::ISODate($dolt);
274             }
275            
276 0 0         croak "missing most-recent-service" unless ($mrsvc);
277 0 0         if (ref($mrsvc) eq "Biblio::ILL::ISO::MostRecentService") {
278 0           $self->{"most-recent-service"} = $mrsvc;
279             } else {
280             # Huh. Must be in text format - MostRecentService will let us know if it's not....
281 0           $self->{"most-recent-service"} = new Biblio::ILL::ISO::MostRecentService($mrsvc);
282             }
283            
284 0 0         croak "missing date-of-most-recent-service" unless ($date_of_mrsvc);
285 0 0         if (ref($date_of_mrsvc) eq "Biblio::ILL::ISO::ISODate") {
286 0           $self->{"date-of-most-recent-service"} = $date_of_mrsvc;
287             } else {
288             # Huh. Must be in text format - ISODate will let us know if it's not....
289 0           $self->{"date-of-most-recent-service"} = new Biblio::ILL::ISO::ISODate($date_of_mrsvc);
290             }
291            
292 0 0         croak "missing initiator-of-most-recent-service" unless ($init_of_mrsvc);
293 0 0         croak "invalid initiator-of-most-recent-service" unless (ref($init_of_mrsvc) eq "Biblio::ILL::ISO::SystemId");
294 0           $self->{"initiator-of-most-recent-service"} = $init_of_mrsvc;
295            
296 0 0         if ($date_req) {
297 0 0         if (ref($date_req) eq "Biblio::ILL::ISO::ISODate") {
298 0           $self->{"date-requested"} = $date_req;
299             } else {
300             # Huh. Must be in text format - ISODate will let us know if it's not....
301 0           $self->{"date-requested"} = new Biblio::ILL::ISO::ISODate($date_req);
302             }
303             }
304            
305 0 0         if ($author) {
306 0 0         if (ref($author) eq "Biblio::ILL::ISO::ILLString") {
307 0           $self->{"author"} = $author;
308             } else {
309 0           $self->{"author"} = new Biblio::ILL::ISO::ILLString($author);
310             }
311             }
312            
313 0 0         if ($title) {
314 0 0         if (ref($title) eq "Biblio::ILL::ISO::ILLString") {
315 0           $self->{"title"} = $title;
316             } else {
317 0           $self->{"title"} = new Biblio::ILL::ISO::ILLString($title);
318             }
319             }
320            
321 0 0         if ($author_of_article) {
322 0 0         if (ref($author_of_article) eq "Biblio::ILL::ISO::ILLString") {
323 0           $self->{"author-of-article"} = $author_of_article;
324             } else {
325 0           $self->{"author-of-article"} = new Biblio::ILL::ISO::ILLString($author_of_article);
326             }
327             }
328            
329 0 0         if ($title_of_article) {
330 0 0         if (ref($title_of_article) eq "Biblio::ILL::ISO::ILLString") {
331 0           $self->{"title-of-article"} = $title_of_article;
332             } else {
333 0           $self->{"title-of-article"} = new Biblio::ILL::ISO::ILLString($title_of_article);
334             }
335             }
336            
337 0 0         if ($sst) {
338 0 0         if (ref($sst) eq "Biblio::ILL::ISO::ShippedServiceType") {
339 0           $self->{"shipped-service-type"} = $sst;
340             } else {
341             # Huh. Must be in text format - ShippedServiceType will let us know if it's not....
342 0           $self->{"shipped-service-type"} = new Biblio::ILL::ISO::ShippedServiceType($sst);
343             }
344             }
345            
346 0 0         croak "invalid transaction-results" unless (ref($trans_res) eq "Biblio::ILL::ISO::TransactionResults");
347 0           $self->{"transaction-results"} = $trans_res;
348            
349 0 0         if ($mrsvc_note) {
350 0 0         if (ref($mrsvc_note) eq "Biblio::ILL::ISO::ILLString") {
351 0           $self->{"most-recent-service-note"} = $mrsvc_note;
352             } else {
353             # Huh. Must be in text format - ILLString will let us know if it's not....
354 0           $self->{"most-recent-service-note"} = new Biblio::ILL::ISO::ILLString($mrsvc_note);
355             }
356             }
357            
358 0           return;
359             }
360              
361             #---------------------------------------------------------------
362             #
363             #---------------------------------------------------------------
364             =head1
365              
366             =head2 from_asn($href)
367              
368             Given a properly formatted hash, builds the object.
369              
370             =cut
371             sub from_asn {
372 0     0 1   my $self = shift;
373 0           my $href = shift;
374              
375 0           foreach my $k (keys %$href) {
376             #print ref($self) . "...$k\n";
377              
378 0 0 0       if (($k =~ /^date-requested$/)
    0 0        
    0 0        
    0 0        
    0 0        
    0 0        
379             || ($k =~ /^date-of-last-transition$/)
380             || ($k =~ /^date-of-most-recent-service$/)
381             ) {
382 0           $self->{$k} = new Biblio::ILL::ISO::ISODate();
383 0           $self->{$k}->from_asn($href->{$k});
384            
385             } elsif (($k =~ /^author$/)
386             || ($k =~ /^title$/)
387             || ($k =~ /^author-of-article$/)
388             || ($k =~ /^title-of-article$/)
389             || ($k =~ /^most-recent-service-note$/)
390             ) {
391 0           $self->{$k} = new Biblio::ILL::ISO::ILLString();
392 0           $self->{$k}->from_asn($href->{$k});
393              
394             } elsif ($k =~ /^most-recent-service$/) {
395 0           $self->{$k} = new Biblio::ILL::ISO::MostRecentService();
396 0           $self->{$k}->from_asn($href->{$k});
397              
398             } elsif ($k =~ /^initiator-of-most-recent-service$/) {
399 0           $self->{$k} = new Biblio::ILL::ISO::SystemId();
400 0           $self->{$k}->from_asn($href->{$k});
401              
402             } elsif ($k =~ /^shipped-service-type$/) {
403 0           $self->{$k} = new Biblio::ILL::ISO::ShippedServiceType();
404 0           $self->{$k}->from_asn($href->{$k});
405              
406             } elsif ($k =~ /^transaction-results$/) {
407 0           $self->{$k} = new Biblio::ILL::ISO::TransactionResults();
408 0           $self->{$k}->from_asn($href->{$k});
409              
410             } else {
411 0           croak "invalid " . ref($self) . " element: [$k]";
412             }
413              
414             }
415 0           return $self;
416             }
417              
418             =head1 SEE ALSO
419              
420             See the README for system design notes.
421             See the parent class(es) for other available methods.
422              
423             For more information on Interlibrary Loan standards (ISO 10160/10161),
424             a good place to start is:
425              
426             http://www.nlc-bnc.ca/iso/ill/main.htm
427              
428             =cut
429              
430             =head1 AUTHOR
431              
432             David Christensen,
433              
434             =cut
435              
436              
437             =head1 COPYRIGHT AND LICENSE
438              
439             Copyright 2003 by David Christensen
440              
441             This library is free software; you can redistribute it and/or modify it
442             under the same terms as Perl itself.
443              
444             =cut
445              
446             1;