File Coverage

blib/lib/Biblio/ILL/ISO/ErrorReport.pm
Criterion Covered Total %
statement 34 68 50.0
branch 8 38 21.0
condition 1 3 33.3
subroutine 8 10 80.0
pod 3 3 100.0
total 54 122 44.2


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