From 0ce407dd8d3ad25f6edad75f746c3ac25fa4e968 Mon Sep 17 00:00:00 2001 From: miker Date: Sun, 3 Sep 2006 02:11:13 +0000 Subject: [PATCH] last minute fixes -- frozen now for all time, as the data is in the DB git-svn-id: svn://svn.open-ils.org/ILS/trunk@5877 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Evergreen/src/extras/import/legacy_hold.sql | 17 +++++++----- Evergreen/src/extras/import/libfixup.pl | 26 +++++++++++++++++++ Evergreen/src/extras/import/load_legacy.sql | 17 ++++++++++++ Evergreen/src/extras/import/pre_cat_items.pl | 21 +++++++++++++++ .../src/extras/import/renewal_subtract.pl | 14 ++++++++++ 5 files changed, 88 insertions(+), 7 deletions(-) create mode 100755 Evergreen/src/extras/import/libfixup.pl create mode 100755 Evergreen/src/extras/import/pre_cat_items.pl create mode 100755 Evergreen/src/extras/import/renewal_subtract.pl diff --git a/Evergreen/src/extras/import/legacy_hold.sql b/Evergreen/src/extras/import/legacy_hold.sql index 47308e7939..37711cd8dd 100644 --- a/Evergreen/src/extras/import/legacy_hold.sql +++ b/Evergreen/src/extras/import/legacy_hold.sql @@ -25,12 +25,13 @@ INSERT INTO action.hold_request JOIN legacy_item jl ON ( jl.cat_key = lh.cat_key AND jl.call_key = lh.call_key - AND jl.item_key = lh.call_key ) + AND jl.item_key = lh.item_key ) JOIN asset.copy cp ON (cp.barcode = jl.item_id) JOIN actor.usr au ON (au.id = lh.user_key) JOIN actor.org_unit rou ON (rou.shortname = lh.placing_lib) JOIN actor.org_unit pou ON (pou.shortname = lh.pickup_lib) - WHERE lh.hold_level = 'C'; + WHERE lh.hold_level = 'C' + AND lh.hold_date > '2006-01-01'; -- And these are CN level holds -- CREATE TABLE legacy_cn_hold_insert AS @@ -57,14 +58,15 @@ INSERT INTO action.hold_request JOIN legacy_item jl ON ( jl.cat_key = lh.cat_key AND jl.call_key = lh.call_key - AND jl.item_key = lh.call_key ) + AND jl.item_key = lh.item_key ) JOIN asset.copy cp ON (cp.barcode = jl.item_id) JOIN actor.usr au ON (au.id = lh.user_key) JOIN actor.org_unit rou ON (rou.shortname = lh.placing_lib) JOIN actor.org_unit pou ON (pou.shortname = lh.pickup_lib) - WHERE lh.hold_level = 'A'; + WHERE lh.hold_level = 'A' + AND lh.hold_date > '2006-01-01'; --- And these are CN level holds +-- And these are Title level holds -- CREATE TABLE legacy_title_hold_insert AS INSERT INTO action.hold_request (id, target, current_copy, hold_type, pickup_lib, selection_ou, selection_depth, request_time, capture_time, request_lib, requestor, usr) @@ -89,12 +91,13 @@ INSERT INTO action.hold_request JOIN legacy_item jl ON ( jl.cat_key = lh.cat_key AND jl.call_key = lh.call_key - AND jl.item_key = lh.call_key ) + AND jl.item_key = lh.item_key ) JOIN asset.copy cp ON (cp.barcode = jl.item_id) JOIN actor.usr au ON (au.id = lh.user_key) JOIN actor.org_unit rou ON (rou.shortname = lh.placing_lib) JOIN actor.org_unit pou ON (pou.shortname = lh.pickup_lib) - WHERE lh.hold_level = 'T'; + WHERE lh.hold_level = 'T' + AND lh.hold_date > '2006-01-01'; SELECT SETVAL('action.hold_request_id_seq',(SELECT MAX(id) FROM action.hold_request),TRUE); diff --git a/Evergreen/src/extras/import/libfixup.pl b/Evergreen/src/extras/import/libfixup.pl new file mode 100755 index 0000000000..3f1a40f3f4 --- /dev/null +++ b/Evergreen/src/extras/import/libfixup.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl + +use strict; + +my $new = shift; +my $old = shift; + +open N, $new; +open O, $old; + +my %oldlibs; +while () { + chomp; + my ($sname, $lib, $sys) = split /\t/; + my ($sys_prefix) = split /-/; + + $oldlibs{$sys_prefix} = $sys; +} + +while () { + chomp; + my ($sname,$lib) = split /\|/; + my ($sys_prefix) = split /-/, $sname; + $lib =~ s/^[^-]+-(.+)/$1/o; + print "$sname\t$lib\t$oldlibs{$sys_prefix}\n"; +} diff --git a/Evergreen/src/extras/import/load_legacy.sql b/Evergreen/src/extras/import/load_legacy.sql index 4cdcfbc31e..3d201c6e29 100644 --- a/Evergreen/src/extras/import/load_legacy.sql +++ b/Evergreen/src/extras/import/load_legacy.sql @@ -157,6 +157,23 @@ INSERT INTO asset.copy (circ_lib,creator,editor,create_date,barcode,status,locat ON (ou.id = cn.owning_lib AND l.cat_key = cn.record AND l.call_num = cn.label) LEFT JOIN legacy_piece_count pc ON (pc.barcode = l.item_id); +-- Import brief copies +INSERT INTO asset.copy (circ_lib,creator,editor,barcode,status,loan_duration,fine_level,dummy_title,dummy_author,opac_visible,circ_modifier,call_number) + SELECT DISTINCT ou.id AS circ_lib, + 1 AS creator, + 1 AS editor, + b.barcode AS barcode, + 1 AS status, + 2 AS loan_duration, + 2 AS fine_level, + b.title AS dummy_title, + b.author AS dummy_author, + FALSE as opac_visible, + 'BOOK' AS circ_modifier, + -1 AS call_number + FROM legacy_pre_cat b + JOIN actor.org_unit ou ON (ou.shortname = b.lib); + -- Move copy notes into the notes table ... non-public INSERT INTO asset.copy_note (owning_copy,creator,title,value) SELECT cp.id, diff --git a/Evergreen/src/extras/import/pre_cat_items.pl b/Evergreen/src/extras/import/pre_cat_items.pl new file mode 100755 index 0000000000..5df59af4c3 --- /dev/null +++ b/Evergreen/src/extras/import/pre_cat_items.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +print <) { + chomp; + my ($bc,$l,$t,$a) = split '\|'; + $bc =~ s/\s*$//o; + print "$bc\t$l\t$t\t$a\n"; +} + +print '\.'."\n"; +print "CREATE INDEX precat_bc_idx ON legacy_pre_cat (barcode);\n"; + diff --git a/Evergreen/src/extras/import/renewal_subtract.pl b/Evergreen/src/extras/import/renewal_subtract.pl new file mode 100755 index 0000000000..efc490b1dd --- /dev/null +++ b/Evergreen/src/extras/import/renewal_subtract.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl + +print "CREATE TABLE legacy_renewal_count ( barcode text, cnt int);\n"; +print "COPY legacy_renewal_count FROM STDIN;\n"; + +while (<>) { + chomp; + my ($b,$c) = split '\|'; + $b =~ s/\s*$//o; + print "$b\t$c\n"; +} + +print "\\.\n"; + -- 2.43.2