| Class | OpenWFE::Extras::ActiveParticipant |
| In: |
lib/openwfe/extras/participants/activeparticipants.rb
|
| Parent: | Object |
A basic ‘ActiveParticipant’. A store participant whose store is a set of ActiveRecord tables.
Sample usage :
class MyDefinition < OpenWFE::ProcessDefinition
sequence do
active0
active1
end
end
def play_with_the_engine
engine = OpenWFE::Engine.new
engine.register_participant(
:active0, OpenWFE::Extras::ActiveParticipant)
engine.register_participant(
:active1, OpenWFE::Extras::ActiveParticipant)
li = OpenWFE::LaunchItem.new(MyDefinition)
li.customer_name = 'toto'
engine.launch li
sleep 0.500
# give some slack to the engine, it's asynchronous after all
wi = OpenWFE::Extras::Workitem.find_by_participant_name("active0")
# ...
end
It is possible to save all the workitem data into a single table, the workitems table, without splitting info between workitems and fields tables.
You can configure the "compact_workitems" behavior by adding to the previous lines:
active0 = engine.register_participant(
:active0, OpenWFE::Extras::ActiveParticipant)
active0.compact_workitems = true
This behaviour is determined participant per participant, it‘s ok to have a participant instance that compacts will there is another that doesn‘t compact.
| compact_workitems | [RW] | when compact_workitems is set to true, the attributes of a workitem are stored in the yattributes column (they are not expanded into the Fields table). By default, workitem attributes are expanded. |
Called by the engine when the whole process instance (or just the segment of it that sports this participant) is cancelled. Will removed the workitem with the same fei as the cancelitem from the database.
No expression will be raised if there is no corresponding workitem.
# File lib/openwfe/extras/participants/activeparticipants.rb, line 645
645: def cancel (cancelitem)
646:
647: Workitem.delete_all([ "fei = ?", cancelitem.fei.to_s ])
648: end
This is the method called by the OpenWFEru engine to hand a workitem to this participant.
# File lib/openwfe/extras/participants/activeparticipants.rb, line 628
628: def consume (workitem)
629:
630: if compact_workitems
631: workitem.attributes["compact_workitems"] = true
632: end
633:
634: Workitem.from_owfe_workitem workitem
635: end
When the activity/work/operation whatever is over and the flow should resume, this is the method to use to hand back the [modified] workitem to the [local] engine.
# File lib/openwfe/extras/participants/activeparticipants.rb, line 655
655: def reply_to_engine (workitem)
656:
657: super workitem.as_owfe_workitem
658: #
659: # replies to the workflow engine
660:
661: workitem.destroy
662: #
663: # removes the workitem from the database
664: end