[open-ils-commits] r12738 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Mar 31 13:36:17 EDT 2009
Author: miker
Date: 2009-03-31 13:36:14 -0400 (Tue, 31 Mar 2009)
New Revision: 12738
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
Log:
give the environment built by O::A::T::Event[Group] access to the event proccessing object; teach O::A::T::Reactor::run_TT how to use this special EventProcessor env element, optionally turning this off via a "nostore" flag to run_TT
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm 2009-03-31 17:29:05 UTC (rev 12737)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm 2009-03-31 17:36:14 UTC (rev 12738)
@@ -356,6 +356,7 @@
try {
+ $self->environment->{EventProcessor} = $self;
$self->environment->{target} = $self->target;
$self->environment->{event} = $self->event;
$self->environment->{template} = $self->event->event_def->template;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm 2009-03-31 17:29:05 UTC (rev 12737)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/EventGroup.pm 2009-03-31 17:36:14 UTC (rev 12738)
@@ -182,6 +182,8 @@
my $state = shift;
return undef unless ($state);
+ my $fields = shift;
+
$self->editor->xact_begin || return undef;
my @oks;
@@ -193,9 +195,13 @@
$e->update_time( 'now' );
$e->update_process( $$ );
$e->state( $state );
-
+
$e->clear_start_time() if ($e->state eq 'pending');
-
+
+ if ($fields && ref($fields)) {
+ $e->$_($$fields{$_}) for (keys %$fields);
+ }
+
my $ok = $self->editor->update_action_trigger_event( $e );
if ($ok) {
push @oks, $ok;
@@ -228,10 +234,12 @@
my $self = shift;
my $env = $self->environment;
+ $$env{EventProcessor} = $self;
$$env{target} = [];
$$env{event} = [];
for my $e ( @{ $self->events } ) {
for my $env_part ( keys %{ $e->environment } ) {
+ next if ($env_part eq 'EventProcessor');
if ($env_part eq 'target') {
push @{ $$env{target} }, $e->environment->{target};
} elsif ($env_part eq 'event') {
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm 2009-03-31 17:29:05 UTC (rev 12737)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm 2009-03-31 17:36:14 UTC (rev 12738)
@@ -76,6 +76,15 @@
$tt->process(\$env->{template}, $env, \$output) or
$logger->error("Error processing Trigger template: " . $tt->error);
+ if (!$nostore && $output) {
+ my $t_o = Fieldmapper::action_trigger::template_output->new;
+ $t_o->data( $output );
+
+ $env->{EventProcessor}->editor->xact_begin;
+ $t_o = $env->{EventProcessor}->editor->create_action_trigger_template_output( $t_o );
+ $env->{EventProcessor}->update_state( $env->{event}->state, { template_output => $t_o->id } );
+ }
+
return $output;
}
More information about the open-ils-commits
mailing list