[open-ils-commits] [GIT] Evergreen ILS branch rel_2_2 updated. e10ec4fa74a4a376fce2191a7811923ae206260f
Evergreen Git
git at git.evergreen-ils.org
Fri Mar 15 10:28:26 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 e10ec4fa74a4a376fce2191a7811923ae206260f (commit)
via 7cf0cb33006041e94580599124857bd2aaed3918 (commit)
from 52e37e54ffb86f42d9a8595a672efdbd02e49cf0 (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 e10ec4fa74a4a376fce2191a7811923ae206260f
Author: Dan Scott <dscott at laurentian.ca>
Date: Fri Mar 15 10:22:13 2013 -0400
Wrap upgrade script for use ID as TCN value fix
Signed-off-by: Dan Scott <dscott at laurentian.ca>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index de67132..c8a9299 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 ('0770', :eg_version); -- mrpeters/bshum
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0783', :eg_version); -- gmcharlt/dbs
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.enforce_use_id_for_tcn.sql b/Open-ILS/src/sql/Pg/upgrade/0783.schema.enforce_use_id_for_tcn.sql
similarity index 88%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.schema.enforce_use_id_for_tcn.sql
rename to Open-ILS/src/sql/Pg/upgrade/0783.schema.enforce_use_id_for_tcn.sql
index 87d74bd..0f13811 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.enforce_use_id_for_tcn.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0783.schema.enforce_use_id_for_tcn.sql
@@ -1,3 +1,14 @@
+-- Evergreen DB patch 0783.schema.enforce_use_id_for_tcn.sql
+--
+-- Sets the TCN value in the biblio.record_entry row to bib ID,
+-- if the appropriate setting is in place
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0783', :eg_version);
+
+-- FIXME: add/check SQL statements to perform the upgrade
CREATE OR REPLACE FUNCTION evergreen.maintain_901 () RETURNS TRIGGER AS $func$
use strict;
use MARC::Record;
@@ -96,3 +107,6 @@ $_TD->{new}{marc} = $xml;
return "MODIFY";
$func$ LANGUAGE PLPERLU;
+
+
+COMMIT;
commit 7cf0cb33006041e94580599124857bd2aaed3918
Author: Galen Charlton <gmc at esilibrary.com>
Date: Thu Mar 14 17:17:54 2013 -0400
LP#1155329: better enforce cat.bib.use_id_for_tcn
Restore previous behavior to the maintain_901() trigger
function so that bib records that are loaded without
explicitly setting the TCN have it set to the bib ID
when the cat.bib.use_id_for_tcn global flag is set, rather
than 'AUTOGENERATED-xxx'.
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: Dan Scott <dscott at laurentian.ca>
diff --git a/Open-ILS/src/sql/Pg/002.functions.config.sql b/Open-ILS/src/sql/Pg/002.functions.config.sql
index 87b6e28..ec57c34 100644
--- a/Open-ILS/src/sql/Pg/002.functions.config.sql
+++ b/Open-ILS/src/sql/Pg/002.functions.config.sql
@@ -446,6 +446,7 @@ if ($schema eq 'biblio') {
");
if (($id_as_tcn->{processed}) && $id_as_tcn->{rows}[0]->{enabled} eq 't') {
$tcn_value = $_TD->{new}{id};
+ $_TD->{new}{tcn_value} = $tcn_value;
}
my $new_901 = MARC::Field->new("901", " ", " ",
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.enforce_use_id_for_tcn.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.enforce_use_id_for_tcn.sql
new file mode 100644
index 0000000..87d74bd
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.enforce_use_id_for_tcn.sql
@@ -0,0 +1,98 @@
+CREATE OR REPLACE FUNCTION evergreen.maintain_901 () RETURNS TRIGGER AS $func$
+use strict;
+use MARC::Record;
+use MARC::File::XML (BinaryEncoding => 'UTF-8');
+use MARC::Charset;
+use Encode;
+use Unicode::Normalize;
+
+MARC::Charset->assume_unicode(1);
+
+my $schema = $_TD->{table_schema};
+my $marc = MARC::Record->new_from_xml($_TD->{new}{marc});
+
+my @old901s = $marc->field('901');
+$marc->delete_fields(@old901s);
+
+if ($schema eq 'biblio') {
+ my $tcn_value = $_TD->{new}{tcn_value};
+
+ # Set TCN value to record ID?
+ my $id_as_tcn = spi_exec_query("
+ SELECT enabled
+ FROM config.global_flag
+ WHERE name = 'cat.bib.use_id_for_tcn'
+ ");
+ if (($id_as_tcn->{processed}) && $id_as_tcn->{rows}[0]->{enabled} eq 't') {
+ $tcn_value = $_TD->{new}{id};
+ $_TD->{new}{tcn_value} = $tcn_value;
+ }
+
+ my $new_901 = MARC::Field->new("901", " ", " ",
+ "a" => $tcn_value,
+ "b" => $_TD->{new}{tcn_source},
+ "c" => $_TD->{new}{id},
+ "t" => $schema
+ );
+
+ if ($_TD->{new}{owner}) {
+ $new_901->add_subfields("o" => $_TD->{new}{owner});
+ }
+
+ if ($_TD->{new}{share_depth}) {
+ $new_901->add_subfields("d" => $_TD->{new}{share_depth});
+ }
+
+ $marc->append_fields($new_901);
+} elsif ($schema eq 'authority') {
+ my $new_901 = MARC::Field->new("901", " ", " ",
+ "c" => $_TD->{new}{id},
+ "t" => $schema,
+ );
+ $marc->append_fields($new_901);
+} elsif ($schema eq 'serial') {
+ my $new_901 = MARC::Field->new("901", " ", " ",
+ "c" => $_TD->{new}{id},
+ "t" => $schema,
+ "o" => $_TD->{new}{owning_lib},
+ );
+
+ if ($_TD->{new}{record}) {
+ $new_901->add_subfields("r" => $_TD->{new}{record});
+ }
+
+ $marc->append_fields($new_901);
+} else {
+ my $new_901 = MARC::Field->new("901", " ", " ",
+ "c" => $_TD->{new}{id},
+ "t" => $schema,
+ );
+ $marc->append_fields($new_901);
+}
+
+my $xml = $marc->as_xml_record();
+$xml =~ s/\n//sgo;
+$xml =~ s/^<\?xml.+\?\s*>//go;
+$xml =~ s/>\s+</></go;
+$xml =~ s/\p{Cc}//go;
+
+# Embed a version of OpenILS::Application::AppUtils->entityize()
+# to avoid having to set PERL5LIB for PostgreSQL as well
+
+# If we are going to convert non-ASCII characters to XML entities,
+# we had better be dealing with a UTF8 string to begin with
+$xml = decode_utf8($xml);
+
+$xml = NFC($xml);
+
+# Convert raw ampersands to entities
+$xml =~ s/&(?!\S+;)/&/gso;
+
+# Convert Unicode characters to entities
+$xml =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
+
+$xml =~ s/[\x00-\x1f]//go;
+$_TD->{new}{marc} = $xml;
+
+return "MODIFY";
+$func$ LANGUAGE PLPERLU;
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.functions.config.sql | 1 +
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
....sql => 0783.schema.enforce_use_id_for_tcn.sql} | 11 ++++++++++-
3 files changed, 12 insertions(+), 2 deletions(-)
copy Open-ILS/src/sql/Pg/upgrade/{0726.schema.fix_maintain_901_regex.sql => 0783.schema.enforce_use_id_for_tcn.sql} (87%)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list