Class | OpenWFE::Extras::CsvParticipant |
In: |
lib/openwfe/extras/participants/csvparticipants.rb
|
Parent: | Object |
Using CSV files to transform workitems This concept is called "decision participant" in OpenWFEja, here it‘s simply called "csv participant".
See CsvTable for an explanation of the core concept behind a CsvParticipant
An example :
class TestDefinition0 < ProcessDefinition sequence do set :field => "weather", :value => "cloudy" set :field => "month", :value => "may" decision _print "${f:take_umbrella?}" end end csvParticipant = CsvParticipant.new( """ in:weather, in:month, out:take_umbrella? ,, raining, , yes sunny, , no cloudy, june, yes cloudy, may, yes cloudy, , no """) engine.register_participant("decision", csvParticipant) # ... engine.launch(new OpenWFE::LaunchItem(TestDefinition0)
Note that the CsvParticipant constructor also accepts a block.
csv_table | [RW] |
Builds a new CsvParticipant instance, csv_data or the block may contain a File instance, a String or an Array of Array of String instances.
# File lib/openwfe/extras/participants/csvparticipants.rb, line 100 100: def initialize (csv_data=nil, &block) 101: 102: super() 103: 104: csv_data = block.call if block 105: 106: @csv_table = Rufus::DecisionTable.new csv_data 107: end
This is the method called by the engine (actually the ParticipantExpression) when handling a workitem to this participant.
# File lib/openwfe/extras/participants/csvparticipants.rb, line 113 113: def consume (workitem) 114: 115: fe = get_flow_expression workitem 116: 117: @csv_table.transform!(FlowDict.new(fe, workitem, 'f')) 118: # 119: # default_prefix set to 'f' 120: 121: reply_to_engine workitem 122: end