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

Evergreen Git git at git.evergreen-ils.org
Fri Jul 27 11:28:59 EDT 2012


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  bc84c7b6d47e1fdfe381ce96e2d2fb78a3d9907f (commit)
      from  d153502f9b2b89b364742a41c0fbe9313c544ec9 (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 bc84c7b6d47e1fdfe381ce96e2d2fb78a3d9907f
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Fri Jul 27 11:23:46 2012 -0400

    lp1028514: fix syntax-o in PL/PERLU version of maintain_901()
    
    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 274adc3..0a93922 100644
--- a/Open-ILS/src/sql/Pg/002.functions.config.sql
+++ b/Open-ILS/src/sql/Pg/002.functions.config.sql
@@ -464,14 +464,14 @@ if ($schema eq 'biblio') {
     }
 
     $marc->append_fields($new_901);
-} elsif ($schema = 'authority') {
+} elsif ($schema eq 'authority') {
     $marc->append_fields(
         ["901", " ", " ",
             "c" => $_TD->{new}{id},
             "t" => $schema,
         ]
     );
-} elsif ($schema = 'serial') {
+} elsif ($schema eq 'serial') {
     my $new_901 = MARC::Field->new("901", " ", " ",
         "c" => $_TD->{new}{id},
         "t" => $schema,
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index a834191..5149753 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 ('0724', :eg_version); -- denials/gmcharlt
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0725', :eg_version); -- gmcharlt/denials
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0725.schema.fix_maintain_901_regex.sql b/Open-ILS/src/sql/Pg/upgrade/0725.schema.fix_maintain_901_regex.sql
new file mode 100644
index 0000000..2b0c206
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0725.schema.fix_maintain_901_regex.sql
@@ -0,0 +1,105 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0725', :eg_version); -- gmcharlt/denials
+
+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}; 
+    }
+
+    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') {
+    $marc->append_fields(
+        ["901", " ", " ",
+            "c" => $_TD->{new}{id},
+            "t" => $schema,
+        ]
+    );
+} 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 {
+    $marc->append_fields(
+        ["901", " ", " ",
+            "c" => $_TD->{new}{id},
+            "t" => $schema,
+        ]
+    );
+}
+
+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+;)/&amp;/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;
+
+COMMIT;

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

Summary of changes:
 Open-ILS/src/sql/Pg/002.functions.config.sql       |    4 ++--
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 ....sql => 0725.schema.fix_maintain_901_regex.sql} |    6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)
 copy Open-ILS/src/sql/Pg/upgrade/{0724.schema.fix_maintain_901_regex.sql => 0725.schema.fix_maintain_901_regex.sql} (96%)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list