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) {
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()) {
246 $detector->trigger($params);
247 $node = $detector->getContext();
248 if ($node->isActive()) {
249 $active_nodes_available =
true;
254 if ($active_nodes_available ==
false) {
255 $this->active =
false;
265 $reflection_class =
new ReflectionClass($detector);
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;
769spl_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.
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.
defineInstanceVar( $id, $name, $reference=false, $reference_target='', $type='mixed', $role='undefined')
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