-
-
Save jasonvasquez/f1f79111565010d3490a to your computer and use it in GitHub Desktop.
draft cursor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.