[open-ils-commits] [GIT] Evergreen ILS branch master updated. 17948e4788293386ac14b8097df495c034f0a42b

Evergreen Git git at git.evergreen-ils.org
Mon Aug 5 20:48:47 EDT 2019


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, master has been updated
       via  17948e4788293386ac14b8097df495c034f0a42b (commit)
       via  90a14c48e275b32bdf088b98ad41707b464bd939 (commit)
      from  8403ec3095c79df46029ff16de05b39b0bb59a74 (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 17948e4788293386ac14b8097df495c034f0a42b
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Mon Aug 5 20:45:28 2019 -0400

    LP#1722827: stamp DB update
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 242b41e0d2..894f540d46 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -92,7 +92,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 ('1170', :eg_version); -- rhamby/csharp
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1171', :eg_version); -- rhamby/mstroup/gmcharlt
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.metabib.trim_spaces_from_located_uris.sql b/Open-ILS/src/sql/Pg/upgrade/1171.schema.trim_spaces_during_856_9_parsing.sql
similarity index 98%
rename from Open-ILS/src/sql/Pg/upgrade/xxxx.metabib.trim_spaces_from_located_uris.sql
rename to Open-ILS/src/sql/Pg/upgrade/1171.schema.trim_spaces_during_856_9_parsing.sql
index 8eb227b6ac..7de64e2547 100644
--- a/Open-ILS/src/sql/Pg/upgrade/xxxx.metabib.trim_spaces_from_located_uris.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/1171.schema.trim_spaces_during_856_9_parsing.sql
@@ -1,3 +1,7 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1171', :eg_version);
+
 CREATE OR REPLACE FUNCTION biblio.extract_located_uris( bib_id BIGINT, marcxml TEXT, editor_id INT ) RETURNS VOID AS $func$
 DECLARE
     uris            TEXT[];
@@ -109,3 +113,4 @@ BEGIN
 END;
 $func$ LANGUAGE PLPGSQL;
 
+COMMIT;

commit 90a14c48e275b32bdf088b98ad41707b464bd939
Author: Rogan Hamby <rogan.hamby at gmail.com>
Date:   Fri Sep 14 10:48:02 2018 -0400

    LP#1722827: trim spaces from 856$9 when parsing locating URIs
    
    This patch ensures that any leading and trailing spaces
    and non-breaking-spaces in the 856$9 are ignored when
    extracting the org unit shortname. As a consequence,
    extraneous leading/trailing whitespace in the $9 will not
    prevent the located URI from being displayed in the appropriate
    places.
    
    Signed-off-by: Rogan Hamby <rogan.hamby at gmail.com>
    Signed-off-by: Meg Stroup <mstroup at statelibrary.sc.gov>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/sql/Pg/030.schema.metabib.sql b/Open-ILS/src/sql/Pg/030.schema.metabib.sql
index dab8316f78..0c82fc89d9 100644
--- a/Open-ILS/src/sql/Pg/030.schema.metabib.sql
+++ b/Open-ILS/src/sql/Pg/030.schema.metabib.sql
@@ -1470,7 +1470,7 @@ BEGIN
                 FOR j IN 1 .. ARRAY_UPPER(uri_owner_list, 1) LOOP
                     uri_owner := uri_owner_list[j];
 
-                    SELECT id INTO uri_owner_id FROM actor.org_unit WHERE shortname = uri_owner;
+                    SELECT id INTO uri_owner_id FROM actor.org_unit WHERE shortname = BTRIM(REPLACE(uri_owner,chr(160),''));
                     CONTINUE WHEN NOT FOUND;
 
                     -- we need a call number to link through
diff --git a/Open-ILS/src/sql/Pg/t/lp1722827_trim_spaces_from_located_uris.pg b/Open-ILS/src/sql/Pg/t/lp1722827_trim_spaces_from_located_uris.pg
new file mode 100644
index 0000000000..11c2fb9774
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/t/lp1722827_trim_spaces_from_located_uris.pg
@@ -0,0 +1,35 @@
+BEGIN;
+
+SELECT plan(4);
+
+SELECT is(
+	(SELECT COUNT(id) FROM asset.call_number WHERE record = 248 AND label = '##URI##')::INTEGER,
+	0::INTEGER,
+	'no URI added to bib yet so count should be 0'
+);
+
+UPDATE biblio.record_entry SET marc = REPLACE(marc,'</record>','<datafield tag="856" ind1="4" ind2="0"><subfield code="u">http://evergreen-ils.org</subfield><subfield code="9">CONS</subfield></datafield></record>') WHERE id = 248;
+
+SELECT is(
+	(SELECT COUNT(id) FROM asset.call_number WHERE record = 248 AND deleted = FALSE AND label = '##URI##')::INTEGER,
+	1::INTEGER,
+	'normally valid URI added without spaces should have 1'
+);
+
+UPDATE biblio.record_entry SET marc = REPLACE(marc,'<subfield code="9">CONS</subfield>','<subfield code="9">' || chr(160) || 'CONS </subfield>') WHERE id = 248;
+
+SELECT is (
+	(SELECT COUNT(id) FROM asset.call_number WHERE record = 248 AND deleted = FALSE AND label = '##URI##')::INTEGER,
+	1::INTEGER,
+	'part 1/2 test for URI creation with spaces, new one should exist despite spaces being added'
+);
+
+SELECT is (
+	(SELECT COUNT(id) FROM asset.call_number WHERE record = 248 AND deleted = TRUE AND label = '##URI##')::INTEGER,
+	1::INTEGER,
+	'part 2/2 test for URI creation with spaces, old URI tag should be deleted now'
+);
+
+SELECT * FROM finish();
+ROLLBACK;
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.metabib.trim_spaces_from_located_uris.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.metabib.trim_spaces_from_located_uris.sql
new file mode 100644
index 0000000000..8eb227b6ac
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.metabib.trim_spaces_from_located_uris.sql
@@ -0,0 +1,111 @@
+CREATE OR REPLACE FUNCTION biblio.extract_located_uris( bib_id BIGINT, marcxml TEXT, editor_id INT ) RETURNS VOID AS $func$
+DECLARE
+    uris            TEXT[];
+    uri_xml         TEXT;
+    uri_label       TEXT;
+    uri_href        TEXT;
+    uri_use         TEXT;
+    uri_owner_list  TEXT[];
+    uri_owner       TEXT;
+    uri_owner_id    INT;
+    uri_id          INT;
+    uri_cn_id       INT;
+    uri_map_id      INT;
+BEGIN
+
+    -- Clear any URI mappings and call numbers for this bib.
+    -- This leads to acn / auricnm inflation, but also enables
+    -- old acn/auricnm's to go away and for bibs to be deleted.
+    FOR uri_cn_id IN SELECT id FROM asset.call_number WHERE record = bib_id AND label = '##URI##' AND NOT deleted LOOP
+        DELETE FROM asset.uri_call_number_map WHERE call_number = uri_cn_id;
+        DELETE FROM asset.call_number WHERE id = uri_cn_id;
+    END LOOP;
+
+    uris := oils_xpath('//*[@tag="856" and (@ind1="4" or @ind1="1") and (@ind2="0" or @ind2="1")]',marcxml);
+    IF ARRAY_UPPER(uris,1) > 0 THEN
+        FOR i IN 1 .. ARRAY_UPPER(uris, 1) LOOP
+            -- First we pull info out of the 856
+            uri_xml     := uris[i];
+
+            uri_href    := (oils_xpath('//*[@code="u"]/text()',uri_xml))[1];
+            uri_label   := (oils_xpath('//*[@code="y"]/text()|//*[@code="3"]/text()',uri_xml))[1];
+            uri_use     := (oils_xpath('//*[@code="z"]/text()|//*[@code="2"]/text()|//*[@code="n"]/text()',uri_xml))[1];
+
+            IF uri_label IS NULL THEN
+                uri_label := uri_href;
+            END IF;
+            CONTINUE WHEN uri_href IS NULL;
+
+            -- Get the distinct list of libraries wanting to use 
+            SELECT  ARRAY_AGG(
+                        DISTINCT REGEXP_REPLACE(
+                            x,
+                            $re$^.*?\((\w+)\).*$$re$,
+                            E'\\1'
+                        )
+                    ) INTO uri_owner_list
+              FROM  UNNEST(
+                        oils_xpath(
+                            '//*[@code="9"]/text()|//*[@code="w"]/text()|//*[@code="n"]/text()',
+                            uri_xml
+                        )
+                    )x;
+
+            IF ARRAY_UPPER(uri_owner_list,1) > 0 THEN
+
+                -- look for a matching uri
+                IF uri_use IS NULL THEN
+                    SELECT id INTO uri_id
+                        FROM asset.uri
+                        WHERE label = uri_label AND href = uri_href AND use_restriction IS NULL AND active
+                        ORDER BY id LIMIT 1;
+                    IF NOT FOUND THEN -- create one
+                        INSERT INTO asset.uri (label, href, use_restriction) VALUES (uri_label, uri_href, uri_use);
+                        SELECT id INTO uri_id
+                            FROM asset.uri
+                            WHERE label = uri_label AND href = uri_href AND use_restriction IS NULL AND active;
+                    END IF;
+                ELSE
+                    SELECT id INTO uri_id
+                        FROM asset.uri
+                        WHERE label = uri_label AND href = uri_href AND use_restriction = uri_use AND active
+                        ORDER BY id LIMIT 1;
+                    IF NOT FOUND THEN -- create one
+                        INSERT INTO asset.uri (label, href, use_restriction) VALUES (uri_label, uri_href, uri_use);
+                        SELECT id INTO uri_id
+                            FROM asset.uri
+                            WHERE label = uri_label AND href = uri_href AND use_restriction = uri_use AND active;
+                    END IF;
+                END IF;
+
+                FOR j IN 1 .. ARRAY_UPPER(uri_owner_list, 1) LOOP
+                    uri_owner := uri_owner_list[j];
+
+                    SELECT id INTO uri_owner_id FROM actor.org_unit WHERE shortname = BTRIM(REPLACE(uri_owner,chr(160),''));
+                    CONTINUE WHEN NOT FOUND;
+
+                    -- we need a call number to link through
+                    SELECT id INTO uri_cn_id FROM asset.call_number WHERE owning_lib = uri_owner_id AND record = bib_id AND label = '##URI##' AND NOT deleted;
+                    IF NOT FOUND THEN
+                        INSERT INTO asset.call_number (owning_lib, record, create_date, edit_date, creator, editor, label)
+                            VALUES (uri_owner_id, bib_id, 'now', 'now', editor_id, editor_id, '##URI##');
+                        SELECT id INTO uri_cn_id FROM asset.call_number WHERE owning_lib = uri_owner_id AND record = bib_id AND label = '##URI##' AND NOT deleted;
+                    END IF;
+
+                    -- now, link them if they're not already
+                    SELECT id INTO uri_map_id FROM asset.uri_call_number_map WHERE call_number = uri_cn_id AND uri = uri_id;
+                    IF NOT FOUND THEN
+                        INSERT INTO asset.uri_call_number_map (call_number, uri) VALUES (uri_cn_id, uri_id);
+                    END IF;
+
+                END LOOP;
+
+            END IF;
+
+        END LOOP;
+    END IF;
+
+    RETURN;
+END;
+$func$ LANGUAGE PLPGSQL;
+

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

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |  2 +-
 Open-ILS/src/sql/Pg/030.schema.metabib.sql         |  2 +-
 .../t/lp1722827_trim_spaces_from_located_uris.pg   | 35 ++++++++++++++++
 ...71.schema.trim_spaces_during_856_9_parsing.sql} | 47 ++--------------------
 4 files changed, 40 insertions(+), 46 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/t/lp1722827_trim_spaces_from_located_uris.pg
 copy Open-ILS/src/sql/Pg/upgrade/{0559.schema.biblio.extract_located_uris.sql => 1171.schema.trim_spaces_during_856_9_parsing.sql} (75%)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list