def schedule_timers(timers)
timers.each do |t|
after, action = if t.is_a?(String)
i = t.rindex(':')
[ t[0..i - 1], t[i + 1..-1] ]
else
t
end
after = after.strip
action = action.strip
next if after == ''
msg = case action
when 'timeout', 'undo', 'pass'
{ 'action' => 'cancel',
'fei' => h.fei,
'flavour' => action == 'timeout' ? 'timeout' : nil }
when 'redo', 'retry'
{ 'action' => 'cancel',
'fei' => h.fei,
're_apply' => true }
when /^err(or)?( *.+)?$/
message = if $~[2]
$~[2].to_s.strip
else
"timer induced error (\"#{after}: #{action}\")"
end
{ 'action' => 'cancel',
'fei' => h.fei,
're_apply' => { 'tree' => [ 'error', { message => nil }, [] ] } }
when CommandExpression::REGEXP
{ 'action' => 'cancel',
'fei' => h.fei,
're_apply' => {
'tree' => [
$~[1], { $~[2].split(' ').last.to_s => nil }, [] ] } }
else
{ 'action' => 'apply',
'wfid' => h.fei['wfid'],
'expid' => h.fei['expid'],
'parent_id' => h.fei,
'flanking' => true,
'tree' => [ action, {}, [] ],
'workitem' => h.applied_workitem }
end
(h.timers ||= []) <<
[ @context.storage.put_schedule('at', h.fei, after, msg), action ]
end
end