Lines 452-481
RECORD: foreach my $record (@{$marc_records}) {
Link Here
|
452 |
unless ($test_parameter) { |
452 |
unless ($test_parameter) { |
453 |
if ($authorities) { |
453 |
if ($authorities) { |
454 |
my $authtypecode = GuessAuthTypeCode($record, $heading_fields); |
454 |
my $authtypecode = GuessAuthTypeCode($record, $heading_fields); |
455 |
my $authid = ($matched_record_id? $matched_record_id : GuessAuthId($record)); |
455 |
my $authid; |
456 |
if ($authid && GetAuthority($authid) && $update) { |
456 |
|
457 |
## Authority has an id and is in database : Replace |
457 |
if (!$matched_record_id && GetAuthority($originalid)) { |
458 |
eval { ( $authid ) = ModAuthority($authid, $record, $authtypecode) }; |
458 |
$matched_record_id = $originalid; |
459 |
if ($@) { |
459 |
} |
460 |
warn "Problem with authority $authid Cannot Modify"; |
460 |
if ($matched_record_id) { |
461 |
printlog({ id => $authid, op => "edit", status => "ERROR" }) if ($logfile); |
461 |
if ($update) { |
|
|
462 |
## Authority has an id and is in database: update |
463 |
eval { ($authid) = ModAuthority($matched_record_id, $record, $authtypecode) }; |
464 |
if ($@) { |
465 |
warn "ERROR: Update authority $matched_record_id failed: $@\n"; |
466 |
printlog({ id => $matched_record_id, op => "update", status => "ERROR" }) if ($logfile); |
467 |
} |
468 |
else { |
469 |
printlog({ id => $authid, op => "update", status => "ok" }) if ($logfile); |
470 |
} |
462 |
} |
471 |
} |
463 |
else{ |
472 |
elsif ($logfile) { |
464 |
printlog({ id=> $authid, op=> "edit", status => "ok"}) if ($logfile); |
473 |
warn "WARNING: Update authority $originalid skipped"; |
|
|
474 |
printlog({ |
475 |
id => $matched_record_id, |
476 |
op => "update", |
477 |
status => "warning: authority already in database and option -update not enabled, skipping..." |
478 |
}); |
465 |
} |
479 |
} |
466 |
} |
480 |
} |
467 |
else { |
481 |
elsif ($insert) { |
468 |
## True insert in database |
482 |
## An authid is defined but no authority in database: insert |
469 |
eval { ( $authid ) = AddAuthority($record, "", $authtypecode) }; |
483 |
eval { ($authid) = AddAuthority($record, $originalid, $authtypecode) }; |
470 |
if ($@) { |
484 |
if ($@) { |
471 |
warn "Problem with authority $originalid Cannot Add ".$@; |
485 |
warn "ERROR: Insert authority $originalid failed: $@\n"; |
472 |
printlog({ id => $originalid, op => "insert", status => "ERROR" }) if ($logfile); |
486 |
printlog({ id => $originalid, op => "insert", status => "ERROR" }) if ($logfile); |
473 |
} |
487 |
} |
474 |
else { |
488 |
else { |
475 |
printlog({ id => $authid, op => "insert", status => "ok" }) if ($logfile); |
489 |
printlog({ id => $authid, op => "insert", status => "ok" }) if ($logfile); |
476 |
} |
490 |
} |
477 |
|
|
|
478 |
} |
491 |
} |
|
|
492 |
else { |
493 |
warn "WARNING: Insert authority $originalid skipped"; |
494 |
printlog( { id => $originalid, op => "insert", status => "warning : biblio not in database and option -insert not enabled, skipping..." } ) if ($logfile); |
495 |
} |
496 |
|
479 |
if ($yamlfile) { |
497 |
if ($yamlfile) { |
480 |
$yamlhash->{$originalid} = YAMLFileEntry( |
498 |
$yamlhash->{$originalid} = YAMLFileEntry( |
481 |
$record, |
499 |
$record, |
Lines 505-513
RECORD: foreach my $record (@{$marc_records}) {
Link Here
|
505 |
} |
523 |
} |
506 |
} |
524 |
} |
507 |
|
525 |
|
508 |
# create biblio, unless we already have it ( either match or isbn ) |
526 |
# Create biblio, unless we already have it (either match or ISBN) |
509 |
if ($matched_record_id) { |
527 |
if ($matched_record_id) { |
510 |
# TODO: Implement also for authority records! |
|
|
511 |
eval{ |
528 |
eval{ |
512 |
$biblioitemnumber = Koha::Biblios->find( $matched_record_id )->biblioitem->biblioitemnumber; |
529 |
$biblioitemnumber = Koha::Biblios->find( $matched_record_id )->biblioitem->biblioitemnumber; |
513 |
}; |
530 |
}; |
Lines 515-526
RECORD: foreach my $record (@{$marc_records}) {
Link Here
|
515 |
my $success; |
532 |
my $success; |
516 |
eval { $success = ModBiblio($record, $matched_record_id, GetFrameworkCode($matched_record_id), $modify_biblio_marc_options) }; |
533 |
eval { $success = ModBiblio($record, $matched_record_id, GetFrameworkCode($matched_record_id), $modify_biblio_marc_options) }; |
517 |
if ($@) { |
534 |
if ($@) { |
518 |
warn "ERROR: Edit biblio $matched_record_id failed: $@\n"; |
535 |
warn "ERROR: Update biblio $matched_record_id failed: $@\n"; |
519 |
printlog( { id => $matched_record_id, op => "update", status => "ERROR" } ) if ($logfile); |
536 |
printlog( { id => $matched_record_id, op => "update", status => "ERROR" } ) if ($logfile); |
520 |
next RECORD; |
537 |
next RECORD; |
521 |
} |
538 |
} |
522 |
elsif (!$success) { |
539 |
elsif (!$success) { |
523 |
warn "ERROR: Edit biblio $matched_record_id failed for unkown reason"; |
540 |
warn "ERROR: Update biblio $matched_record_id failed for unkown reason"; |
524 |
printlog( { id => $matched_record_id, op => "update", status => "ERROR" } ) if ($logfile); |
541 |
printlog( { id => $matched_record_id, op => "update", status => "ERROR" } ) if ($logfile); |
525 |
next RECORD; |
542 |
next RECORD; |
526 |
} |
543 |
} |
Lines 530-552
RECORD: foreach my $record (@{$marc_records}) {
Link Here
|
530 |
} |
547 |
} |
531 |
} |
548 |
} |
532 |
else { |
549 |
else { |
|
|
550 |
warn "WARNING: Update biblio $originalid skipped"; |
533 |
printlog( { id => $matched_record_id, op => "update", status => "warning : already in database and option -update not enabled, skipping..." } ) if ($logfile); |
551 |
printlog( { id => $matched_record_id, op => "update", status => "warning : already in database and option -update not enabled, skipping..." } ) if ($logfile); |
534 |
} |
552 |
} |
535 |
} |
553 |
} |
536 |
elsif ($insert) { |
554 |
elsif ($insert) { |
537 |
eval { ($record_id, $biblioitemnumber) = AddBiblio($record, $framework, { defer_marc_save => 1 }) }; |
555 |
eval { ($record_id, $biblioitemnumber) = AddBiblio($record, $framework, { defer_marc_save => 1 }) }; |
538 |
if ($@) { |
556 |
if ($@) { |
539 |
warn "ERROR: Adding biblio $record_id failed: $@\n"; |
557 |
warn "ERROR: Insert biblio $originalid failed: $@\n"; |
540 |
printlog( { id => $record_id, op => "insert", status => "ERROR" } ) if ($logfile); |
558 |
printlog( { id => $originalid, op => "insert", status => "ERROR" } ) if ($logfile); |
541 |
next RECORD; |
559 |
next RECORD; |
542 |
} |
560 |
} |
543 |
else { |
561 |
else { |
544 |
printlog( { id => $record_id, op => "insert", status => "ok" } ) if ($logfile); |
562 |
printlog( { id => $originalid, op => "insert", status => "ok" } ) if ($logfile); |
545 |
} |
563 |
} |
546 |
} |
564 |
} |
547 |
else { |
565 |
else { |
548 |
warn "WARNING: Updating record ".($originalid)." failed"; |
566 |
warn "WARNING: Insert biblio $originalid skipped"; |
549 |
printlog( { id => $originalid, op => "insert", status => "warning : not in database and option -insert not enabled, skipping..." } ) if ($logfile); |
567 |
printlog( { id => $originalid, op => "insert", status => "warning : biblio not in database and option -insert not enabled, skipping..." } ) if ($logfile); |
550 |
next RECORD; |
568 |
next RECORD; |
551 |
} |
569 |
} |
552 |
my $record_has_added_items = 0; |
570 |
my $record_has_added_items = 0; |
553 |
- |
|
|