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) {
166 if (count($this->nodes) != 0) {
167 $this->start_node = $this->nodes[0];
170 throw new Exception(
'No start_node, no node, no start. Doh.');
173 $this->start_node->activate();
174 ilWorkflowDbHelper::writeWorkflow($this);
182 $this->active =
false;
183 foreach ($this->nodes as $node) {
241 $active_nodes_available =
false;
243 foreach ((array) $this->detectors as $detector) {
244 $node = $detector->getContext();
245 if ($node->isActive()) {
247 $node = $detector->getContext();
248 if ($node->isActive()) {
249 $active_nodes_available =
true;
254 if ($active_nodes_available ==
false) {
255 $this->active =
false;
266 if (in_array(
'ilExternalDetector', $reflection_class->getInterfaceNames())) {
267 $this->detectors[] = $detector;
278 return array(
'type' => $this->workflow_type,
'content' => $this->workflow_content);
288 return array(
'type' => $this->workflow_subject_type,
'identifier' => $this->workflow_subject_identifier);
298 return array(
'type' => $this->workflow_context_type,
'identifier' => $this->workflow_context_identifier);
319 if ($this->db_id != null) {
322 require_once
'./Services/WorkflowEngine/exceptions/ilWorkflowObjectStateException.php';
333 if ($this->db_id == null) {
347 $this->start_node = $node;
357 $this->nodes[] = $node;
369 $this->workflow_class = $class;
393 $this->workflow_location =
$path;
427 case strtolower(substr($class_name, strlen($class_name) - 8, 8)) ==
'activity':
428 $componentDirectory =
'activities';
431 case strtolower(substr($class_name, strlen($class_name) - 8, 8)) ==
'detector':
432 $componentDirectory =
'detectors';
435 case strtolower(substr($class_name, strlen($class_name) - 7, 7)) ==
'emitter':
436 $componentDirectory =
'emitters';
439 case strtolower(substr($class_name, strlen($class_name) - 4, 4)) ==
'node':
440 $componentDirectory =
'node';
447 $filename =
'./Services/WorkflowEngine/classes/' . $componentDirectory .
'/class.' . $class_name .
'.php';
466 $this->require_data_persistence =
false;
493 $reference_target =
'',
497 $this->instance_vars[] = array(
501 'reference' => $reference,
502 'target' => $reference_target,
516 foreach ($this->instance_vars as $instance_var) {
517 if ($instance_var[
'name'] ==
$name) {
533 foreach ($this->instance_vars as $instance_var) {
534 if ($instance_var[
'id'] ==
$id) {
549 foreach ($this->instance_vars as &$instance_var) {
550 if ($instance_var[
'name'] ==
$name) {
551 if ($instance_var[
'reference'] ===
true) {
554 return $instance_var[
'value'];
569 foreach ($this->instance_vars as $instance_var) {
570 if ($instance_var[
'id'] ==
$id) {
571 if ($instance_var[
'reference'] ===
true) {
574 return $instance_var[
'value'];
588 foreach ($this->instance_vars as &$instance_var) {
589 if ($instance_var[
'name'] ==
$name) {
590 if ($instance_var[
'reference'] ===
true) {
593 $instance_var[
'value'] = $value;
607 foreach ($this->instance_vars as &$instance_var) {
608 if ($instance_var[
'id'] ==
$id) {
609 if ($instance_var[
'reference'] ===
true) {
612 $instance_var[
'value'] = $value;
627 foreach ($this->instance_vars as &$instance_var) {
628 if ($instance_var[
'role'] == $role) {
629 if ($instance_var[
'reference'] ===
true) {
632 $instance_var[
'value'] = $value;
654 $this->instance_vars = array();
666 $this->data_inputs[
$name] = null;
667 $this->require_data_persistence =
true;
675 $this->data_outputs[
$name] = null;
676 $this->require_data_persistence =
true;
684 if ($this->data_inputs[
$name]) {
685 return $this->data_inputs[
$name];
695 return array_key_exists(
$name, (array) $this->data_inputs);
703 return array_key_exists(
$name, (array) $this->data_outputs);
711 $this->data_inputs[
$name] = $value;
712 $this->require_data_persistence =
true;
720 if ($this->data_outputs[
$name]) {
721 return $this->data_outputs[
$name];
731 $this->data_outputs[
$name] = $value;
732 $this->require_data_persistence =
true;
754 $definition[
'name'] =
$name;
755 $this->data_inputs[
$name] = $definition;
763 $this->data_outputs[] =
$name;
769 spl_autoload_register(array(
'ilBaseWorkflow',
'autoload'));
startWorkflow()
Starts the workflow, activating the start_node.
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.
if(!array_key_exists('StateId', $_REQUEST)) $id
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.
defineInstanceVar( $id, $name, $reference=false, $reference_target='', $type='mixed', $role='undefined')
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.
__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.