5require_once
'./Services/WorkflowEngine/interfaces/ilExternalDetector.php';
7require_once
'./Services/WorkflowEngine/interfaces/ilWorkflow.php';
9require_once
'./Services/WorkflowEngine/classes/nodes/class.ilBasicNode.php';
159 require_once
'./Services/WorkflowEngine/classes/utils/class.ilWorkflowDbHelper.php';
160 $this->active =
true;
161 ilWorkflowDbHelper::writeWorkflow($this);
165 if ($this->start_node ==
null)
167 if (count($this->nodes) != 0)
169 $this->start_node = $this->nodes[0];
172 throw new Exception (
'No start_node, no node, no start. Doh.');
175 $this->start_node->activate();
176 ilWorkflowDbHelper::writeWorkflow($this);
184 $this->active =
false;
185 foreach ($this->nodes as $node)
244 $active_nodes_available =
false;
246 foreach ((array)$this->detectors as $detector)
248 $node = $detector->getContext();
249 if ($node->isActive())
252 $node = $detector->getContext();
253 if ($node->isActive())
255 $active_nodes_available =
true;
260 if ($active_nodes_available ==
false)
262 $this->active =
false;
272 $reflection_class =
new ReflectionClass($detector);
273 if (in_array(
'ilExternalDetector', $reflection_class->getInterfaceNames()))
275 $this->detectors[] = $detector;
286 return array(
'type' => $this->workflow_type,
'content' => $this->workflow_content);
296 return array(
'type' => $this->workflow_subject_type,
'identifier' => $this->workflow_subject_identifier);
306 return array(
'type' => $this->workflow_context_type,
'identifier' => $this->workflow_context_identifier);
327 if ($this->db_id !=
null)
333 require_once
'./Services/WorkflowEngine/exceptions/ilWorkflowObjectStateException.php';
344 if ($this->db_id ==
null)
359 $this->start_node = $node;
369 $this->nodes[] = $node;
381 $this->workflow_class = $class;
405 $this->workflow_location =
$path;
440 case strtolower(substr($class_name, strlen($class_name) - 8, 8)) ==
'activity':
441 $componentDirectory =
'activities';
444 case strtolower(substr($class_name, strlen($class_name) - 8, 8)) ==
'detector':
445 $componentDirectory =
'detectors';
448 case strtolower(substr($class_name, strlen($class_name) - 7, 7)) ==
'emitter':
449 $componentDirectory =
'emitters';
452 case strtolower(substr($class_name, strlen($class_name) - 4, 4)) ==
'node':
453 $componentDirectory =
'node';
460 $filename =
'./Services/WorkflowEngine/classes/' . $componentDirectory .
'/class.'.$class_name.
'.php';
480 $this->require_data_persistence =
false;
504 $type =
'mixed', $role =
'undefined')
506 $this->instance_vars[] = array(
510 'reference' => $reference,
511 'target' => $reference_target,
525 foreach($this->instance_vars as $instance_var)
527 if($instance_var[
'name'] == $name)
544 foreach($this->instance_vars as $instance_var)
546 if($instance_var[
'id'] == $id)
562 foreach($this->instance_vars as &$instance_var)
564 if($instance_var[
'name'] == $name)
566 if($instance_var[
'reference'] ===
true)
572 return $instance_var[
'value'];
587 foreach($this->instance_vars as $instance_var)
589 if($instance_var[
'id'] == $id)
591 if($instance_var[
'reference'] ===
true)
597 return $instance_var[
'value'];
611 foreach($this->instance_vars as &$instance_var)
613 if($instance_var[
'name'] == $name)
615 if($instance_var[
'reference'] ===
true)
621 $instance_var[
'value'] = $value;
635 foreach($this->instance_vars as &$instance_var)
637 if($instance_var[
'id'] == $id)
639 if($instance_var[
'reference'] ===
true)
645 $instance_var[
'value'] = $value;
660 foreach($this->instance_vars as &$instance_var)
662 if($instance_var[
'role'] == $role)
664 if($instance_var[
'reference'] ===
true)
670 $instance_var[
'value'] = $value;
692 $this->instance_vars = array();
704 $this->data_inputs[$name] =
null;
705 $this->require_data_persistence =
true;
713 $this->data_outputs[$name] =
null;
714 $this->require_data_persistence =
true;
722 if($this->data_inputs[$name])
724 return $this->data_inputs[$name];
734 return array_key_exists($name, (array)$this->data_inputs);
742 return array_key_exists($name, (array)$this->data_outputs);
750 $this->data_inputs[$name] = $value;
751 $this->require_data_persistence =
true;
759 if($this->data_outputs[$name])
761 return $this->data_outputs[$name];
771 $this->data_outputs[$name] = $value;
772 $this->require_data_persistence =
true;
794 $definition[
'name'] = $name;
795 $this->data_inputs[$name] = $definition;
803 $this->data_outputs[] = $name;
809spl_autoload_register(array(
'ilBaseWorkflow',
'autoload'));
An exception for terminatinating execution or to throw for unit testing.
@noinspection PhpIncludeInspection
onStopWorkflow()
Method called on stopping of the workflow, after deactivating all nodes.
setWorkflowClass($class)
Sets the classname of the workflow definition.
writeOutputVar($name, $value)
getWorkflowClass()
Returns the currently set workflow class definition name.
hasDbId()
Returns, if the detector has a database id.
isDataPersistenceRequired()
setInstanceVarByName($name, $value)
Sets the given instance var with the given content.
static autoload($class_name)
Autoloader function to dynamically include files for instantiation of objects during deserialization.
onStartWorkflow()
Method called on start of the workflow, prior to activating the first node.
setDbId($id)
Sets the database id of the detector.
$db_id
This holds the database id of the workflow.
registerInputVar($name, $definition)
isActive()
Returns the activation status of the workflow.
stopWorkflow()
Stops the workflow, deactivating all nodes.
getInstanceVars()
Returns an array with all set instance variables.
$active
Holds the activation state of the workflow.
setStartNode(ilNode $node)
Sets the start node of the workflow.
resetDataPersistenceRequirement()
__construct()
Default constructor.
getNodes()
Returns all nodes attached to the workflow.
getDbId()
Returns the database id of the detector if set.
addNode(ilNode $node)
This method adds a node to the workflow.
getInstanceVarById($id)
Returns the given instance variables content.
getWorkflowSubject()
Get the workflow subject set to the workflow.
getWorkflowContext()
Get the event context set to the workflow.
writeInputVar($name, $value)
getInstanceVarByName($name)
Returns the given instance variables content
registerDetector(ilDetector $detector)
onWorkflowFinished()
Method called after workflow is finished, after detecting no more nodes are active.
defineInstanceVar($id, $name, $reference=false, $reference_target='', $type='mixed', $role='undefined')
startWorkflow()
Starts the workflow, activating the start_node.
$require_data_persistence
handleEvent($params)
Handles an event.
setWorkflowLocation($path)
Sets the location of the workflow definition file as relative path.
flushInstanceVars()
Empties the instance variables.
hasInstanceVarByName($name)
Returns if an instance variable of the given name is set.
getWorkflowData()
Returns the workflow type and content currently set to the workflow.
hasInstanceVarById($id)
Returns if an instance variable of the given id is set.
getWorkflowLocation()
Returns the currently set path to the workflow definition.
$workflow_context_identifier
$workflow_subject_identifier
setInstanceVarByRole($role, $value)
Sets the given instance var with the given content.
setInstanceVarById($id, $value)
Sets the given instance var with the given content.
@noinspection PhpIncludeInspection
ilDetector Interface is part of the petri net based workflow engine.
@noinspection PhpIncludeInspection
@noinspection PhpIncludeInspection