last minute fixes -- frozen now for all time, as the data is in the DB
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 3 Sep 2006 02:11:13 +0000 (02:11 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 3 Sep 2006 02:11:13 +0000 (02:11 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5877 dcc99617-32d9-48b4-a31d-7c20da2025e4

Evergreen/src/extras/import/legacy_hold.sql
Evergreen/src/extras/import/libfixup.pl [new file with mode: 0755]
Evergreen/src/extras/import/load_legacy.sql
Evergreen/src/extras/import/pre_cat_items.pl [new file with mode: 0755]
Evergreen/src/extras/import/renewal_subtract.pl [new file with mode: 0755]

index 47308e7..37711cd 100644 (file)
@@ -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 (executable)
index 0000000..3f1a40f
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+use strict;
+
+my $new = shift;
+my $old = shift;
+
+open N, $new;
+open O, $old;
+
+my %oldlibs;
+while (<O>) {
+       chomp;
+       my ($sname, $lib, $sys) = split /\t/;
+       my ($sys_prefix) = split /-/;
+
+       $oldlibs{$sys_prefix} = $sys;
+}
+
+while (<N>) {
+       chomp;
+       my ($sname,$lib) = split /\|/;
+       my ($sys_prefix) = split /-/, $sname;
+       $lib =~ s/^[^-]+-(.+)/$1/o;
+       print "$sname\t$lib\t$oldlibs{$sys_prefix}\n";
+}
index 4cdcfbc..3d201c6 100644 (file)
@@ -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 (executable)
index 0000000..5df59af
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+print <<SQL;
+DROP TABLE legacy_pre_cat;
+CREATE TABLE legacy_pre_cat (barcode text, lib text, title text, author text);
+COPY legacy_pre_cat (barcode, lib, title, author) FROM STDIN;
+SQL
+
+while (<>) {
+       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 (executable)
index 0000000..efc490b
--- /dev/null
@@ -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";
+