[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch rel_2_4 updated. 30254da66050e4a6ba1262b62391eb016e83a72f
Evergreen Git
git at git.evergreen-ils.org
Wed Oct 30 15:38:17 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_4 has been updated
via 30254da66050e4a6ba1262b62391eb016e83a72f (commit)
via bcef2183a73035ef13e76a1ee19594452c224f83 (commit)
from 4ea0ee9e445714d24e24d20abcd44f5516f56b29 (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 30254da66050e4a6ba1262b62391eb016e83a72f
Author: Dan Wells <dbw2 at calvin.edu>
Date: Wed Oct 30 15:33:28 2013 -0400
Stamping 0846: overlay subfield order fix
Respect source XML subfield order during overlay
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 901c017..9da9581 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 ('0842', :eg_version); -- dbwells/senator
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0846', :eg_version); -- eeevil/dbwells
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.vand-add_field.sql b/Open-ILS/src/sql/Pg/upgrade/0846.function.vand-add_field.sql
similarity index 97%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.function.vand-add_field.sql
rename to Open-ILS/src/sql/Pg/upgrade/0846.function.vand-add_field.sql
index 521395e..eea8a306 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.vand-add_field.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0846.function.vand-add_field.sql
@@ -1,6 +1,6 @@
BEGIN;
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0846', :eg_version);
CREATE OR REPLACE FUNCTION vandelay.add_field ( target_xml TEXT, source_xml TEXT, field TEXT, force_add INT ) RETURNS TEXT AS $_$
commit bcef2183a73035ef13e76a1ee19594452c224f83
Author: Mike Rylander <mrylander at gmail.com>
Date: Fri Oct 25 12:15:25 2013 -0400
Respect source XML subfield order during overlay
When adding specific subfields to a field as described by an add
or replace rule we were adding them in rule-order. Instead, they
should be added in source-XML physical order. This commit does
that.
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/012.schema.vandelay.sql b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
index 4122444..e9e643c 100644
--- a/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
+++ b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
@@ -1070,8 +1070,9 @@ CREATE OR REPLACE FUNCTION vandelay.add_field ( target_xml TEXT, source_xml TEXT
if (exists($fields{$f}{match})) {
next unless (grep { $_ =~ $fields{$f}{match}{re} } $to_field->subfield($fields{$f}{match}{sf}));
}
- my @new_sf = map { ($_ => $from_field->subfield($_)) } grep { defined($from_field->subfield($_)) } @{$fields{$f}{sf}};
- $to_field->add_subfields( @new_sf );
+ for my $old_sf ($from_field->subfields) {
+ $to_field->add_subfields( @$old_sf ) if grep(/$$old_sf[0]/,@{$fields{$f}{sf}});
+ }
}
}
}
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.vand-add_field.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.vand-add_field.sql
new file mode 100644
index 0000000..521395e
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.vand-add_field.sql
@@ -0,0 +1,83 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE FUNCTION vandelay.add_field ( target_xml TEXT, source_xml TEXT, field TEXT, force_add INT ) RETURNS TEXT AS $_$
+
+ use MARC::Record;
+ use MARC::File::XML (BinaryEncoding => 'UTF-8');
+ use MARC::Charset;
+ use strict;
+
+ MARC::Charset->assume_unicode(1);
+
+ my $target_xml = shift;
+ my $source_xml = shift;
+ my $field_spec = shift;
+ my $force_add = shift || 0;
+
+ my $target_r = MARC::Record->new_from_xml( $target_xml );
+ my $source_r = MARC::Record->new_from_xml( $source_xml );
+
+ return $target_xml unless ($target_r && $source_r);
+
+ my @field_list = split(',', $field_spec);
+
+ my %fields;
+ for my $f (@field_list) {
+ $f =~ s/^\s*//; $f =~ s/\s*$//;
+ if ($f =~ /^(.{3})(\w*)(?:\[([^]]*)\])?$/) {
+ my $field = $1;
+ $field =~ s/\s+//;
+ my $sf = $2;
+ $sf =~ s/\s+//;
+ my $match = $3;
+ $match =~ s/^\s*//; $match =~ s/\s*$//;
+ $fields{$field} = { sf => [ split('', $sf) ] };
+ if ($match) {
+ my ($msf,$mre) = split('~', $match);
+ if (length($msf) > 0 and length($mre) > 0) {
+ $msf =~ s/^\s*//; $msf =~ s/\s*$//;
+ $mre =~ s/^\s*//; $mre =~ s/\s*$//;
+ $fields{$field}{match} = { sf => $msf, re => qr/$mre/ };
+ }
+ }
+ }
+ }
+
+ for my $f ( keys %fields) {
+ if ( @{$fields{$f}{sf}} ) {
+ for my $from_field ($source_r->field( $f )) {
+ my @tos = $target_r->field( $f );
+ if (!@tos) {
+ next if (exists($fields{$f}{match}) and !$force_add);
+ my @new_fields = map { $_->clone } $source_r->field( $f );
+ $target_r->insert_fields_ordered( @new_fields );
+ } else {
+ for my $to_field (@tos) {
+ if (exists($fields{$f}{match})) {
+ next unless (grep { $_ =~ $fields{$f}{match}{re} } $to_field->subfield($fields{$f}{match}{sf}));
+ }
+ for my $old_sf ($from_field->subfields) {
+ $to_field->add_subfields( @$old_sf ) if grep(/$$old_sf[0]/,@{$fields{$f}{sf}});
+ }
+ }
+ }
+ }
+ } else {
+ my @new_fields = map { $_->clone } $source_r->field( $f );
+ $target_r->insert_fields_ordered( @new_fields );
+ }
+ }
+
+ $target_xml = $target_r->as_xml_record;
+ $target_xml =~ s/^<\?.+?\?>$//mo;
+ $target_xml =~ s/\n//sgo;
+ $target_xml =~ s/>\s+</></sgo;
+
+ return $target_xml;
+
+$_$ LANGUAGE PLPERLU;
+
+COMMIT;
+
-----------------------------------------------------------------------
Summary of changes:
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/012.schema.vandelay.sql | 5 +++--
...-field.sql => 0846.function.vand-add_field.sql} | 15 ++++++++++-----
3 files changed, 14 insertions(+), 8 deletions(-)
copy Open-ILS/src/sql/Pg/upgrade/{0435.schema.template-add-field.sql => 0846.function.vand-add_field.sql} (82%)
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list