[open-ils-commits] [GIT] Evergreen ILS branch master updated. fe073386ee82b3f6788db754aa01f3a05c0908e6
Evergreen Git
git at git.evergreen-ils.org
Wed Feb 18 10:15:51 EST 2015
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 fe073386ee82b3f6788db754aa01f3a05c0908e6 (commit)
via 522b6ff61c36db7b6883f5db53f273a8fde7abf0 (commit)
via 62510da3171c54bfeb2b34478c4e4a6c2c05acb1 (commit)
from 9238334caad810f09e53466e65a634a58e332931 (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 fe073386ee82b3f6788db754aa01f3a05c0908e6
Author: Jason Stephenson <jstephenson at mvlc.org>
Date: Wed Feb 18 10:13:56 2015 -0500
LP#957466: Stamping Upgrade Script
Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index aefb0f5..1d2aea9 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 ('0907', :eg_version); -- miker
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0908', :eg_version); -- ldw/mdriscoll/dyrcona
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.vandelay-overlay_bib_record.sql b/Open-ILS/src/sql/Pg/upgrade/0908.function.vandelay-overlay_bib_record.sql
similarity index 96%
rename from Open-ILS/src/sql/Pg/upgrade/XXXX.function.vandelay-overlay_bib_record.sql
rename to Open-ILS/src/sql/Pg/upgrade/0908.function.vandelay-overlay_bib_record.sql
index 82dda29..f947fe8 100644
--- a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.vandelay-overlay_bib_record.sql
+++ b/Open-ILS/src/sql/Pg/upgrade/0908.function.vandelay-overlay_bib_record.sql
@@ -1,6 +1,6 @@
BEGIN;
---SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('0908', :eg_version);
CREATE OR REPLACE FUNCTION vandelay.overlay_bib_record ( import_id BIGINT, eg_id BIGINT, merge_profile_id INT ) RETURNS BOOL AS $$
DECLARE
commit 522b6ff61c36db7b6883f5db53f273a8fde7abf0
Author: Jason Stephenson <jstephenson at mvlc.org>
Date: Fri Feb 13 12:22:19 2015 -0500
LP#957466 Vandelay set the 905$u on imported bib records to current user.
This will cause the code in the previous commit to trigger and update the
appropriate fields in biblio.record_entry.
Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
Signed-off-by: Martha Driscoll <driscoll at noblenet.org>
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
index 1dc306e..8de64a5 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm
@@ -2133,6 +2133,49 @@ sub strip_marc_fields {
return $class->entityize($marcdoc->documentElement->toString);
}
+# marcdoc is an XML::LibXML document
+# updates the document and returns the entityized MARC string.
+sub set_marc_905u {
+ my ($class, $marcdoc, $username) = @_;
+
+ # We add to the $parentNode, if set.
+ my $parentNode;
+ # Look for existing 905$u subfields and remove them:
+ for my $node ($marcdoc->findnodes('//field[@tag="905"]/subfield[@code="u"]')) {
+ $parentNode = $node->parentNode();
+ $parentNode->removeChild($node);
+ # If the 905 has no subfield nodes, remove it, too:
+ unless ($parentNode->findnodes('child::subfield')) {
+ $parentNode->parentNode->removeChild($parentNode);
+ undef($parentNode);
+ }
+ }
+
+ # Check if we deleted any existing 905s or don't have any.
+ unless ($parentNode) {
+ # Look for the last one, if any.
+ my @nodes = $marcdoc->findnodes('(//field[@tag="905"])[last()]');
+ if (@nodes) {
+ $parentNode = $nodes[0];
+ } else {
+ # We have to create a new one.
+ $parentNode = $marcdoc->createElement('field');
+ $parentNode->setAttribute('tag', '905');
+ $parentNode->setAttribute('ind1', '');
+ $parentNode->setAttribute('ind2', '');
+ $marcdoc->documentElement->addChild($parentNode);
+ }
+ }
+
+ # Now we add the subfield u to parentNode.
+ my $node = $marcdoc->createElement('subfield');
+ $node->setAttribute('code', 'u');
+ $node->appendTextNode($username);
+ $parentNode->addChild($node);
+
+ return $class->entityize($marcdoc->documentElement->toString);
+}
+
# Given a list of PostgreSQL arrays of numbers,
# unnest the numbers and return a unique set, skipping any list elements
# that are just '{NULL}'.
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm
index 26eddad..efb6cc7 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm
@@ -989,6 +989,11 @@ sub import_record_list_impl {
my $marcdoc = XML::LibXML->new->parse_string($rec->marc);
$rec->marc($U->strip_marc_fields($e, $marcdoc, $strip_grps));
+ # Set the imported record's 905$u, so
+ # editor/creator/edit_date are set correctly.
+ $marcdoc = XML::LibXML->new->parse_string($rec->marc);
+ $rec->marc($U->set_marc_905u($marcdoc, $requestor->usrname));
+
unless ($e->$update_func($rec)) {
$$report_args{evt} = $e->die_event;
finish_rec_import_attempt($report_args);
commit 62510da3171c54bfeb2b34478c4e4a6c2c05acb1
Author: Remington Steed <rjs7 at calvin.edu>
Date: Mon Oct 13 12:22:32 2014 -0400
LP#957466: Update editor/edit_date/source on overlay
This commit does three things.
1. It removes some declared variables that are never used in this
function.
2. It updates the bib record edit_date field (along with the editor) if
an editor is found in the MARC. If an editor is not found (or doesn't
match an Evergreen user), it seems best to leave the edit_date
unchanged so as not to imply that the previous editor is responsible for
the newest edit.
3. If a bib source is chosen in the vandelay importer UI, it updates the
bib record with the source. To access this field, the reference to table
"queued_record" is replaced by its child table "queued_bib_record".
Since the new table is a child of the other, all of the other needed
values are still available.
Signed-off-by: Remington Steed <rjs7 at calvin.edu>
Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
Signed-off-by: Martha Driscoll <driscoll at noblenet.org>
diff --git a/Open-ILS/src/sql/Pg/012.schema.vandelay.sql b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
index 2ca0fcc..67aab22 100644
--- a/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
+++ b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
@@ -1415,19 +1415,16 @@ $$ LANGUAGE SQL;
CREATE OR REPLACE FUNCTION vandelay.overlay_bib_record ( import_id BIGINT, eg_id BIGINT, merge_profile_id INT ) RETURNS BOOL AS $$
DECLARE
- merge_profile vandelay.merge_profile%ROWTYPE;
- dyn_profile vandelay.compile_profile%ROWTYPE;
editor_string TEXT;
editor_id INT;
- source_marc TEXT;
- target_marc TEXT;
- eg_marc TEXT;
v_marc TEXT;
- replace_rule TEXT;
+ v_bib_source INT;
+ update_fields TEXT[];
+ update_query TEXT;
BEGIN
- SELECT q.marc INTO v_marc
- FROM vandelay.queued_record q
+ SELECT q.marc, q.bib_source INTO v_marc, v_bib_source
+ FROM vandelay.queued_bib_record q
JOIN vandelay.bib_match m ON (m.queued_record = q.id AND q.id = import_id)
LIMIT 1;
@@ -1452,10 +1449,21 @@ BEGIN
END IF;
IF editor_id IS NOT NULL THEN
- UPDATE biblio.record_entry SET editor = editor_id WHERE id = eg_id;
+ --only update the edit date if we have a valid editor
+ update_fields := ARRAY_APPEND(update_fields, 'editor = ' || editor_id || ', edit_date = NOW()');
END IF;
END IF;
+ IF v_bib_source IS NOT NULL THEN
+ update_fields := ARRAY_APPEND(update_fields, 'source = ' || v_bib_source);
+ END IF;
+
+ IF ARRAY_LENGTH(update_fields, 1) > 0 THEN
+ update_query := 'UPDATE biblio.record_entry SET ' || ARRAY_TO_STRING(update_fields, ',') || ' WHERE id = ' || eg_id || ';';
+ --RAISE NOTICE 'query: %', update_query;
+ EXECUTE update_query;
+ END IF;
+
RETURN TRUE;
END IF;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.vandelay-overlay_bib_record.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.vandelay-overlay_bib_record.sql
new file mode 100644
index 0000000..82dda29
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.vandelay-overlay_bib_record.sql
@@ -0,0 +1,66 @@
+BEGIN;
+
+--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE FUNCTION vandelay.overlay_bib_record ( import_id BIGINT, eg_id BIGINT, merge_profile_id INT ) RETURNS BOOL AS $$
+DECLARE
+ editor_string TEXT;
+ editor_id INT;
+ v_marc TEXT;
+ v_bib_source INT;
+ update_fields TEXT[];
+ update_query TEXT;
+BEGIN
+
+ SELECT q.marc, q.bib_source INTO v_marc, v_bib_source
+ FROM vandelay.queued_bib_record q
+ JOIN vandelay.bib_match m ON (m.queued_record = q.id AND q.id = import_id)
+ LIMIT 1;
+
+ IF v_marc IS NULL THEN
+ -- RAISE NOTICE 'no marc for vandelay or bib record';
+ RETURN FALSE;
+ END IF;
+
+ IF vandelay.template_overlay_bib_record( v_marc, eg_id, merge_profile_id) THEN
+ UPDATE vandelay.queued_bib_record
+ SET imported_as = eg_id,
+ import_time = NOW()
+ WHERE id = import_id;
+
+ editor_string := (oils_xpath('//*[@tag="905"]/*[@code="u"]/text()',v_marc))[1];
+
+ IF editor_string IS NOT NULL AND editor_string <> '' THEN
+ SELECT usr INTO editor_id FROM actor.card WHERE barcode = editor_string;
+
+ IF editor_id IS NULL THEN
+ SELECT id INTO editor_id FROM actor.usr WHERE usrname = editor_string;
+ END IF;
+
+ IF editor_id IS NOT NULL THEN
+ --only update the edit date if we have a valid editor
+ update_fields := ARRAY_APPEND(update_fields, 'editor = ' || editor_id || ', edit_date = NOW()');
+ END IF;
+ END IF;
+
+ IF v_bib_source IS NOT NULL THEN
+ update_fields := ARRAY_APPEND(update_fields, 'source = ' || v_bib_source);
+ END IF;
+
+ IF ARRAY_LENGTH(update_fields, 1) > 0 THEN
+ update_query := 'UPDATE biblio.record_entry SET ' || ARRAY_TO_STRING(update_fields, ',') || ' WHERE id = ' || eg_id || ';';
+ --RAISE NOTICE 'query: %', update_query;
+ EXECUTE update_query;
+ END IF;
+
+ RETURN TRUE;
+ END IF;
+
+ -- RAISE NOTICE 'update of biblio.record_entry failed';
+
+ RETURN FALSE;
+
+END;
+$$ LANGUAGE PLPGSQL;
+
+COMMIT;
-----------------------------------------------------------------------
Summary of changes:
.../perlmods/lib/OpenILS/Application/AppUtils.pm | 43 +++++++++++++
.../perlmods/lib/OpenILS/Application/Vandelay.pm | 5 ++
Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +-
Open-ILS/src/sql/Pg/012.schema.vandelay.sql | 26 +++++---
.../0908.function.vandelay-overlay_bib_record.sql | 66 ++++++++++++++++++++
5 files changed, 132 insertions(+), 10 deletions(-)
create mode 100644 Open-ILS/src/sql/Pg/upgrade/0908.function.vandelay-overlay_bib_record.sql
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list