29 public static function writeWorkflow(
ilWorkflow $workflow)
41 $mode = self::DB_MODE_UPDATE;
45 $wf_id =
$ilDB->nextId(
'wfe_workflows');
47 $mode = self::DB_MODE_CREATE;
54 $instance = serialize($workflow);
56 if ($mode == self::DB_MODE_UPDATE)
58 $ilDB->update(
'wfe_workflows',
60 'workflow_type' =>
array (
'text', $wf_data[
'type'] ),
61 'workflow_content' =>
array (
'text', $wf_data[
'content']),
64 'subject_type' =>
array (
'text', $wf_subject[
'type']),
65 'subject_id' =>
array (
'integer', $wf_subject[
'identifier']),
66 'context_type' =>
array (
'text', $wf_context[
'type']),
67 'context_id' =>
array (
'integer', $wf_context[
'identifier']),
68 'workflow_instance' =>
array (
'clob', $instance),
69 'active' =>
array (
'integer', (
int)$active)
72 'workflow_id' =>
array (
'integer', $wf_id)
77 if ($mode == self::DB_MODE_CREATE)
79 $ilDB->insert(
'wfe_workflows',
81 'workflow_id' =>
array (
'integer', $wf_id),
82 'workflow_type' =>
array (
'text', $wf_data[
'type'] ),
85 'workflow_content' =>
array (
'text', $wf_data[
'content']),
86 'subject_type' =>
array (
'text', $wf_subject[
'type']),
87 'subject_id' =>
array (
'integer', $wf_subject[
'identifier']),
88 'context_type' =>
array (
'text', $wf_context[
'type']),
89 'context_id' =>
array (
'integer', $wf_context[
'identifier']),
90 'workflow_instance' =>
array (
'clob', $instance),
91 'active' =>
array (
'integer', (
int)$active)
96 if($require_data_persistance)
98 self::persistWorkflowIOData($workflow);
105 public static function persistWorkflowIOData(
ilWorkflow $workflow)
109 $ilDB = $DIC[
'ilDB'];
111 $workflow_id = $workflow->getId();
113 $input_data = $workflow->getInputVars();
114 foreach($input_data as $name => $value)
118 array(
'workflow_id' => $workflow_id,
'name' => $name),
119 array(
'value' => $value)
123 $output_data = $workflow->getOutputVars();
124 foreach($output_data as $name => $value)
128 array(
'workflow_id' => $workflow_id,
'name' => $name),
129 array(
'value' => $value)
142 public static function deleteWorkflow(
ilWorkflow $a_workflow)
146 $ilDB = $DIC[
'ilDB'];
153 WHERE workflow_id = ' .
$ilDB->quote($a_workflow->
getDbId(),
'integer')
160 FROM wfe_det_listening 161 WHERE workflow_id = ' .
$ilDB->quote($a_workflow->
getDbId(),
'integer')
167 WHERE workflow_id = ' .
$ilDB->quote($a_workflow->
getDbId(),
'integer')
173 WHERE workflow_id = ' .
$ilDB->quote($a_workflow->
getDbId(),
'integer')
189 public static function writeDetector(
ilDetector $a_detector)
193 $ilDB = $DIC[
'ilDB'];
195 if ($a_detector->hasDbId())
197 $det_id = $a_detector->getDbId();
198 $mode = self::DB_MODE_UPDATE;
202 $det_id =
$ilDB->nextId(
'wfe_det_listening');
203 $a_detector->setDbId($det_id);
204 $mode = self::DB_MODE_CREATE;
207 $node = $a_detector->getContext();
208 $workflow = $node->getContext();
216 $det_data = $a_detector->getEvent();
217 $det_subject = $a_detector->getEventSubject();
218 $det_context = $a_detector->getEventContext();
219 $det_listen = $a_detector->getListeningTimeframe();
221 if($det_context[
'identifier'] ===
'{{THIS:WFID}}')
223 $det_context[
'identifier'] = $wf_id;
226 if($det_subject[
'identifier'] ===
'{{THIS:WFID}}')
228 $det_subject[
'identifier'] = $wf_id;
231 if ($mode == self::DB_MODE_UPDATE)
233 $ilDB->update(
'wfe_det_listening',
235 'workflow_id' =>
array (
'integer', $wf_id),
236 'type' =>
array (
'text', $det_data[
'type'] ),
237 'content' =>
array (
'text', $det_data[
'content']),
238 'subject_type' =>
array (
'text', $det_subject[
'type']),
239 'subject_id' =>
array (
'integer', $det_subject[
'identifier']),
240 'context_type' =>
array (
'text', $det_context[
'type']),
241 'context_id' =>
array (
'integer', $det_context[
'identifier']),
242 'listening_start' =>
array (
'integer', $det_listen[
'listening_start']),
243 'listening_end' =>
array (
'integer', $det_listen[
'listening_end'])
246 'detector_id' =>
array (
'integer', $det_id)
251 if ($mode == self::DB_MODE_CREATE)
253 $ilDB->insert(
'wfe_det_listening',
255 'detector_id' =>
array (
'integer', $det_id),
256 'workflow_id' =>
array (
'integer', $wf_id),
257 'type' =>
array (
'text', $det_data[
'type'] ),
258 'content' =>
array (
'text', $det_data[
'content']),
259 'subject_type' =>
array (
'text', $det_subject[
'type']),
260 'subject_id' =>
array (
'integer', $det_subject[
'identifier']),
261 'context_type' =>
array (
'text', $det_context[
'type']),
262 'context_id' =>
array (
'integer', $det_context[
'identifier']),
263 'listening_start' =>
array (
'integer', $det_listen[
'listening_start']),
264 'listening_end' =>
array (
'integer', $det_listen[
'listening_end'])
283 $ilDB = $DIC[
'ilDB'];
289 FROM wfe_det_listening 290 WHERE detector_id = ' .
$ilDB->quote($detector->
getDbId(),
'integer')
314 public static function getDetectors(
325 $ilDB = $DIC[
'ilDB'];
327 require_once
'./Services/WorkflowEngine/classes/utils/class.ilWorkflowUtils.php';
329 $workflows =
array();
333 FROM wfe_det_listening 334 WHERE type = ' .
$ilDB->quote($type,
'text') .
' 335 AND content = ' .
$ilDB->quote($content,
'text') .
' 336 AND subject_type = ' .
$ilDB->quote($subject_type,
'text') .
' 337 AND (subject_id = ' .
$ilDB->quote($subject_id,
'integer') .
' OR subject_id = ' .
$ilDB->quote(0,
'integer') .
') 338 AND context_type = ' .
$ilDB->quote($context_type,
'text') .
' 339 AND (context_id = ' .
$ilDB->quote($context_id,
'integer') .
' OR context_id = ' .
$ilDB->quote(0,
'integer') .
') 340 AND (listening_start = ' .
$ilDB->quote(0,
'integer') .
' 341 OR listening_start <= ' .
$ilDB->quote($now,
'integer') .
') AND (listening_end = '.
$ilDB->quote(0,
'integer') .
' 342 OR listening_end >= ' .
$ilDB->quote($now,
'integer') .
')' 347 $workflows[] =
$row[
'workflow_id'];
363 public static function wakeupWorkflow($id)
367 $ilDB = $DIC[
'ilDB'];
370 'SELECT workflow_class, workflow_location, workflow_instance 372 WHERE workflow_id = ' .
$ilDB->quote($id,
'integer')
377 require_once
'./Services/WorkflowEngine/classes/workflows/class.ilBaseWorkflow.php';
378 $path = rtrim($workflow[
'workflow_location'],
'/') .
'/' . $workflow[
'workflow_class'];
383 $instance = unserialize($workflow[
'workflow_instance']);
399 public static function writeStartEventData($event, $process_id)
403 $ilDB = $DIC[
'ilDB'];
405 $event_id =
$ilDB->nextId(
'wfe_startup_events');
407 $ilDB->insert(
'wfe_startup_events',
409 'event_id' =>
array (
'integer', $event_id),
410 'workflow_id' =>
array (
'text', $process_id),
411 'type' =>
array (
'text', $event[
'type'] ),
412 'content' =>
array (
'text', $event[
'content']),
413 'subject_type' =>
array (
'text', $event[
'subject_type']),
414 'subject_id' =>
array (
'integer', $event[
'subject_id']),
415 'context_type' =>
array (
'text', $event[
'context_type']),
416 'context_id' =>
array (
'integer', $event[
'context_id'])
428 public static function writeStaticInput($key, $value, $start_event)
432 $ilDB = $DIC[
'ilDB'];
437 'input_id' =>
array (
'integer',
$ilDB->nextId(
'wfe_static_inputs')),
438 'event_id' =>
array (
'integer', $start_event),
439 'name' =>
array (
'text', $key),
440 'value' =>
array (
'text', $value)
445 public static function findApplicableWorkflows($component, $event,
$params)
447 $query =
"SELECT event_id, workflow_id FROM wfe_startup_events WHERE 448 type = '".$component.
"' AND content = '".$event.
"' AND subject_type = '".
$params->getSubjectType().
"' 449 AND context_type = '".
$params->getContextType().
"' ";
451 $query .=
"AND ( subject_id = '".$params->getSubjectId().
"' OR subject_id ='0' ) ";
452 $query .=
"AND ( context_id = '".$params->getContextId().
"' OR context_id ='0' ) ";
456 $ilDB = $DIC[
'ilDB'];
458 $workflows =
array();
462 $workflows[] =
array(
'event' =>
$row[
'event_id'],
'workflow' =>
$row[
'workflow_id']);
467 public static function getStaticInputDataForEvent($event_id)
469 $query =
"SELECT name, value FROM wfe_static_inputs WHERE event_id = '" . $event_id .
"'";
473 $ilDB = $DIC[
'ilDB'];
481 $retval[
$row[
'name']] = $row[
'value'];
487 public static function deleteStartEventData($event_id)
491 $ilDB = $DIC[
'ilDB'];
494 'SELECT event_id FROM wfe_startup_events 495 WHERE workflow_id = ' .
$ilDB->quote($event_id,
'integer')
501 $events =
$row[
'revent_id'];
506 FROM wfe_startup_events 507 WHERE workflow_id = ' .
$ilDB->quote($event_id,
'integer')
514 FROM wfe_static_inputs 515 WHERE ' .
$ilDB->in(
'event_id', $events,
false,
'integer')
isDataPersistenceRequired()
resetDataPersistenceRequirement()
Create styles array
The data for the language used.
ilWorkflowDbHelper is part of the petri net based workflow engine.
ilDetector Interface is part of the petri net based workflow engine.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.