ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilBasicNode.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
5 require_once './Services/WorkflowEngine/classes/nodes/class.ilBaseNode.php';
6 
15 class ilBasicNode extends ilBaseNode
16 {
29 
32 
34  public $ident;
35 
41  public function __construct(ilWorkflow $context)
42  {
43  $this->context = $context;
44  $this->detectors = array();
45  $this->emitters = array();
46  $this->activities = array();
47  $this->active = false;
48  $this->is_forward_condition_node = false;
49  $this->is_forward_condition_event = false;
50  $this->ident = strtoupper(substr(md5(spl_object_hash($this)),0,6));
51  }
52 
56  public function activate()
57  {
58  if ($this->isActive())
59  {
60  return;
61  }
62 
63  $this->active = true;
64 
65  foreach($this->detectors as $detector)
66  {
67  $detector->onActivate();
68  }
69  $this->onActivate();
70  $this->attemptTransition();
71  }
72 
76  public function deactivate()
77  {
78  $this->active = false;
79  foreach($this->detectors as $detector)
80  {
81  $detector->onDeactivate();
82  }
83  $this->onDeactivate();
84  }
85 
91  public function checkTransitionPreconditions()
92  {
93  // queries the $detectors if their conditions are met.
94  $isPreconditionMet = true;
95  foreach ($this->detectors as $detector)
96  {
97  if ($isPreconditionMet == true)
98  {
99  $isPreconditionMet = $detector->getDetectorState();
100  }
101  }
102  return $isPreconditionMet;
103  }
104 
113  public function attemptTransition()
114  {
115  if ($this->checkTransitionPreconditions() == true)
116  {
117  $this->executeTransition();
118  return true;
119  }
120  else
121  {
122  return false;
123  }
124  }
125 
129  private function executeActivities()
130  {
131  if (count($this->activities) != 0)
132  {
133  foreach ($this->activities as $activity)
134  {
135  $activity->execute();
136  }
137  }
138  }
139 
143  private function executeEmitters()
144  {
145  if (count($this->emitters) != 0)
146  {
147  foreach ($this->emitters as $emitter)
148  {
149  $emitter->emit();
150  }
151  }
152  }
153 
157  public function executeTransition()
158  {
159  $this->deactivate();
160  $this->executeActivities();
161  $this->pingbackToPredecessorNodes();
162  $this->executeEmitters();
163  }
164 
172  public function notifyDetectorSatisfaction(ilDetector $detector)
173  {
174  if ($this->isActive())
175  {
176  $this->attemptTransition();
177  }
178  }
179 
183  public function isForwardConditionNode()
184  {
186  }
187 
192  {
193  $this->is_forward_condition_node = $is_forward_condition_node;
194  }
195 
203  public function deactivateForwardConditionNodes(ilNode $activated_node)
204  {
205  if($this->is_forward_condition_node)
206  {
207  foreach ($this->emitters as $emitter)
208  {
210  $target_detector = $emitter->getTargetDetector();
211 
213  $target_node = $target_detector->getContext();
214 
215  if ($target_node === $activated_node)
216  {
217  continue;
218  }
219  $target_node->deactivate();
220  }
221  }
222  }
223 
224  public function pingbackToPredecessorNodes()
225  {
227  foreach ($this->detectors as $detector)
228  {
230  $source_node = $detector->getSourceNode();
231  if ($source_node && $source_node->is_forward_condition_node)
232  {
233  $source_node->deactivateForwardConditionNodes( $this );
234  }
235  }
236  }
237 }
executeTransition()
Executes the transition, calls all activities and emitters to execute.
isActive()
Returns the activation status of the node.
checkTransitionPreconditions()
Checks, if the preconditions of the node to transit are met.
deactivate()
Deactivates the node.
notifyDetectorSatisfaction(ilDetector $detector)
This method is called by detectors, that just switched to being satisfied.
__construct(ilWorkflow $context)
Default constructor.
onActivate()
Method called on activation of the node.
PhpIncludeInspection
PhpIncludeInspection
Definition: ilNode.php:25
onDeactivate()
Method calles on deactivation of the node.
executeEmitters()
Executes all attached emitters.
Create styles array
The data for the language used.
executeActivities()
Executes all attached activities.
attemptTransition()
Attempts to transit the node.
PhpIncludeInspection
Definition: ilWorkflow.php:23
PhpIncludeInspection
ilDetector Interface is part of the petri net based workflow engine.
Definition: ilDetector.php:16
setIsForwardConditionNode($is_forward_condition_node)
activate()
Activates the node.