From 9dac1d5178955a732351a8bdf54dddef97dc2c34 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sun, 19 Mar 2006 21:50:49 +0000 Subject: [PATCH] a couple small bug fixes --- lib/Spectre/Workflow.pm | 9 +++++++++ lib/WebGUI/Workflow/Instance.pm | 14 +++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/Spectre/Workflow.pm b/lib/Spectre/Workflow.pm index 9c7cf362a..8527d293f 100644 --- a/lib/Spectre/Workflow.pm +++ b/lib/Spectre/Workflow.pm @@ -317,6 +317,15 @@ Suspends a workflow instance for a number of seconds defined in the config file, sub suspendInstance { my ($self, $instanceId, $kernel) = @_[OBJECT, ARG0, KERNEL]; $self->debug("Suspending workflow instance ".$instanceId." for ".$self->config->get("suspensionDelay")." seconds."); + # normally this is taken care of by the returnInstanceToQueue method, but we want to free up the running count + # so that other things can be run while this thing is suspended + if ($self->{_instances}{$instanceId}) { + for (my $i=0; $i < scalar(@{$self->{_runningInstances}}); $i++) { + if ($self->{_runningInstances}[$i] eq $instanceId) { + splice(@{$self->{_runningInstances}}, $i, 1); + } + } + } $kernel->delay_set("returnInstanceToQueue",$self->config->get("suspensionDelay"), $instanceId); } diff --git a/lib/WebGUI/Workflow/Instance.pm b/lib/WebGUI/Workflow/Instance.pm index cd460da4e..8dbf4594a 100644 --- a/lib/WebGUI/Workflow/Instance.pm +++ b/lib/WebGUI/Workflow/Instance.pm @@ -216,9 +216,7 @@ sub run { return "undefined" unless (defined $workflow); return "disabled" unless ($workflow->get("enabled")); my $activity = $workflow->getNextActivity($self->get("currentActivityId")); - if (defined $activity) { - $self->set({"currentActivityId",$activity->getId}); - } else { + unless (defined $activity) { $self->delete; return "done"; } @@ -226,6 +224,7 @@ sub run { my $class = $self->get("className"); my $method = $self->get("methodName"); my $params = $self->get("parameters"); + my $status = ""; if ($class && $method) { my $cmd = "use $class"; eval($cmd); @@ -238,9 +237,14 @@ sub run { $self->session->errorHandler->warn("Error instanciating activity (".$activity->getId.") pass-in object: ".$@); return "error"; } - return $activity->execute($object, $self); + $status = $activity->execute($object, $self); + } else { + $status = $activity->execute(undef, $self); } - return $activity->execute(undef, $self); + if ($status eq "complete") { + $self->set({"currentActivityId"=>$activity->getId}); + } + return $status; }