Prevent control numbers from duplicating collab/dbwells/oclcnumbers
authorDan Wells <dbw2@calvin.edu>
Thu, 21 Jul 2011 16:14:02 +0000 (12:14 -0400)
committerDan Wells <dbw2@calvin.edu>
Thu, 21 Jul 2011 16:14:02 +0000 (12:14 -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.

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

Signed-off-by: Dan Wells <dbw2@calvin.edu>
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