From: dbs Date: Tue, 19 Jan 2010 19:34:46 +0000 (+0000) Subject: Substitute configure variables appropriately in fast-extract X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7631abf8cfc2623b7127a38220bbc6a3c60d28c7;p=contrib%2FConifer.git Substitute configure variables appropriately in fast-extract git-svn-id: svn://svn.open-ils.org/ILS/trunk@15341 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/Makefile.am b/Open-ILS/src/Makefile.am index 1a70c46000..ca873b1461 100644 --- a/Open-ILS/src/Makefile.am +++ b/Open-ILS/src/Makefile.am @@ -75,7 +75,6 @@ core_scripts = $(examples)/oils_ctl.sh \ $(supportscr)/long-overdue-status-update.pl \ $(supportscr)/action_trigger_runner.pl \ $(srcdir)/extras/openurl_map.pl \ - $(srcdir)/extras/fast-extract \ $(srcdir)/extras/import/marc_add_ids installautojs = $(autojsbinscripts) @@ -135,7 +134,7 @@ if BUILDEGJAVA OILSJAVA_DIR = java endif -bin_SCRIPTS = $(core_scripts) $(reporter_scripts) $(installautojs) @srcdir@/extras/eg_config +bin_SCRIPTS = $(core_scripts) $(reporter_scripts) $(installautojs) @srcdir@/extras/eg_config @srcdir@/extras/fast-extract data_DATA = $(core_data) $(reporter_data) # Take care of which subdirectories to build, and which extra files to include in a distribution. diff --git a/Open-ILS/src/extras/fast-extract b/Open-ILS/src/extras/fast-extract deleted file mode 100755 index d5fddf652e..0000000000 --- a/Open-ILS/src/extras/fast-extract +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/perl -# vim:ts=4:noet: - -use strict; -use DBI; -use FileHandle; -use Getopt::Long; -use OpenSRF::EX qw/:try/; -use OpenSRF::Utils::Logger qw/$logger/; -use OpenSRF::System; -use OpenSRF::AppSession; -use OpenSRF::Utils::SettingsClient; - -use open ':utf8'; - -binmode(STDIN, ':utf8'); -binmode(STDOUT, ':utf8'); - -$| = 1; - -my ($config, $delim, $after,$deleted) = ('SYSCONFDIR/opensrf_core.xml', ' | '); - -GetOptions( - "after=s" => \$after, - "bootstrap=s" => \$config, - "delimiter=s" => \$delim, - "include-deleted" => \$deleted, -); - -OpenSRF::System->bootstrap_client( config_file => $config ); - -# XXX Get this stuff from the settings server -my $sc = OpenSRF::Utils::SettingsClient->new; -my $db_driver = $sc->config_value( reporter => setup => database => 'driver' ); -my $db_host = $sc->config_value( reporter => setup => database => 'host' ); -my $db_port = $sc->config_value( reporter => setup => database => 'port' ); -my $db_name = $sc->config_value( reporter => setup => database => 'db' ); -if (!$db_name) { - $db_name = $sc->config_value( reporter => setup => database => 'name' ); - print STDERR "WARN: is a deprecated setting for database name. For future compatibility, you should use instead." if $db_name; -} -my $db_user = $sc->config_value( reporter => setup => database => 'user' ); -my $db_pw = $sc->config_value( reporter => setup => database => 'pw' ); - -die "Unable to retrieve database connection information from the settings server" unless ($db_driver && $db_host && $db_port && $db_name && $db_user); - -my $dsn = "dbi:" . $db_driver . ":dbname=" . $db_name .';host=' . $db_host . ';port=' . $db_port; - -my $dbh = DBI->connect($dsn,$db_user,$db_pw, {AutoCommit => 1, pg_enable_utf8 => 1, RaiseError => 1}); - -my $SQL = 'SELECT id FROM biblio.record_entry WHERE id > 0'; -$SQL .= " AND edit_date > '$after'" if ($after); -$SQL .= " AND deleted IS FALSE" if (!$deleted); - -my $ids = $dbh->selectcol_arrayref($SQL); - -$SQL = <<'SQL'; -SELECT id, - tcn_source, - tcn_value, - deleted, - REGEXP_REPLACE(marc, E'\\n','','g') AS marc - FROM biblio.record_entry - WHERE id = ? -SQL - -for my $id ( @$ids ) { - my $row = $dbh->selectrow_hashref( $SQL, {}, $id ); - print "$$row{deleted}$delim$$row{id}$delim$$row{tcn_source}$delim$$row{tcn_value}$delim$$row{marc}\n"; -} - diff --git a/Open-ILS/src/extras/fast-extract.in b/Open-ILS/src/extras/fast-extract.in new file mode 100755 index 0000000000..32f122a234 --- /dev/null +++ b/Open-ILS/src/extras/fast-extract.in @@ -0,0 +1,71 @@ +#!/usr/bin/perl +# vim:ts=4:noet: + +use strict; +use DBI; +use FileHandle; +use Getopt::Long; +use OpenSRF::EX qw/:try/; +use OpenSRF::Utils::Logger qw/$logger/; +use OpenSRF::System; +use OpenSRF::AppSession; +use OpenSRF::Utils::SettingsClient; + +use open ':utf8'; + +binmode(STDIN, ':utf8'); +binmode(STDOUT, ':utf8'); + +$| = 1; + +my ($config, $delim, $after,$deleted) = ('@sysconfdir@/opensrf_core.xml', ' | '); + +GetOptions( + "after=s" => \$after, + "bootstrap=s" => \$config, + "delimiter=s" => \$delim, + "include-deleted" => \$deleted, +); + +OpenSRF::System->bootstrap_client( config_file => $config ); + +# XXX Get this stuff from the settings server +my $sc = OpenSRF::Utils::SettingsClient->new; +my $db_driver = $sc->config_value( reporter => setup => database => 'driver' ); +my $db_host = $sc->config_value( reporter => setup => database => 'host' ); +my $db_port = $sc->config_value( reporter => setup => database => 'port' ); +my $db_name = $sc->config_value( reporter => setup => database => 'db' ); +if (!$db_name) { + $db_name = $sc->config_value( reporter => setup => database => 'name' ); + print STDERR "WARN: is a deprecated setting for database name. For future compatibility, you should use instead." if $db_name; +} +my $db_user = $sc->config_value( reporter => setup => database => 'user' ); +my $db_pw = $sc->config_value( reporter => setup => database => 'pw' ); + +die "Unable to retrieve database connection information from the settings server" unless ($db_driver && $db_host && $db_port && $db_name && $db_user); + +my $dsn = "dbi:" . $db_driver . ":dbname=" . $db_name .';host=' . $db_host . ';port=' . $db_port; + +my $dbh = DBI->connect($dsn,$db_user,$db_pw, {AutoCommit => 1, pg_enable_utf8 => 1, RaiseError => 1}); + +my $SQL = 'SELECT id FROM biblio.record_entry WHERE id > 0'; +$SQL .= " AND edit_date > '$after'" if ($after); +$SQL .= " AND deleted IS FALSE" if (!$deleted); + +my $ids = $dbh->selectcol_arrayref($SQL); + +$SQL = <<'SQL'; +SELECT id, + tcn_source, + tcn_value, + deleted, + REGEXP_REPLACE(marc, E'\\n','','g') AS marc + FROM biblio.record_entry + WHERE id = ? +SQL + +for my $id ( @$ids ) { + my $row = $dbh->selectrow_hashref( $SQL, {}, $id ); + print "$$row{deleted}$delim$$row{id}$delim$$row{tcn_source}$delim$$row{tcn_value}$delim$$row{marc}\n"; +} + diff --git a/configure.ac b/configure.ac index 229e4d721c..547d8add6b 100644 --- a/configure.ac +++ b/configure.ac @@ -322,7 +322,12 @@ AC_CONFIG_FILES([Makefile Open-ILS/src/Makefile Open-ILS/web/Makefile Open-ILS/xul/staff_client/Makefile - Open-ILS/src/extras/eg_config], [if test -e "./Open-ILS/src/extras/eg_config"; then chmod 755 Open-ILS/src/extras/eg_config; fi]) + Open-ILS/src/extras/eg_config + Open-ILS/src/extras/fast-extract], + [ + if test -e "./Open-ILS/src/extras/eg_config"; then chmod 755 Open-ILS/src/extras/eg_config; fi; + if test -e "./Open-ILS/src/extras/fast-extract"; then chmod 755 Open-ILS/src/extras/fast-extract; fi; + ]) AC_OUTPUT #-------------------------------------------------