diff --git a/lib/WebGUI/Operation/Workflow.pm b/lib/WebGUI/Operation/Workflow.pm
index a6b0bf476..ef87d082c 100644
--- a/lib/WebGUI/Operation/Workflow.pm
+++ b/lib/WebGUI/Operation/Workflow.pm
@@ -127,16 +127,10 @@ sub www_editWorkflow {
$workflow = WebGUI::Workflow->new($session, $session->form->get("workflowId")) unless (defined $workflow);
my $i18n = WebGUI::International->new($session, "Workflow");
my $workflowActivities = $session->config->get("workflowActivities");
- my $addmenu = '
';
- foreach my $activity (@{$workflowActivities->{$workflow->get("type")}}) {
- my $cmd = "use $activity";
- eval ($cmd);
- if ($@) {
- $session->errorHandler->warn("Couldn't compile activity package: ".$activity.". Root cause: ".$@);
- return undef;
- } else {
- $addmenu .= '
getId).'">'.$activity->getName($session)."\n";
- }
+ my $addmenu = '
';
+ foreach my $class (@{$workflowActivities->{$workflow->get("type")}}) {
+ my $activity = WebGUI::Workflow::Activity->newByPropertyHashRef($session, {className=>$class});
+ $addmenu .= '
getId).'">'.$activity->getName."\n";
}
$addmenu .= '
';
my $f = WebGUI::HTMLForm->new($session);
@@ -246,7 +240,7 @@ sub www_editWorkflowActivity {
my $ac = WebGUI::AdminConsole->new($session,"workflow");
$ac->addSubmenuItem($session->url->page("op=addWorkflow"), $i18n->get("add a new workflow"));
$ac->addSubmenuItem($session->url->page("op=manageWorkflows"), $i18n->get("manage workflows"));
- return $ac->render($form->print,$activity->getName($session));
+ return $ac->render($form->print,$activity->getName);
}
#-------------------------------------------------------------------
diff --git a/lib/WebGUI/Workflow.pm b/lib/WebGUI/Workflow.pm
index c4b19231b..38682d7f5 100644
--- a/lib/WebGUI/Workflow.pm
+++ b/lib/WebGUI/Workflow.pm
@@ -160,7 +160,7 @@ sub get {
#-------------------------------------------------------------------
-=head2 getActivity ( activityId [, classname ] )
+=head2 getActivity ( activityId )
Retrieves an activity object. This is just a convenience method, so you don't have to manually load and construct activity objects when you're already working with a workflow.
@@ -168,20 +168,12 @@ Retrieves an activity object. This is just a convenience method, so you don't ha
The unique id of the activity.
-=head3 classname
-
-The classname of the activity. This will be looked up if you don't specify it.
-
=cut
sub getActivity {
my $self = shift;
my $activityId = shift;
- my $class = shift;
- unless ($class) {
- ($class) = $self->session->db->quickArray("select className from WorkflowActivity where activityId=?",[$activityId]);
- }
- return WebGUI::Workflow::Activity->new($self->session, $activityId, $class);
+ return WebGUI::Workflow::Activity->new($self->session, $activityId);
}
#-------------------------------------------------------------------
@@ -195,10 +187,10 @@ Returns an array reference of the activity objects associated with this workflow
sub getActivities {
my $self = shift;
my @activities = ();
- my $rs = $self->session->db->prepare("select activityId, className from WorkflowActivity where workflowId=? order by sequenceNumber");
+ my $rs = $self->session->db->prepare("select activityId from WorkflowActivity where workflowId=? order by sequenceNumber");
$rs->execute([$self->getId]);
- while (my ($activityId, $class) = $rs->array) {
- push(@activities, $self->getActivity($activityId, $class));
+ while (my ($activityId) = $rs->array) {
+ push(@activities, $self->getActivity($activityId));
}
return \@activities;
}
@@ -260,11 +252,9 @@ sub getNextActivity {
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=?
+ my ($id) = $self->session->db->quickArray("select activityId from WorkflowActivity where workflowId=?
and sequenceNumber>=? order by sequenceNumber", [$self->getId, $sequenceNumber]);
- my ($id, $class) = $rs->array;
- $rs->finish;
- return $self->getActivity($id, $class);
+ return $self->getActivity($id);
}
diff --git a/lib/WebGUI/Workflow/Activity.pm b/lib/WebGUI/Workflow/Activity.pm
index d0d9e8aaa..9937357bf 100644
--- a/lib/WebGUI/Workflow/Activity.pm
+++ b/lib/WebGUI/Workflow/Activity.pm
@@ -97,7 +97,7 @@ An array reference containing a list of hash hreferences of properties.
sub definition {
my $class = shift;
my $session = shift;
- my $definition = shift;
+ my $definition = shift || [];
my $i18n = WebGUI::International->new($session, "Workflow_Activity");
push (@{$definition}, {
name=>$i18n->get("topicName"),
@@ -228,26 +228,21 @@ sub getId {
#-------------------------------------------------------------------
-=head2 getName ( session )
+=head2 getName ( )
-Returns the name of the activity. Must be overridden. This is a class method.
-
-=head3 session
-
-A reference to the current session.
+Returns the name of the activity.
=cut
sub getName {
- my $class = shift;
- my $session = shift;
- my $definition = $class->definition($session);
+ my $self = shift;
+ my $definition = $self->definition($self->session);
return $definition->[0]{name};
}
#-------------------------------------------------------------------
-=head2 new ( session, activityId [, classname] )
+=head2 new ( session, activityId )
Constructor.
@@ -259,28 +254,21 @@ A reference to the current session.
A unique id refering to an instance of an activity.
-=head3 classname
-
-The classsname of the activity you wish to add.
-
=cut
sub new {
my $class = shift;
my $session = shift;
my $activityId = shift;
- my $className = shift;
my $main = $session->db->getRow("WorkflowActivity","activityId", $activityId);
return undef unless $main->{activityId};
- if ($className) {
- my $cmd = "use ".$className;
- eval ($cmd);
- if ($@) {
- $session->errorHandler->error("Couldn't compile workflow activity package: ".$className.". Root cause: ".$@);
- return undef;
- }
- $class = $className;
- }
+ $class = $main->{className};
+ my $cmd = "use ".$class;
+ eval ($cmd);
+ if ($@) {
+ $session->errorHandler->error("Couldn't compile workflow activity package: ".$class.". Root cause: ".$@);
+ return undef;
+ }
my $sub = $session->db->buildHashRef("select name,value from WorkflowActivityData where activityId=?",[$activityId]);
my %data = (%{$main}, %{$sub});
bless {_session=>$session, _id=>$activityId, _data=>\%data}, $class;