| 1 |
|
| 2 |
package Biblio::SICI::ItemSegmentscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/; |
| 3 |
{ |
| 4 |
$Biblio::SICI::ItemSegment::VERSIONscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$VERSION. = '0.04'; |
| 5 |
} |
| 6 |
|
| 7 |
# ABSTRACT: The item segment of a SICI |
| 8 |
|
| 9 |
use strictscip-perl cpan Biblio-SICI 0.04 strict/; |
| 10 |
use warningsscip-perl cpan Biblio-SICI 0.04 warnings/; |
| 11 |
use 5.010001scip-perl cpan Biblio-SICI 0.04 `5.010001`/; |
| 12 |
|
| 13 |
use Mooscip-perl cpan Biblio-SICI 0.04 Moo/; |
| 14 |
use Sub::Quotescip-perl cpan Biblio-SICI 0.04 Sub/Quote/; |
| 15 |
|
| 16 |
use Business::ISSNscip-perl cpan Biblio-SICI 0.04 Business/ISSN/; |
| 17 |
|
| 18 |
use Biblio::SICIscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/; |
| 19 |
withscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/with(). 'Biblio::SICI::Role::ValidSegment', 'Biblio::SICI::Role::RecursiveLink'; |
| 20 |
|
| 21 |
|
| 22 |
hasscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has(). 'issn' => ( is => 'rw', trigger => 1, predicate => 1, clearer => 1, ); |
| 23 |
|
| 24 |
sub _trigger_issnscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/_trigger_issn(). { |
| 25 |
my ( $self, $newVal ) = @_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/`@_`.; |
| 26 |
my @problems = (); |
| 27 |
|
| 28 |
if ( $newVal !~ m!\A[0-9X-]+\Z! ) { |
| 29 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'contains invalid characters'; |
| 30 |
} |
| 31 |
|
| 32 |
if ( $newVal !~ m!\A[0-9]{4}\-[0-9]{3}[0-9X]\Z! ) { |
| 33 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'structural error'; |
| 34 |
} |
| 35 |
|
| 36 |
unless (@problems) { |
| 37 |
if ( my $is = Business::ISSN->newscip-perl cpan Biblio-SICI 0.04 Business/ISSN/new().($newVal) ) { |
| 38 |
unless ( $is->is_validscip-perl cpan Biblio-SICI 0.04 Business/ISSN/is_valid(). ) { |
| 39 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'invalid issn'; |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
if (@problems) { |
| 45 |
$self->log_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/log_problem_on().( 'issn' => [@problems] ); |
| 46 |
} |
| 47 |
else { |
| 48 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('issn'); |
| 49 |
} |
| 50 |
|
| 51 |
return; |
| 52 |
} ## end sub _trigger_issn |
| 53 |
|
| 54 |
|
| 55 |
hasscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has(). 'chronology' => ( is => 'rw', trigger => 1, predicate => 1, clearer => 1, ); |
| 56 |
|
| 57 |
sub _trigger_chronologyscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/_trigger_chronology(). { |
| 58 |
my ( $self, $newVal ) = @_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/`@_`.; |
| 59 |
|
| 60 |
# TODO calendar schemes other than Gregorian may be used?! |
| 61 |
|
| 62 |
my @problems = (); |
| 63 |
|
| 64 |
# 1 YYYY |
| 65 |
# 2 YYYY/YYYY with second YYYY > first YYYY |
| 66 |
# 3 YYYYMM |
| 67 |
# 4 YYYYMM/MM with second MM > first MM |
| 68 |
# 5 YYYYMM/YYYYMM with second YYYY > first YYYY |
| 69 |
# 6 YYYYMMDD |
| 70 |
# 7 YYYYMMDD/DD with second DD > first DD |
| 71 |
# 8 YYYYMMDD/MMDD with second MM > first MM |
| 72 |
# 9 YYYYMMDD/YYYYMMDD with second YYYY > first YYYY |
| 73 |
|
| 74 |
my (%e) = (); |
| 75 |
|
| 76 |
if ( $newVal =~ /\A[0-9]{4}\Z/ ) { |
| 77 |
$e{'1Y'} = $newVal; |
| 78 |
} |
| 79 |
elsif ( $newVal =~ /\A([0-9]{4})\/([0-9]{4})\Z/ ) { |
| 80 |
$e{'1Y'} = $1scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$1.; |
| 81 |
$e{'2Y'} = $2scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$2.; |
| 82 |
|
| 83 |
unless ( $e{'2Y'} > $e{'1Y'} ) { |
| 84 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'if specified, second year must be larger than first year'; |
| 85 |
} |
| 86 |
} |
| 87 |
elsif ( $newVal =~ /\A([0-9]{4})([0-9]{2})\Z/ ) { |
| 88 |
$e{'1Y'} = $1scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$1.; |
| 89 |
$e{'1M'} = $2scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$2.; |
| 90 |
} |
| 91 |
elsif ( $newVal =~ /\A([0-9]{4})([0-9]{2})\/([0-9]{2})\Z/ ) { |
| 92 |
$e{'1Y'} = $1scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$1.; |
| 93 |
$e{'1M'} = $2scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$2.; |
| 94 |
$e{'2M'} = $3scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$3.; |
| 95 |
|
| 96 |
unless ( $e{'2M'} > $e{'1M'} ) { |
| 97 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'if specified, second month must be larger than first month'; |
| 98 |
} |
| 99 |
} |
| 100 |
elsif ( $newVal =~ /\A([0-9]{4})([0-9]{2})\/([0-9]{4})([0-9]{2})\Z/ ) { |
| 101 |
$e{'1Y'} = $1scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$1.; |
| 102 |
$e{'1M'} = $2scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$2.; |
| 103 |
$e{'2Y'} = $3scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$3.; |
| 104 |
$e{'2M'} = $4scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$4.; |
| 105 |
|
| 106 |
unless ( $e{'2Y'} > $e{'1Y'} ) { |
| 107 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'if specified, second year must be larger than first year'; |
| 108 |
} |
| 109 |
} |
| 110 |
elsif ( $newVal =~ /\A([0-9]{4})([0-9]{2})([0-9]{2})\Z/ ) { |
| 111 |
$e{'1Y'} = $1scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$1.; |
| 112 |
$e{'1M'} = $2scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$2.; |
| 113 |
$e{'1D'} = $3scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$3.; |
| 114 |
} |
| 115 |
elsif ( $newVal =~ /\A([0-9]{4})([0-9]{2})([0-9]{2})\/([0-9]{2})\Z/ ) { |
| 116 |
$e{'1Y'} = $1scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$1.; |
| 117 |
$e{'1M'} = $2scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$2.; |
| 118 |
$e{'1D'} = $3scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$3.; |
| 119 |
$e{'2D'} = $4scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$4.; |
| 120 |
|
| 121 |
unless ( $e{'2D'} > $e{'1D'} ) { |
| 122 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'if specified, second day must be larger than first day'; |
| 123 |
} |
| 124 |
} |
| 125 |
elsif ( $newVal =~ /\A([0-9]{4})([0-9]{2})([0-9]{2})\/([0-9]{2})([0-9]{2})\Z/ ) { |
| 126 |
$e{'1Y'} = $1scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$1.; |
| 127 |
$e{'1M'} = $2scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$2.; |
| 128 |
$e{'1D'} = $3scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$3.; |
| 129 |
$e{'2M'} = $4scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$4.; |
| 130 |
$e{'2D'} = $5scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$5.; |
| 131 |
|
| 132 |
unless ( $e{'2M'} > $e{'1M'} ) { |
| 133 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'if specified, second month must be larger than first month'; |
| 134 |
} |
| 135 |
} |
| 136 |
elsif ( $newVal =~ /\A([0-9]{4})([0-9]{2})([0-9]{2})\/([0-9]{4})([0-9]{2})([0-9]{2})\Z/ ) { |
| 137 |
$e{'1Y'} = $1scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$1.; |
| 138 |
$e{'1M'} = $2scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$2.; |
| 139 |
$e{'1D'} = $3scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$3.; |
| 140 |
$e{'2Y'} = $4scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$4.; |
| 141 |
$e{'2M'} = $5scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$5.; |
| 142 |
$e{'2D'} = $6scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$6.; |
| 143 |
|
| 144 |
unless ( $e{'2Y'} > $e{'1Y'} ) { |
| 145 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'if specified, second year must be larger than first year'; |
| 146 |
} |
| 147 |
} |
| 148 |
else { |
| 149 |
$self->log_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/log_problem_on().( 'chronology', ['illegal chronology structure'] ); |
| 150 |
return; |
| 151 |
} |
| 152 |
|
| 153 |
# lets accept pub dates up to one year in the future |
| 154 |
# (relative to the date when this code is executed!) |
| 155 |
my (@time) = localtimescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/localtime().(timescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/time().); |
| 156 |
my $yr = $time[5] + 1900; |
| 157 |
my ( undef, undef, $decade, $year ) = splitscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/split().( '', $yr ); |
| 158 |
if ( $year == 9 ) { |
| 159 |
$year = 0; |
| 160 |
$decade += 1; |
| 161 |
} |
| 162 |
else { |
| 163 |
$year += 1; |
| 164 |
} |
| 165 |
my $prevDecade = $decade - 1; |
| 166 |
|
| 167 |
for (qw( 2D 1D )) { |
| 168 |
if ( existsscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/exists(). $e{$_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$_.} and $e{$_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$_.} !~ /\A(?:[012][0-9]|3[01])\Z/ ) { |
| 169 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, |
| 170 |
'illegal value for ' |
| 171 |
. ( $_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$_. eq '2D' ? 'second' : 'first' ) |
| 172 |
. ' day: should be 01-31'; |
| 173 |
} |
| 174 |
} |
| 175 |
for (qw( 2M 1M )) { |
| 176 |
if ( existsscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/exists(). $e{$_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$_.} and $e{$_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$_.} !~ /\A(?:0[0-9]|1[012]|[23][1-4])\Z/ ) { |
| 177 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, |
| 178 |
'illegal value for ' |
| 179 |
. ( $_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$_. eq '2M' ? 'second' : 'first' ) |
| 180 |
. ' month: should be 00-12, or 21-24, or 31-34'; |
| 181 |
} |
| 182 |
} |
| 183 |
for (qw( 2Y 1Y )) { |
| 184 |
if ( existsscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/exists(). $e{$_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$_.} |
| 185 |
and $e{$_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$_.} !~ /\A(?:1[0-9][0-9]{2}|20[0-$prevDecade][0-9]|20$decade[0-$year])\Z/o ) |
| 186 |
{ |
| 187 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'illegal value for ' . ( $_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/$_. eq '2Y' ? 'second' : 'first' ) . ' year'; |
| 188 |
} |
| 189 |
} |
| 190 |
|
| 191 |
if ( !@problems ) { |
| 192 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('chronology'); |
| 193 |
} |
| 194 |
else { |
| 195 |
$self->log_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/log_problem_on().( 'chronology', \@problems ); |
| 196 |
} |
| 197 |
|
| 198 |
return; |
| 199 |
} ## end sub _trigger_chronology |
| 200 |
|
| 201 |
|
| 202 |
hasscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has(). 'enumeration' => ( is => 'rw', predicate => 1, clearer => 1, trigger => 1, ); |
| 203 |
|
| 204 |
sub _trigger_enumerationscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/_trigger_enumeration(). { |
| 205 |
my ( $self, $newVal ) = @_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/`@_`.; |
| 206 |
|
| 207 |
# clear partial values |
| 208 |
$self->clear_volumescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_volume().(); |
| 209 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('volume'); |
| 210 |
$self->clear_issuescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_issue().(); |
| 211 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('issue'); |
| 212 |
$self->clear_supplOrIdxscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_supplOrIdx().(); |
| 213 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('supplOrIdx'); |
| 214 |
|
| 215 |
if ( $newVal !~ /\A[0-9A-Z:]*[+*]?\Z/ ) { |
| 216 |
$self->log_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/log_problem_on().( 'enumeration' => ['invalid characters used'] ); |
| 217 |
} |
| 218 |
return; |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
hasscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has(). 'volume' => ( is => 'rw', predicate => 1, clearer => 1, trigger => 1, ); |
| 223 |
|
| 224 |
sub _trigger_volumescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/_trigger_volume(). { |
| 225 |
my ( $self, $newVal ) = @_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/`@_`.; |
| 226 |
|
| 227 |
# clear aggregate value |
| 228 |
$self->clear_enumerationscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_enumeration().(); |
| 229 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('enumeration'); |
| 230 |
|
| 231 |
my @problems = (); |
| 232 |
|
| 233 |
if ( $newVal !~ m!\A[A-Z0-9/]+\Z! ) { |
| 234 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'contains invalid characters'; |
| 235 |
} |
| 236 |
|
| 237 |
if ( $newVal !~ m!\A[A-Z0-9]+(?:/[A-Z0-9]+)?\Z! ) { |
| 238 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'structural error'; |
| 239 |
} |
| 240 |
|
| 241 |
if (@problems) { |
| 242 |
$self->log_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/log_problem_on().( 'volume' => [@problems] ); |
| 243 |
} |
| 244 |
else { |
| 245 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('volume'); |
| 246 |
} |
| 247 |
|
| 248 |
return; |
| 249 |
} ## end sub _trigger_volume |
| 250 |
|
| 251 |
|
| 252 |
hasscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has(). 'issue' => ( is => 'rw', predicate => 1, clearer => 1, trigger => 1, ); |
| 253 |
|
| 254 |
sub _trigger_issuescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/_trigger_issue(). { |
| 255 |
my ( $self, $newVal ) = @_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/`@_`.; |
| 256 |
|
| 257 |
# clear aggregate value |
| 258 |
$self->clear_enumerationscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_enumeration().(); |
| 259 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('enumeration'); |
| 260 |
|
| 261 |
my @problems = (); |
| 262 |
|
| 263 |
if ( $newVal !~ m!\A[A-Z0-9/]+\Z! ) { |
| 264 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'contains invalid characters'; |
| 265 |
} |
| 266 |
|
| 267 |
if ( $newVal !~ m!\A[A-Z0-9]+(?:/[A-Z0-9]+)?\Z! ) { |
| 268 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'structural error'; |
| 269 |
} |
| 270 |
|
| 271 |
if (@problems) { |
| 272 |
$self->log_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/log_problem_on().( 'issue' => [@problems] ); |
| 273 |
} |
| 274 |
else { |
| 275 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('issue'); |
| 276 |
} |
| 277 |
|
| 278 |
return; |
| 279 |
} ## end sub _trigger_issue |
| 280 |
|
| 281 |
|
| 282 |
hasscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has(). 'supplOrIdx' => ( is => 'rw', predicate => 1, clearer => 1, trigger => 1, ); |
| 283 |
|
| 284 |
sub _trigger_supplOrIdxscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/_trigger_supplOrIdx(). { |
| 285 |
my ( $self, $newVal ) = @_scip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/`@_`.; |
| 286 |
|
| 287 |
# clear aggregate value |
| 288 |
$self->clear_enumerationscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_enumeration().(); |
| 289 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('enumeration'); |
| 290 |
|
| 291 |
my @problems = (); |
| 292 |
|
| 293 |
if ( lengthscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/length(). $newVal != 1 ) { |
| 294 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'too many characters (allowed: 1)'; |
| 295 |
} |
| 296 |
|
| 297 |
if ( $newVal ne '+' and $newVal ne '*' ) { |
| 298 |
pushscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/push(). @problems, 'contains invalid characters'; |
| 299 |
} |
| 300 |
|
| 301 |
if (@problems) { |
| 302 |
$self->log_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/log_problem_on().( 'supplOrIdx' => [@problems] ); |
| 303 |
} |
| 304 |
else { |
| 305 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('supplOrIdx'); |
| 306 |
} |
| 307 |
|
| 308 |
return; |
| 309 |
} ## end sub _trigger_supplOrIdx |
| 310 |
|
| 311 |
|
| 312 |
sub yearscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/year(). { |
| 313 |
my $self = shiftscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/shift().; |
| 314 |
|
| 315 |
return unless $self->has_chronologyscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has_chronology().(); |
| 316 |
|
| 317 |
my $c = $self->chronologyscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/chronology().; |
| 318 |
|
| 319 |
# 1 YYYY |
| 320 |
# 2 YYYY/YYYY with second YYYY > first YYYY |
| 321 |
# 3 YYYYMM |
| 322 |
# 4 YYYYMM/MM with second MM > first MM |
| 323 |
# 5 YYYYMM/YYYYMM with second YYYY > first YYYY |
| 324 |
# 6 YYYYMMDD |
| 325 |
# 7 YYYYMMDD/DD with second DD > first DD |
| 326 |
# 8 YYYYMMDD/MMDD with second MM > first MM |
| 327 |
# 9 YYYYMMDD/YYYYMMDD with second YYYY > first YYYY |
| 328 |
|
| 329 |
if ( $c =~ /\A[0-9]{4}\Z/ ) { |
| 330 |
return "$c"; |
| 331 |
} |
| 332 |
elsif ( $c =~ /\A([0-9]{4})\/([0-9]{4})\Z/ ) { |
| 333 |
return ( "$1", "$2" ); |
| 334 |
} |
| 335 |
elsif ( $c =~ /\A([0-9]{4})(?:[0-9]{2})\Z/ ) { |
| 336 |
return "$1"; |
| 337 |
} |
| 338 |
elsif ( $c =~ /\A([0-9]{4})(?:[0-9]{2})\/(?:[0-9]{2})\Z/ ) { |
| 339 |
return "$1"; |
| 340 |
} |
| 341 |
elsif ( $c =~ /\A([0-9]{4})(?:[0-9]{2})\/([0-9]{4})(?:[0-9]{2})\Z/ ) { |
| 342 |
return ( "$1", "$2" ); |
| 343 |
} |
| 344 |
elsif ( $c =~ /\A([0-9]{4})(?:[0-9]{2})(?:[0-9]{2})\Z/ ) { |
| 345 |
return "$1"; |
| 346 |
} |
| 347 |
elsif ( $c =~ /\A([0-9]{4})(?:[0-9]{2})(?:[0-9]{2})\/(?:[0-9]{2})\Z/ ) { |
| 348 |
return "$1"; |
| 349 |
} |
| 350 |
elsif ( $c =~ /\A([0-9]{4})(?:[0-9]{2})(?:[0-9]{2})\/(?:[0-9]{2})(?:[0-9]{2})\Z/ ) { |
| 351 |
return "$1"; |
| 352 |
} |
| 353 |
elsif ( $c =~ /\A([0-9]{4})(?:[0-9]{2})(?:[0-9]{2})\/([0-9]{4})(?:[0-9]{2})(?:[0-9]{2})\Z/ ) { |
| 354 |
return ( "$1", "$2" ); |
| 355 |
} |
| 356 |
|
| 357 |
return; |
| 358 |
} ## end sub year |
| 359 |
|
| 360 |
|
| 361 |
sub monthscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/month(). { |
| 362 |
my $self = shiftscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/shift().; |
| 363 |
|
| 364 |
return unless $self->has_chronologyscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has_chronology().(); |
| 365 |
|
| 366 |
my $c = $self->chronologyscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/chronology().; |
| 367 |
|
| 368 |
# 3 YYYYMM |
| 369 |
# 4 YYYYMM/MM with second MM > first MM |
| 370 |
# 5 YYYYMM/YYYYMM with second YYYY > first YYYY |
| 371 |
# 6 YYYYMMDD |
| 372 |
# 7 YYYYMMDD/DD with second DD > first DD |
| 373 |
# 8 YYYYMMDD/MMDD with second MM > first MM |
| 374 |
# 9 YYYYMMDD/YYYYMMDD with second YYYY > first YYYY |
| 375 |
|
| 376 |
if ( $c =~ /\A(?:[0-9]{4})([0-9]{2})\Z/ ) { |
| 377 |
return "$1"; |
| 378 |
} |
| 379 |
elsif ( $c =~ /\A(?:[0-9]{4})([0-9]{2})\/([0-9]{2})\Z/ ) { |
| 380 |
return ( "$1", "$2" ); |
| 381 |
} |
| 382 |
elsif ( $c =~ /\A(?:[0-9]{4})([0-9]{2})\/(?:[0-9]{4})([0-9]{2})\Z/ ) { |
| 383 |
return ( "$1", "$2" ); |
| 384 |
} |
| 385 |
elsif ( $c =~ /\A(?:[0-9]{4})([0-9]{2})(?:[0-9]{2})\Z/ ) { |
| 386 |
return "$1"; |
| 387 |
} |
| 388 |
elsif ( $c =~ /\A(?:[0-9]{4})([0-9]{2})(?:[0-9]{2})\/(?:[0-9]{2})\Z/ ) { |
| 389 |
return "$1"; |
| 390 |
} |
| 391 |
elsif ( $c =~ /\A(?:[0-9]{4})([0-9]{2})(?:[0-9]{2})\/([0-9]{2})(?:[0-9]{2})\Z/ ) { |
| 392 |
return ( "$1", "$2" ); |
| 393 |
} |
| 394 |
elsif ( $c =~ /\A(?:[0-9]{4})([0-9]{2})(?:[0-9]{2})\/(?:[0-9]{4})([0-9]{2})(?:[0-9]{2})\Z/ ) { |
| 395 |
return ( "$1", "$2" ); |
| 396 |
} |
| 397 |
|
| 398 |
return; |
| 399 |
} ## end sub month |
| 400 |
|
| 401 |
|
| 402 |
sub dayscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/day(). { |
| 403 |
my $self = shiftscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/shift().; |
| 404 |
|
| 405 |
return unless $self->has_chronologyscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has_chronology().(); |
| 406 |
|
| 407 |
my $c = $self->chronologyscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/chronology().; |
| 408 |
|
| 409 |
# 6 YYYYMMDD |
| 410 |
# 7 YYYYMMDD/DD with second DD > first DD |
| 411 |
# 8 YYYYMMDD/MMDD with second MM > first MM |
| 412 |
# 9 YYYYMMDD/YYYYMMDD with second YYYY > first YYYY |
| 413 |
|
| 414 |
if ( $c =~ /\A(?:[0-9]{4})(?:[0-9]{2})([0-9]{2})\Z/ ) { |
| 415 |
return "$1"; |
| 416 |
} |
| 417 |
elsif ( $c =~ /\A(?:[0-9]{4})(?:[0-9]{2})([0-9]{2})\/([0-9]{2})\Z/ ) { |
| 418 |
return ( "$1", "$2" ); |
| 419 |
} |
| 420 |
elsif ( $c =~ /\A(?:[0-9]{4})(?:[0-9]{2})([0-9]{2})\/(?:[0-9]{2})([0-9]{2})\Z/ ) { |
| 421 |
return ( "$1", "$2" ); |
| 422 |
} |
| 423 |
elsif ( $c =~ /\A(?:[0-9]{4})(?:[0-9]{2})([0-9]{2})\/(?:[0-9]{4})(?:[0-9]{2})([0-9]{2})\Z/ ) { |
| 424 |
return ( "$1", "$2" ); |
| 425 |
} |
| 426 |
|
| 427 |
return; |
| 428 |
} ## end sub day |
| 429 |
|
| 430 |
|
| 431 |
sub to_stringscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/to_string(). { |
| 432 |
my $self = shiftscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/shift().; |
| 433 |
|
| 434 |
my $str = ''; |
| 435 |
|
| 436 |
if ( $self->has_issnscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has_issn().() ) { |
| 437 |
$str = $self->issnscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/issn().(); |
| 438 |
} |
| 439 |
|
| 440 |
if ( $self->has_chronologyscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has_chronology().() ) { |
| 441 |
$str .= '(' . $self->chronologyscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/chronology().() . ')'; |
| 442 |
} |
| 443 |
else { |
| 444 |
$str .= '()'; |
| 445 |
} |
| 446 |
|
| 447 |
if ( $self->has_enumerationscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has_enumeration().() ) { |
| 448 |
$str .= $self->enumerationscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/enumeration().(); |
| 449 |
} |
| 450 |
else { |
| 451 |
if ( $self->has_volumescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has_volume().() ) { |
| 452 |
$str .= $self->volumescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/volume().(); |
| 453 |
if ( $self->has_issuescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has_issue().() ) { |
| 454 |
$str .= ':' . $self->issuescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/issue().(); |
| 455 |
} |
| 456 |
} |
| 457 |
if ( $self->has_supplOrIdxscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/has_supplOrIdx().() ) { |
| 458 |
$str .= $self->supplOrIdxscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/supplOrIdx().(); |
| 459 |
} |
| 460 |
} |
| 461 |
|
| 462 |
return $str; |
| 463 |
} ## end sub to_string |
| 464 |
|
| 465 |
|
| 466 |
sub resetscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/reset(). { |
| 467 |
my $self = shiftscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/shift().; |
| 468 |
$self->clear_issnscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_issn().(); |
| 469 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('issn'); |
| 470 |
$self->clear_chronologyscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_chronology().(); |
| 471 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('chronology'); |
| 472 |
$self->clear_enumerationscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_enumeration().(); |
| 473 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('enumeration'); |
| 474 |
$self->clear_volumescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_volume().(); |
| 475 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('volumne'); |
| 476 |
$self->clear_issuescip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_issue().(); |
| 477 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('issue'); |
| 478 |
$self->clear_supplOrIdxscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_supplOrIdx().(); |
| 479 |
$self->clear_problem_onscip-perl cpan Biblio-SICI 0.04 Biblio/SICI/ItemSegment/clear_problem_on().('supplOrIdx'); |
| 480 |
return; |
| 481 |
} |
| 482 |
|
| 483 |
|
| 484 |
1; |
| 485 |
|
| 486 |
__END__ |
| 487 |
|
| 488 |
=pod |
| 489 |
|
| 490 |
=encoding utf-8 |
| 491 |
|
| 492 |
=head1 NAME |
| 493 |
|
| 494 |
Biblio::SICI::ItemSegment - The item segment of a SICI |
| 495 |
|
| 496 |
=head1 VERSION |
| 497 |
|
| 498 |
version 0.04 |
| 499 |
|
| 500 |
=head1 SYNOPSIS |
| 501 |
|
| 502 |
my $sici = Biblio::SICI->new(); |
| 503 |
|
| 504 |
$sici->item->issn('2232-7651'); |
| 505 |
|
| 506 |
=head1 DESCRIPTION |
| 507 |
|
| 508 |
I<Please note:> You are expected to not directly instantiate objects of this class! |
| 509 |
|
| 510 |
The item segment of a SICI describes various aspects of the serial item referenced |
| 511 |
by the SICI. |
| 512 |
Unlike the contribution segment, which may be empty, the item segment is required! |
| 513 |
|
| 514 |
=head1 ATTRIBUTES |
| 515 |
|
| 516 |
For each attribute, clearer ("clear_") and predicate ("has_") methods |
| 517 |
are provided. |
| 518 |
|
| 519 |
=over 4 |
| 520 |
|
| 521 |
=item C<issn> |
| 522 |
|
| 523 |
The ISSN of the serial. |
| 524 |
|
| 525 |
=item C<chronology> |
| 526 |
|
| 527 |
Identifies a specific date - usually the cover date - for an item |
| 528 |
of a serial title. |
| 529 |
Follows the format "YYYYMMDD" with only the applicable levels being |
| 530 |
used. |
| 531 |
For "MM", in addition to 01 to 12, the values 21 to 24 represent |
| 532 |
seasons (Spring, Summer, Fall, Winter) and the values 31 to 34 |
| 533 |
represent the four quarters of a year. |
| 534 |
|
| 535 |
=item C<enumeration> |
| 536 |
|
| 537 |
Describes, which item of the serial is referenced. |
| 538 |
The most common way of identifying an item is using a |
| 539 |
combination of volume and issue numbers, which is why |
| 540 |
there are separate attributes for these kinds of data. |
| 541 |
|
| 542 |
Please not that setting a value for C<enumeration> means |
| 543 |
that any value present in the attributes C<volume>, |
| 544 |
C<issue> or C<supplOrIdx> gets removed! |
| 545 |
|
| 546 |
=item C<volume> |
| 547 |
|
| 548 |
The volume designation of the serial item. |
| 549 |
|
| 550 |
Please note that setting a value for this attribute automatically |
| 551 |
clears the C<enumeration> attribute. |
| 552 |
|
| 553 |
=item C<issue> |
| 554 |
|
| 555 |
The issue designation of the serial item. |
| 556 |
|
| 557 |
Please note that setting a value for this attribute automatically |
| 558 |
clears the C<enumeration> attribute. |
| 559 |
|
| 560 |
=item C<supplOrIdx> |
| 561 |
|
| 562 |
A one character code to describe if the SICI refers to either a |
| 563 |
supplement of the described item (represented as '+') or to an |
| 564 |
index (represented as '*') which is published independently |
| 565 |
from a regular item. |
| 566 |
|
| •567 |
(If you wish to refer to an index within an item please have |
| 568 |
a look at the C<dpi> attribute of the control segment!) |
| 569 |
|
| 570 |
Please note that setting a value for this attribute automatically |
| 571 |
clears the C<enumeration> attribute. |
| 572 |
|
| 573 |
=back |
| 574 |
|
| 575 |
=head1 METHODS |
| 576 |
|
| 577 |
=over 4 |
| 578 |
|
| 579 |
=item LIST C<year>() |
| 580 |
|
| 581 |
Extracts the year info from the C<chronology> attribute. |
| 582 |
Returns C<undef> if no chronology has been set. |
| 583 |
May return either one or two values, depending on the given |
| 584 |
chronology. |
| 585 |
E.g.: |
| 586 |
|
| 587 |
=over 4 |
| 588 |
|
| 589 |
=item |
| 590 |
|
| 591 |
if the chronology value is B<199624/199721> (an item |
| 592 |
published Winter 1996 / Spring 1997) this method will return |
| 593 |
C<(1996, 1997)> |
| 594 |
|
| 595 |
=item |
| 596 |
|
| 597 |
if the chronology value is B<20021201> (item published on |
| 598 |
Dec. 1st, 2002) this method will return C<(2002)> |
| 599 |
|
| 600 |
=back |
| 601 |
|
| 602 |
=item LIST C<month>() |
| 603 |
|
| 604 |
Extracts the month(s) from the chronology. |
| 605 |
Returns C<undef> if no chronology has been set or no month info |
| 606 |
is available from the chronology. |
| 607 |
May return either one or two values, depending on the given |
| 608 |
chronology. Each value may be in the ranges 01 to 12, or 21 to 24, |
| 609 |
or 31 to 34; with 21 to 24 being the codes for the seasons Spring, |
| 610 |
Summer, Fall, and Winter and 31 to 34 being the codes for the four |
| 611 |
quarters of a year (cf. the info on the C<chronology> attribute). |
| 612 |
E.g.: |
| 613 |
|
| 614 |
=over 4 |
| 615 |
|
| 616 |
=item |
| 617 |
|
| 618 |
if the chronology value is B<199911/12> (an item |
| 619 |
published November / December 1999) this method will return |
| 620 |
C<(11, 12)> |
| 621 |
|
| 622 |
=item |
| 623 |
|
| 624 |
if the chronology value is B<20021201> (item published on |
| 625 |
Dec. 1st, 2002) this method will return C<(12)> |
| 626 |
|
| 627 |
=item |
| 628 |
|
| 629 |
if the chronology value is B<200721/22> (an item |
| 630 |
published Spring / Summer 2007) this method will return |
| 631 |
C<(21, 22)> |
| 632 |
|
| 633 |
=back |
| 634 |
|
| 635 |
=item LIST C<day>() |
| 636 |
|
| 637 |
Extracts the days(s) from the chronology. |
| 638 |
Returns C<undef> if no chronology has been set or no day info |
| 639 |
is available from the chronology. |
| 640 |
May return either one or two values, depending on the given |
| 641 |
chronology. |
| 642 |
E.g.: |
| 643 |
|
| 644 |
=over 4 |
| 645 |
|
| 646 |
=item |
| 647 |
|
| 648 |
if the chronology value is B<19991101/02> (an item |
| 649 |
published November 1st / November 2nd 1999) this method will return |
| 650 |
C<(01, 02)> (note the leading zeroes!); day spans are quite unlikely, |
| 651 |
but not prohibited |
| 652 |
|
| 653 |
=item |
| 654 |
|
| 655 |
if the chronology value is B<20021201> (item published on |
| 656 |
Dec. 1st, 2002) this method will return C<(01)> |
| 657 |
|
| 658 |
=back |
| 659 |
|
| 660 |
=item STRING C<to_string>() |
| 661 |
|
| 662 |
Returns a stringified representation of the data in the |
| 663 |
item segment. |
| 664 |
|
| 665 |
=item C<reset>() |
| 666 |
|
| 667 |
Resets all attributes to their default values. |
| 668 |
|
| 669 |
=item BOOL C<is_valid>() |
| 670 |
|
| 671 |
Checks if the data for the control segment conforms |
| 672 |
to the standard. |
| 673 |
|
| 674 |
=back |
| 675 |
|
| 676 |
=head1 SEE ALSO |
| 677 |
|
| 678 |
L<Biblio::SICI::Role::ValidSegment> |
| 679 |
|
| 680 |
=head1 AUTHOR |
| 681 |
|
| 682 |
Heiko Jansen <[email protected]> |
| 683 |
|
| 684 |
=head1 COPYRIGHT AND LICENSE |
| 685 |
|
| 686 |
This software is copyright (c) 2014 by Heiko Jansen. |
| 687 |
|
| 688 |
This is free software; you can redistribute it and/or modify it under |
| 689 |
the same terms as the Perl 5 programming language system itself. |
| 690 |
|
| 691 |
=cut |