[open-ils-commits] [GIT] Evergreen ILS branch rel_2_2 updated. b157d6aad28ed25a6f19f95036180d0dab55273c
Evergreen Git
git at git.evergreen-ils.org
Tue Apr 2 09:46:49 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_2 has been updated
via b157d6aad28ed25a6f19f95036180d0dab55273c (commit)
via da5ff02010c1dcff780aa4797dd4fd79c4bc00fc (commit)
from b15cac11c9a1b518cbd2b6a24278b9e8f2ecd4d9 (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 b157d6aad28ed25a6f19f95036180d0dab55273c
Author: Mike Rylander <mrylander at gmail.com>
Date: Tue Apr 2 09:40:07 2013 -0400
stamping upgrade script for authority validation fix
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 59b012c..ab6ee88 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -87,7 +87,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 ('0784', :eg_version); -- Callender/berick
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0787', :eg_version); -- callender/miker
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.authority_normalize_heading.sql b/Open-ILS/src/sql/Pg/upgrade/0787.schema.authority_normalize_heading.sql
similarity index 98%
rename from Open-ILS/src/sql/Pg/upgrade/xxxx.schema.authority_normalize_heading.sql
rename to Open-ILS/src/sql/Pg/upgrade/0787.schema.authority_normalize_heading.sql
index 29b748a..ec324d5 100644
--- a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.authority_normalize_heading.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0787.schema.authority_normalize_heading.sql
@@ -1,6 +1,6 @@
BEGIN;
-INSERT INTO config.upgrade_log (version) VALUES ('xxxx');
+INSERT INTO config.upgrade_log (version) VALUES ('0787');
CREATE OR REPLACE FUNCTION authority.normalize_heading( marcxml TEXT, no_thesaurus BOOL ) RETURNS TEXT AS $func$
DECLARE
commit da5ff02010c1dcff780aa4797dd4fd79c4bc00fc
Author: Steven Callender <stevecallender at esilibrary.com>
Date: Fri Jun 15 13:27:33 2012 -0400
Avoid problems when auth recs are missing the 901c
Fixed the authority.normalize_heading function to better handle
INT's when there is no 901 present. Now we look for the best-fit
control set instead of throwing a db-level error.
Signed-off-by: Steven Callender <stevecallender at esilibrary.com>
Signed-off-by: Mike Rylander <mrylander at gmail.com>
diff --git a/Open-ILS/src/sql/Pg/011.schema.authority.sql b/Open-ILS/src/sql/Pg/011.schema.authority.sql
index 2e4f14a..4ac6b2c 100644
--- a/Open-ILS/src/sql/Pg/011.schema.authority.sql
+++ b/Open-ILS/src/sql/Pg/011.schema.authority.sql
@@ -157,7 +157,7 @@ DECLARE
heading_text TEXT;
tmp_text TEXT;
first_sf BOOL;
- auth_id INT DEFAULT oils_xpath_string('//*[@tag="901"]/*[local-name()="subfield" and @code="c"]', marcxml)::INT;
+ auth_id INT DEFAULT COALESCE(NULLIF(oils_xpath_string('//*[@tag="901"]/*[local-name()="subfield" and @code="c"]', marcxml), ''), '0')::INT;
BEGIN
SELECT control_set INTO cset FROM authority.record_entry WHERE id = auth_id;
diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.authority_normalize_heading.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.authority_normalize_heading.sql
new file mode 100644
index 0000000..29b748a
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.authority_normalize_heading.sql
@@ -0,0 +1,84 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('xxxx');
+
+CREATE OR REPLACE FUNCTION authority.normalize_heading( marcxml TEXT, no_thesaurus BOOL ) RETURNS TEXT AS $func$
+DECLARE
+ acsaf authority.control_set_authority_field%ROWTYPE;
+ tag_used TEXT;
+ nfi_used TEXT;
+ sf TEXT;
+ thes_code TEXT;
+ cset INT;
+ heading_text TEXT;
+ tmp_text TEXT;
+ first_sf BOOL;
+ auth_id INT DEFAULT COALESCE(NULLIF(oils_xpath_string('//*[@tag="901"]/*[local-name()="subfield" and @code="c"]', marcxml), ''), '0')::INT;
+BEGIN
+ SELECT control_set INTO cset FROM authority.record_entry WHERE id = auth_id;
+
+ IF cset IS NULL THEN
+ SELECT control_set INTO cset
+ FROM authority.control_set_authority_field
+ WHERE tag IN ( SELECT UNNEST(XPATH('//*[starts-with(@tag,"1")]/@tag',marcxml::XML)::TEXT[]))
+ LIMIT 1;
+ END IF;
+
+ thes_code := vandelay.marc21_extract_fixed_field(marcxml,'Subj');
+ IF thes_code IS NULL THEN
+ thes_code := '|';
+ ELSIF thes_code = 'z' THEN
+ thes_code := COALESCE( oils_xpath_string('//*[@tag="040"]/*[@code="f"][1]', marcxml), '' );
+ END IF;
+
+ heading_text := '';
+ FOR acsaf IN SELECT * FROM authority.control_set_authority_field WHERE control_set = cset AND main_entry IS NULL LOOP
+ tag_used := acsaf.tag;
+ nfi_used := acsaf.nfi;
+ first_sf := TRUE;
+ FOR sf IN SELECT * FROM regexp_split_to_table(acsaf.sf_list,'') LOOP
+ tmp_text := oils_xpath_string('//*[@tag="'||tag_used||'"]/*[@code="'||sf||'"]', marcxml);
+
+ IF first_sf AND tmp_text IS NOT NULL AND nfi_used IS NOT NULL THEN
+
+ tmp_text := SUBSTRING(
+ tmp_text FROM
+ COALESCE(
+ NULLIF(
+ REGEXP_REPLACE(
+ oils_xpath_string('//*[@tag="'||tag_used||'"]/@ind'||nfi_used, marcxml),
+ $$\D+$$,
+ '',
+ 'g'
+ ),
+ ''
+ )::INT,
+ 0
+ ) + 1
+ );
+
+ END IF;
+
+ first_sf := FALSE;
+
+ IF tmp_text IS NOT NULL AND tmp_text <> '' THEN
+ heading_text := heading_text || E'\u2021' || sf || ' ' || tmp_text;
+ END IF;
+ END LOOP;
+ EXIT WHEN heading_text <> '';
+ END LOOP;
+
+ IF heading_text <> '' THEN
+ IF no_thesaurus IS TRUE THEN
+ heading_text := tag_used || ' ' || public.naco_normalize(heading_text);
+ ELSE
+ heading_text := tag_used || '_' || COALESCE(nfi_used,'-') || '_' || thes_code || ' ' || public.naco_normalize(heading_text);
+ END IF;
+ ELSE
+ heading_text := 'NOHEADING_' || thes_code || ' ' || MD5(marcxml);
+ END IF;
+ RETURN heading_text;
+END;
+$func$ LANGUAGE PLPGSQL IMMUTABLE;
+
+COMMIT;
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/011.schema.authority.sql | 2 +-
.../0787.schema.authority_normalize_heading.sql | 84 ++++++++++++++++++++
3 files changed, 86 insertions(+), 2 deletions(-)
create mode 100644 Open-ILS/src/sql/Pg/upgrade/0787.schema.authority_normalize_heading.sql
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list