File Coverage

blib/lib/Biblio/ILL/ISO/ProviderErrorReport.pm
Criterion Covered Total %
statement 24 47 51.0
branch 3 20 15.0
condition 1 3 33.3
subroutine 7 9 77.7
pod 3 3 100.0
total 38 82 46.3


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