File Coverage

blib/lib/Biblio/ILL/ISO/SupplyDetails.pm
Criterion Covered Total %
statement 58 164 35.3
branch 19 116 16.3
condition 2 18 11.1
subroutine 10 21 47.6
pod 12 12 100.0
total 101 331 30.5


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::SupplyDetails;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::SupplyDetails
6              
7             =cut
8              
9 4     4   744 use Biblio::ILL::ISO::ILLASNtype;
  4         11  
  4         123  
10 4     4   26 use Biblio::ILL::ISO::ILLString;
  4         369  
  4         94  
11 4     4   23 use Biblio::ILL::ISO::DateDue;
  4         9  
  4         132  
12 4     4   23 use Biblio::ILL::ISO::Amount;
  4         7  
  4         94  
13 4     4   23 use Biblio::ILL::ISO::ShippedConditions;
  4         7  
  4         100  
14 4     4   29 use Biblio::ILL::ISO::ShippedVia;
  4         8  
  4         90  
15 4     4   2751 use Biblio::ILL::ISO::UnitsPerMediumTypeSequence;
  4         11  
  4         135  
16              
17 4     4   24 use Carp;
  4         11  
  4         346  
18              
19             =head1 VERSION
20              
21             Version 0.01
22              
23             =cut
24             our $VERSION = '0.01';
25             #---------------------------------------------------------------------------
26             # Mods
27             # 0.01 - 2003.08.11 - original version
28             #---------------------------------------------------------------------------
29              
30             =head1 DESCRIPTION
31              
32             Biblio::ILL::ISO::SupplyDetails is a derivation of Biblio::ILL::ISO::ILLASNtype.
33              
34             =head1 USES
35              
36             Biblio::ILL::ISO::ILLString
37             Biblio::ILL::ISO::DateDue
38             Biblio::ILL::ISO::Amount
39             Biblio::ILL::ISO::ShippedConditions
40             Biblio::ILL::ISO::ShippedVia
41             Biblio::ILL::ISO::UnitsPerMediumTypeSequence
42              
43             =head1 USED IN
44              
45             Biblio::ILL::ISO::Shipped
46              
47             =cut
48              
49 4     4   7934 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
50              
51             =head1 FROM THE ASN DEFINITION
52            
53             Supply-Details ::= EXPLICIT SEQUENCE {
54             date-shipped [0] IMPLICIT ISO-Date OPTIONAL,
55             date-due [1] IMPLICIT Date-Due OPTIONAL,
56             chargeable-units [2] IMPLICIT INTEGER OPTIONAL, -- (1..9999)
57             cost [3] IMPLICIT Amount OPTIONAL,
58             shipped-conditions [4] IMPLICIT Shipped-Conditions OPTIONAL,
59             shipped-via Shipped-Via OPTIONAL,
60             -- electronic-delivery may only be present in APDUs with a
61             -- protocol-version-num value of 2 or greater
62             insured-for [6] IMPLICIT Amount OPTIONAL,
63             return-insurance-require [7] IMPLICIT Amount OPTIONAL,
64             no-of-units-per-medium [8] IMPLICIT SEQUENCE OF Units-Per-Medium-Type OPTIONAL
65             }
66              
67             =cut
68              
69             =head1 METHODS
70              
71             =cut
72              
73             #---------------------------------------------------------------
74             #
75             #---------------------------------------------------------------
76             =head1
77              
78             =head2 new( $date_shipped,$date_due, $chargeable_units, $cost, $shipped_conditions, $shipped_via, $insured_for, $return_insurance_require, $no_of_units_per_medium )
79              
80             Creates a new SupplyDetails object.
81             Expects (optionally) date-shipped (Biblio::ILL::ISO::ISODate or text string YYYYMMDD),
82             (optionally) date-due (Biblio::ILL::ISO::ISODate or text string YYYYMMDD),
83             (optionally) chargeable-units (integer),
84             (optionally) cost (Biblio::ILL::ISO::Amount or text string),
85             (optionally) shipped-conditions (Biblio::ILL::ISO::ShippedConditions),
86             (optionally) shipped-via (Biblio::ILL::ISO::ShippedVia),
87             (optionally) insured-for (Biblio::ILL::ISO::Amount or text string),
88             (optionally) return-insurance-require (Biblio::ILL::ISO::Amount or text string),
89             (optionally) no-of-units-per-medium (Biblio::ILL::ISO::UnitsPerMediumTypeSequence).
90              
91             Pass empty strings ("") as placeholders.
92              
93             =cut
94             sub new {
95 2     2 1 4 my $class = shift;
96 2         7 my $self = {};
97              
98 2 50       8 if (@_) {
99 2         6 my ($date_shipped, $date_due, $chargeable_units, $cost,
100             $shipped_conditions, $shipped_via, $insured_for,
101             $return_insurance_require, $no_of_units_per_medium) = @_;
102            
103 2 50       5 if ($date_shipped) {
104 2 50       6 if (ref($date_shipped) eq "Biblio::ILL::ISO::ISODate") {
105 0         0 $self->{"date-shipped"} = $date_shipped;
106             } else {
107             # assume it's in text format (ISODate will tell you if it's not)
108 2         9 $self->{"date-shipped"} = new Biblio::ILL::ISO::ISODate($date_shipped);
109             }
110             }
111              
112 2 50       7 if ($date_due) {
113 2 50       5 if (ref($date_due) eq "Biblio::ILL::ISO::DateDue") {
114 0         0 $self->{"date-due"} = $date_due;
115             } else {
116             # assume it's in text format (DateDue will tell you if it's not)
117             # also assume it's renewable.
118 2         13 $self->{"date-due"} = new Biblio::ILL::ISO::DateDue($date_due,"true");
119             }
120             }
121              
122 2 50       35 if ($chargeable_units) {
123 2 50 33     21 croak "invalid chargeable-units" unless (($chargeable_units > 0) && ($chargeable_units <= 9999));
124 2         5 $self->{"chargeable-units"} = $chargeable_units;
125             }
126              
127 2 50       6 if ($cost) {
128 2 50       6 if (ref($cost) eq "Biblio::ILL::ISO::Amount") {
129 0         0 $self->{"cost"} = $cost;
130             } else {
131             # assume it's in text format (Amount will tell you if it's not)
132 2         9 $self->{"cost"} = new Biblio::ILL::ISO::Amount($cost);
133             }
134             }
135              
136 2 50       25 if ($shipped_conditions) {
137 2 50       9 croak "invalid shipped-conditions" unless (ref($shipped_conditions) eq "Biblio::ILL::ISO::ShippedConditions");
138 2         4 $self->{"shipped-conditions"} = $shipped_conditions;
139             }
140              
141 2 50       14 if ($shipped_via) {
142 2 50       9 croak "invalid shipped-via" unless (ref($shipped_via) eq "Biblio::ILL::ISO::ShippedVia");
143 2         4 $self->{"shipped-via"} = $shipped_via;
144             }
145              
146 2 50       14 if ($insured_for) {
147 2 50       6 if (ref($insured_for) eq "Biblio::ILL::ISO::Amount") {
148 2         5 $self->{"insured_for"} = $insured_for;
149             } else {
150             # assume it's in text format (Amount will tell you if it's not)
151 0         0 $self->{"insured-for"} = new Biblio::ILL::ISO::Amount($insured_for);
152             }
153             }
154              
155 2 50       13 if ($return_insurance_require) {
156 2 50       344 if (ref($return_insurance_require) eq "Biblio::ILL::ISO::Amount") {
157 0         0 $self->{"return-insurance-require"} = $return_insurance_require;
158             } else {
159             # assume it's in text format (Amount will tell you if it's not)
160 2         9 $self->{"return-insurance-require"} = new Biblio::ILL::ISO::Amount($return_insurance_require);
161             }
162             }
163              
164 2 50       20 if ($no_of_units_per_medium) {
165 2 50       9 croak "invalid no-of-units-per-medium" unless (ref($no_of_units_per_medium) eq "Biblio::ILL::ISO::UnitsPerMediumTypeSequence");
166 2         7 $self->{"no-of-units-per-medium"} = $no_of_units_per_medium;
167             }
168             }
169              
170 2   33     12 bless($self, ref($class) || $class);
171 2         6 return ($self);
172             }
173              
174              
175             #---------------------------------------------------------------
176             #
177             #---------------------------------------------------------------
178             =head1
179              
180             =head2 set( $date_shipped, $date_due, $chargeable_units, $cost, $shipped_conditions, $shipped_via, $insured_for, $return_insurance_require, $no_of_units_per_medium )
181              
182             Sets the object's fields:
183             (optionally) date-shipped (Biblio::ILL::ISO::ISODate or text string YYYYMMDD),
184             (optionally) date-due (Biblio::ILL::ISO::ISODate or text string YYYYMMDD),
185             (optionally) chargeable-units (integer),
186             (optionally) cost (Biblio::ILL::ISO::Amount or text string),
187             (optionally) shipped-conditions (Biblio::ILL::ISO::ShippedConditions),
188             (optionally) shipped-via (Biblio::ILL::ISO::ShippedVia),
189             (optionally) insured-for (Biblio::ILL::ISO::Amount or text string),
190             (optionally) return-insurance-require (Biblio::ILL::ISO::Amount or text string),
191             (optionally) no-of-units-per-medium (Biblio::ILL::ISO::UnitsPerMediumTypeSequence).
192              
193             Pass empty strings ("") as placeholders.
194              
195             =cut
196             sub set {
197 0     0 1   my $self = shift;
198 0           my ($date_shipped, $date_due, $chargeable_units, $cost,
199             $shipped_conditions, $shipped_via, $insured_for,
200             $return_insurance_require, $no_of_units_per_medium) = @_;
201            
202 0 0         if ($date_shipped) {
203 0 0         if (ref($date_shipped) eq "Biblio::ILL::ISO::ISODate") {
204 0           $self->{"date-shipped"} = $date_shipped;
205             } else {
206             # assume it's in text format (ISODate will tell you if it's not)
207 0 0         $self->{"date-shipped"} = new Biblio::ILL::ISO::ISODate($date_shipped) if ($date_shipped);
208             }
209             }
210            
211 0 0         if ($date_due) {
212 0 0         if (ref($date_due) eq "Biblio::ILL::ISO::DateDue") {
213 0           $self->{"date-due"} = $date_due;
214             } else {
215             # assume it's in text format (DateDue will tell you if it's not)
216             # also assume it's renewable.
217 0           $self->{"date-due"} = new Biblio::ILL::ISO::DateDue($date_due,"true");
218             }
219             }
220              
221 0 0         if ($chargeable_units) {
222 0 0 0       croak "invalid chargeable-units" unless (($chargeable_units > 0) && ($chargeable_units <= 9999));
223 0           $self->{"chargeable-units"} = $chargeable_units;
224             }
225            
226 0 0         if ($cost) {
227 0 0         if (ref($cost) eq "Biblio::ILL::ISO::Amount") {
228 0           $self->{"cost"} = $cost;
229             } else {
230             # assume it's in text format (Amount will tell you if it's not)
231 0           $self->{"cost"} = new Biblio::ILL::ISO::Amount($cost);
232             }
233             }
234            
235 0 0         if ($shipped_conditions) {
236 0 0         croak "invalid shipped-conditions" unless (ref($shipped_conditions) eq "Biblio::ILL::ISO::ShippedConditions");
237 0           $self->{"shipped-conditions"} = $shipped_conditions;
238             }
239            
240 0 0         if ($shipped_via) {
241 0 0         croak "invalid shipped-via" unless (ref($shipped_via) eq "Biblio::ILL::ISO::ShippedVia");
242 0           $self->{"shipped-via"} = $shipped_via;
243             }
244            
245 0 0         if ($insured_for) {
246 0 0         if (ref($insured_for) eq "Biblio::ILL::ISO::Amount") {
247 0           $self->{"insured_for"} = $insured_for;
248             } else {
249             # assume it's in text format (Amount will tell you if it's not)
250 0           $self->{"insured-for"} = new Biblio::ILL::ISO::Amount($insured_for);
251             }
252             }
253            
254 0 0         if ($return_insurance_require) {
255 0 0         if (ref($return_insurance_require) eq "Biblio::ILL::ISO::Amount") {
256 0           $self->{"return-insurance-require"} = $return_insurance_require;
257             } else {
258             # assume it's in text format (Amount will tell you if it's not)
259 0           $self->{"return-insurance-require"} = new Biblio::ILL::ISO::Amount($return_insurance_require);
260             }
261             }
262            
263 0 0         if ($no_of_units_per_medium) {
264 0 0         croak "invalid no-of-units-per-medium" unless (ref($no_of_units_per_medium) eq "Biblio::ILL::ISO::UnitsPerMediumTypeSequence");
265 0           $self->{"no-of-units-per-medium"} = $no_of_units_per_medium;
266             }
267            
268 0           return;
269             }
270              
271             #---------------------------------------------------------------
272             #
273             #---------------------------------------------------------------
274             =head1
275              
276             =head2 from_asn($href)
277              
278             Given a properly formatted hash, builds the object.
279              
280             =cut
281             sub from_asn {
282 0     0 1   my $self = shift;
283 0           my $href = shift;
284              
285 0           foreach my $k (keys %$href) {
286             #print ref($self) . "...$k\n";
287              
288 0 0 0       if (($k =~ /^client-name$/)
      0        
289             || ($k =~ /^client-status$/)
290             || ($k =~ /^client-identifier$/)
291             ) {
292 0           $self->{$k} = new Biblio::ILL::ISO::ILLString();
293 0           $self->{$k}->from_asn($href->{$k});
294            
295             } else {
296 0           croak "invalid " . ref($self) . " element: [$k]";
297             }
298              
299             }
300 0           return $self;
301             }
302              
303              
304             #---------------------------------------------------------------
305             #
306             #---------------------------------------------------------------
307             =head1
308              
309             =head2 set_date_shipped( $dt )
310              
311             Sets the object's date-shipped.
312             Expects a valid Biblio::ILL::ISO::ISODate or a properly formattted text string (YYYYMMDD).
313              
314             =cut
315             sub set_date_shipped {
316 0     0 1   my $self = shift;
317 0           my ($date_shipped) = @_;
318            
319 0 0         croak "missing date-shipped" unless ($date_shipped);
320 0 0         if (ref($date_shipped) eq "Biblio::ILL::ISO::ISODate") {
321 0           $self->{"date-shipped"} = $date_shipped;
322             } else {
323             # assume it's in text format (ISODate will tell you if it's not)
324 0 0         $self->{"date-shipped"} = new Biblio::ILL::ISO::ISODate($date_shipped) if ($date_shipped);
325             }
326            
327 0           return;
328             }
329              
330             #---------------------------------------------------------------
331             #
332             #---------------------------------------------------------------
333             =head1
334              
335             =head2 set_date_due( $dt )
336              
337             Sets the object's date-due.
338             Expects a valid Biblio::ILL::ISO::ISODate or a properly formattted text string (YYYYMMDD).
339              
340             =cut
341             sub set_date_due {
342 0     0 1   my $self = shift;
343 0           my ($date_due) = @_;
344            
345 0 0         croak "missing date-due" unless ($date_due);
346 0 0         croak "invalid date-due" unless (ref($date_due) eq "Biblio::ILL::ISO::DateDue");
347 0           $self->{"date-due"} = $date_due;
348 0           return;
349             }
350              
351             #---------------------------------------------------------------
352             #
353             #---------------------------------------------------------------
354             =head1
355              
356             =head2 set_chargeable_units( $cu )
357              
358             Sets the object's chargeable-units.
359             Expects an integer (1-9999).
360              
361             =cut
362             sub set_chargeable_units {
363 0     0 1   my $self = shift;
364 0           my ($chargeable_units) = @_;
365            
366 0 0         croak "missing chargeable-units" unless ($chargeable_units);
367 0 0 0       croak "invalid chargeable-units" unless (($chargeable_units > 0) && ($chargeable_units <= 9999));
368 0           $self->{"chargeable-units"} = $chargeable_units;
369 0           return;
370             }
371              
372             #---------------------------------------------------------------
373             #
374             #---------------------------------------------------------------
375             =head1
376              
377             =head2 set_cost( $cost )
378              
379             Sets the object's cost.
380             Expects a valid Biblio::ILL::ISO::Amount or a text string.
381              
382             =cut
383             sub set_cost {
384 0     0 1   my $self = shift;
385 0           my ($cost) = @_;
386            
387 0 0         croak "missing cost" unless ($cost);
388 0 0         if (ref($cost) eq "Biblio::ILL::ISO::Amount") {
389 0           $self->{"cost"} = $cost;
390             } else {
391             # assume it's in text format (Amount will tell you if it's not)
392 0           $self->{"cost"} = new Biblio::ILL::ISO::Amount($cost);
393             }
394 0           return;
395             }
396              
397             #---------------------------------------------------------------
398             #
399             #---------------------------------------------------------------
400             =head1
401              
402             =head2 set_shipped_conditions( $sc )
403              
404             Sets the object's shipped-conditions.
405             Expects a valid Biblio::ILL::ISO::ShippedConditions.
406              
407             =cut
408             sub set_shipped_conditions {
409 0     0 1   my $self = shift;
410 0           my ($shipped_conditions) = @_;
411            
412 0 0         croak "missing shipped-conditions" unless ($shipped_conditions);
413 0 0         croak "invalid shipped-conditions" unless (ref($shipped_conditions) eq "Biblio::ILL::ISO::ShippedConditions");
414 0           $self->{"shipped-conditions"} = $shipped_conditions;
415 0           return;
416             }
417              
418             #---------------------------------------------------------------
419             #
420             #---------------------------------------------------------------
421             =head1
422              
423             =head2 set_shipped_via( $sv )
424              
425             Sets the object's shipped-via.
426             Expects a valid Biblio::ILL::ISO::ShippedVia.
427              
428             =cut
429             sub set_shipped_via {
430 0     0 1   my $self = shift;
431 0           my ($shipped_via) = @_;
432            
433 0 0         croak "missing shipped-via" unless ($shipped_via);
434 0 0         croak "invalid shipped-via" unless (ref($shipped_via) eq "Biblio::ILL::ISO::ShippedVia");
435 0           $self->{"shipped-via"} = $shipped_via;
436 0           return;
437             }
438              
439             #---------------------------------------------------------------
440             #
441             #---------------------------------------------------------------
442             =head1
443              
444             =head2 set_insured_for( $insured_amount )
445              
446             Sets the object's insured-for.
447             Expects a valid Biblio::ILL::ISO::Amount or a text string.
448              
449             =cut
450             sub set_insured_for {
451 0     0 1   my $self = shift;
452 0           my ($insured_for) = @_;
453            
454 0 0         croak "missing insured-for" unless ($insured_for);
455 0 0         if (ref($insured_for) eq "Biblio::ILL::ISO::Amount") {
456 0           $self->{"insured_for"} = $insured_for;
457             } else {
458             # assume it's in text format (Amount will tell you if it's not)
459 0           $self->{"insured-for"} = new Biblio::ILL::ISO::Amount($insured_for);
460             }
461 0           return;
462             }
463              
464             #---------------------------------------------------------------
465             #
466             #---------------------------------------------------------------
467             =head1
468              
469             =head2 set_return_insurance_require( $insurance_required_amount )
470              
471             Sets the object's return-insurance-require.
472             Expects a valid Biblio::ILL::ISO::Amount or a text string.
473              
474             =cut
475             sub set_return_insurance_require {
476 0     0 1   my $self = shift;
477 0           my ($return_insurance_require) = @_;
478            
479 0 0         croak "missing return-insurance-require" unless ($return_insurance_require);
480 0 0         if (ref($insured_for) eq "Biblio::ILL::ISO::Amount") {
481 0           $self->{"return-insurance-require"} = $return_insurance_require;
482             } else {
483             # assume it's in text format (Amount will tell you if it's not)
484 0           $self->{"return-insurance-require"} = new Biblio::ILL::ISO::Amount($return_insurance_requre);
485             }
486 0           return;
487             }
488              
489             #---------------------------------------------------------------
490             #
491             #---------------------------------------------------------------
492             =head1
493              
494             =head2 set_no_of_units_per_medium( $units )
495              
496             Sets the object's no-of-units-per-medium.
497             Expects a valid Biblio::ILL::ISO::UnitsPerMediumType.
498              
499             =cut
500             sub set_no_of_units_per_medium {
501 0     0 1   my $self = shift;
502 0           my ($no_of_units_per_medium) = @_;
503            
504 0 0         croak "missing no-of-units-per-medium" unless ($no_of_units_per_medium);
505 0 0         croak "invalid no-of-units-per-medium" unless (ref($no_of_units_per_medium) eq "Biblio::ILL::ISO::UnitsPerMediumType");
506 0           $self->{"no-of-units-per-medium"} = $no_of_units_per_medium;
507            
508 0           return;
509             }
510              
511             =head1 SEE ALSO
512              
513             See the README for system design notes.
514             See the parent class(es) for other available methods.
515              
516             For more information on Interlibrary Loan standards (ISO 10160/10161),
517             a good place to start is:
518              
519             http://www.nlc-bnc.ca/iso/ill/main.htm
520              
521             =cut
522              
523             =head1 AUTHOR
524              
525             David Christensen,
526              
527             =cut
528              
529              
530             =head1 COPYRIGHT AND LICENSE
531              
532             Copyright 2003 by David Christensen
533              
534             This library is free software; you can redistribute it and/or modify it
535             under the same terms as Perl itself.
536              
537             =cut
538              
539             1;