Prevent control numbers from duplicating
authorDan Wells <dbw2@calvin.edu>
Thu, 21 Jul 2011 16:14:02 +0000 (12:14 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 28 Jul 2011 16:36:58 +0000 (12:36 -0400)
In maintain_control_numbers(), if you have more than one 001 or
003, and at least one is the correct one, you will end up
duplicating the correct number every time the record is saved.

For example, if the incoming record was record ID # 12345, and
the record contained:

001: 12345
001: ocm10202

... then after maintain_control_numbers() ran, the record would
contain:

001: 12345
001: 12345

Also, clean up some leftovers from the refactor I suggested in the
previous commit.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Dan Scott <dscott@laurentian.ca>

Open-ILS/src/sql/Pg/002.functions.config.sql
Open-ILS/src/sql/Pg/upgrade/xxxx.maintain_control_numbers_with_OCLC_awareness.sql

index fefae05..353c7f2 100644 (file)
@@ -553,9 +553,7 @@ foreach my $id_field ('001', '003') {
     } else {
         # Delete the other fields, as with more than 1 001/003 we do not know which 003/001 to match
         foreach my $control (@controls) {
-            unless ($control->data() eq $spec_value) {
-                $record->delete_field($control);
-            }
+            $record->delete_field($control);
         }
         $record->insert_fields_ordered(MARC::Field->new($id_field, $spec_value));
         $create = 1;
@@ -581,9 +579,6 @@ if ($munge and not $create) {
     unless (grep $_->subfield('a') eq $scn, @scns) {
         $record->insert_fields_ordered(MARC::Field->new('035', '', '', 'a' => $scn));
     }
-
-    # Update the list of SCNs to avoid duplicates
-    @scns = $record->field('035');
 }
 
 # Set the 001/003 and update the MARC
index dd386f0..784744d 100644 (file)
@@ -66,9 +66,7 @@ foreach my $id_field ('001', '003') {
     } else {
         # Delete the other fields, as with more than 1 001/003 we do not know which 003/001 to match
         foreach my $control (@controls) {
-            unless ($control->data() eq $spec_value) {
-                $record->delete_field($control);
-            }
+            $record->delete_field($control);
         }
         $record->insert_fields_ordered(MARC::Field->new($id_field, $spec_value));
         $create = 1;
@@ -94,9 +92,6 @@ if ($munge and not $create) {
     unless (grep $_->subfield('a') eq $scn, @scns) {
         $record->insert_fields_ordered(MARC::Field->new('035', '', '', 'a' => $scn));
     }
-
-    # Update the list of SCNs to avoid duplicates
-    @scns = $record->field('035');
 }
 
 # Set the 001/003 and update the MARC