From: Jason Stephenson Date: Fri, 27 Jul 2012 13:25:05 +0000 (-0400) Subject: Add pub date to CSV output. X-Git-Url: http://git.equinoxoli.org/?p=transitory.git;a=commitdiff_plain;h=49bc2a5ef1ed7c08433fd66311dccb1e6a906841 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 Signed-off-by: Dan Scott --- 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 41eb5fe..e5daf85 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 0000000..5af0feb --- /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;