ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilConditionalNode Class Reference

@noinspection PhpIncludeInspection More...

+ Inheritance diagram for ilConditionalNode:
+ Collaboration diagram for ilConditionalNode:

Public Member Functions

 __construct (ilWorkflow $a_context)
 Default constructor. More...
 
 activate ()
 Activates the node. More...
 
 deactivate ()
 Deactivates the node. More...
 
 checkTransitionPreconditions ()
 Checks, if the preconditions of the node to transit are met. More...
 
 attemptTransition ()
 Attempts to transit the node. More...
 
 executeTransition ()
 Executes the 'then'-transition of the node. More...
 
 executeElseTransition ()
 Executes the 'else'-transition of the node. More...
 
 addEmitter (ilEmitter $emitter, $else_emitter=false)
 Adds an emitter to one of the lists attached to the node. More...
 
 addActivity (ilActivity $activity, $else_activity=false)
 Adds an activity to one of the lists attached to the node. More...
 
 setEvaluationExpression ($a_expression)
 
 notifyDetectorSatisfaction (ilDetector $detector)
 This method is called by detectors, that just switched to being satisfied. More...
 
 getActivities ($else=false)
 Returns all currently set activites. More...
 
 getEmitters ($else=false)
 Returns all currently set emitters. More...
 
- Public Member Functions inherited from ilBaseNode
 addDetector (ilDetector $detector)
 Adds a detector to the list of detectors. More...
 
 getDetectors ()
 Returns all currently set detectors. More...
 
 addEmitter (ilEmitter $emitter)
 Adds an emitter to the list of emitters. More...
 
 getEmitters ()
 Returns all currently set emitters. More...
 
 addActivity (ilActivity $activity)
 Adds an activity to the list of activities. More...
 
 getActivities ()
 Returns all currently set activities. More...
 
 getContext ()
 Returns a reference to the parent workflow object. More...
 
 setName ($name)
 
 getName ()
 
 getRuntimeVars ()
 
 setRuntimeVars ($runtime_vars)
 
 getRuntimeVar ($name)
 
 setRuntimeVar ($name, $value)
 
 onActivate ()
 Method called on activation of the node. More...
 
 onDeactivate ()
 Method calles on deactivation of the node. More...
 
 isActive ()
 Returns the activation status of the node. More...
 
 attemptTransition ()
 
 checkTransitionPreconditions ()
 
 executeTransition ()
 
 activate ()
 
 deactivate ()
 
 notifyDetectorSatisfaction (ilDetector $detector)
 
 attemptTransition ()
 
 checkTransitionPreconditions ()
 
 executeTransition ()
 
 addDetector (ilDetector $detector)
 
 addEmitter (ilEmitter $emitter)
 
 addActivity (ilActivity $activity)
 
 activate ()
 
 deactivate ()
 
 onActivate ()
 
 onDeactivate ()
 
 notifyDetectorSatisfaction (ilDetector $detector)
 
 getDetectors ()
 
 getEmitters ()
 
 getRuntimeVars ()
 
 setRuntimeVars ($runtime_vars)
 
 getRuntimeVar ($name)
 
 setRuntimeVar ($name, $value)
 
 getContext ()
 This method returns the context of the element. More...
 
 setName ($name)
 
 getName ()
 

Private Member Functions

 executeActivities ()
 Executes all 'then'-activities attached to the node. More...
 
 executeElseActivities ()
 Exectes all 'else'-activities attached to the node. More...
 
 executeEmitters ()
 Executes all 'then'-emitters attached to the node. More...
 
 executeElseEmitters ()
 Executes all 'else'-emitters attached to the node. More...
 

Private Attributes

 $else_emitters
 
 $else_activities
 
 $evaluation_expression = "return true;"
 

Additional Inherited Members

- Protected Attributes inherited from ilBaseNode
 $context
 
 $detectors
 
 $emitters
 
 $activities
 
 $active = false
 
 $name
 
 $runtime_vars
 

Detailed Description

@noinspection PhpIncludeInspection

Conditional node of the petri net based workflow engine.

The conditional node is a deciding node. It features a doubled set of emitters and activities. The new set is prefixed with 'else_'. In the core of it, a given piece of php code is executed that returns either true, false or null, telling the node which set is to be executed - if any. This takes advantage of create_function, which is just as evil as eval. Because of that, the configuration of the conditional node must not be made available to users/admins and the content which makes up the evaluation method has no business in the database as this may pose a severe risk. Put these code pieces into the workflow object and set it during workflow creation. Remember: I told you before. Alternatively, you can extend this class and pre-set a code, that takes parameters from ilSetting, ini-Files, water diviner... up to you. Keep in mind to check these parameters for type and where possible, avoid strings and/or types that allow larger code segments.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

/

Definition at line 29 of file class.ilConditionalNode.php.

Constructor & Destructor Documentation

◆ __construct()

ilConditionalNode::__construct ( ilWorkflow  $a_context)

Default constructor.

Parameters
ilWorkflowReference to the parent workflow.

Definition at line 60 of file class.ilConditionalNode.php.

61 {
62 $this->context = $a_context;
63 $this->detectors = array();
64 $this->emitters = array();
65 $this->else_emitters = array();
66 $this->activities = array();
67 $this->else_activities = array();
68 }

Member Function Documentation

◆ activate()

ilConditionalNode::activate ( )

Activates the node.

Reimplemented from ilBaseNode.

Definition at line 73 of file class.ilConditionalNode.php.

74 {
75 $this->active = true;
76 foreach($this->detectors as $detector)
77 {
78 $detector->onActivate();
79 }
80 $this->onActivate();
81 $this->attemptTransition();
82 }
onActivate()
Method called on activation of the node.
attemptTransition()
Attempts to transit the node.

References attemptTransition(), and ilBaseNode\onActivate().

+ Here is the call graph for this function:

◆ addActivity()

ilConditionalNode::addActivity ( ilActivity  $activity,
  $else_activity = false 
)

Adds an activity to one of the lists attached to the node.

Parameters
ilActivity$activity
boolean$else_activityTrue, if the activity should be an 'else'-activity.

Definition at line 254 of file class.ilConditionalNode.php.

255 {
256 if (!$else_activity)
257 {
258 $this->activities[] = $activity;
259 }
260 else
261 {
262 $this->else_activities[] = $activity;
263 }
264 }

◆ addEmitter()

ilConditionalNode::addEmitter ( ilEmitter  $emitter,
  $else_emitter = false 
)

Adds an emitter to one of the lists attached to the node.

Parameters
ilEmitter$emitter
boolean$else_emitterTrue, if the emitter should be an 'else'-emitter.

Definition at line 236 of file class.ilConditionalNode.php.

237 {
238 if (!$else_emitter)
239 {
240 $this->emitters[] = $emitter;
241 }
242 else
243 {
244 $this->else_emitters[] = $emitter;
245 }
246 }

◆ attemptTransition()

ilConditionalNode::attemptTransition ( )

Attempts to transit the node.

Basically, this checks for preconditions and transits, returning true or false if preconditions are not met, aka detectors are not fully satisfied.

Returns
boolean True, if transition succeeded.

Reimplemented from ilBaseNode.

Definition at line 133 of file class.ilConditionalNode.php.

134 {
135 $eval_function = create_function('$detectors', $this->evaluation_expression);
136
137 if ($eval_function($this->detectors) === null)
138 {
139 return false;
140 }
141
142 if ($eval_function($this->detectors) === true)
143 {
144 $this->executeTransition();
145 return true;
146 }
147 else
148 {
149 $this->executeElseTransition();
150 return true;
151 }
152 }
executeElseTransition()
Executes the 'else'-transition of the node.
executeTransition()
Executes the 'then'-transition of the node.

References executeElseTransition(), and executeTransition().

Referenced by activate(), and notifyDetectorSatisfaction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkTransitionPreconditions()

ilConditionalNode::checkTransitionPreconditions ( )

Checks, if the preconditions of the node to transit are met.

Please note, that in a conditional node, this means the node can transit to one or another outcome. This method only returns false, if the return value of the method is neither true nor false.

Returns
boolean True, if node is ready to transit.

Reimplemented from ilBaseNode.

Definition at line 106 of file class.ilConditionalNode.php.

107 {
108 $eval_function = create_function('$detectors', $this->evaluation_expression);
109
110 if ($eval_function($this->detectors) === null)
111 {
112 return false;
113 }
114
115 if ($eval_function($this->detectors) === true)
116 {
117 return true;
118 }
119 else
120 {
121 return true;
122 }
123 }

◆ deactivate()

ilConditionalNode::deactivate ( )

Deactivates the node.

Reimplemented from ilBaseNode.

Definition at line 87 of file class.ilConditionalNode.php.

88 {
89 $this->active = false;
90 foreach($this->detectors as $detector)
91 {
92 $detector->onDeactivate();
93 }
94 $this->onDeactivate();
95 }
onDeactivate()
Method calles on deactivation of the node.

References ilBaseNode\onDeactivate().

Referenced by executeElseTransition(), and executeTransition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeActivities()

ilConditionalNode::executeActivities ( )
private

Executes all 'then'-activities attached to the node.

Definition at line 157 of file class.ilConditionalNode.php.

158 {
159 if (count($this->activities) != 0)
160 {
161 foreach ($this->activities as $activity)
162 {
163 $activity->execute();
164 }
165 }
166 }

Referenced by executeTransition().

+ Here is the caller graph for this function:

◆ executeElseActivities()

ilConditionalNode::executeElseActivities ( )
private

Exectes all 'else'-activities attached to the node.

Definition at line 171 of file class.ilConditionalNode.php.

172 {
173 if (count($this->else_activities) != 0)
174 {
175 foreach ($this->else_activities as $activity)
176 {
177 $activity->execute();
178 }
179 }
180 }

Referenced by executeElseTransition().

+ Here is the caller graph for this function:

◆ executeElseEmitters()

ilConditionalNode::executeElseEmitters ( )
private

Executes all 'else'-emitters attached to the node.

Definition at line 199 of file class.ilConditionalNode.php.

200 {
201 if (count($this->else_emitters) != 0)
202 {
203 foreach ($this->else_emitters as $emitter)
204 {
205 $emitter->emit();
206 }
207 }
208 }

Referenced by executeElseTransition().

+ Here is the caller graph for this function:

◆ executeElseTransition()

ilConditionalNode::executeElseTransition ( )

Executes the 'else'-transition of the node.

Definition at line 223 of file class.ilConditionalNode.php.

224 {
225 $this->deactivate();
226 $this->executeElseActivities();
227 $this->executeElseEmitters();
228 }
executeElseActivities()
Exectes all 'else'-activities attached to the node.
deactivate()
Deactivates the node.
executeElseEmitters()
Executes all 'else'-emitters attached to the node.

References deactivate(), executeElseActivities(), and executeElseEmitters().

Referenced by attemptTransition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeEmitters()

ilConditionalNode::executeEmitters ( )
private

Executes all 'then'-emitters attached to the node.

Definition at line 185 of file class.ilConditionalNode.php.

186 {
187 if (count($this->emitters) != 0)
188 {
189 foreach ($this->emitters as $emitter)
190 {
191 $emitter->emit();
192 }
193 }
194 }

Referenced by executeTransition().

+ Here is the caller graph for this function:

◆ executeTransition()

ilConditionalNode::executeTransition ( )

Executes the 'then'-transition of the node.

Reimplemented from ilBaseNode.

Definition at line 213 of file class.ilConditionalNode.php.

214 {
215 $this->deactivate();
216 $this->executeActivities();
217 $this->executeEmitters();
218 }
executeEmitters()
Executes all 'then'-emitters attached to the node.
executeActivities()
Executes all 'then'-activities attached to the node.

References deactivate(), executeActivities(), and executeEmitters().

Referenced by attemptTransition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActivities()

ilConditionalNode::getActivities (   $else = false)

Returns all currently set activites.

Parameters
boolean$elseTrue, if else activities should be returned.
Returns
Array Array with objects of ilActivity

Definition at line 329 of file class.ilConditionalNode.php.

330 {
331 if ($else)
332 {
334 }
335
336 return $this->activities;
337 }

References ilBaseNode\$activities, and $else_activities.

◆ getEmitters()

ilConditionalNode::getEmitters (   $else = false)

Returns all currently set emitters.

Parameters
boolean$elseTrue, if else emitters should be returned.
Returns
Array Array with objects of ilEmitter

Definition at line 346 of file class.ilConditionalNode.php.

347 {
348 if ($else)
349 {
351 }
352
353 return $this->emitters;
354 }

References $else_emitters, and ilBaseNode\$emitters.

◆ notifyDetectorSatisfaction()

ilConditionalNode::notifyDetectorSatisfaction ( ilDetector  $detector)

This method is called by detectors, that just switched to being satisfied.

Parameters
ilDetector$detectorilDetector which is now satisfied.
Returns
mixed|void

Reimplemented from ilBaseNode.

Definition at line 314 of file class.ilConditionalNode.php.

315 {
316 if ($this->isActive())
317 {
318 $this->attemptTransition();
319 }
320 }
isActive()
Returns the activation status of the node.

References attemptTransition(), and ilBaseNode\isActive().

+ Here is the call graph for this function:

◆ setEvaluationExpression()

ilConditionalNode::setEvaluationExpression (   $a_expression)

Definition at line 302 of file class.ilConditionalNode.php.

303 {
304 $this->evaluation_expression = $a_expression;
305 }

Field Documentation

◆ $else_activities

ilConditionalNode::$else_activities
private

Definition at line 45 of file class.ilConditionalNode.php.

Referenced by getActivities().

◆ $else_emitters

ilConditionalNode::$else_emitters
private

Definition at line 37 of file class.ilConditionalNode.php.

Referenced by getEmitters().

◆ $evaluation_expression

ilConditionalNode::$evaluation_expression = "return true;"
private

Definition at line 53 of file class.ilConditionalNode.php.


The documentation for this class was generated from the following file: