[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch rel_2_4 updated. e54bbbbe0c0462cbb07612f16b6c92c015ba47e4

Evergreen Git git at git.evergreen-ils.org
Fri Nov 1 16:18:48 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_4 has been updated
       via  e54bbbbe0c0462cbb07612f16b6c92c015ba47e4 (commit)
       via  cbff8b11d02118cbb0be74549eb1e2331e9b0a8f (commit)
      from  f0e75d70147afc087af0d63a3f70163a409971c5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e54bbbbe0c0462cbb07612f16b6c92c015ba47e4
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Oct 29 12:15:56 2013 -0400

    Add --refresh mode to completely rewrite linking
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Dan Wells <dbw2 at calvin.edu>

diff --git a/Open-ILS/src/support-scripts/authority_control_fields.pl.in b/Open-ILS/src/support-scripts/authority_control_fields.pl.in
index 046589e..963af19 100755
--- a/Open-ILS/src/support-scripts/authority_control_fields.pl.in
+++ b/Open-ILS/src/support-scripts/authority_control_fields.pl.in
@@ -32,7 +32,7 @@ use Pod::Usage qw/ pod2usage /;
 
 MARC::Charset->assume_unicode(1);
 
-my ($start_id, $end_id);
+my ($start_id, $end_id, $refresh);
 my ($days_back);
 my $bootstrap = '@sysconfdir@/opensrf_core.xml';
 my @records;
@@ -42,6 +42,7 @@ my $result = GetOptions(
     \%options,
     'configuration=s' => \$bootstrap,
     'record=i' => \@records,
+    'refresh' => \$refresh,
     'all', 'help',
     'start_id=i' => \$start_id,
     'end_id=i' => \$end_id,
@@ -384,7 +385,7 @@ foreach my $rec_id (@records) {
     # print "$rec_id\n";
 
     # State variable; was the record changed?
-    my $changed;
+    my $changed = 0;
 
     # get the record
     my $record = $e->retrieve_biblio_record_entry($rec_id);
@@ -406,6 +407,12 @@ foreach my $rec_id (@records) {
             my @bib_fields = ($marc->field($c_tag));
             foreach my $bib_field (@bib_fields) {
                 # print $_->as_formatted(); 
+
+                if ($refresh and defined(scalar($bib_field->subfield('0')))) {
+                    $bib_field->delete_subfield(code => '0');
+                    $changed = 1;
+                }
+                    
                 my %match_subfields;
                 my $match_tag;
                 my @searches;
@@ -442,29 +449,30 @@ foreach my $rec_id (@records) {
                 # Protect against failed (error condition) search request
                 if (!$validates) {
                     print STDERR "Search for matching authority failed; record # $rec_id\n";
-                    next;
+                    next if (!$changed);
                 }
 
-                if (scalar(@$validates) == 0) {
-                    next;
-                }
+                # Only add linking if one or more was found, but we may have changed
+                # the record already if in --refresh mode.
+                if (scalar(@$validates) > 0) {
 
-                # Iterate through the returned authority record IDs to delete any
-                # matching $0 subfields already in the bib record
-                foreach my $auth_zero (@$validates) {
-                    $bib_field->delete_subfield(code => '0', match => qr/\)$auth_zero$/);
+                    # Iterate through the returned authority record IDs to delete any
+                    # matching $0 subfields already in the bib record
+                    foreach my $auth_zero (@$validates) {
+                        $bib_field->delete_subfield(code => '0', match => qr/\)$auth_zero$/);
+                    }
+    
+                    # Okay, we have a matching authority control; time to
+                    # add the magical subfield 0. Use the first returned auth
+                    # record as a match.
+                    my $auth_id = @$validates[0];
+                    my $auth_rec = $e->retrieve_authority_record_entry($auth_id);
+                    my $auth_marc = MARC::Record->new_from_xml($auth_rec->marc());
+                    my $cni = $auth_marc->field('003')->data();
+                    
+                    $bib_field->add_subfields('0' => "($cni)$auth_id");
+                    $changed = 1;
                 }
-
-                # Okay, we have a matching authority control; time to
-                # add the magical subfield 0. Use the first returned auth
-                # record as a match.
-                my $auth_id = @$validates[0];
-                my $auth_rec = $e->retrieve_authority_record_entry($auth_id);
-                my $auth_marc = MARC::Record->new_from_xml($auth_rec->marc());
-                my $cni = $auth_marc->field('003')->data();
-                
-                $bib_field->add_subfields('0' => "($cni)$auth_id");
-                $changed = 1;
             }
         }
         if ($changed) {
@@ -496,7 +504,7 @@ authority_control_fields.pl - Controls fields in bibliographic records with auth
 
 =head1 SYNOPSIS
 
-C<authority_control_fields.pl> [B<--configuration>=I<opensrf_core.conf>]
+C<authority_control_fields.pl> [B<--configuration>=I<opensrf_core.conf>] [B<--refresh>]
 [[B<--record>=I<record>[ B<--record>=I<record>]]] | [B<--all>] | [B<--start_id>=I<start-ID> B<--end_id>=I<end-ID>]
 
 =head1 DESCRIPTION
@@ -559,6 +567,12 @@ to process multiple records in a single run.
 Specifies that all bibliographic records should be processed. For large
 databases, this may take an extraordinarily long amount of time.
 
+=item * B<-r>, B<--refresh>
+
+Specifies that all authority links should be removed from the target
+bibliographic record(s).  This will effectively rewrite all authority
+linking anew.
+
 =item * B<-s> I<start-ID>, B<--start_id>=I<start-ID>
 
 Specifies the starting ID of the range of bibliographic records to process.

commit cbff8b11d02118cbb0be74549eb1e2331e9b0a8f
Author: Mike Rylander <mrylander at gmail.com>
Date:   Tue Oct 29 11:37:36 2013 -0400

    Use all subfield values to link authority records to bibs
    
    Given an Evergreen instance with two authority records loaded, one
    being a more specific than the other via a repeated subdivision subfield,
    we must make sure that we use all the bib-supplied subfield values when
    attempting to auto-link to the correct authority.  Otherwise, the "shorter"
    authority record may be selected as appropriate, and data in the bib record
    would be lost.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Dan Wells <dbw2 at calvin.edu>

diff --git a/Open-ILS/src/support-scripts/authority_control_fields.pl.in b/Open-ILS/src/support-scripts/authority_control_fields.pl.in
index 83f7db2..046589e 100755
--- a/Open-ILS/src/support-scripts/authority_control_fields.pl.in
+++ b/Open-ILS/src/support-scripts/authority_control_fields.pl.in
@@ -410,14 +410,14 @@ foreach my $rec_id (@records) {
                 my $match_tag;
                 my @searches;
                 foreach my $c_subfield (@c_subfields) {
-                    my $sf = $bib_field->subfield($c_subfield);
-                    if ($sf) {
+                    my @sf_values = $bib_field->subfield($c_subfield);
+                    if (@sf_values) {
                         # Give me the first element of the list of authority controlling tags for this subfield
                         # XXX Will we need to support more than one controlling tag per subfield? Probably. That
                         # will suck. Oh well, leave that up to Ole to implement.
                         $match_subfields{$c_subfield} = (keys %{$controllees{$c_tag}{$c_subfield}})[0];
                         $match_tag = $match_subfields{$c_subfield};
-                        push @searches, {term => $sf, subfield => $c_subfield};
+                        push @searches, map {{term => $_, subfield => $c_subfield}} @sf_values;
                     }
                 }
                 # print Dumper(\%match_subfields);

-----------------------------------------------------------------------

Summary of changes:
 .../support-scripts/authority_control_fields.pl.in |   64 ++++++++++++--------
 1 files changed, 39 insertions(+), 25 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list