From a7534229e228bbfb34fed719fdcc78f702a79d24 Mon Sep 17 00:00:00 2001 From: Jason Stephenson <jstephenson@mvlc.org> Date: Fri, 27 Jul 2012 09:25:05 -0400 Subject: [PATCH] Add pub date to CSV output. Change the template for the ContainerCSV reactor to add the publication date (MARC 260$c) in the csv output in the same position that the previous commit adds it to the html output. Add an upgrade script to update the existing template for the ContainerCSV reactor in action_trigger.event_definition. Signed-off-by: Jason Stephenson <jstephenson@mvlc.org> Signed-off-by: Dan Scott <dscott@laurentian.ca> --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 11 ++++++-- .../XXXX.data.update_ContainerCSV_template.sql | 33 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.update_ContainerCSV_template.sql diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 41eb5fecce..e5daf85d12 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -9989,8 +9989,15 @@ FOR item IN items; END; author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); - - helpers.csv_datum(title) %],[% helpers.csv_datum(author) %],[% helpers.csv_datum(item_type) %],[% FOR note IN item.notes; helpers.csv_datum(note.note); ","; END; "\n"; + pub_date = ""; + FOR pdatum IN bibxml.findnodes('//*[@tag="260"]/*[@code="c"]'); + IF pub_date ; + pub_date = pub_date _ ", " _ pdatum.textContent; + ELSE ; + pub_date = pdatum.textContent; + END; + END; + helpers.csv_datum(title) %],[% helpers.csv_datum(author) %],[% helpers.csv_datum(pub_date) %],[% helpers.csv_datum(item_type) %],[% FOR note IN item.notes; helpers.csv_datum(note.note); ","; END; "\n"; END -%] $$ ); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.update_ContainerCSV_template.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.update_ContainerCSV_template.sql new file mode 100644 index 0000000000..5af0feb52a --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.update_ContainerCSV_template.sql @@ -0,0 +1,33 @@ +BEGIN; +-- check whether patch can be applied +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +UPDATE action_trigger.event_definition +SET template = +$$ +[%- +# target is the bookbag itself. The 'items' variable does not need to be in +# the environment because a special reactor will take care of filling it in. + +FOR item IN items; + bibxml = helpers.unapi_bre(item.target_biblio_record_entry, {flesh => '{mra}'}); + title = ""; + FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); + title = title _ part.textContent; + END; + author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; + item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value'); + pub_date = ""; + FOR pdatum IN bibxml.findnodes('//*[@tag="260"]/*[@code="c"]'); + IF pub_date ; + pub_date = pub_date _ ", " _ pdatum.textContent; + ELSE ; + pub_date = pdatum.textContent; + END; + END; + helpers.csv_datum(title) %],[% helpers.csv_datum(author) %],[% helpers.csv_datum(pub_date) %],[% helpers.csv_datum(item_type) %],[% FOR note IN item.notes; helpers.csv_datum(note.note); ","; END; "\n"; +END -%] +$$ +WHERE id = 48; + +COMMIT; -- 2.11.0