Skip to content

Instantly share code, notes, and snippets.

@jasonvasquez

jasonvasquez/updater.rb Secret

Created May 7, 2012
Embed
What would you like to do?
draft cursor
pdef = TestWorkflow_v1_0.main_flow
wfid = RuoteKit.engine.launch(pdef, {'status' => 'draft'})
sleep 8
p = RuoteKit.engine.process(wfid)
p.workitems.each do |wi|
puts "Setting status field on #{wi}"
wi.set_field('status', 'submitted')
RuoteKit.engine.receive(wi)
end
class TestWorkflow_v1_0
def self.main_flow
Ruote.process_definition :name => 'report', :revision => '1.0' do
sequence 'main_flow' do
echo "Beginning main flow"
cursor 'draft_state' do
echo "Beginning draft_state, status: ${f:status}"
form_submitter :timers => '2s: form_draft_reminder, 4s: form_draft_reminder, 12s: cancel_draft_submission'
rewind :if => "${f:status} != 'submitted'"
notifier :message_type => 'form_submitted'
end
cursor 'submitted_state' do
echo "Beginning submitted state"
reviewer :timers => '2s: submitted_form_reminder, 4s: submitted_form_reminder, 6s: submitted_form_reminder'
rewind :if => "${f:status} != 'closed'"
notifier :message_type => 'form_reviewed'
end
echo "submission closed!"
end
define 'form_draft_reminder' do
echo "Beginning form_draft_reminder"
notifier :message_type => 'draft_reminder'
end
define 'submitted_form_reminder' do
echo "Beginning submitted_form_reminder"
notifier :message_type => 'submission_reminder'
end
define 'cancel_draft_submission' do
echo "Beginning cancel_draft_submission"
sequence do
kill_draft
notifier :message_type => 'draft_timeout'
kill_process
end
end
end
end
end
@jasonvasquez

This comment has been minimized.

Copy link
Owner Author

@jasonvasquez jasonvasquez commented May 7, 2012

updater.rb may be called multiple times, sometimes with the same status applied, so the idea is to not proceed past the current cursor until the 'status' field changes to the expected value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.