Interfacing Ruby and OpenWFE.
One of the quickest written connector (Ruby is great).
Recently, OpenWFE-ruby got moved to RubyForge and became OpenWFEru. It's a port of the OpenWFE workflow engine to Ruby.
client = OpenWFE::WorklistClient\
.new("http://127.0.0.1:5080/worklist", "alice", "alice")
puts "sessionId : #{client.sessionId}"
#puts client.get('getstorenames', nil, nil)
puts "Stores :"
l = client.listStores()
l.each do |s|
puts " - store name : '#{s.name}' wi count : #{s.workitemCount} permissi
ons : #{s.permissions}"
end
puts
puts "launching a flow"
li = OpenWFE::LaunchItem.new()
li.workflowDefinitionUrl = "http://localhost:7079/flow__1.0.xml"
li.attributes["__subject__"] = "openwfe-ruby"
fei = client.launchFlow("mainEngine", li)
puts fei
puts
feiToFetch = nil
puts "Store.alpha's headers :"
l = client.getHeaders("Store.alpha")
l.each do |h|
puts " - header lastModified : #{h.lastModified} locked : #{h.locked} ac
: #{h.attributes.length}"
puts " fei : #{h.flowExpressionId}"
feiToFetch = h.flowExpressionId
end
puts "Fetching the first workitem :"
wi = client.getWorkitem("Store.alpha", feiToFetch)
#puts wi.inspect()
puts
puts "Fetching (and locking) the first workitem :"
wi = client.getAndLockWorkitem("Store.alpha", feiToFetch)
puts wi.inspect()
puts
puts "Releasing the workitem :"
puts "ok" if client.releaseWorkitem(wi)
puts
puts "Listing launchables :"
client.listLaunchables().each do |l|
puts " - launchable #{l.engineId} :: #{l.url}"
end
puts
puts "Closing worklist worksession"
puts client.close()
Or play with the engine :
def display_expressions (exps)
i = 0
exps.each do |exp|
print " - exp #{i} : #{exp.id}"
print " / #{exp.applyTime}" if exp.applyTime
print "\n"
i = i+1
end
end
puts "Testing the control interface..."
#
# launching a test flow
#TEST_NAME = '-- testing ruby control (0) --'
#client = OpenWFE::WorklistClient\
# .new("http://127.0.0.1:5080/worklist", "alice", "alice")
#li = OpenWFE::LaunchItem.new()
#li.workflowDefinitionUrl = "http://localhost:7079/flow__1.0.xml"
#li.attributes["__subject__"] = TEST_NAME
#fei = client.launchFlow("mainEngine", li)
#puts "launched : #{fei}"
#client.close()
#
# controlling the test flow
client = OpenWFE::ControlClient\
.new("http://127.0.0.1:6080/engine", "admin", "admin")
puts "sessionId : #{client.sessionId}"
puts
puts "listing expressions :"
exps = client.listExpressions()
display_expressions(exps)
client.close()