Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds GenericObject to Workflow - for use by Flux workflows
To be fully flexible, Flux needs to be able to pass any data it likes into workflow activities, whereas WebGUI's workflow system requires that you specify what object the workflow instance will work with (User, etc..) To work around this, I added a new object that can take arbitrary data. This was motivated by the "email user about flux rule" workflow activity, which needed to know which flux rule had just become true. Previously, all flux workflows expected a User object, whereas now you can use the GenericObject and pass in a userId, fluxRuleId, and anything else you need.
- Loading branch information
Showing
4 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/*.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package WebGUI::Workflow::Instance::GenericObject; | ||
|
||
sub new { | ||
my ($class, $session, $properties) = @_; | ||
bless { session => $session, %$properties }, $class; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Tests WebGUI::Workflow::Instance::GenericObject | ||
|
||
use strict; | ||
use warnings; | ||
use FindBin; | ||
use lib "$FindBin::Bin/../lib"; | ||
use Test::More; | ||
use WebGUI::Test; # Must use this before any other WebGUI modules | ||
use WebGUI::Session; | ||
|
||
#---------------------------------------------------------------------------- | ||
# Init | ||
my $session = WebGUI::Test->session; | ||
|
||
#---------------------------------------------------------------------------- | ||
# Tests | ||
plan tests => 5; | ||
|
||
#---------------------------------------------------------------------------- | ||
# put your tests here | ||
|
||
use_ok('WebGUI::Workflow::Instance::GenericObject'); | ||
|
||
my %props = ( a => 1, b => 2, c => 3 ); | ||
my $d = WebGUI::Workflow::Instance::GenericObject->new( $session, {%props} ); | ||
is( $d->{$_}, $props{$_}, qq{Property "$_" matches} ) for qw(a b); | ||
|
||
my $wf = WebGUI::Workflow->create( | ||
$session, | ||
{ title => 'WebGUI::Workflow::Instance Test', | ||
description => 'Description', | ||
type => 'None', | ||
mode => 'singleton', | ||
} | ||
); | ||
WebGUI::Test->workflowsToDelete($wf); | ||
my $instance = WebGUI::Workflow::Instance->create( | ||
$session, | ||
{ workflowId => $wf->getId, | ||
methodName => "new", | ||
className => "WebGUI::Workflow::Instance::GenericObject", | ||
parameters => {%props}, | ||
} | ||
); | ||
|
||
my $obj = $instance->getObject; | ||
is( $obj->{$_}, $props{$_}, qq{Property "$_" matches} ) for qw(a b); |