@@ -144,6 +144,8 @@ func (tb *TaskBehavior) Done(ctx model.TaskContext) (notifyFlow bool, taskEntrie
144
144
logger .Debugf ("Task '%s' has %d outgoing links" , ctx .Task ().ID (), numLinks )
145
145
}
146
146
147
+ var linkFollowed bool
148
+ var otherwiseLinkInst model.LinkInstance
147
149
for _ , linkInst := range linkInsts {
148
150
149
151
follow := true
@@ -153,6 +155,11 @@ func (tb *TaskBehavior) Done(ctx model.TaskContext) (notifyFlow bool, taskEntrie
153
155
continue
154
156
}
155
157
158
+ if linkInst .Link ().Type () == definition .LtOtherwise {
159
+ otherwiseLinkInst = linkInst
160
+ continue
161
+ }
162
+
156
163
if linkInst .Link ().Type () == definition .LtExpression {
157
164
//todo handle error
158
165
if logger .DebugEnabled () {
@@ -166,6 +173,7 @@ func (tb *TaskBehavior) Done(ctx model.TaskContext) (notifyFlow bool, taskEntrie
166
173
}
167
174
168
175
if follow {
176
+ linkFollowed = true
169
177
linkInst .SetStatus (model .LinkStatusTrue )
170
178
171
179
if logger .DebugEnabled () {
@@ -181,6 +189,16 @@ func (tb *TaskBehavior) Done(ctx model.TaskContext) (notifyFlow bool, taskEntrie
181
189
}
182
190
}
183
191
192
+ //Otherwise branch while no link to follow
193
+ if ! linkFollowed && otherwiseLinkInst != nil {
194
+ otherwiseLinkInst .SetStatus (model .LinkStatusTrue )
195
+ if logger .DebugEnabled () {
196
+ logger .Debugf ("Task '%s': Following Link to task '%s'" , ctx .Task ().ID (), otherwiseLinkInst .Link ().ToTask ().ID ())
197
+ }
198
+ taskEntry := & model.TaskEntry {Task : otherwiseLinkInst .Link ().ToTask ()}
199
+ taskEntries = append (taskEntries , taskEntry )
200
+ }
201
+
184
202
//continue on to successor tasks
185
203
return false , taskEntries , nil
186
204
}
0 commit comments