added a mechanism to workflows so that they can be run serially rather than parallel

This commit is contained in:
JT Smith 2006-02-13 16:59:29 +00:00
parent f9a60ab55a
commit 3d92467451
3 changed files with 14 additions and 1 deletions

View file

@ -288,6 +288,10 @@ A boolean indicating whether this workflow may be executed right now.
A string indicating the type of object this workflow will be operating on. Valid values are "none", "versiontag" and "user".
=head4 isSerial
A boolean indicating whether this workflow can be run in parallel or serial. If it's serial, then only one instance of the workflow will be allowed to be created at a given time. So if you try to create a new instance of it, and one instance is already created, the create() method will return undef instead of a reference to the object.
=cut
sub set {
@ -298,6 +302,11 @@ sub set {
} elsif ($properties->{enabled} == 0) {
$self->{_data}{enabled} = 0;
}
if ($properties->{isSerial} == 1) {
$self->{_data}{isSerial} = 1;
} elsif ($properties->{isSerial} == 0) {
$self->{_data}{isSerial} = 0;
}
$self->{_data}{title} = $properties->{title} || $self->{_data}{title} || "Untitled";
$self->{_data}{description} = (exists $properties->{description}) ? $properties->{description} : $self->{_data}{description};
$self->{_data}{type} = $properties->{type} || $self->{_data}{type} || "none";

View file

@ -41,7 +41,7 @@ These methods are available from this class:
=head2 create ( session, properties [, id ] )
Creates a new workflow instance.
Creates a new workflow instance and returns a reference to the object. Will return undef if the workflow specified is serial and an instance of it already exists.
=head3 session
@ -62,6 +62,9 @@ sub create {
my $session = shift;
my $properties = shift;
my $id = shift;
my ($isSerial) = $session->db->quickArray("select isSerial from Workflow where workflowId=?",[$properties->{workflowId}]);
my ($count) = $session->db->quickArray("select count(*) from WorkflowInstance where workflowId=?",[$properties->{workflowId}]);
return undef if ($isSerial && $count);
my $instanceId = $session->db->setRow("WorkflowInstance","instanceId",{instanceId=>"new", runningSince=>time()}, $id);
my $self = $class->new($session, $instanceId);
$self->set($properties);