52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/ruote/exp/fe_ref.rb', line 52
def apply
key = (attribute(:ref) || attribute_text).to_s
if name != 'ref'
key = name
tree[1]['ref'] = key
end
key = @context.dollar_sub.s(key, self, h.applied_workitem)
key2, value = iterative_var_lookup(key)
tree[1]['ref'] = key2 if key2
tree[1]['original_ref'] = key if key2 != key
unless value
@h['participant'] =
@context.plist.lookup_info(tree[1]['ref'], h.applied_workitem)
value = key2 if ( ! @h['participant']) && (key2 != key)
end
new_exp_name, new_exp_class = nil
if value.is_a?(String)
if value.index("def consume(") && (Rufus::TreeChecker.parse(value) rescue false)
@h['participant'] = [ 'Ruote::CodeParticipant', { 'code' => value } ]
tree[1]['ref'] = key
elsif klass = @context.expmap.expression_class(tree[1]['ref'])
new_exp_name = value
new_exp_class = klass
end
elsif value.is_a?(Hash) && value['on_workitem']
@h['participant'] = [ 'Ruote::BlockParticipant', value ]
elsif value.is_a?(Array) && value.size == 2 && value.last.is_a?(Hash)
@h['participant'] = value
end
if value == nil and @h['participant'] == nil
@h['state'] = 'failed'
persist_or_raise
raise("unknown participant or subprocess '#{tree[1]['ref']}'")
end
new_exp_name, new_exp_class = if new_exp_name
[ new_exp_name, new_exp_class ]
elsif @h['participant']
[ 'participant', Ruote::Exp::ParticipantExpression ]
else
[ 'subprocess', Ruote::Exp::SubprocessExpression ]
end
tree[0] = new_exp_name
@h['name'] = new_exp_name
new_exp = new_exp_class.new(@context, @h)
do_schedule_timeout(attribute(:timeout)) if new_exp_name == 'subprocess'
new_exp.apply
end
|