[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch rel_2_6 updated. 4490f119db724bbf2cffb85957f0482e5a55bcbe

Evergreen Git git at git.evergreen-ils.org
Tue May 20 19:59:30 EDT 2014


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_6 has been updated
       via  4490f119db724bbf2cffb85957f0482e5a55bcbe (commit)
       via  9997e147fcbd09ba4d5a8725a02d0dae8cbb10f2 (commit)
       via  18da138381ef99733da3b8c7b814805e11f52ec8 (commit)
       via  9842029f3d74301c2141dd0e42c0cce9744c5a31 (commit)
       via  e99c01b381de054b0abafcf6d39724fd1555050e (commit)
      from  7cf93166cc5defc55592c454ab728d3485c5581b (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 4490f119db724bbf2cffb85957f0482e5a55bcbe
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Tue May 20 16:48:57 2014 -0700

    LP#1312945: pin schema update
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 9b02560..ba3ac96 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0879', :eg_version); -- dbwells/bshum
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0880', :eg_version); -- miker/sreyseng/gmcharlt
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority.calculate_authority_linking.sql b/Open-ILS/src/sql/Pg/upgrade/0880.function.authority.calculate_authority_linking.sql
similarity index 97%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority.calculate_authority_linking.sql
rename to Open-ILS/src/sql/Pg/upgrade/0880.function.authority.calculate_authority_linking.sql
index 4347aaa..507ceaf 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority.calculate_authority_linking.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0880.function.authority.calculate_authority_linking.sql
@@ -1,6 +1,6 @@
 BEGIN;
 
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0880', :eg_version);
 
 CREATE OR REPLACE FUNCTION authority.calculate_authority_linking(
     rec_id BIGINT, rec_control_set INT, rec_marc_xml XML

commit 9997e147fcbd09ba4d5a8725a02d0dae8cbb10f2
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Tue May 20 16:46:02 2014 -0700

    LP#1312945: add regression test
    
    This adds a test for the change to the
    authority.calculate_authority_linking stored function.
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/t/regress/lp1312945_auth_linking.pg b/Open-ILS/src/sql/Pg/t/regress/lp1312945_auth_linking.pg
new file mode 100644
index 0000000..4ec9b36
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/t/regress/lp1312945_auth_linking.pg
@@ -0,0 +1,59 @@
+BEGIN;
+
+SELECT plan(1);
+
+INSERT INTO authority.record_entry (id, marc, last_xact_id)
+VALUES (999999100, $$<record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21
+/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim">
+    <leader>01601cz  a2200289n  4500</leader>
+    <datafield tag="100" ind1="1" ind2=" ">
+        <subfield code="a">Doe, Jane</subfield>
+    </datafield>
+    <datafield tag="500" ind1="1" ind2=" ">
+        <subfield code="w">nnnc</subfield>
+        <subfield code="a">Alias, Annie</subfield>
+        <subfield code="0">999999101</subfield>
+    </datafield>
+    <datafield tag="500" ind1="1" ind2=" ">
+        <subfield code="w">nnnc</subfield>
+        <subfield code="a">Pen-name, Penny</subfield>
+        <subfield code="0">999999102</subfield>
+    </datafield>
+</record>$$, 'test'),
+(999999101, $$<record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21
+/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim">
+    <leader>01601cz  a2200289n  4500</leader>
+    <datafield tag="100" ind1="1" ind2=" ">
+        <subfield code="a">Alias, Annie</subfield>
+    </datafield>
+    <datafield tag="500" ind1="1" ind2=" ">
+        <subfield code="w">nnnc</subfield>
+        <subfield code="a">Doe, Jane</subfield>
+        <subfield code="0">999999100</subfield>
+    </datafield>
+</record>$$, 'test'),
+(999999102, $$<record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21
+/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim">
+    <leader>01601cz  a2200289n  4500</leader>
+    <datafield tag="100" ind1="1" ind2=" ">
+        <subfield code="a">Pen-name, Penny</subfield>
+    </datafield>
+    <datafield tag="500" ind1="1" ind2=" ">
+        <subfield code="w">nnnc</subfield>
+        <subfield code="a">Doe, Jane</subfield>
+        <subfield code="0">999999100</subfield>
+    </datafield>
+</record>$$, 'test');
+
+SELECT is(
+    ARRAY(
+        SELECT (authority.calculate_authority_linking(id, 1, marc::XML)).target
+        FROM authority.record_entry 
+        WHERE id = 999999100 
+        ORDER BY 1
+    ),
+    ARRAY[ 999999101::BIGINT, 999999102::BIGINT ],
+    'retrieve all of the links to other authority records'
+);
+
+ROLLBACK;

commit 18da138381ef99733da3b8c7b814805e11f52ec8
Author: Mike Rylander <mrylander at gmail.com>
Date:   Wed Apr 30 18:38:29 2014 -0400

    LP#1312945: baseline schema update
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Srey Seng <sreyseng at gmail.com>
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql
index ac20ce7..69b77e2 100644
--- a/Open-ILS/src/sql/Pg/999.functions.global.sql
+++ b/Open-ILS/src/sql/Pg/999.functions.global.sql
@@ -1553,22 +1553,32 @@ BEGIN
             AND linking_subfield IS NOT NULL
             AND main_entry IS NOT NULL
     LOOP
-        link := SUBSTRING(
-            (XPATH('//*[@tag="' || acsaf.tag || '"]/*[@code="' ||
-                acsaf.linking_subfield || '"]/text()', rec_marc_xml))[1]::TEXT,
-            '\d+$'
-        );
+        -- Loop over the trailing-number contents of all linking subfields
+        FOR link IN
+            SELECT  SUBSTRING( x::TEXT, '\d+$' )
+              FROM  UNNEST(
+                        XPATH(
+                            '//*[@tag="'
+                                || acsaf.tag
+                                || '"]/*[@code="'
+                                || acsaf.linking_subfield
+                                || '"]/text()',
+                            rec_marc_xml
+                        )
+                    ) x
+        LOOP
 
-        -- Ignore links that are null, malformed, circular, or point to
-        -- non-existent authority records.
-        IF link IS NOT NULL AND link::BIGINT <> rec_id THEN
-            PERFORM * FROM authority.record_entry WHERE id = link::BIGINT;
-            IF FOUND THEN
-                aal.target := link::BIGINT;
-                aal.field := acsaf.id;
-                RETURN NEXT aal;
+            -- Ignore links that are null, malformed, circular, or point to
+            -- non-existent authority records.
+            IF link IS NOT NULL AND link::BIGINT <> rec_id THEN
+                PERFORM * FROM authority.record_entry WHERE id = link::BIGINT;
+                IF FOUND THEN
+                    aal.target := link::BIGINT;
+                    aal.field := acsaf.id;
+                    RETURN NEXT aal;
+                END IF;
             END IF;
-        END IF;
+        END LOOP;
     END LOOP;
 END;
 $func$ LANGUAGE PLPGSQL;

commit 9842029f3d74301c2141dd0e42c0cce9744c5a31
Author: Srey Seng <sreyseng at gmail.com>
Date:   Wed Apr 30 15:20:17 2014 -0700

    LP#1312945: authority.calculate_authority_linking and multiple linked tags
    
    The function "authority.calculate_authority_linking" was not able to deal with
    situations where there are multiple marc tags that are linkable. The function
    only process the first tag that contains a linking_subfield and returns that
    to be inserted into the authority_linking table, even when there are more than
    one of the same tag with linking_subfield.
    
    Added an additional loop to loop through each tag, for situations where there are
    multiples of each tag.
    
    Signed-off-by: Srey Seng <sreyseng at gmail.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority.calculate_authority_linking.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority.calculate_authority_linking.sql
new file mode 100644
index 0000000..4347aaa
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority.calculate_authority_linking.sql
@@ -0,0 +1,68 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE FUNCTION authority.calculate_authority_linking(
+    rec_id BIGINT, rec_control_set INT, rec_marc_xml XML
+) RETURNS SETOF authority.authority_linking AS $func$
+DECLARE
+    acsaf       authority.control_set_authority_field%ROWTYPE;
+    link        TEXT;
+    aal         authority.authority_linking%ROWTYPE;
+BEGIN
+    IF rec_control_set IS NULL THEN
+        -- No control_set on record?  Guess at one
+        SELECT control_set INTO rec_control_set
+            FROM authority.control_set_authority_field
+            WHERE tag IN (
+                SELECT UNNEST(
+                    XPATH('//*[starts-with(@tag,"1")]/@tag',rec_marc_xml)::TEXT[]
+                )
+            ) LIMIT 1;
+
+        IF NOT FOUND THEN
+            RAISE WARNING 'Could not even guess at control set for authority record %', rec_id;
+            RETURN;
+        END IF;
+    END IF;
+
+    aal.source := rec_id;
+
+    FOR acsaf IN
+        SELECT * FROM authority.control_set_authority_field
+        WHERE control_set = rec_control_set
+            AND linking_subfield IS NOT NULL
+            AND main_entry IS NOT NULL
+    LOOP
+        -- Loop over the trailing-number contents of all linking subfields
+        FOR link IN
+            SELECT  SUBSTRING( x::TEXT, '\d+$' )
+              FROM  UNNEST(
+                        XPATH(
+                            '//*[@tag="'
+                                || acsaf.tag
+                                || '"]/*[@code="'
+                                || acsaf.linking_subfield
+                                || '"]/text()',
+                            rec_marc_xml
+                        )
+                    ) x
+        LOOP
+
+            -- Ignore links that are null, malformed, circular, or point to
+            -- non-existent authority records.
+            IF link IS NOT NULL AND link::BIGINT <> rec_id THEN
+                PERFORM * FROM authority.record_entry WHERE id = link::BIGINT;
+                IF FOUND THEN
+                    aal.target := link::BIGINT;
+                    aal.field := acsaf.id;
+                    RETURN NEXT aal;
+                END IF;
+            END IF;
+        END LOOP;
+    END LOOP;
+END;
+$func$ LANGUAGE PLPGSQL;
+
+COMMIT;
+

commit e99c01b381de054b0abafcf6d39724fd1555050e
Author: Mike Rylander <mrylander at gmail.com>
Date:   Wed Apr 30 12:58:11 2014 -0400

    LP#1312945: auth-auth linking: cache less agressively and look for all links
    
    There was a logic inversion that was causing miss-use of a per-
    record cache mechanism.  I remove that entirely, as it's not helpful
    in practice.
    
    Also, after finding one use of a linked field we moved on to the
    next, though it is possible for more than one link to exist for
    different uses of a name, say.  Now we'll loop through all fields
    to find all possible linkages.
    
    Signed-off-by: Mike Rylander <mrylander at gmail.com>
    Signed-off-by: Srey Seng <sreyseng at gmail.com>
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>

diff --git a/Open-ILS/src/support-scripts/authority_authority_linker.pl.in b/Open-ILS/src/support-scripts/authority_authority_linker.pl.in
index 5f00f2b..d9ba725 100755
--- a/Open-ILS/src/support-scripts/authority_authority_linker.pl.in
+++ b/Open-ILS/src/support-scripts/authority_authority_linker.pl.in
@@ -71,9 +71,10 @@ sub marcxml_eg {
 }
 
 sub matchable_string {
-    my ($field, $sf_list) = @_;
+    my ($field, $sf_list, $joiner) = @_;
+    $joiner ||= ' ';
 
-    return join("", map { $field->subfield($_) } split "", $sf_list);
+    return join($joiner, map { $field->subfield($_) } split "", $sf_list);
 }
 
 # ########### main
@@ -148,19 +149,17 @@ my $problems = 0;
 while (my ($src, $links) = $sth->fetchrow_array) {
     print "src: $src\n" if $options{debug};
 
-    my $per_src_target_cache = {};
     try {
         my $src_rec = $e->retrieve_authority_record_entry($src) or
             die $e->die_event;
         my $src_marc = MARC::Record->new_from_xml($src_rec->marc);
 
-        LINK: for my $link (split ';', $links) {
+        for my $link (split ';', $links) {
             my ($target, $field_id) = split ',', $link;
 
             print "target: $target, field_id: $field_id\n" if $options{debug};
 
-            my $target_rec = ($per_src_target_cache->{$src} ||=
-                $e->retrieve_authority_record_entry($target)) or
+            my $target_rec = $e->retrieve_authority_record_entry($target) or
                     die $e->die_event;
             my $target_marc = MARC::Record->new_from_xml($target_rec->marc);
             my $cni = $target_marc->field('003')->data;
@@ -169,31 +168,31 @@ while (my ($src, $links) = $sth->fetchrow_array) {
 
             for my $field ($src_marc->field($acsaf->tag)) {
                 my $src_string = matchable_string(
-                    $field, $acsaf->main_entry->display_sf_list
+                    $field, $acsaf->main_entry->display_sf_list, $acsaf->main_entry->joiner
                 );
 
                 print("at field ", $acsaf->id, " (", $acsaf->tag,
                     "), trying to match '$src_string'...\n") if $options{debug};
 
-                for my $tfield ($target_marc->field($acsaf->main_entry->tag)) {
-                    my $target_string = matchable_string(
-                        $tfield, $acsaf->main_entry->display_sf_list
-                    );
-
-                    if ($target_string eq $src_string) {
-                        print "got a match ...\n" if $options{debug};
-                        $field->update('0' => "($cni)$target");
-                        $src_rec->marc(marcxml_eg($src_marc->as_xml_record));
-
-                        $e->xact_begin;
-                        $e->update_authority_record_entry($src_rec) or
-                            die $e->die_event;
-                        $e->xact_commit;
-                        next LINK;
-                    }
+                my ($tfield) = $target_marc->field($acsaf->main_entry->tag);
+                my $target_string = matchable_string(
+                    $tfield, $acsaf->main_entry->display_sf_list, $acsaf->main_entry->joiner
+                );
+
+                if ($target_string eq $src_string) {
+                    print "got a match ...\n" if $options{debug};
+                    $field->update('0' => "($cni)$target");
                 }
             }
         }
+
+        $src_rec->marc(marcxml_eg($src_marc->as_xml_record));
+
+        $e->xact_begin;
+        $e->update_authority_record_entry($src_rec) or
+            die $e->die_event;
+        $e->xact_commit;
+
     } otherwise {
         my $err = shift;
         print STDERR "\nRecord # $src : ",

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

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/999.functions.global.sql       |   40 +++++++----
 .../src/sql/Pg/t/regress/lp1312945_auth_linking.pg |   59 +++++++++++++++++
 ...ction.authority.calculate_authority_linking.sql |   68 ++++++++++++++++++++
 .../authority_authority_linker.pl.in               |   45 ++++++-------
 5 files changed, 175 insertions(+), 39 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/t/regress/lp1312945_auth_linking.pg
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0880.function.authority.calculate_authority_linking.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list