5 use lib '/openils/lib/perl5/';
8 use OpenSRF::EX qw/:try/;
9 use OpenSRF::AppSession;
10 use OpenSRF::Application;
11 use OpenSRF::MultiSession;
12 use OpenSRF::Utils::SettingsClient;
13 use OpenILS::Application::Ingest;
14 use OpenILS::Application::AppUtils;
15 use OpenILS::Utils::Fieldmapper;
16 use Digest::MD5 qw/md5_hex/;
17 use OpenSRF::Utils::JSON;
21 use Time::HiRes qw/time/;
27 MARC::Charset->ignore_errors(1);
29 my ($auth, $config, $quiet) =
30 (0, '/openils/conf/opensrf_core.xml');
33 'config=s' => \$config,
34 'authority' => \$auth,
40 open NEWERR, ">&STDERR";
42 select NEWERR; $| = 1;
43 select STDERR; $| = 1;
44 select STDOUT; $| = 1;
46 OpenSRF::System->bootstrap_client( config_file => $config );
47 Fieldmapper->import(IDL => OpenSRF::Utils::SettingsClient->new->config_value("IDL"));
49 OpenILS::Application::Ingest->use;
51 my $meth = 'open-ils.ingest.full.biblio.object.readonly';
52 $meth = 'open-ils.ingest.full.authority.object.readonly' if ($auth);
54 $meth = OpenILS::Application::Ingest->method_lookup( $meth );
58 while (my $rec = <>) {
61 my $bib = OpenSRF::Utils::JSON->JSON2perl($rec);
65 ($data) = $meth->run( $bib );
68 warn "Couldn't process record: $e\n >>> $rec\n";
73 postprocess( { bib => $bib, ingest_data => $data } );
75 if (!$quiet && !($count % 20)) {
76 print NEWERR "\r$count\t". $count / (time - $starttime);
85 my $bib = $data->{bib};
86 my $full_rec = $data->{ingest_data}->{full_rec};
88 my $field_entries = $data->{ingest_data}->{field_entries} unless ($auth);
89 my $fp = $data->{ingest_data}->{fingerprint} unless ($auth);
90 my $rd = $data->{ingest_data}->{descriptor} unless ($auth);
92 $bib->fingerprint( $fp->{fingerprint} ) unless ($auth);
93 $bib->quality( $fp->{quality} ) unless ($auth);
95 print( OpenSRF::Utils::JSON->perl2JSON($bib)."\n" );
97 print( OpenSRF::Utils::JSON->perl2JSON($rd)."\n" );
98 print( OpenSRF::Utils::JSON->perl2JSON($_)."\n" ) for (@$field_entries);
101 print( OpenSRF::Utils::JSON->perl2JSON($_)."\n" ) for (@$full_rec);