changed the old isSerial to isSingleton and created a new isSerial that would do what you'd expect
This commit is contained in:
parent
5a59c41771
commit
b43cb6aaeb
6 changed files with 40 additions and 6 deletions
|
|
@ -52,6 +52,7 @@ password and email address, as well as some other WebGUI settings.
|
|||
#-------------------------------------------------------------------
|
||||
sub www_setup {
|
||||
my $session = shift;
|
||||
$session->http->setCacheControl("none");
|
||||
$session->http->setMimeType("text/html");
|
||||
return "" unless ($session->setting->get("specialState") eq "init");
|
||||
my $i18n = WebGUI::International->new($session, "WebGUI");
|
||||
|
|
|
|||
|
|
@ -197,6 +197,13 @@ sub www_editWorkflow {
|
|||
label=>$i18n->get("is enabled"),
|
||||
hoverHelp=>$i18n->get("is enabled help")
|
||||
);
|
||||
$f->yesNo(
|
||||
name=>"isSingleton",
|
||||
value=>$workflow->get("isSingleton"),
|
||||
defaultValue=>0,
|
||||
label=>$i18n->get("is singleton"),
|
||||
hoverHelp=>$i18n->get("is singleton help")
|
||||
);
|
||||
$f->yesNo(
|
||||
name=>"isSerial",
|
||||
value=>$workflow->get("isSerial"),
|
||||
|
|
|
|||
|
|
@ -393,9 +393,13 @@ 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", or any object type, like "WebGUI::VersionTag".
|
||||
|
||||
=head4 isSingleton
|
||||
|
||||
A boolean indicating whether this workflow should be run as a singleton. If it's a singleton, 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.
|
||||
|
||||
=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.
|
||||
A boolean indicating whether this workflow should be run in serial mode. If it's run in serial, then only one instance of this workflow will be run at a given time, and all other instances of it will queue up.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -412,6 +416,11 @@ sub set {
|
|||
} elsif ($properties->{isSerial} == 0) {
|
||||
$self->{_data}{isSerial} = 0;
|
||||
}
|
||||
if ($properties->{isSingleton} == 1) {
|
||||
$self->{_data}{isSingleton} = 1;
|
||||
} elsif ($properties->{isSingleton} == 0) {
|
||||
$self->{_data}{isSingleton} = 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";
|
||||
|
|
|
|||
|
|
@ -63,10 +63,10 @@ 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 ($isSingleton) = $session->db->quickArray("select isSingleton from Workflow where workflowId=?",[$properties->{workflowId}]);
|
||||
my $params = (exists $properties->{parameters}) ? JSON::objToJson({parameters => $properties->{parameters}}) : undef;
|
||||
my ($count) = $session->db->quickArray("select count(*) from WorkflowInstance where workflowId=? and parameters=?",[$properties->{workflowId},$params]);
|
||||
return undef if ($isSerial && $count);
|
||||
return undef if ($isSingleton && $count);
|
||||
my $instanceId = $session->db->setRow("WorkflowInstance","instanceId",{instanceId=>"new", runningSince=>time()}, $id);
|
||||
my $self = $class->new($session, $instanceId);
|
||||
$properties->{notifySpectre} = 1 unless ($properties->{notifySpectre} eq "0");
|
||||
|
|
@ -244,6 +244,10 @@ sub run {
|
|||
my $workflow = $self->getWorkflow;
|
||||
return "undefined" unless (defined $workflow);
|
||||
return "disabled" unless ($workflow->get("enabled"));
|
||||
if ($workflow->get("isSerial")) {
|
||||
my ($firstId) = $self->session->db->quickArray("select workflowId from WorkflowInstance order by runningSince");
|
||||
return "waiting" if ($workflow->getId ne $firstId); # must wait for currently running instance to complete
|
||||
}
|
||||
my $activity = $workflow->getNextActivity($self->get("currentActivityId"));
|
||||
unless (defined $activity) {
|
||||
$self->delete;
|
||||
|
|
|
|||
|
|
@ -31,8 +31,20 @@ our $I18N = {
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'is serial help' => {
|
||||
'is singleton help' => {
|
||||
message => q|If yes is selected then only one instance of this workflow will be allowed to be created at one time. Generally speaking this would be a bad idea for approval workflows, but is probably a good idea for workflows that download emails from a remote server, to avoid getting duplicates.|,
|
||||
context => q|the hover help for the is singleton field|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'is singleton' => {
|
||||
message => q|Is a singleton?|,
|
||||
context => q|A question that asks the user whether this workflow may be instanciated multiple times concurrently or not.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'is serial help' => {
|
||||
message => q|If yes is selected then only one instance of this workflow will be allowed to be run at one time, while new instances get queued up and wait for the running one to complete. This is generally bad for a workflow, but it can be good when multiple instances of workflow have to operate on the same data.|,
|
||||
context => q|the hover help for the is serial field|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue