Class: OpenWFE::Extras::ActiveParticipant
- Inherits:
-
Object
- Object
- OpenWFE::Extras::ActiveParticipant
- Includes:
- LocalParticipant
- Defined in:
- lib/openwfe/extras/participants/activeparticipants.rb
Overview
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
Compact workitems
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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#compact_workitems ⇒ Object
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).
Instance Method Summary collapse
-
#cancel(cancelitem) ⇒ Object
Called by the engine when the whole process instance (or just the segment of it that sports this participant) is cancelled.
-
#consume(workitem) ⇒ Object
This is the method called by the OpenWFEru engine to hand a workitem to this participant.
-
#reply_to_engine(workitem) ⇒ Object
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.
Instance Attribute Details
#compact_workitems ⇒ Object
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.
622 623 624 |
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 622 def compact_workitems @compact_workitems end |
Instance Method Details
#cancel(cancelitem) ⇒ Object
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.
645 646 647 648 |
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 645 def cancel (cancelitem) Workitem.delete_all([ "fei = ?", cancelitem.fei.to_s ]) end |
#consume(workitem) ⇒ Object
This is the method called by the OpenWFEru engine to hand a workitem to this participant.
628 629 630 631 632 633 634 635 |
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 628 def consume (workitem) if compact_workitems workitem.attributes["compact_workitems"] = true end Workitem.from_owfe_workitem workitem end |
#reply_to_engine(workitem) ⇒ Object
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.
655 656 657 658 659 660 661 662 663 664 |
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 655 def reply_to_engine (workitem) super workitem.as_owfe_workitem # # replies to the workflow engine workitem.destroy # # removes the workitem from the database end |