Skip to content

Commit

Permalink
participant : setting the field 'params'
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Jul 1, 2009
1 parent 60262ae commit 04afec3
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 8 deletions.
2 changes: 1 addition & 1 deletion TODO.txt
Expand Up @@ -34,7 +34,7 @@

[o] wi test (and fix) ${f:xyz}
[o] wi#to_h #from_h
[ ] wi.params ?
[o] wi.params

[o] self rec for [main] process

Expand Down
10 changes: 9 additions & 1 deletion lib/ruote/exp/attribute.rb → lib/ruote/exp/attributes.rb
Expand Up @@ -29,7 +29,7 @@ module Ruote
# Those methods are mixed in FlowExpression. They were put here to offload
# FlowExpression and especially, to gather them around their attribute topic.
#
module AttributeMixin
module AttributesMixin

# Given a list of attribute names, returns the first attribute name for
# which there is a value.
Expand Down Expand Up @@ -112,6 +112,14 @@ def lookup_value (prefix)
end
end

# Returns a Hash containing all attributes set for an expression with
# their values resolved.
#
def lookup_attributes

attributes.keys.inject({}) { |h, k| h[k] = attribute(k); h }
end

protected

def list_att_keys (prefix, suffixes)
Expand Down
10 changes: 7 additions & 3 deletions lib/ruote/exp/fe_participant.rb
Expand Up @@ -55,15 +55,13 @@ def apply
) unless participant

@applied_workitem.participant_name = @participant_name
@applied_workitem.fields['params'] = lookup_attributes

persist

dispatch_to(participant)
end

#def reply (workitem)
#end

def cancel

participant = plist.lookup(@participant_name)
Expand All @@ -73,6 +71,12 @@ def cancel
reply_to_parent(@applied_workitem)
end

def reply_to_parent (workitem)

workitem.fields.delete('params')
super(workitem)
end

protected

def dispatch_to (participant)
Expand Down
4 changes: 2 additions & 2 deletions lib/ruote/exp/flowexpression.rb
Expand Up @@ -25,15 +25,15 @@
require 'ruote/util/ometa'
require 'ruote/util/dollar'
require 'ruote/engine/context'
require 'ruote/exp/attribute'
require 'ruote/exp/attributes'


module Ruote

class FlowExpression < ObjectWithMeta

include EngineContext
include AttributeMixin
include AttributesMixin


attr_accessor :fei
Expand Down
2 changes: 1 addition & 1 deletion test/functional/eft_6_concurrence.rb
Expand Up @@ -123,7 +123,7 @@ def test_concurrence_merge_type_isolate
wi = run_concurrence({ :merge_type => :isolate }, false)

assert_equal(
{1=>{"seen"=>"0_0_0_1"}, 0=>{"seen"=>"0_0_0_0"}},
{1=>{"seen"=>"0_0_0_1"}, 0=>{"seen"=>"0_0_0_0"}, "params"=>{"ref"=>"alpha"}},
wi.fields)
end

Expand Down
45 changes: 45 additions & 0 deletions test/functional/ft_16_participant_params.rb
@@ -0,0 +1,45 @@

#
# Testing Ruote (OpenWFEru)
#
# Wed Jul 1 09:51:30 JST 2009
#

require File.dirname(__FILE__) + '/base'

require 'ruote/part/hash_participant'


class FtParticipantParamsTest < Test::Unit::TestCase
include FunctionalBase

def test_params

pdef = Ruote.process_definition do
sequence do
alpha
alpha :activity => 'buy groceries'
alpha
end
end

alpha = @engine.register_participant :alpha, Ruote::HashParticipant

#noisy

wfid = @engine.launch(pdef)

wait_for(:alpha)
assert_equal({ 'ref' => 'alpha' }, alpha.first.fields['params'])
alpha.reply(alpha.first)

wait_for(:alpha)
assert_equal('buy groceries', alpha.first.fields['params']['activity'])
alpha.reply(alpha.first)

wait_for(:alpha)
assert_equal({ 'ref' => 'alpha' }, alpha.first.fields['params'])
alpha.reply(alpha.first)
end
end

0 comments on commit 04afec3

Please sign in to comment.