[open-ils-commits] [GIT] Evergreen ILS branch master updated. 4cfa942dab61505927d2ebb996ec3a385fc96064
Evergreen Git
git at git.evergreen-ils.org
Tue Jul 9 11:52:30 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, master has been updated
via 4cfa942dab61505927d2ebb996ec3a385fc96064 (commit)
via 333c1b847552f1682ba856c9608e2e0b3db40fdf (commit)
via 4307f5d7377906100b7fbc55f3f2344e778d0c59 (commit)
from f6c06a2e370281680d35f3094f09b05a6ca0d56b (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 4cfa942dab61505927d2ebb996ec3a385fc96064
Author: Dan Wells <dbw2 at calvin.edu>
Date: Tue Jul 9 11:46:31 2013 -0400
Stamping upgrade script for file-order authority subfields
And fixing a small typo.
Signed-off-by: Dan Wells <dbw2 at calvin.edu>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index adf0b23..89e5232 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 ('0801', :eg_version); -- tsbere/paxed/bshum
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0802', :eg_version); -- miker/ysuarez/dbwells
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority-sf-file-order.sql b/Open-ILS/src/sql/Pg/upgrade/0802.function.authority-sf-file-order.sql
similarity index 96%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority-sf-file-order.sql
rename to Open-ILS/src/sql/Pg/upgrade/0802.function.authority-sf-file-order.sql
index f370008..b38b622 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority-sf-file-order.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0802.function.authority-sf-file-order.sql
@@ -1,6 +1,6 @@
BEGIN;
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0802', :eg_version);
CREATE OR REPLACE FUNCTION authority.normalize_heading( marcxml TEXT, no_thesaurus BOOL ) RETURNS TEXT AS $func$
DECLARE
@@ -92,7 +92,7 @@ BEGIN
END;
$func$ LANGUAGE PLPGSQL IMMUTABLE;
-REATE OR REPLACE FUNCTION authority.simple_heading_set( marcxml TEXT ) RETURNS SETOF authority.simple_heading AS $func$
+CREATE OR REPLACE FUNCTION authority.simple_heading_set( marcxml TEXT ) RETURNS SETOF authority.simple_heading AS $func$
DECLARE
res authority.simple_heading%ROWTYPE;
acsaf authority.control_set_authority_field%ROWTYPE;
commit 333c1b847552f1682ba856c9608e2e0b3db40fdf
Author: Mike Rylander <mrylander at gmail.com>
Date: Tue Jul 9 10:09:39 2013 -0400
Upgrade script for file-order authority subfields
Signed-off-by: Mike Rylander <mrylander at gmail.com>
Signed-off-by: Dan Wells <dbw2 at calvin.edu>
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority-sf-file-order.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority-sf-file-order.sql
new file mode 100644
index 0000000..f370008
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.authority-sf-file-order.sql
@@ -0,0 +1,170 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('XXXX', :eg_version);
+
+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;
+ sf_node TEXT;
+ tag_node 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 tag_node IN SELECT unnest(oils_xpath('//*[@tag="'||tag_used||'"]',marcxml)) LOOP
+ FOR sf_node IN SELECT unnest(oils_xpath('//*[contains("'||acsaf.sf_list||'", at code)]',tag_node)) LOOP
+
+ tmp_text := oils_xpath_string('.', sf_node);
+ sf := oils_xpath_string('./@code', sf_node);
+
+ 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('./@ind'||nfi_used, tag_node),
+ $$\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;
+
+ 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;
+
+REATE OR REPLACE FUNCTION authority.simple_heading_set( marcxml TEXT ) RETURNS SETOF authority.simple_heading AS $func$
+DECLARE
+ res authority.simple_heading%ROWTYPE;
+ acsaf authority.control_set_authority_field%ROWTYPE;
+ tag_used TEXT;
+ nfi_used TEXT;
+ sf TEXT;
+ cset INT;
+ heading_text TEXT;
+ sort_text TEXT;
+ tmp_text TEXT;
+ tmp_xml TEXT;
+ first_sf BOOL;
+ auth_id INT DEFAULT oils_xpath_string('//*[@tag="901"]/*[local-name()="subfield" and @code="c"]', marcxml)::INT;
+BEGIN
+
+ res.record := auth_id;
+
+ 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;
+
+ FOR acsaf IN SELECT * FROM authority.control_set_authority_field WHERE control_set = cset LOOP
+
+ res.atag := acsaf.id;
+ tag_used := acsaf.tag;
+ nfi_used := acsaf.nfi;
+
+ FOR tmp_xml IN SELECT UNNEST(XPATH('//*[@tag="'||tag_used||'"]', marcxml::XML)) LOOP
+
+ heading_text := public.naco_normalize(
+ COALESCE(
+ oils_xpath_string('//*[contains("'||acsaf.sf_list||'", at code)]',tmp_xml::TEXT, ' '),
+ ''
+ )
+ );
+
+ IF nfi_used IS NOT NULL THEN
+
+ sort_text := SUBSTRING(
+ heading_text FROM
+ COALESCE(
+ NULLIF(
+ REGEXP_REPLACE(
+ oils_xpath_string('./@ind'||nfi_used, tmp_xml::TEXT),
+ $$\D+$$,
+ '',
+ 'g'
+ ),
+ ''
+ )::INT,
+ 0
+ ) + 1
+ );
+
+ ELSE
+ sort_text := heading_text;
+ END IF;
+
+ IF heading_text IS NOT NULL AND heading_text <> '' THEN
+ res.value := heading_text;
+ res.sort_value := sort_text;
+ RETURN NEXT res;
+ END IF;
+
+ END LOOP;
+
+ END LOOP;
+
+ RETURN;
+END;
+$func$ LANGUAGE PLPGSQL IMMUTABLE;
+
+COMMIT;
+
commit 4307f5d7377906100b7fbc55f3f2344e778d0c59
Author: Mike Rylander <mrylander at gmail.com>
Date: Tue Jun 25 10:03:36 2013 -0400
Preserve record order of subfields for authority heading extraction
When extracting headings from authority records we currently read the
subfields of a tag in configuration order. We should, instead, read
them in record order, to preserve the desired sorting properties that
the cataloger has encoded in the record.
Signed-off-by: Mike Rylander <mrylander at gmail.com>
Signed-off-by: Yamil Suarez <yamil at yamil.com>
diff --git a/Open-ILS/src/sql/Pg/011.schema.authority.sql b/Open-ILS/src/sql/Pg/011.schema.authority.sql
index 4ac6b2c..0d0e308 100644
--- a/Open-ILS/src/sql/Pg/011.schema.authority.sql
+++ b/Open-ILS/src/sql/Pg/011.schema.authority.sql
@@ -152,6 +152,8 @@ DECLARE
tag_used TEXT;
nfi_used TEXT;
sf TEXT;
+ sf_node TEXT;
+ tag_node TEXT;
thes_code TEXT;
cset INT;
heading_text TEXT;
@@ -180,35 +182,43 @@ BEGIN
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;
+ FOR tag_node IN SELECT unnest(oils_xpath('//*[@tag="'||tag_used||'"]',marcxml)) LOOP
+ FOR sf_node IN SELECT unnest(oils_xpath('//*[contains("'||acsaf.sf_list||'", at code)]',tag_node)) LOOP
+
+ tmp_text := oils_xpath_string('.', sf_node);
+ sf := oils_xpath_string('./@code', sf_node);
+
+ 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('./@ind'||nfi_used, tag_node),
+ $$\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;
- IF tmp_text IS NOT NULL AND tmp_text <> '' THEN
- heading_text := heading_text || E'\u2021' || sf || ' ' || tmp_text;
- END IF;
+ EXIT WHEN heading_text <> '';
END LOOP;
+
EXIT WHEN heading_text <> '';
END LOOP;
@@ -272,13 +282,13 @@ BEGIN
nfi_used := acsaf.nfi;
FOR tmp_xml IN SELECT UNNEST(XPATH('//*[@tag="'||tag_used||'"]', marcxml::XML)) LOOP
- heading_text := '';
- FOR sf IN SELECT * FROM regexp_split_to_table(acsaf.sf_list,'') LOOP
- heading_text := heading_text || COALESCE( ' ' || oils_xpath_string('//*[@code="'||sf||'"]',tmp_xml::TEXT), '');
- END LOOP;
-
- heading_text := public.naco_normalize(heading_text);
+ heading_text := public.naco_normalize(
+ COALESCE(
+ oils_xpath_string('//*[contains("'||acsaf.sf_list||'", at code)]',tmp_xml::TEXT, ' '),
+ ''
+ )
+ );
IF nfi_used IS NOT NULL THEN
@@ -287,7 +297,7 @@ BEGIN
COALESCE(
NULLIF(
REGEXP_REPLACE(
- oils_xpath_string('//*[@tag="'||tag_used||'"]/@ind'||nfi_used, marcxml),
+ oils_xpath_string('./@ind'||nfi_used, tmp_xml::TEXT),
$$\D+$$,
'',
'g'
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/011.schema.authority.sql | 76 +++++----
.../0802.function.authority-sf-file-order.sql | 170 ++++++++++++++++++++
3 files changed, 214 insertions(+), 34 deletions(-)
create mode 100644 Open-ILS/src/sql/Pg/upgrade/0802.function.authority-sf-file-order.sql
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list