From e24d8469032a1dfe58c5494a71a16509bab0816e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 8 Aug 2013 08:44:55 -0400 Subject: [PATCH] LP1209291 vandelay item import defaults Signed-off-by: Bill Erickson --- Open-ILS/src/sql/Pg/999.functions.global.sql | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql index c3f1533369..8cb6c2d34f 100644 --- a/Open-ILS/src/sql/Pg/999.functions.global.sql +++ b/Open-ILS/src/sql/Pg/999.functions.global.sql @@ -1803,6 +1803,10 @@ BEGIN attr_set.deposit_amount := NULL; attr_set.copy_number := NULL; attr_set.price := NULL; + attr_set.circ_modifier := NULL; + attr_set.location := NULL; + attr_set.barcode := NULL; + attr_set.call_number := NULL; IF tmp_attr_set.pr != '' THEN tmp_str = REGEXP_REPLACE(tmp_attr_set.pr, E'[^0-9\\.]', '', 'g'); @@ -1861,7 +1865,16 @@ BEGIN END IF; END IF; - IF tmp_attr_set.circ_mod != '' THEN + IF COALESCE(tmp_attr_set.circ_mod, '') = '' THEN + + -- no circ mod defined, see if we should apply a default + SELECT INTO attr_set.circ_modifier TRIM(BOTH '"' FROM value) + FROM actor.org_unit_ancestor_setting( + 'vandelay.item.circ_modifier.default', + attr_set.owning_lib + ); + ELSE + SELECT code INTO attr_set.circ_modifier FROM config.circ_modifier WHERE code = tmp_attr_set.circ_mod; IF NOT FOUND THEN attr_set.import_error := 'import.item.invalid.circ_modifier'; @@ -1879,7 +1892,15 @@ BEGIN END IF; END IF; - IF tmp_attr_set.cl != '' THEN + IF COALESCE(tmp_attr_set.cl, '') = '' THEN + -- no location specified, see if we should apply a default + + SELECT INTO attr_set.location TRIM(BOTH '"' FROM value) + FROM actor.org_unit_ancestor_setting( + 'vandelay.item.copy_location.default', + attr_set.owning_lib + ); + ELSE -- search up the org unit tree for a matching copy location WITH RECURSIVE anscestor_depth AS ( @@ -1949,6 +1970,8 @@ BEGIN END; $$ LANGUAGE PLPGSQL; + + CREATE OR REPLACE FUNCTION vandelay.ingest_bib_items ( ) RETURNS TRIGGER AS $func$ DECLARE attr_def BIGINT; -- 2.11.0