[open-ils-commits] r12748 - in trunk/Open-ILS: examples src/perlmods/OpenILS/Application/Trigger src/sql/Pg (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 1 09:54:44 EDT 2009


Author: erickson
Date: 2009-04-01 09:54:42 -0400 (Wed, 01 Apr 2009)
New Revision: 12748

Modified:
   trunk/Open-ILS/examples/fm_IDL.xml
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
   trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql
Log:

Updated the IDL to match the table name in the sql:  template_output => event_output
Added an is_error column to event_output
Updated event.error_output to link to event_output table
Storing error text in event_output table with is_error='t'



Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml	2009-04-01 11:08:08 UTC (rev 12747)
+++ trunk/Open-ILS/examples/fm_IDL.xml	2009-04-01 13:54:42 UTC (rev 12748)
@@ -580,18 +580,21 @@
         </links>
     </class>
 
-	<class id="atto" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="action_trigger::template_output" oils_persist:tablename="action_trigger.template_output" reporter:label="Event output">
-		<fields oils_persist:primary="id" oils_persist:sequence="action_trigger.template_output_id_seq">
+	<class id="ateo" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="action_trigger::event_output" oils_persist:tablename="action_trigger.event_output" reporter:label="Event output">
+		<fields oils_persist:primary="id" oils_persist:sequence="action_trigger.event_output_id_seq">
 			<field name="isnew" oils_obj:array_position="0" oils_persist:virtual="true" />
 			<field name="ischanged" oils_obj:array_position="1" oils_persist:virtual="true" />
 			<field name="isdeleted" oils_obj:array_position="2" oils_persist:virtual="true" />
 			<field reporter:label="Output ID" name="id" oils_obj:array_position="3" oils_persist:virtual="false" reporter:datatype="id"/>
 			<field reporter:label="Create Date/Time" name="create_time" oils_obj:array_position="4" oils_persist:virtual="false" reporter:datatype="timestamp"/>
 			<field reporter:label="Data" name="data" oils_obj:array_position="5" oils_persist:virtual="false" reporter:datatype="text"/>
-			<field reporter:label="Events" name="events" oils_obj:array_position="6" oils_persist:virtual="true"  reporter:datatype="link"/>
+			<field reporter:label="Is Error" name="is_error" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="bool"/>
+			<field reporter:label="Events" name="events" oils_obj:array_position="7" oils_persist:virtual="true"  reporter:datatype="link"/>
+			<field reporter:label="Events" name="error_events" oils_obj:array_position="8" oils_persist:virtual="true"  reporter:datatype="link"/>
 		</fields>
 		<links>
             <link field="events" reltype="has_many" key="template_output" map="" class="atev"/>
+            <link field="error_events" reltype="has_many" key="error_output" map="" class="atev"/>
 		</links>
 		<permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
 			<actions>
@@ -783,7 +786,8 @@
 		</fields>
 		<links>
 			<link field="event_def" reltype="has_a" key="id" map="" class="atevdef"/>
-			<link field="template_output" reltype="has_a" key="id" map="" class="atto"/>
+			<link field="template_output" reltype="has_a" key="id" map="" class="ateo"/>
+			<link field="error_output" reltype="has_a" key="id" map="" class="ateo"/>
 		</links>
 	</class>
 

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm	2009-04-01 11:08:08 UTC (rev 12747)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm	2009-04-01 13:54:42 UTC (rev 12748)
@@ -70,22 +70,28 @@
     my $nostore = shift;
     return undef unless $env->{template};
 
+    my $error;
     my $output = '';
     my $tt = Template->new;
     $env->{helpers} = $_TT_helpers;
 
-    $tt->process(\$env->{template}, $env, \$output) or 
-        $logger->error("Error processing Trigger template: " . $tt->error);
+    unless( $tt->process(\$env->{template}, $env, \$output) ) {
+        $output = undef;
+        ($error = $tt->error) =~ s/\n/ /og;
+        $logger->error("Error processing Trigger template: $error");
+    }
 
-    if (!$nostore && $output) {
-        my $t_o = Fieldmapper::action_trigger::template_output->new;
-        $t_o->data( $output );
+    if ( $error or (!$nostore && $output) ) {
+        my $t_o = Fieldmapper::action_trigger::event_output->new;
+        $t_o->data( ($error) ? $error : $output );
+        $t_o->is_error( ($error) ? 't' : 'f' );
 
         $env->{EventProcessor}->editor->xact_begin;
-        $t_o = $env->{EventProcessor}->editor->create_action_trigger_template_output( $t_o );
+        $t_o = $env->{EventProcessor}->editor->create_action_trigger_event_output( $t_o );
 
         my $state = (ref $$env{event} eq 'ARRAY') ? $$env{event}->[0]->state : $env->{event}->state;
-        $env->{EventProcessor}->update_state( $state, { template_output => $t_o->id } );
+        my $key = ($error) ? 'error_output' : 'template_output';
+        $env->{EventProcessor}->update_state( $state, { $key => $t_o->id } );
     }
 	
     return $output;

Modified: trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql	2009-04-01 11:08:08 UTC (rev 12747)
+++ trunk/Open-ILS/src/sql/Pg/400.schema.action_trigger.sql	2009-04-01 13:54:42 UTC (rev 12748)
@@ -123,6 +123,7 @@
 CREATE TABLE action_trigger.event_output (
     id              BIGSERIAL   PRIMARY KEY,
     create_time     TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+    is_error        BOOLEAN     NOT NULL DEFAULT FALSE,
     data            TEXT        NOT NULL
 );
 
@@ -138,7 +139,7 @@
     update_process  INT,
     state           TEXT        NOT NULL DEFAULT 'pending' CHECK (state IN ('pending','invalid','found','collecting','collected','validating','valid','reacting','reacted','cleaning','complete','error')),
     template_output BIGINT      REFERENCES action_trigger.event_output (id),
-    error_output    TEXT
+    error_output    BIGINT      REFERENCES action_trigger.event_output (id),
 );
 
 CREATE TABLE action_trigger.event_params (



More information about the open-ils-commits mailing list