Lines 290-300
sub AddOAISet {
Link Here
|
290 |
GetOAISetsMappings returns mappings for all OAI Sets. |
290 |
GetOAISetsMappings returns mappings for all OAI Sets. |
291 |
|
291 |
|
292 |
Mappings define how biblios are categorized in sets. |
292 |
Mappings define how biblios are categorized in sets. |
293 |
A mapping is defined by three properties: |
293 |
A mapping is defined by four properties: |
294 |
|
294 |
|
295 |
{ |
295 |
{ |
296 |
marcfield => 'XXX', # the MARC field to check |
296 |
marcfield => 'XXX', # the MARC field to check |
297 |
marcsubfield => 'Y', # the MARC subfield to check |
297 |
marcsubfield => 'Y', # the MARC subfield to check |
|
|
298 |
operator => 'A', # the operator 'equal' or 'notequal'; 'equal' if '' |
298 |
marcvalue => 'zzzz', # the value to check |
299 |
marcvalue => 'zzzz', # the value to check |
299 |
} |
300 |
} |
300 |
|
301 |
|
Lines 311-316
The first hashref keys are the sets IDs, so it looks like this:
Link Here
|
311 |
{ |
312 |
{ |
312 |
marcfield => 'XXX', |
313 |
marcfield => 'XXX', |
313 |
marcsubfield => 'Y', |
314 |
marcsubfield => 'Y', |
|
|
315 |
operator => 'A', |
314 |
marcvalue => 'zzzz' |
316 |
marcvalue => 'zzzz' |
315 |
}, |
317 |
}, |
316 |
{ |
318 |
{ |
Lines 337-342
sub GetOAISetsMappings {
Link Here
|
337 |
push @{ $mappings->{$result->{'set_id'}} }, { |
339 |
push @{ $mappings->{$result->{'set_id'}} }, { |
338 |
marcfield => $result->{'marcfield'}, |
340 |
marcfield => $result->{'marcfield'}, |
339 |
marcsubfield => $result->{'marcsubfield'}, |
341 |
marcsubfield => $result->{'marcsubfield'}, |
|
|
342 |
operator => $result->{'operator'}, |
340 |
marcvalue => $result->{'marcvalue'} |
343 |
marcvalue => $result->{'marcvalue'} |
341 |
}; |
344 |
}; |
342 |
} |
345 |
} |
Lines 371-376
sub GetOAISetMappings {
Link Here
|
371 |
push @mappings, { |
374 |
push @mappings, { |
372 |
marcfield => $result->{'marcfield'}, |
375 |
marcfield => $result->{'marcfield'}, |
373 |
marcsubfield => $result->{'marcsubfield'}, |
376 |
marcsubfield => $result->{'marcsubfield'}, |
|
|
377 |
operator => $result->{'operator'}, |
374 |
marcvalue => $result->{'marcvalue'} |
378 |
marcvalue => $result->{'marcvalue'} |
375 |
}; |
379 |
}; |
376 |
} |
380 |
} |
Lines 384-389
sub GetOAISetMappings {
Link Here
|
384 |
{ |
388 |
{ |
385 |
marcfield => 'XXX', |
389 |
marcfield => 'XXX', |
386 |
marcsubfield => 'Y', |
390 |
marcsubfield => 'Y', |
|
|
391 |
operator => 'A', |
387 |
marcvalue => 'zzzz' |
392 |
marcvalue => 'zzzz' |
388 |
}, |
393 |
}, |
389 |
... |
394 |
... |
Lines 409-420
sub ModOAISetMappings {
Link Here
|
409 |
|
414 |
|
410 |
if(scalar @$mappings > 0) { |
415 |
if(scalar @$mappings > 0) { |
411 |
$query = qq{ |
416 |
$query = qq{ |
412 |
INSERT INTO oai_sets_mappings (set_id, marcfield, marcsubfield, marcvalue) |
417 |
INSERT INTO oai_sets_mappings (set_id, marcfield, marcsubfield, operator, marcvalue) |
413 |
VALUES (?,?,?,?) |
418 |
VALUES (?,?,?,?,?) |
414 |
}; |
419 |
}; |
415 |
$sth = $dbh->prepare($query); |
420 |
$sth = $dbh->prepare($query); |
416 |
foreach (@$mappings) { |
421 |
foreach (@$mappings) { |
417 |
$sth->execute($set_id, $_->{'marcfield'}, $_->{'marcsubfield'}, $_->{'marcvalue'}); |
422 |
$sth->execute($set_id, $_->{'marcfield'}, $_->{'marcsubfield'}, $_->{'operator'}, $_->{'marcvalue'}); |
418 |
} |
423 |
} |
419 |
} |
424 |
} |
420 |
} |
425 |
} |
Lines 491-502
sub CalcOAISetsBiblio {
Link Here
|
491 |
next if not $mapping; |
496 |
next if not $mapping; |
492 |
my $field = $mapping->{'marcfield'}; |
497 |
my $field = $mapping->{'marcfield'}; |
493 |
my $subfield = $mapping->{'marcsubfield'}; |
498 |
my $subfield = $mapping->{'marcsubfield'}; |
|
|
499 |
my $operator = $mapping->{'operator'}; |
494 |
my $value = $mapping->{'marcvalue'}; |
500 |
my $value = $mapping->{'marcvalue'}; |
495 |
|
|
|
496 |
my @subfield_values = $record->subfield($field, $subfield); |
501 |
my @subfield_values = $record->subfield($field, $subfield); |
497 |
if(0 < grep /^$value$/, @subfield_values) { |
502 |
if ($operator eq 'notequal') { |
498 |
push @biblio_sets, $set_id; |
503 |
if(0 == grep /^$value$/, @subfield_values) { |
499 |
last; |
504 |
push @biblio_sets, $set_id; |
|
|
505 |
last; |
506 |
} |
507 |
} |
508 |
else { |
509 |
if(0 < grep /^$value$/, @subfield_values) { |
510 |
push @biblio_sets, $set_id; |
511 |
last; |
512 |
} |
500 |
} |
513 |
} |
501 |
} |
514 |
} |
502 |
} |
515 |
} |