File Coverage

blib/lib/Biblio/ILL/ISO/UserErrorReport.pm
Criterion Covered Total %
statement 27 54 50.0
branch 4 26 15.3
condition 1 3 33.3
subroutine 8 10 80.0
pod 3 3 100.0
total 43 96 44.7


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::UserErrorReport;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::UserErrorReport
6              
7             =cut
8              
9 4     4   26 use Biblio::ILL::ISO::ILLASNtype;
  4         9  
  4         109  
10 4     4   1829 use Biblio::ILL::ISO::AlreadyForwarded;
  4         13  
  4         111  
11 4     4   2442 use Biblio::ILL::ISO::IntermediaryProblem;
  4         13  
  4         132  
12 4     4   2423 use Biblio::ILL::ISO::SecurityProblem;
  4         15  
  4         132  
13 4     4   2465 use Biblio::ILL::ISO::UnableToPerform;
  4         11  
  4         140  
14              
15 4     4   29 use Carp;
  4         10  
  4         368  
16              
17             =head1 VERSION
18              
19             Version 0.01
20              
21             =cut
22              
23             our $VERSION = '0.01';
24             #---------------------------------------------------------------------------
25             # Mods
26             # 0.01 - 2003.08.12 - original version
27             #---------------------------------------------------------------------------
28              
29             =head1 DESCRIPTION
30              
31             Biblio::ILL::ISO::UserErrorReport is a derivation of Biblio::ILL::ISO::ILLASNtype.
32              
33             =head1 USES
34              
35             Biblio::ILL::ISO::AlreadyForwarded
36             Biblio::ILL::ISO::IntermediaryProblem
37             Biblio::ILL::ISO::SecurityProblem
38             Biblio::ILL::ISO::UnableToPerform
39              
40             =head1 USED IN
41              
42             Biblio::ILL::ISO::ErrorReport
43              
44             =cut
45              
46 4     4   2817 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
47              
48             =head1 FROM THE ASN DEFINITION
49            
50             User-Error-Report ::= CHOICE {
51             already-forwarded [0] IMPLICIT Already-Forwarded,
52             intermediary-problem [1] IMPLICIT Intermediary-Problem,
53             security-problem [2] Security-Problem,
54             unable-to-perform [3] IMPLICIT Unable-To-Perform
55             }
56              
57             =cut
58              
59             =head1 METHODS
60              
61             =cut
62              
63             #---------------------------------------------------------------
64             #
65             #---------------------------------------------------------------
66             =head1
67              
68             =head2 new( [$objref] )
69              
70             Creates a new UserErrorReport object.
71             Expects either no paramaters, or one of:
72             already-forwarded (Biblio::ILL::ISO::AlreadyForwarded),
73             intermediary-problem (Biblio::ILL::ISO::IntermediaryProblem),
74             security-problem (Biblio::ILL::ISO::SecurityProblem), or
75             unable-to-perform (Biblio::ILL::ISO::UnableToPerform).
76              
77             =cut
78             sub new {
79 1     1 1 9 my $class = shift;
80 1         1 my $self = {};
81              
82 1 50       3 if (@_) {
83 1         1 my ($objref) = @_;
84            
85 1 50       7 if (ref($objref) eq "Biblio::ILL::ISO::AlreadyForwarded") {
    50          
    50          
    0          
86 0         0 $self->{"already-forwarded"} = $objref;
87             } elsif (ref($objref) eq "Biblio::ILL::ISO::IntermediaryProblem") {
88 0         0 $self->{"intermediary-problem"} = $objref;
89             } elsif (ref($objref) eq "Biblio::ILL::ISO::SecurityProblem") {
90 1         2 $self->{"security-problem"} = $objref;
91             } elsif (ref($objref) eq "Biblio::ILL::ISO::UnableToPerform") {
92 0         0 $self->{"unable-to-perform"} = $objref;
93             } else {
94 0         0 croak "Invalid UserErrorReport";
95             }
96             }
97              
98 1   33     5 bless($self, ref($class) || $class);
99 1         2 return ($self);
100             }
101              
102              
103             #---------------------------------------------------------------
104             #
105             #---------------------------------------------------------------
106             =head1
107              
108             =head2 set( $objref )
109              
110             Sets the object's report type.
111             Expects one of:
112             already-forwarded (Biblio::ILL::ISO::AlreadyForwarded),
113             intermediary-problem (Biblio::ILL::ISO::IntermediaryProblem),
114             security-problem (Biblio::ILL::ISO::SecurityProblem), or
115             unable-to-perform (Biblio::ILL::ISO::UnableToPerform).
116              
117             =cut
118             sub set {
119 0     0 1   my $self = shift;
120 0           my ($objref) = @_;
121            
122 0 0         if (ref($objref) eq "Biblio::ILL::ISO::AlreadyForwarded") {
    0          
    0          
    0          
123 0           $self->{"already-forwarded"} = $objref;
124             } elsif (ref($objref) eq "Biblio::ILL::ISO::IntermediaryProblem") {
125 0           $self->{"intermediary-problem"} = $objref;
126             } elsif (ref($objref) eq "Biblio::ILL::ISO::SecurityProblem") {
127 0           $self->{"security-problem"} = $objref;
128             } elsif (ref($objref) eq "Biblio::ILL::ISO::UnableToPerform") {
129 0           $self->{"unable-to-perform"} = $objref;
130             } else {
131 0           croak "Invalid UserErrorReport";
132             }
133            
134 0           return;
135             }
136              
137             #---------------------------------------------------------------
138             #
139             #---------------------------------------------------------------
140             =head1
141              
142             =head2 from_asn($href)
143              
144             Given a properly formatted hash, builds the object.
145              
146             =cut
147             sub from_asn {
148 0     0 1   my $self = shift;
149 0           my $href = shift;
150              
151 0           foreach my $k (keys %$href) {
152             #print ref($self) . "...$k\n";
153              
154 0 0         if ($k =~ /^already-forwarded$/) {
    0          
    0          
    0          
155 0           $self->{$k} = new Biblio::ILL::ISO::AlreadyForwarded();
156 0           $self->{$k}->from_asn($href->{$k});
157              
158             } elsif ($k =~ /^intermediary-problem$/) {
159 0           $self->{$k} = new Biblio::ILL::ISO::IntermediaryProblem();
160 0           $self->{$k}->from_asn($href->{$k});
161              
162             } elsif ($k =~ /^security-problem$/) {
163 0           $self->{$k} = new Biblio::ILL::ISO::SecurityProblem();
164 0           $self->{$k}->from_asn($href->{$k});
165              
166             } elsif ($k =~ /^unable-to-perform$/) {
167 0           $self->{$k} = new Biblio::ILL::ISO::UnableToPerform();
168 0           $self->{$k}->from_asn($href->{$k});
169              
170             } else {
171 0           croak "invalid " . ref($self) . " element: [$k]";
172             }
173              
174             }
175 0           return $self;
176             }
177              
178             =head1 SEE ALSO
179              
180             See the README for system design notes.
181             See the parent class(es) for other available methods.
182              
183             For more information on Interlibrary Loan standards (ISO 10160/10161),
184             a good place to start is:
185              
186             http://www.nlc-bnc.ca/iso/ill/main.htm
187              
188             =cut
189              
190             =head1 AUTHOR
191              
192             David Christensen,
193              
194             =cut
195              
196              
197             =head1 COPYRIGHT AND LICENSE
198              
199             Copyright 2003 by David Christensen
200              
201             This library is free software; you can redistribute it and/or modify it
202             under the same terms as Perl itself.
203              
204             =cut
205              
206             1;