lib/Biblio/ILL/ISO/ErrorReport.pm

filter: Statementstmt 51.4% 36 / 70 Branchbran 21.0% 8 / 38 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 8 / 10 Podpod 100% 3 / 3 totaltotal 44.4% 56 / 126 CC 22 SCAR 34.6
CC
22
Cov
41%
set
72.0
from_asn
42.0
new
15.0
CRAP 31.8
« lib/Biblio/ILL/ISO/Received.pm ↑ Summary lib/Biblio/ILL/ISO/Extension.pm »
1 package Biblio::ILL::ISO::ErrorReport;
2  
3 =head1 NAME
4  
5 Biblio::ILL::ISO::ErrorReport
6  
7 =cut
8  
9 4 ▶use Biblio::ILL::ISO::ILLASNtype;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Biblio::ILL::ISO::ILLString;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Biblio::ILL::ISO::ReportSource;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Biblio::ILL::ISO::UserErrorReport;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Biblio::ILL::ISO::ProviderErrorReport;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 =head1 VERSION
18  
19 Version 0.02
20  
21 =cut
22  
23 4 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 ▶BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
Subroutine BEGIN: called CC=1 SCAR=0.0
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 1 ▶sub new {
Subroutine new: called CC=10 SCAR=27.1
Pod documented
81 1 my $class = shift;
82 1 my $self = {};
83  
84 1 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 0 1
85 1 my ($corr, $report_source, $report) = @_;
86  
87 1 ▶ croak "missing correlation-information" unless ($corr);
Branch: 1 branch
BranchTrueFalseTotal
unless $corr 0 1 1
88 1 ▶ if (ref($corr) eq "Biblio::ILL::ISO::ILLString") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $corr eq 'Biblio::ILL::ISO::ILLString') { } 0 1 1
89 0 $self->{"correlation-information"} = $cost;
90 } else {
91 1 $self->{"correlation-information"} = new Biblio::ILL::ISO::ILLString($corr);
92 }
93  
94 1 ▶ croak "missing report-source" unless ($report_source);
Branch: 1 branch
BranchTrueFalseTotal
unless $report_source 0 1 1
95 1 ▶ if (ref($report_source) eq "Biblio::ILL::ISO::ReportSource") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $report_source eq 'Biblio::ILL::ISO::ReportSource') { } 0 1 1
96 0 $self->{"report-source"} = $report_source;
97 } else {
98 1 $self->{"report-source"} = new Biblio::ILL::ISO::ReportSource($report_source);
99 }
100  
101 1 ▶ croak "missing report" unless ($report);
Branch: 1 branch
BranchTrueFalseTotal
unless $report 0 1 1
102 1 ▶ if (ref($report) eq "Biblio::ILL::ISO::UserErrorReport") {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $report eq 'Biblio::ILL::ISO::UserErrorReport') { } 0 1 1
elsif (ref $report eq 'Biblio::ILL::ISO::ProviderErrorReport') { } 1 0 1
103 0 $self->{"user-error-report"} = $report;
104 } elsif (ref($report) eq "Biblio::ILL::ISO::ProviderErrorReport") {
105 1 $self->{"provider-error-report"} = $report;
106 } else {
107 0 croak "invalid report type";
108 }
109
110 }
111  
112 1 ▶ bless($self, ref($class) || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
113 1 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 0 ▶sub set {
Subroutine set: not called CC=8 SCAR=42.8
Pod documented
130 0 my $self = shift;
131  
132 0 my ($corr, $report_source, $report) = @_;
133
134 0 ▶ croak "missing correlation-information" unless ($corr);
Branch: 1 branch
BranchTrueFalseTotal
unless $corr 0 0 0
135 0 ▶ if (ref($corr) eq "Biblio::ILL::ISO::ILLString") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $corr eq 'Biblio::ILL::ISO::ILLString') { } 0 0 0
136 0 $self->{"correlation-information"} = $cost;
137 } else {
138 0 $self->{"correlation-information"} = new Biblio::ILL::ISO::ILLString($corr);
139 }
140
141 0 ▶ croak "missing report-source" unless ($report_source);
Branch: 1 branch
BranchTrueFalseTotal
unless $report_source 0 0 0
142 0 ▶ if (ref($report_source) eq "Biblio::ILL::ISO::ReportSource") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $report_source eq 'Biblio::ILL::ISO::ReportSource') { } 0 0 0
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 ▶ croak "missing report" unless ($report);
Branch: 1 branch
BranchTrueFalseTotal
unless $report 0 0 0
149 0 ▶ if (ref($report) eq "Biblio::ILL::ISO::UserErrorReport") {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $report eq 'Biblio::ILL::ISO::UserErrorReport') { } 0 0 0
elsif (ref $report eq 'Biblio::ILL::ISO::ProviderErrorReport') { } 0 0 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 0 ▶sub from_asn {
Subroutine from_asn: not called CC=6 SCAR=37.4
Pod documented
171 0 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 ▶ if ($k =~ /^correlation-information$/) {
Branch: 4 branches
BranchTrueFalseTotal
if ($k =~ /^correlation-information$/) { } 0 0 0
elsif ($k =~ /^report-source$/) { } 0 0 0
elsif ($k =~ /^user-error-report$/) { } 0 0 0
elsif ($k =~ /^provider-error-report$/) { } 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, <DChristensenSPAMLESS@westman.wave.ca>
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 4 1;
« lib/Biblio/ILL/ISO/Received.pm ↑ Summary lib/Biblio/ILL/ISO/Extension.pm »