From ec1afb85e0ac2942b195f5505310aaa6b41b0622 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 24 Aug 2006 23:42:49 +0000 Subject: [PATCH 1/1] import tweaks git-svn-id: svn://svn.open-ils.org/ILS/trunk@5666 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Evergreen/src/extras/import/load_legacy.sql | 6 ++++-- Open-ILS/src/extras/import/marc2bre.pl | 17 +++++++++++------ Open-ILS/src/sql/Pg/005.schema.actors.sql | 2 +- Open-ILS/src/sql/Pg/040.schema.asset.sql | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Evergreen/src/extras/import/load_legacy.sql b/Evergreen/src/extras/import/load_legacy.sql index 9adcbec4ab..eb8d7b72f8 100644 --- a/Evergreen/src/extras/import/load_legacy.sql +++ b/Evergreen/src/extras/import/load_legacy.sql @@ -118,6 +118,8 @@ CREATE TABLE joined_legacy AS FROM legacy_item i JOIN legacy_callnum c USING (cat_key,call_key); +CREATE INDEX lj_cat_call_idx ON joined_legacy (cat_key,call_key); + -- Import the call numbers -- Getting the owning lib from the first available copy on the CN INSERT INTO asset.call_number (creator,editor,record,label,owning_lib) @@ -129,7 +131,7 @@ INSERT INTO asset.call_number (creator,editor,record,label,owning_lib) -- Import base copy data -INSERT INTO asset.copy (circ_lib,creator,editor,create_date,barcode,status,location,loan_duration,fine_level,opac_visible,price,circ_modifier,call_number) +INSERT INTO asset.copy (circ_lib,creator,editor,create_date,barcode,status,location,loan_duration,fine_level,opac_visible,price,circ_modifier,call_number, alert_message) SELECT DISTINCT ou.id AS circ_lib, 1 AS creator, 1 AS editor, @@ -143,7 +145,7 @@ INSERT INTO asset.copy (circ_lib,creator,editor,create_date,barcode,status,locat (l.price/100::numeric)::numeric(8,2) AS price, l.item_type AS circ_modifier, cn.id AS call_number, - pc.cnt || " pieces" as alert_message + pc.cnt || ' pieces' as alert_message FROM joined_legacy l JOIN legacy_copy_status_map s_map ON (s_map.name = l.current_location) diff --git a/Open-ILS/src/extras/import/marc2bre.pl b/Open-ILS/src/extras/import/marc2bre.pl index 1e84ab1be3..579cc1cd65 100755 --- a/Open-ILS/src/extras/import/marc2bre.pl +++ b/Open-ILS/src/extras/import/marc2bre.pl @@ -77,6 +77,8 @@ my $batch = new MARC::Batch ( 'USMARC', @files ); $batch->strict_off(); $batch->warnings_off(); +my %seen; + my $starttime = time; my $rec; while ( try { $rec = $batch->next } otherwise { $rec = -1 } ) { @@ -111,13 +113,17 @@ while ( try { $rec = $batch->next } otherwise { $rec = -1 } ) { } $rec = preprocess($rec); + $rec->delete_field( $_ ) for ($rec->field($id_field)); if (!$rec) { next; } - my $tcn_value = $rec->subfield($id_field => 'a'); - my $tcn_source = $rec->subfield($id_field => 'b'); + my $tcn_value = $rec->subfield('901' => 'a'); + my $tcn_source = $rec->subfield('901' => 'b'); + + next if ($seen{$tcn_value}); + $seen{$tcn_value} = 1; (my $xml = $rec->as_xml_record()) =~ s/\n//sog; $xml =~ s/^<\?xml.+\?\s*>//go; @@ -207,10 +213,9 @@ sub preprocess { } my $tcn = MARC::Field->new( - $id_field, - '', '', - 'a', $id, - 'b', do { $source_map{$source} || 'System' }, + '901' => ('', ''), + a => $id, + b => do { $source_map{$source} || 'System' }, ); $rec->append_fields($tcn); diff --git a/Open-ILS/src/sql/Pg/005.schema.actors.sql b/Open-ILS/src/sql/Pg/005.schema.actors.sql index 4b3ce83a82..d42ffc4407 100644 --- a/Open-ILS/src/sql/Pg/005.schema.actors.sql +++ b/Open-ILS/src/sql/Pg/005.schema.actors.sql @@ -246,7 +246,7 @@ CREATE TABLE actor.stat_cat_entry ( stat_cat INT NOT NULL, owner INT NOT NULL, value TEXT NOT NULL, - CONSTRAINT sce_once_per_owner UNIQUE (owner,value) + CONSTRAINT sce_once_per_owner UNIQUE (stat_cat,owner,value) ); COMMENT ON TABLE actor.stat_cat_entry IS $$ /* diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index 8722c4e41c..6d8b47967d 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -93,7 +93,7 @@ CREATE TABLE asset.stat_cat_entry ( stat_cat INT NOT NULL, owner INT NOT NULL, value TEXT NOT NULL, - CONSTRAINT sce_once_per_owner UNIQUE (owner,value) + CONSTRAINT sce_once_per_owner UNIQUE (stat_cat,owner,value) ); CREATE TABLE asset.stat_cat_entry_copy_map ( -- 2.43.2