5 require_once
'./Services/WorkflowEngine/interfaces/ilExternalDetector.php';
7 require_once
'./Services/WorkflowEngine/interfaces/ilWorkflow.php';
9 require_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;
809 spl_autoload_register(
array(
'ilBaseWorkflow',
'autoload'));
startWorkflow()
Starts the workflow, activating the start_node.
defineInstanceVar($id, $name, $reference=false, $reference_target='', $type='mixed', $role='undefined')
getNodes()
Returns all nodes attached to the workflow.
hasInstanceVarById($id)
Returns if an instance variable of the given id is set.
getInstanceVarByName($name)
Returns the given instance variables content.
getWorkflowClass()
Returns the currently set workflow class definition name.
setDbId($id)
Sets the database id of the detector.
isDataPersistenceRequired()
onStopWorkflow()
Method called on stopping of the workflow, after deactivating all nodes.
setInstanceVarById($id, $value)
Sets the given instance var with the given content.
hasInstanceVarByName($name)
Returns if an instance variable of the given name is set.
setWorkflowClass($class)
Sets the classname of the workflow definition.
getWorkflowSubject()
Get the workflow subject set to the workflow.
getDbId()
Returns the database id of the detector if set.
onWorkflowFinished()
Method called after workflow is finished, after detecting no more nodes are active.
$db_id
This holds the database id of the workflow.
resetDataPersistenceRequirement()
addNode(ilNode $node)
This method adds a node to the workflow.
handleEvent($params)
Handles an event.
flushInstanceVars()
Empties the instance variables.
registerDetector(ilDetector $detector)
getWorkflowLocation()
Returns the currently set path to the workflow definition.
$workflow_subject_identifier
hasDbId()
Returns, if the detector has a database id.
Create styles array
The data for the language used.
__construct()
Default constructor.
$active
Holds the activation state of the workflow.
$workflow_context_identifier
getInstanceVars()
Returns an array with all set instance variables.
$require_data_persistence
stopWorkflow()
Stops the workflow, deactivating all nodes.
setWorkflowLocation($path)
Sets the location of the workflow definition file as relative path.
registerInputVar($name, $definition)
getWorkflowData()
Returns the workflow type and content currently set to the workflow.
setStartNode(ilNode $node)
Sets the start node of the workflow.
setInstanceVarByRole($role, $value)
Sets the given instance var with the given content.
onStartWorkflow()
Method called on start of the workflow, prior to activating the first node.
writeInputVar($name, $value)
isActive()
Returns the activation status of the workflow.
ilDetector Interface is part of the petri net based workflow engine.
static autoload($class_name)
Autoloader function to dynamically include files for instantiation of objects during deserialization...
getWorkflowContext()
Get the event context set to the workflow.
writeOutputVar($name, $value)
setInstanceVarByName($name, $value)
Sets the given instance var with the given content.
getInstanceVarById($id)
Returns the given instance variables content.