File Coverage

blib/lib/Biblio/ILL/ISO/WillSupplyResults.pm
Criterion Covered Total %
statement 42 77 54.5
branch 14 68 20.5
condition 1 3 33.3
subroutine 9 11 81.8
pod 3 3 100.0
total 69 162 42.5


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::WillSupplyResults;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::WillSupplyResults
6              
7             =cut
8              
9 4     4   21 use Biblio::ILL::ISO::ILLASNtype;
  4         10  
  4         90  
10 4     4   2051 use Biblio::ILL::ISO::ReasonWillSupply;
  4         8  
  4         110  
11 4     4   23 use Biblio::ILL::ISO::ISODate;
  4         7  
  4         80  
12 4     4   22 use Biblio::ILL::ISO::PostalAddress;
  4         6  
  4         82  
13 4     4   19 use Biblio::ILL::ISO::LocationInfoSequence;
  4         6  
  4         73  
14 4     4   21 use Biblio::ILL::ISO::ElectronicDeliveryService;
  4         8  
  4         94  
15              
16 4     4   18 use Carp;
  4         7  
  4         319  
17              
18             =head1 VERSION
19              
20             Version 0.01
21              
22             =cut
23              
24             our $VERSION = '0.01';
25             #---------------------------------------------------------------------------
26             # Mods
27             # 0.01 - 2003.07.26 - original version
28             #---------------------------------------------------------------------------
29              
30             =head1 DESCRIPTION
31              
32             Biblio::ILL::ISO::WillSupplyResults is a derivation of Biblio::ILL::ISO::ILLASNtype.
33              
34             =head1 USES
35              
36             Biblio::ILL::ISO::ReasonWillSupply
37             Biblio::ILL::ISO::ISODate
38             Biblio::ILL::ISO::PostalAddress
39             Biblio::ILL::ISO::LocationInfoSequence
40             Biblio::ILL::ISO::ElectronicDeliveryService
41              
42             =head1 USED IN
43              
44             Biblio::ILL::ISO::ResultsExplanation
45              
46             =cut
47              
48 4     4   3156 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
49              
50             =head1 FROM THE ASN DEFINITION
51            
52             Will-Supply-Results ::= EXPLICIT SEQUENCE {
53             reason-will-supply [0] ReasonWillSupply,
54             supply-date [1] ISO-Date OPTIONAL,
55             return-to-address [2] Postal-Address OPTIONAL,
56             locations [3] IMPLICIT SEQUENCE OF Location-Info OPTIONAL,
57             electronic-delivery-service [4] Electronic-Delivery-Service OPTIONAL
58             -- if present, this must be one of the services proposed by
59             -- the requester
60             }
61              
62             =cut
63              
64             =head1 METHODS
65              
66             =cut
67              
68             #---------------------------------------------------------------
69             #
70             #---------------------------------------------------------------
71             =head1
72              
73             =head2 new( $reason, [$supplydate [,$returnto [,$locations [,$electronic_delivery_service]]]] )
74              
75             Creates a new WillSupplyResults object.
76             Expects either no paramaters, or
77             a reason (Biblio::ILL::ISO::ReasonWillSupply),
78             (optionally) a supply-date (Biblio::ILL::ISO::ISODate),
79             (optionally) a return-to address (Biblio::ILL::ISO::PostalAddress),
80             (optionally) a locations sequence (Biblio::ILL::ISO::LocationInfoSequence), and
81             (optionally) an electronic delivery address (Biblio::ILL::ISO::ElectronicDeliveryService).
82              
83             =cut
84             sub new {
85 1     1 1 2 my $class = shift;
86 1         1 my $self = {};
87              
88 1 50       4 if (@_) {
89 1         3 my ($reason, $supplydate, $returnto, $locations, $electronic_delivery_service) = @_;
90              
91 1 50       8 croak "missing will-supply-result reason-will-supply" unless ($reason);
92 1 50       4 croak "invalid will-supply-result reason-will-supply" unless (ref($reason) eq "Biblio::ILL::ISO::ReasonWillSupply");
93              
94 1 50       2 if ($supplydate) {
95 1 50       4 croak "invalid supply-date" unless (ref($supplydate) eq "Biblio::ILL::ISO::ISODate");
96             }
97 1 50       6 if ($returnto) {
98 1 50       3 croak "invalid return-to-address" unless (ref($returnto) eq "Biblio::ILL::ISO::PostalAddress");
99             }
100 1 50       8 if ($locations) {
101 1 50       4 croak "invalid locations" unless (ref($locations) eq "Biblio::ILL::ISO::LocationInfoSequence");
102             }
103 1 50       3 if ($electronic_delivery_service) {
104 0 0       0 croak "invalid electronic-delivery-service" unless (ref($electronic_delivery_service) eq "Biblio::ILL::ISO::ElectronicDeliveryService");
105             }
106            
107 1         2 $self->{"reason-will-supply"} = $reason;
108 1 50       4 $self->{"supply-date"} = $supplydate if ($supplydate);
109 1 50       3 $self->{"return-to-address"} = $returnto if ($returnto);
110 1 50       7 $self->{"locations"} = $locations if ($locations);
111 1 50       3 $self->{"electronic-delivery-address"} = $electronic_delivery_address if ($electronic_delivery_address);
112             }
113              
114 1   33     7 bless($self, ref($class) || $class);
115 1         3 return ($self);
116             }
117              
118              
119             #---------------------------------------------------------------
120             #
121             #---------------------------------------------------------------
122             =head1
123              
124             =head2 set( $reason, [$supplydate [,$returnto [,$locations [,$electronic_delivery_service]]]] )
125              
126             Sets the object's reason-will-supply (Biblio::ILL::ISO::ReasonWillSupply),
127             (optionally) supply-date (Biblio::ILL::ISO::ISODate),
128             (optionally) return-to-address (Biblio::ILL::ISO::PostalAddress),
129             (optionally) locations (Biblio::ILL::ISO::LocationInfoSequence), and
130             (optionally) electronic-delivery-address (Biblio::ILL::ISO::ElectronicDeliveryService).
131              
132             =cut
133             sub set {
134 0     0 1   my $self = shift;
135              
136 0           my ($reason, $supplydate, $returnto, $locations, $electronic_delivery_service) = @_;
137              
138 0 0         croak "missing will-supply-result reason-will-supply" unless ($reason);
139 0 0         croak "invalid will-supply-result reason-will-supply" unless (ref($reason) eq "Biblio::ILL::ISO::ReasonWillSupply");
140              
141 0 0         if ($supplydate) {
142 0 0         croak "invalid supply-date" unless (ref($supplydate) eq "Biblio::ILL::ISO::ISODate");
143             }
144 0 0         if ($returnto) {
145 0 0         croak "invalid return-to-address" unless (ref($returnto) eq "Biblio::ILL::ISO::PostalAddress");
146             }
147 0 0         if ($locations) {
148 0 0         croak "invalid locations" unless (ref($locations) eq "Biblio::ILL::ISO::LocationInfoSequence");
149             }
150 0 0         if ($electronic_delivery_service) {
151 0 0         croak "invalid electronic-delivery-service" unless (ref($electronic_delivery_service) eq "Biblio::ILL::ISO::ElectronicDeliveryService");
152             }
153            
154 0           $self->{"reason-will-supply"} = $reason;
155 0 0         $self->{"supply-date"} = $supplydate if ($supplydate);
156 0 0         $self->{"return-to-address"} = $returnto if ($returnto);
157 0 0         $self->{"locations"} = $locations if ($locations);
158 0 0         $self->{"electronic-delivery-address"} = $electronic_delivery_address if ($electronic_delivery_address);
159            
160 0           return;
161             }
162              
163             #---------------------------------------------------------------
164             #
165             #---------------------------------------------------------------
166             =head1
167              
168             =head2 from_asn($href)
169              
170             Given a properly formatted hash, builds the object.
171              
172             =cut
173             sub from_asn {
174 0     0 1   my $self = shift;
175 0           my $href = shift;
176              
177 0           foreach my $k (keys %$href) {
178             #print ref($self) . "...$k\n";
179              
180 0 0         if ($k =~ /^reason-will-supply$/) {
    0          
    0          
    0          
    0          
181 0           $self->{$k} = new Biblio::ILL::ISO::ReasonWillSupply();
182 0           $self->{$k}->from_asn($href->{$k});
183            
184             } elsif ($k =~ /^supply-date$/) {
185 0           $self->{$k} = new Biblio::ILL::ISO::ISODate();
186 0           $self->{$k}->from_asn($href->{$k});
187              
188             } elsif ($k =~ /^return-to-address$/) {
189 0           $self->{$k} = new Biblio::ILL::ISO::PostalAddress();
190 0           $self->{$k}->from_asn($href->{$k});
191              
192             } elsif ($k =~ /^locations$/) {
193 0           $self->{$k} = new Biblio::ILL::ISO::LocationInfoSequence();
194 0           $self->{$k}->from_asn($href->{$k});
195              
196             } elsif ($k =~ /^electronic-delivery-address$/) {
197 0           $self->{$k} = new Biblio::ILL::ISO::ElectronicDeliveryAddress();
198 0           $self->{$k}->from_asn($href->{$k});
199              
200             } else {
201 0           croak "invalid " . ref($self) . " element: [$k]";
202             }
203              
204             }
205 0           return $self;
206             }
207              
208             =head1 SEE ALSO
209              
210             See the README for system design notes.
211             See the parent class(es) for other available methods.
212              
213             For more information on Interlibrary Loan standards (ISO 10160/10161),
214             a good place to start is:
215              
216             http://www.nlc-bnc.ca/iso/ill/main.htm
217              
218             =cut
219              
220             =head1 AUTHOR
221              
222             David Christensen,
223              
224             =cut
225              
226              
227             =head1 COPYRIGHT AND LICENSE
228              
229             Copyright 2003 by David Christensen
230              
231             This library is free software; you can redistribute it and/or modify it
232             under the same terms as Perl itself.
233              
234             =cut
235              
236             1;