| 1 | package Biblio::ILL::ISO::SearchType; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | Biblio::ILL::ISO::SearchType | ||||||||||||||||||||
| 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::ISODate; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 4 | ▶ | use Biblio::ILL::ISO::ExpiryFlag; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 4 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | =head1 VERSION | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | Version 0.02 | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 4 | our $VERSION = '0.02'; | |||||||||||||||||||
| 23 | #--------------------------------------------------------------------------- | ||||||||||||||||||||
| 24 | # Mods | ||||||||||||||||||||
| 25 | # 0.02 - 2003.07.17 - new and set were setting dates as ILLStrings, not | ||||||||||||||||||||
| 26 | # ISODates. Fixed. | ||||||||||||||||||||
| 27 | # 0.01 - 2003.07.15 - original version | ||||||||||||||||||||
| 28 | #--------------------------------------------------------------------------- | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | =head1 DESCRIPTION | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | Biblio::ILL::ISO::SearchType is a derivation of Biblio::ILL::ISO::ILLASNtype. | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | =head1 USES | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | Biblio::ILL::ISO::ILLString; | ||||||||||||||||||||
| 37 | Biblio::ILL::ISO::ISODate; | ||||||||||||||||||||
| 38 | Biblio::ILL::ISO::ExpiryFlag; | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | =head1 USED IN | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | Biblio::ILL::ISO::Request | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | =cut | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 4 | ▶ | BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | =head1 FROM THE ASN DEFINITION | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | Search-Type ::= SEQUENCE { | ||||||||||||||||||||
| 51 | level-of-service [0] ILL-String OPTIONAL, -- (SIZE (1)) | ||||||||||||||||||||
| 52 | need-before-date [1] IMPLICIT ISO-Date OPTIONAL, | ||||||||||||||||||||
| 53 | expiry-flag [2] IMPLICIT ENUMERATED { | ||||||||||||||||||||
| 54 | need-Before-Date (1), | ||||||||||||||||||||
| 55 | other-Date (2), | ||||||||||||||||||||
| 56 | no-Expiry (3) | ||||||||||||||||||||
| 57 | } -- DEFAULT 3, | ||||||||||||||||||||
| 58 | -- value of "need-Before-Date" indicates that | ||||||||||||||||||||
| 59 | -- need-before-date also specifies transaction expiry | ||||||||||||||||||||
| 60 | -- date | ||||||||||||||||||||
| 61 | expiry-date [3] IMPLICIT ISO-Date OPTIONAL | ||||||||||||||||||||
| 62 | -- alternative expiry date can be used only when expiry-flag | ||||||||||||||||||||
| 63 | -- is set to "Other-Date" | ||||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | =cut | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | =head1 METHODS | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | =cut | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 73 | # | ||||||||||||||||||||
| 74 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 75 | =head1 | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | =head2 new( $expiry [,$service_level] [,$need_before] [,$expiry_date] ) | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | Creates a new SearchType object. | ||||||||||||||||||||
| 80 | Expects an expiry-flag string (text string, valid Biblio::ILL::ISO::ExpiryFlag enumerated value), | ||||||||||||||||||||
| 81 | (optionally) a service-level (text string), | ||||||||||||||||||||
| 82 | (optionally) a need-before-date (Biblio::ILL::ISO::ISODate), and | ||||||||||||||||||||
| 83 | (optionally) an expiry-date (Biblio::ILL::ISO::ISODate). | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||
| 86 | 2 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=23.1
Pod
documented
| |||||||||||||||||||||
| 87 | 2 | my $class = shift; | |||||||||||||||||||
| 88 | 2 | my $self = {}; | |||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 2 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 91 | 2 | my ($expiry, $servicelevel, $needbefore, $expirydate) = @_; | |||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 2 | ▶ | croak "missing expiry-flag" unless ($expiry); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 94 | 2 | ▶ | if ($servicelevel) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 95 | 2 | ▶ | croak "invalid service-level length" unless ((length $servicelevel) == 1); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 2 | $self->{"expiry-flag"} = new Biblio::ILL::ISO::ExpiryFlag($expiry); | |||||||||||||||||||
| 99 | 2 | ▶ | $self->{"level-of-service"} = new Biblio::ILL::ISO::ILLString($servicelevel) if ($servicelevel); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 100 | 2 | ▶ | $self->{"need-before-date"} = new Biblio::ILL::ISO::ISODate($needbefore) if ($needbefore); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 101 | 2 | ▶ | $self->{"expiry-date"} = new Biblio::ILL::ISO::ISODate($expirydate) if ($expirydate); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 102 | } | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | 2 | ▶ | bless($self, ref($class) || $class); | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 105 | 2 | return ($self); | |||||||||||||||||||
| 106 | } | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 110 | # | ||||||||||||||||||||
| 111 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 112 | =head1 | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | =head2 set( $expiry [,$service_level] [,$need_before] [,$expiry_date] ) | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | Sets the object's expiry-flag (text string, valid Biblio::ILL::ISO::ExpiryFlag enumerated value), | ||||||||||||||||||||
| 117 | (optionally) service-level (text string), | ||||||||||||||||||||
| 118 | (optionally) need-before-date (Biblio::ILL::ISO::ISODate), and | ||||||||||||||||||||
| 119 | (optionally) expiry-date (Biblio::ILL::ISO::ISODate). | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | =cut | ||||||||||||||||||||
| 122 | 0 | ▶ | sub set { | ||||||||||||||||||
|
Subroutine
set: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||
| 123 | 0 | my $self = shift; | |||||||||||||||||||
| 124 | 0 | my ($expiry, $servicelevel, $needbefore, $expirydate) = @_; | |||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 0 | ▶ | croak "missing expiry-flag" unless ($expiry); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 127 | 0 | ▶ | if ($servicelevel) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 128 | 0 | ▶ | croak "invalid service-level length" unless ((length $servicelevel) == 1); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 129 | } | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | 0 | $self->{"expiry-flag"} = new Biblio::ILL::ISO::ExpiryFlag($expiry); | |||||||||||||||||||
| 132 | 0 | ▶ | $self->{"level-of-service"} = new Biblio::ILL::ISO::ILLString($servicelevel) if ($servicelevel); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 133 | 0 | ▶ | $self->{"need-before-date"} = new Biblio::ILL::ISO::ISODate($needbefore) if ($needbefore); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 134 | 0 | ▶ | $self->{"expiry-date"} = new Biblio::ILL::ISO::ISODate($expirydate) if ($expirydate); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | 0 | return; | |||||||||||||||||||
| 137 | } | ||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 140 | # | ||||||||||||||||||||
| 141 | #--------------------------------------------------------------- | ||||||||||||||||||||
| 142 | =head1 | ||||||||||||||||||||
| 143 | |||||||||||||||||||||
| 144 | =head2 from_asn($href) | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | Given a properly formatted hash, builds the object. | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | =cut | ||||||||||||||||||||
| 149 | 0 | ▶ | sub from_asn { | ||||||||||||||||||
|
Subroutine
from_asn: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||
| 150 | 0 | my $self = shift; | |||||||||||||||||||
| 151 | 0 | my $href = shift; | |||||||||||||||||||
| 152 | |||||||||||||||||||||
| 153 | 0 | foreach my $k (keys %$href) { | |||||||||||||||||||
| 154 | #print ref($self) . "...$k\n"; | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | 0 | ▶ | if ($k =~ /^level-of-service$/) { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 157 | 0 | $self->{$k} = new Biblio::ILL::ISO::ILLString(); | |||||||||||||||||||
| 158 | 0 | $self->{$k}->from_asn($href->{$k}); | |||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | ▶ | } elsif (($k =~ /^need-before-date$/) | |||||||||||||||||||
|
Condition0%0/3
$k =~ /^need-before-date$/ or $k =~ /^expiry-date$/
MC/DC0%0/2
$k =~ /^need-before-date$/ or $k =~ /^expiry-date$/
$k =~ /^need-before-date$/
$k =~ /^expiry-date$/
Truth table0%0/3
A or B
A= $k =~ /^need-before-date$/B= $k =~ /^expiry-date$/
| |||||||||||||||||||||
| 161 | || ($k =~ /^expiry-date$/) | ||||||||||||||||||||
| 162 | ) { | ||||||||||||||||||||
| 163 | 0 | print "$k: $href->{$k}\n"; | |||||||||||||||||||
| 164 | 0 | $self->{$k} = new Biblio::ILL::ISO::ISODate(); | |||||||||||||||||||
| 165 | 0 | $self->{$k}->from_asn($href->{$k}); | |||||||||||||||||||
| 166 | 0 | print $self->{$k}->as_string(); | |||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | } elsif ($k =~ /^expiry-flag$/) { | ||||||||||||||||||||
| 169 | 0 | $self->{$k} = new Biblio::ILL::ISO::ExpiryFlag(); | |||||||||||||||||||
| 170 | 0 | $self->{$k}->from_asn($href->{$k}); | |||||||||||||||||||
| 171 | |||||||||||||||||||||
| 172 | } else { | ||||||||||||||||||||
| 173 | 0 | croak "invalid " . ref($self) . " element: [$k]"; | |||||||||||||||||||
| 174 | } | ||||||||||||||||||||
| 175 | |||||||||||||||||||||
| 176 | } | ||||||||||||||||||||
| 177 | 0 | return $self; | |||||||||||||||||||
| 178 | } | ||||||||||||||||||||
| 179 | |||||||||||||||||||||
| 180 | =head1 SEE ALSO | ||||||||||||||||||||
| 181 | |||||||||||||||||||||
| 182 | See the README for system design notes. | ||||||||||||||||||||
| 183 | See the parent class(es) for other available methods. | ||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | For more information on Interlibrary Loan standards (ISO 10160/10161), | ||||||||||||||||||||
| 186 | a good place to start is: | ||||||||||||||||||||
| 187 | |||||||||||||||||||||
| 188 | http://www.nlc-bnc.ca/iso/ill/main.htm | ||||||||||||||||||||
| 189 | |||||||||||||||||||||
| 190 | =cut | ||||||||||||||||||||
| 191 | |||||||||||||||||||||
| 192 | =head1 AUTHOR | ||||||||||||||||||||
| 193 | |||||||||||||||||||||
| 194 | David Christensen, <DChristensenSPAMLESS@westman.wave.ca> | ||||||||||||||||||||
| 195 | |||||||||||||||||||||
| 196 | =cut | ||||||||||||||||||||
| 197 | |||||||||||||||||||||
| 198 | |||||||||||||||||||||
| 199 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 200 | |||||||||||||||||||||
| 201 | Copyright 2003 by David Christensen | ||||||||||||||||||||
| 202 | |||||||||||||||||||||
| 203 | This library is free software; you can redistribute it and/or modify it | ||||||||||||||||||||
| 204 | under the same terms as Perl itself. | ||||||||||||||||||||
| 205 | |||||||||||||||||||||
| 206 | =cut | ||||||||||||||||||||
| 207 | =head1 | ||||||||||||||||||||
| 208 | |||||||||||||||||||||
| 209 | =head2 from_asn($href) | ||||||||||||||||||||
| 210 | |||||||||||||||||||||
| 211 | Given a properly formatted hash, builds the object. | ||||||||||||||||||||
| 212 | |||||||||||||||||||||
| 213 | =cut | ||||||||||||||||||||
| 214 | |||||||||||||||||||||
| 215 | 4 | 1; | |||||||||||||||||||