ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilCaseNode.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
5 require_once './Services/WorkflowEngine/classes/nodes/class.ilBaseNode.php';
6 
18 class ilCaseNode extends ilBaseNode
19 {
22 
25 
28 
30  public $is_exclusive;
31 
37  public function __construct(ilWorkflow $context)
38  {
39  $this->context = $context;
40  $this->detectors = array();
41  $this->emitters = array();
42  $this->else_emitters = array();
43  $this->activities = array();
44  $this->is_exclusive = false;
45  }
46 
51  {
52  $this->is_exclusive_join = $is_exclusive;
53  }
54 
59  {
60  $this->is_exclusive_fork = $is_exclusive;
61  }
62 
66  public function activate()
67  {
68  $this->active = true;
69  foreach($this->detectors as $detector)
70  {
71  $detector->onActivate();
72  }
73  $this->onActivate();
74  $this->attemptTransition();
75  }
76 
80  public function deactivate()
81  {
82  $this->active = false;
83  foreach($this->detectors as $detector)
84  {
85  $detector->onDeactivate();
86  }
87  $this->onDeactivate();
88  }
89 
99  public function checkTransitionPreconditions()
100  {
101  // queries the $detectors if their conditions are met.
102  $isPreconditionMet = true;
103  foreach ($this->detectors as $detector)
104  {
105  if ($isPreconditionMet == true)
106  {
107  $isPreconditionMet = $detector->getDetectorState();
108  if($isPreconditionMet && ($this->is_exclusive_join || $this->is_exclusive_fork || $this->is_exclusive))
109  {
110  break;
111  }
112  }
113  }
114  return $isPreconditionMet;
115  }
116 
125  public function attemptTransition()
126  {
127  if ($this->checkTransitionPreconditions() == true)
128  {
129  $this->executeTransition();
130  return true;
131  }
132  else
133  {
134  return false;
135  }
136  }
137 
141  public function executeTransition()
142  {
143  $this->deactivate();
144  if (count($this->activities) != 0)
145  {
146  foreach ($this->activities as $activity)
147  {
148  $activity->execute();
149  }
150  }
151 
152  foreach((array)$this->condition_emitter_pairs as $pair)
153  {
154  $that = $this;
155  $eval_function = create_function('$that', $pair['expression']);
156  if($eval_function($this->detectors) === true)
157  {
158  $emitter = $pair['emitter'];
159  $emitter->emit();
160  if($this->is_exclusive_fork || $this->is_exclusive_join)
161  {
162  return;
163  }
164  }
165  }
166  }
167 
174  public function addEmitter(ilEmitter $emitter, $expression = 'return true;')
175  {
176  $this->condition_emitter_pairs[] = array(
177  'emitter' => $emitter,
178  'expression' => $expression
179  );
180  }
181 
189  public function notifyDetectorSatisfaction(ilDetector $detector)
190  {
191  if ($this->isActive())
192  {
193  $this->attemptTransition();
194  }
195  }
196 }
attemptTransition()
Attempts to transit the node.
checkTransitionPreconditions()
Checks, if the preconditions of the node to transit are met.
notifyDetectorSatisfaction(ilDetector $detector)
This method is called by detectors, that just switched to being satisfied.
setIsExclusiveFork($is_exclusive)
activate()
Activates the node.
isActive()
Returns the activation status of the node.
PhpIncludeInspection
addEmitter(ilEmitter $emitter, $expression='return true;')
Adds an emitter to one of the lists attached to the node.
deactivate()
Deactivates the node.
onActivate()
Method called on activation of the node.
onDeactivate()
Method calles on deactivation of the node.
executeTransition()
Executes the &#39;then&#39;-transition of the node.
Create styles array
The data for the language used.
PhpIncludeInspection
Definition: ilWorkflow.php:23
__construct(ilWorkflow $context)
Default constructor.
PhpIncludeInspection
ilDetector Interface is part of the petri net based workflow engine.
Definition: ilDetector.php:16
ilEmitter Interface is part of the petri net based workflow engine.
Definition: ilEmitter.php:16
setIsExclusiveJoin($is_exclusive)