Skip to content
Snippets Groups Projects
Commit 090fbf43 authored by Gerhard Gonter's avatar Gerhard Gonter :speech_balloon:
Browse files

more filtering and field transcribing

parent 1c2665fa
Branches
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ use strict;
use Data::Dumper;
use JSON;
use IRMA::db;
use Util::ts;
......@@ -100,15 +101,24 @@ sub find_books
{
my $self= shift;
my $search= shift;
print __LINE__, " search: ", join(', ', %$search), "\n";
# print __LINE__, " search: ", join(', ', %$search), "\n"; ... can contain {$in:[...]} clauses!
# print __LINE__, " search: ", Dumper ($search);
print __LINE__, " search: ", JSON::encode_json ($search), "\n";
my $foxml_col= $self->get_db_col('inventory_database', 'foxml.data');
my $cur= $foxml_col->find( $search );
# print __LINE__, ' cur: ', Dumper($cur);
while (my $foxml_rec= $cur->next())
FOXML_REC: while (my $foxml_rec= $cur->next())
{
# print __LINE__, " foxml_rec=[$foxml_rec]\n";
# print __LINE__, " foxml_rec: foxml_rec=[$foxml_rec] found:", Dumper($foxml_rec);
if (exists ($self->{agent_cnf}->{prefiltered_pids}->{$foxml_rec->{pid}}))
{
print __LINE__, " NOTE: prefiltered pid; foxml_rec: ", Dumper($foxml_rec);
next FOXML_REC;
}
# print __LINE__, " foxml_rec=[$foxml_rec] added: ", Dumper($foxml_rec);
$self->add_book($foxml_rec);
}
}
......@@ -176,10 +186,10 @@ sub check_book
return 'filtered_pids' if (exists ($self->{agent_cnf}->{filtered_pids}->{$pid}));
# check tickets
my $ticket_col= $self->get_db_col('irma_database', 'eod.tickets');
my $ticket_col= $self->get_db_col('stage_database', 'eod.tickets');
my @tickets= $ticket_col->find({ ac_number => $ac_number })->all();
print __LINE__, " ac_number=[$ac_number] tickets: ", scalar @tickets, "\n";
# print __LINE__, Dumper(\@tickets);
# print __LINE__, ' ', Dumper(\@tickets);
if (@tickets > 1)
{
$book->{ticket}= join(',', map { $_->{ticket} } @tickets);
......@@ -190,11 +200,13 @@ sub check_book
my $t0= @tickets[0];
$book->{ticket}= $t0->{ticket};
$book->{ticket_status}= $t0->{status};
$book->{vt}= $t0->{custom_fields}->{vt}->[1];
$book->{ticket_pid}= $t0->{custom_fields}->{ph_pid}->[1];
$book->{ticket_url}= $t0->{custom_fields}->{ph_url}->[1];
$book->{vt}= $t0->{custom_fields}->{vt}->[1];
}
# check IRMA for registered identifiers
my $irma_col= $self->get_db_col('irma_database', 'irma.map');
my $irma_col= $self->get_db_col('stage_database', 'irma.map');
my @irma_records= $irma_col->find({ ac_number => $ac_number })->all();
# my @irma_records= $irma_col->find({ pid => $pid })->all(); # NOTE: there is no field named "pid" in the irma record!
print __LINE__, " ac_number=[$ac_number] irma_records: ", scalar @irma_records, "\n";
......@@ -214,7 +226,7 @@ sub check_book
$self->{counters}->{missing_irma_record}++;
}
my $marc_col= $self->get_db_col('marc_database', 'alma.marc');
my $marc_col= $self->get_db_col('stage_database', 'alma.marc');
my $marc= $marc_col->find_one({ ac_number => $ac_number });
# print __LINE__, " marc: ", Dumper($marc);
return 'missing_marc_record' unless (defined ($marc));
......@@ -229,7 +241,7 @@ sub check_book
if (exists($book->{mex}))
{
my $mex= $book->{mex};
print __LINE__, " ac_number=[$ac_number] mex: ", Dumper($mex);
# print __LINE__, " ac_number=[$ac_number] mex: ", Dumper($mex);
foreach my $mf (keys %$mex)
{
my $mfa= $mex->{$mf};
......@@ -264,7 +276,7 @@ sub check_book
if ($val =~ m#^11353/10\.(\d+)$#)
{
$copy= 1; # only transcribe those URLs that really look like some
if ($val ne $book->{hdl})
if ($book->{hdl} && $val ne $book->{hdl})
{ # TODO:
$book->{update_hdl}= $book->{hdl};
$self->{counters}->{update_hdl}++;
......@@ -337,6 +349,13 @@ sub check_book
push(@alma_notes, 'set_urn');
}
if (!exists($book->{val_hdl}) && exists ($book->{hdl}))
{
$book->{update_hdl}= $book->{hdl};
$self->{counters}->{set_hdl}++;
push(@alma_notes, 'set_hdl');
}
unless (exists($book->{df_phaidra}))
{ # TODO: if there is no phaidra_url at all, set it...
$self->{counters}->{set_phaidra_url}++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment