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);
30 (0, '/openils/conf/opensrf_core.xml');
33 'config=s' => \$config,
34 'authority' => \$auth,
39 open NEWERR, ">&STDERR";
41 select NEWERR; $| = 1;
42 select STDERR; $| = 1;
43 select STDOUT; $| = 1;
45 OpenSRF::System->bootstrap_client( config_file => $config );
46 Fieldmapper->import(IDL => OpenSRF::Utils::SettingsClient->new->config_value("IDL"));
48 OpenILS::Application::Ingest->use;
50 my $meth = 'open-ils.ingest.full.biblio.object.readonly';
51 $meth = 'open-ils.ingest.full.authority.object.readonly' if ($auth);
53 $meth = OpenILS::Application::Ingest->method_lookup( $meth );
57 while (my $rec = <>) {
60 my $bib = OpenSRF::Utils::JSON->JSON2perl($rec);
64 ($data) = $meth->run( $bib );
67 warn "Couldn't process record: $e\n >>> $rec\n";
72 postprocess( { bib => $bib, ingest_data => $data } );
75 print NEWERR "\r$count\t". $count / (time - $starttime);
84 my $bib = $data->{bib};
85 my $full_rec = $data->{ingest_data}->{full_rec};
87 my $field_entries = $data->{ingest_data}->{field_entries} unless ($auth);
88 my $fp = $data->{ingest_data}->{fingerprint} unless ($auth);
89 my $rd = $data->{ingest_data}->{descriptor} unless ($auth);
91 $bib->fingerprint( $fp->{fingerprint} ) unless ($auth);
92 $bib->quality( $fp->{quality} ) unless ($auth);
94 print( OpenSRF::Utils::JSON->perl2JSON($bib)."\n" );
96 print( OpenSRF::Utils::JSON->perl2JSON($rd)."\n" );
97 print( OpenSRF::Utils::JSON->perl2JSON($_)."\n" ) for (@$field_entries);
100 print( OpenSRF::Utils::JSON->perl2JSON($_)."\n" ) for (@$full_rec);