http://openwferu.rubyforge.org/
JRubyも1.0.1になったことだし、そろそろOpenWFEruも動くのでは…ってことで、以下インストールより。
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>bin\gem.bat install openwferu-0.9.13.874.gem
Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find openwferu-0.9.13.874.gem (> 0) in any repository
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>bin\gem.bat install openwferu
Successfully installed openwferu-0.9.13
Installing ri documentation for openwferu-0.9.13...
Installing RDoc documentation for openwferu-0.9.13...
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>bin\gem.bat install openwferu-extras
Successfully installed openwferu-extras-0.9.13
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>
さてさて、ではQuickStartから。以下です。
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>more openwferu.rb
require 'rubygems'
require 'openwfe/def'
require 'openwfe/workitem'
require 'openwfe/engine/engine'
#
# instantiating an engine
engine = OpenWFE::Engine.new
#
# adding some participants
engine.register_participant :alice do |workitem|
puts "alice got a workitem..."
workitem.alice_comment = "this thing looks interesting"
end
engine.register_participant :bob do |workitem|
puts "bob got a workitem..."
workitem.bob_comment = "not for me, I prefer VB"
workitem.bob_comment2 = "Bob rules"
end
engine.register_participant :summarize do |workitem|
puts
puts "summary of process #{workitem.fei.workflow_instance_id}"
workitem.attributes.each do |k, v|
next unless k.match ".*_comment$"
puts " - #{k} : '#{v}'"
end
end
#
# a process definition
class TheProcessDefinition0 < OpenWFE::ProcessDefinition
sequence do
concurrence do
participant :alice
participant :bob
end
participant :summarize
end
end
#
# launching the process
li = OpenWFE::LaunchItem.new(TheProcessDefinition0)
li.initial_comment = "please give your impressions about http://ruby-lang.org"
fei = engine.launch(li)
engine.wait_for fei
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>bin\jruby.bat openwferu.rb
alice got a workitem...
bob got a workitem...
summary of process 20070828-diyutzugisa
- bob_comment : 'not for me, I prefer VB'
- alice_comment : 'this thing looks interesting'
- initial_comment : 'please give your impressions about http://ruby-lang.org'
バッチ ジョブを終了しますか (Y/N)? ^C
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>
おお、いけてるいけてる。では最近のCSV-Decision Tablesを…以下。
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>more csv_sample.rb
require 'rubygems'
require 'openwfe/extras/util/csvtable'
require 'openwfe/workitem'
include OpenWFE::Extras
table = CsvTable.new("""
in:topic,in:region,out:team_member
sports,europe,Alice
sports,,Bob
finance,america,Charly
finance,europe,Donald
finance,,Ernest
politics,asia,Fujio
politics,america,Gilbert
politics,,Henry
,,Zach
""")
h = {}
h["topic"] = "politics"
table.transform(h)
puts h["team_member"]
h["topic"] = "sports"
table.transform(h)
puts h["team_member"]
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>bin\jruby csv_sample.rb
Henry
Bob
C:\temp\jruby-bin-1.0.1\jruby-1.0.1>
おお、できるできる…のOpenWFEru on JRubyでした。動作環境はJRE1.6.0_02/JRuby1.0.1/OpenWFE0.9.13でした。
Permalink
Categories: {Script_on_Java} {workflow}