introduced type concept into workflow

This commit is contained in:
JT Smith 2006-02-11 21:03:14 +00:00
parent d194d3760a
commit 063e8703c7
4 changed files with 60 additions and 13 deletions

View file

@ -50,6 +50,7 @@ sub addWorkflow {
workflowId varchar(22) binary not null,
className varchar(255),
methodName varchar(255),
priority int not null default 2,
parameters text
)");
$session->db->write("create table WorkflowInstance (
@ -60,7 +61,8 @@ sub addWorkflow {
className varchar(255),
methodName varchar(255),
parameters text,
runningSince bigint
runningSince bigint,
lastUpdate bigint
)");
$session->db->write("create table Workflow (
workflowId varchar(22) binary not null primary key,

View file

@ -159,6 +159,32 @@ sub getActivities {
return \@activities;
}
#-------------------------------------------------------------------
=head2 getNextActivity ( [ activityId ] )
Returns the next activity in the workflow after the activity specified. If no activity id is specified, then the first workflow will be returned.
=head3 activityId
The unique id of an activity in this workflow.
=cut
sub getNextActivity {
my $self = shift;
my $activityId = shift;
my ($sequenceNumber) = $self->session->db->quickArray("select sequenceNumber from WorkflowActivity where activityId=?", [$activityId]);
$sequenceNumber++;
my $rs = $self->session->db->read("select activityId, className from WorkflowActivity where workflowId=?
and sequenceNumber>=? order by sequenceNumber", [$self->getId, $sequenceNumber]);
my ($id, $class) = $rs->array;
$rs->finish;
return $class->new($self->session, $id);
}
#-------------------------------------------------------------------
=head2 getId ( )
@ -212,13 +238,13 @@ sub session {
#-------------------------------------------------------------------
=head2 set ( name , value )
=head2 set ( properties )
Sets a variable for this workflow.
=head3 name
=head3 properties
The name of the variable to set. The following are the available fields to set.
A hash reference containing the properties to set.
=head4 title
@ -232,17 +258,23 @@ A longer description of the workflow.
A boolean indicating whether this workflow may be executed right now.
=head3 value
=head4 type
The value of the variable.
A string indicating the type of object this workflow will be operating on. Valid values are "none", "versiontag" and "user".
=cut
sub set {
my $self = shift;
my $name = shift;
my $value = shift;
$self->{_data}{$name} = $value;
my $properties = shift;
if ($properties->{enabled} == 1) {
$self->{_data}{enabled} = 1;
} elsif ($properties->{enabled} == 0) {
$self->{_data}{enabled} = 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";
$self->session->db->setRow("Workflow","workflowId",$self->{_data});
}

View file

@ -168,6 +168,19 @@ sub getName {
return "Unnamed";
}
#-------------------------------------------------------------------
=head2 getType ( )
Returns the type of workflow that this activity may be used in. Unless this method is overriden, the type is "none". This is a class method.
=cut
sub getType {
return "none";
}
#-------------------------------------------------------------------
=head2 new ( session, activityId )

View file

@ -221,14 +221,14 @@ sub set {
my $self = shift;
my $properties = shift;
if ($properties->{enabled} == 1) {
$self->{enabled} = 1;
$self->{_data}{enabled} = 1;
} elsif ($properties->{enabled} == 0) {
$self->{enabled} = 0;
$self->{_data}{enabled} = 0;
}
if ($properties->{runOnce} == 1) {
$self->{runOnce} = 1;
$self->{_data}{runOnce} = 1;
} elsif ($properties->{runOnce} == 0) {
$self->{runOnce} = 0;
$self->{_data}{runOnce} = 0;
}
$self->{_data}{minuteOfHour} = $properties->{minuteOfHour} || $self->{_data}{minuteOfHour} || 0;
$self->{_data}{hourOfDay} = $properties->{hourOfDay} || $self->{_data}{hourOfDay} || "*";