File Coverage

blib/lib/Biblio/ILL/ISO/StatusReport.pm
Criterion Covered Total %
statement 25 44 56.8
branch 5 22 22.7
condition 1 3 33.3
subroutine 6 8 75.0
pod 3 3 100.0
total 40 80 50.0


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