LP1209291 vandelay item import defaults
authorBill Erickson <berick@esilibrary.com>
Thu, 8 Aug 2013 12:44:55 +0000 (08:44 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 8 Aug 2013 12:44:55 +0000 (08:44 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/sql/Pg/999.functions.global.sql

index c3f1533..8cb6c2d 100644 (file)
@@ -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;