From: dbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Wed, 15 Sep 2010 20:04:55 +0000 (+0000)
Subject: Drop arn_value and arn_source from the authority.record_entry table
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f9176c060d7f718bfd81d2574647db21f8429e4e;p=evergreen%2Fmasslnc.git

Drop arn_value and arn_source from the authority.record_entry table

Now that we have the unique index by thesaurus on actual headings, arn_value
and arn_source are a dead weight that we can gleefully toss overboard.

Tested with authority record import via Vandelay and authority record
creation during bibliographic editing; confirmed that validating authorities
still works, no apparent visible difference to the world.


git-svn-id: svn://svn.open-ils.org/ILS/trunk@17706 dcc99617-32d9-48b4-a31d-7c20da2025e4
---

diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml
index eca8ba3e18..0c00fda8e4 100644
--- a/Open-ILS/examples/fm_IDL.xml
+++ b/Open-ILS/examples/fm_IDL.xml
@@ -1401,8 +1401,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 	<class id="are" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="authority::record_entry" oils_persist:tablename="authority.record_entry" reporter:label="Authority Record Entry">
 		<fields oils_persist:primary="id" oils_persist:sequence="authority.record_entry_id_seq">
 			<field name="active" reporter:datatype="bool"/>
-			<field name="arn_source" />
-			<field name="arn_value" />
 			<field name="create_date" reporter:datatype="timestamp"/>
 			<field name="creator" />
 			<field name="deleted" reporter:datatype="bool"/>
diff --git a/Open-ILS/src/extras/import/marc2are.pl b/Open-ILS/src/extras/import/marc2are.pl
index 5da337c460..1eb86d43cf 100755
--- a/Open-ILS/src/extras/import/marc2are.pl
+++ b/Open-ILS/src/extras/import/marc2are.pl
@@ -61,9 +61,6 @@ my $rec;
 while ( try { $rec = $batch->next } otherwise { $rec = -1 } ) {
 	next if ($rec == -1);
 	my $id = $count;
-	my $_001 = $rec->field('001');
-	my $arn = $count;
-	$arn = $_001->data if ($_001);
 
 	(my $xml = $rec->as_xml_record()) =~ s/\n//sog;
 	$xml =~ s/^<\?xml.+\?\s*>//go;
@@ -81,8 +78,6 @@ while ( try { $rec = $batch->next } otherwise { $rec = -1 } ) {
 	$bib->create_date('now');
 	$bib->editor($user);
 	$bib->edit_date('now');
-	$bib->arn_source('LEGACY');
-	$bib->arn_value($arn);
 	$bib->last_xact_id('IMPORT-'.$starttime);
 
 	print OpenSRF::Utils::JSON->perl2JSON($bib)."\n";
diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm
index a00dc5c169..a8ef1f0bcb 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat/AuthCommon.pm
@@ -36,10 +36,6 @@ sub import_authority_record {
 	$rec->edit_date('now');
 	$rec->marc($U->entityize($marc_doc->documentElement->toString));
 
-    my ($arn, $evt) = find_arn($e, $marc_doc);
-    return $evt if $evt;
-    $rec->arn_value($arn);
-
     $rec = $e->create_authority_record_entry($rec) or return $e->die_event;
 
     # we don't care about the result, just fire off the request
@@ -68,24 +64,4 @@ sub overlay_authority_record {
 	return $rec;
 }
 
-sub find_arn {
-    my($e, $marc_doc) = @_;
-
-    my $xpath = '//marc:controlfield[@tag="001"]';
-    my ($arn) = $marc_doc->documentElement->findvalue($xpath);
-
-    if(my $existing_rec = $e->search_authority_record_entry({arn_value => $arn, deleted => 'f'})->[0]) {
-        # this arn is taken
-        return (
-            undef, 
-            OpenILS::Event->new(
-                'AUTHORITY_RECORD_NUMBER_EXISTS', 
-                payload => {existing_record => $existing_rec, arn => $arn}
-            )
-        );
-    }
-
-    return ($arn);
-}
-
 1;
diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/authority.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/authority.pm
index a30f789a27..64a035032c 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/authority.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/authority.pm
@@ -10,7 +10,7 @@ use base qw/authority/;
 
 authority::record_entry->table( 'authority_record_entry' );
 authority::record_entry->columns( Primary => qw/id/ );
-authority::record_entry->columns( Essential => qw/arn_source arn_value creator editor
+authority::record_entry->columns( Essential => qw/creator editor
 				      create_date edit_date source active
 				      deleted marc last_xact_id/ );
 
diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm b/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm
index 56d59ba8ce..8234d1cfeb 100644
--- a/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm
+++ b/Open-ILS/src/perlmods/OpenILS/WWW/Exporter.pm
@@ -114,11 +114,6 @@ sub handler {
 	my $tcn_v = 'tcn_value';
 	my $tcn_s = 'tcn_source';
 
-	if ($type eq 'authority') {
-		$tcn_v = 'arn_value';
-		$tcn_s = 'arn_source';
-	}
-
 	my $holdings = $cgi->param('holdings') if ($type eq 'biblio');
 	my $location = $cgi->param('location') || 'gaaagpl'; # just because...
 
diff --git a/Open-ILS/src/sql/Pg/002.functions.config.sql b/Open-ILS/src/sql/Pg/002.functions.config.sql
index 54e2cfb4e6..6b43ceb4b3 100644
--- a/Open-ILS/src/sql/Pg/002.functions.config.sql
+++ b/Open-ILS/src/sql/Pg/002.functions.config.sql
@@ -437,8 +437,6 @@ BEGIN
             NEW.marc,
             E'(</(?:[^:]*?:)?record>)',
             E'<datafield tag="901" ind1=" " ind2=" ">' ||
-                '<subfield code="a">' || NEW.arn_value || E'</subfield>' ||
-                '<subfield code="b">' || NEW.arn_source || E'</subfield>' ||
                 '<subfield code="c">' || NEW.id || E'</subfield>' ||
                 '<subfield code="t">' || TG_TABLE_SCHEMA || E'</subfield>' ||
              E'</datafield>\\1'
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 7a23e09cc9..07c44e7428 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -68,7 +68,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0400'); -- dbs
+INSERT INTO config.upgrade_log (version) VALUES ('0401'); -- dbs
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/011.schema.authority.sql b/Open-ILS/src/sql/Pg/011.schema.authority.sql
index 0f777dc08d..480a429c2a 100644
--- a/Open-ILS/src/sql/Pg/011.schema.authority.sql
+++ b/Open-ILS/src/sql/Pg/011.schema.authority.sql
@@ -24,8 +24,6 @@ CREATE SCHEMA authority;
 
 CREATE TABLE authority.record_entry (
 	id		BIGSERIAL	PRIMARY KEY,
-	arn_source	TEXT		NOT NULL DEFAULT 'AUTOGEN',
-	arn_value	TEXT		NOT NULL,
 	creator		INT		NOT NULL DEFAULT 1,
 	editor		INT		NOT NULL DEFAULT 1,
 	create_date	TIMESTAMP WITH TIME ZONE	NOT NULL DEFAULT now(),
@@ -39,7 +37,6 @@ CREATE TABLE authority.record_entry (
 );
 CREATE INDEX authority_record_entry_creator_idx ON authority.record_entry ( creator );
 CREATE INDEX authority_record_entry_editor_idx ON authority.record_entry ( editor );
-CREATE UNIQUE INDEX authority_record_unique_tcn ON authority.record_entry (arn_source,arn_value) WHERE deleted = FALSE OR deleted IS FALSE;
 CREATE TRIGGER a_marcxml_is_well_formed BEFORE INSERT OR UPDATE ON authority.record_entry FOR EACH ROW EXECUTE PROCEDURE biblio.check_marcxml_well_formed();
 CREATE TRIGGER b_maintain_901 BEFORE INSERT OR UPDATE ON authority.record_entry FOR EACH ROW EXECUTE PROCEDURE maintain_901();
 CREATE TRIGGER c_maintain_control_numbers BEFORE INSERT OR UPDATE ON authority.record_entry FOR EACH ROW EXECUTE PROCEDURE maintain_control_numbers();
diff --git a/Open-ILS/src/sql/Pg/upgrade/0401.schema.authority_record_entry_drop_arn.sql b/Open-ILS/src/sql/Pg/upgrade/0401.schema.authority_record_entry_drop_arn.sql
new file mode 100644
index 0000000000..61d9871879
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0401.schema.authority_record_entry_drop_arn.sql
@@ -0,0 +1,9 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0401'); -- dbs
+
+DROP INDEX authority.authority_record_unique_tcn;
+ALTER TABLE authority.record_entry DROP COLUMN arn_value;
+ALTER TABLE authority.record_entry DROP COLUMN arn_source;
+
+COMMIT;
diff --git a/Open-ILS/xul/staff_client/server/cat/marcedit.js b/Open-ILS/xul/staff_client/server/cat/marcedit.js
index abde13bdf4..6c68fcdd92 100644
--- a/Open-ILS/xul/staff_client/server/cat/marcedit.js
+++ b/Open-ILS/xul/staff_client/server/cat/marcedit.js
@@ -2575,9 +2575,9 @@ function loadMarcEditor(pcrud, marcxml) {
     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
     win = window.open('/xul/server/cat/marcedit.xul'); // XXX version?
 
-    /* Ugly hack to satisfy arn_value and last_xact_id db schema reqs */
+    // Match marc2are.pl last_xact_id format, roughly
     var now = new Date;
-    var arn = 'AUTOGEN' + Date.parse(now);
+    var xact_id = 'IMPORT-' + Date.parse(now);
     
     win.xulG = {
         "record": {"marc": marcxml, "rtype": "are"},
@@ -2586,8 +2586,7 @@ function loadMarcEditor(pcrud, marcxml) {
             "func": function(xmlString) {
                 var rec = new are();
                 rec.marc(xmlString);
-                rec.arn_value(arn);
-                rec.last_xact_id(arn);
+                rec.last_xact_id(xact_id);
                 rec.isnew(true);
                 pcrud.create(rec, {
                     "oncomplete": function () {