LP#1527342 SQL / IDL
authorBill Erickson <berickxx@gmail.com>
Mon, 21 Dec 2015 15:39:07 +0000 (10:39 -0500)
committerBill Erickson <berickxx@gmail.com>
Mon, 21 Dec 2015 15:39:07 +0000 (10:39 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.decouple_co_history.sql

index 8cff802..732a8b6 100644 (file)
@@ -4261,7 +4261,27 @@ SELECT  usr,
                        <link field="aaasc_entries" reltype="has_many" key="xact" map="" class="aaasc"/>
                </links>
        </class>
-
+       <class id="auch" 
+               controller="open-ils.cstore" 
+               oils_obj:fieldmapper="action::user_circ_history" 
+               oils_persist:tablename="action.usr_circ_history" 
+               reporter:label="User Checkout History">
+               <fields oils_persist:primary="id" oils_persist:sequence="action.usr_circ_history_id_seq">
+                       <field reporter:label="ID" name="id" reporter:datatype="id"/>
+                       <!-- prevent reporting on the user that owns the checkout history -->
+                       <field reporter:label="User" name="usr" reporter:datatype="link" suppress_controller="open-ils.reporter-store"/>
+                       <field reporter:label="Circulating Item" name="target_copy" reporter:datatype="link"/>
+                       <field reporter:label="Checkin Time" name="checkin_time" reporter:datatype="timestamp" />
+                       <field reporter:label="Due Date" name="due_date" reporter:datatype="timestamp" />
+                       <field reporter:label="Checkout Time" name="xact_start" reporter:datatype="timestamp" />
+                       <field reporter:label="Source Circulation" name="source_circ" reporter:datatype="link" />
+               </fields>
+               <links>
+                       <link field="usr" reltype="has_a" key="id" map="" class="au"/>
+                       <link field="target_copy" reltype="has_a" key="id" map="" class="acp"/>
+                       <link field="source_circ" reltype="has_a" key="id" map="" class="circ"/>
+               </links>
+       </class>
        <class id="brt" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="booking::resource_type" oils_persist:tablename="booking.resource_type" reporter:label="Resource Type">
                <fields oils_persist:primary="id" oils_persist:sequence="booking.resource_type_id_seq">
                        <field reporter:label="Resource Type ID" name="id" reporter:datatype="id" reporter:selector="name"/>
index 5065ae6..f070f58 100644 (file)
@@ -81,12 +81,12 @@ BEGIN
         WHERE 
             source_circ = first_circ 
             AND (
-                due_date <> NEW.due_date OR
-                -- coalesce on a common value so we can <> compare NULL's
-                COALESCE(checkin_time, NEW.xact_start) <> 
-                    COALESCE(NEW.checkin_time, NEW.xact_start)
+                due_date <> NEW.due_date OR (
+                    (checkin_time IS NULL AND NEW.checkin_time IS NOT NULL) OR
+                    (checkin_time IS NOT NULL AND NEW.checkin_time IS NULL) OR
+                    (checkin_time <> NEW.checkin_time)
+                )
             );
-
     RETURN NEW;
 END;                                                                           
 $FUNK$ LANGUAGE PLPGSQL; 
@@ -97,3 +97,14 @@ CREATE TRIGGER maintain_usr_circ_history_tgr
 
 COMMIT;
 
+/* REVERT -- */
+/*
+BEGIN;
+
+DROP TRIGGER IF EXISTS maintain_usr_circ_history_tgr ON action.circulation;
+DROP FUNCTION IF EXISTS action.maintain_usr_circ_history();
+DROP TABLE action.usr_circ_history;
+
+COMMIT;
+*/
+