ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilBPMN2Parser Class Reference

Class ilBPMN2Parser. More...

+ Collaboration diagram for ilBPMN2Parser:

Public Member Functions

 parseBPMN2XML ($bpmn2_xml, $workflow_name=null)
 
 convertXmlToArray ($xml)
 
 getProcessNodeFromArray ($bpmn2)
 
 getMessageNodesFromArray ($bpmn2)
 
 determineWorkflowClassName ($workflow_name, $bpmn2_array, $process)
 

Detailed Description

Class ilBPMN2Parser.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

/

Definition at line 12 of file class.ilBPMN2Parser.php.

Member Function Documentation

◆ convertXmlToArray()

ilBPMN2Parser::convertXmlToArray (   $xml)
Parameters
string$xml
Returns
mixed

Definition at line 113 of file class.ilBPMN2Parser.php.

References $xml.

Referenced by parseBPMN2XML().

114  {
115  require_once './Services/WorkflowEngine/classes/parser/class.ilBPMN2ParserUtils.php';
116  $xml_to_array_parser = new ilBPMN2ParserUtils();
117  $bpmn2 = $xml_to_array_parser->load_string($xml);
118  return $bpmn2;
119  }
Class ilBPMN2ParserUtils.
$xml
Definition: metadata.php:240
+ Here is the caller graph for this function:

◆ determineWorkflowClassName()

ilBPMN2Parser::determineWorkflowClassName (   $workflow_name,
  $bpmn2_array,
  $process 
)
Parameters
string$workflow_name
array$bpmn2_array
array$process
Returns
mixed

Definition at line 162 of file class.ilBPMN2Parser.php.

Referenced by parseBPMN2XML().

163  {
164  $hasChildren = (isset($bpmn2_array['children']) && is_array($bpmn2_array['children']) && count($bpmn2_array['children']) > 0);
165  if (!$workflow_name && !$hasChildren) {
166  $workflow_name = $bpmn2_array['attributes']['id'];
167  }
168 
169  if (!$workflow_name) {
170  $workflow_name = $process['attributes']['id'];
171  return $workflow_name;
172  }
173 
174  if ($workflow_name) {
175  $workflow_name = substr($workflow_name, 0, strpos($workflow_name, '.'));
176  }
177  return $workflow_name;
178  }
+ Here is the caller graph for this function:

◆ getMessageNodesFromArray()

ilBPMN2Parser::getMessageNodesFromArray (   $bpmn2)
Parameters
array$bpmn2
Returns
array

Definition at line 143 of file class.ilBPMN2Parser.php.

References $messages, and array.

Referenced by parseBPMN2XML().

144  {
145  $messages = array();
146  foreach ((array) @$bpmn2['children'] as $bpmn2_part) {
147  if ($bpmn2_part['name'] == 'message') {
148  $messages[] = $bpmn2_part;
149  break;
150  }
151  }
152  return $messages;
153  }
Create styles array
The data for the language used.
$messages
Definition: en-x-test.php:7
+ Here is the caller graph for this function:

◆ getProcessNodeFromArray()

ilBPMN2Parser::getProcessNodeFromArray (   $bpmn2)
Parameters
array$bpmn2
Returns
array

Definition at line 126 of file class.ilBPMN2Parser.php.

References array.

Referenced by parseBPMN2XML().

127  {
128  $process = array();
129  foreach ((array) @$bpmn2['children'] as $bpmn2_part) {
130  if ($bpmn2_part['name'] == 'process') {
131  $process = $bpmn2_part;
132  break;
133  }
134  }
135  return $process;
136  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ parseBPMN2XML()

ilBPMN2Parser::parseBPMN2XML (   $bpmn2_xml,
  $workflow_name = null 
)
Parameters
string$bpmn2_xml
string | null$workflow_name
Returns
string

Definition at line 20 of file class.ilBPMN2Parser.php.

References $code, $loader, $message, $messages, array, convertXmlToArray(), determineWorkflowClassName(), getMessageNodesFromArray(), and getProcessNodeFromArray().

21  {
22  $bpmn2_array = $this->convertXmlToArray($bpmn2_xml);
23  $process = $this->getProcessNodeFromArray($bpmn2_array);
24  $messages = $this->getMessageNodesFromArray($bpmn2_array);
25 
26  $workflow_name = $this->determineWorkflowClassName($workflow_name, $bpmn2_array, $process);
27 
28  require_once './Services/WorkflowEngine/classes/parser/class.ilWorkflowScaffold.php';
29  $class_object = new ilWorkflowScaffold($bpmn2_array);
30 
31  $constructor_method_content = '';
32 
33  $class_object->setWorkflowName($workflow_name);
34 
35  $hasChildren = (isset($process['children']) && is_array($process['children']) && count($process['children']) > 0);
36  if ($hasChildren) {
37  $stashed_sequence_flows = array(); // There can be no assumption, that the workflow is modeled in sequence,
38  // so we need to stash the connectors to add them after the nodes.
39  $stashed_associations = array(); // There can be no assumption, that the workflow is modeled in sequence,
40  // so we need to stash the connectors to add them after the nodes.
41  $stashed_process_extensions = array(); // It was found that modelers add extensions at process level,
42  // they are stored for possible future use.
43  require_once './Services/WorkflowEngine/classes/parser/elements/class.ilBPMN2ElementLoader.php';
44 
45  $loader = new ilBPMN2ElementLoader($bpmn2_array);
46 
47  foreach ($process['children'] as $element) {
48  if ($element['name'] == 'ioSpecification') {
49  foreach ($element['children'] as $iospec_element) {
50  $element_object = $loader->load($iospec_element['name']);
51  $constructor_method_content .= $element_object->getPHP($iospec_element, $class_object);
52  }
53 
54  continue;
55  }
56 
57  if ($element['name'] == 'sequenceFlow') {
58  $stashed_sequence_flows[] = $element;
59  } elseif ($element['name'] == 'association') {
60  $stashed_associations[] = $element;
61  } elseif ($element['name'] == 'extensionElements') {
62  $stashed_process_extensions[] = $element;
63  } else {
64  $element_object = $loader->load($element['name']);
65  $constructor_method_content .= $element_object->getPHP($element, $class_object);
66  }
67  }
68 
69  foreach ($stashed_sequence_flows as $element) {
70  $element_object = $loader->load($element['name']);
71  $constructor_method_content .= $element_object->getPHP($element, $class_object);
72  }
73 
74  foreach ($stashed_associations as $element) {
75  $element_object = $loader->load($element['name']);
76  $constructor_method_content .= $element_object->getPHP($element, $class_object);
77  }
78  }
79 
80  if (count($messages)) {
81  $message_definitions = array();
82  foreach ($messages as $message) {
83  $element_object = $loader->load('messageDefinition');
84  $message_definitions[] = $element_object->getMessageDefinitionArray($message);
85  }
86 
87  $code = '
88  public static function getMessageDefinition($id)
89  {
90  $definitions = array(' . implode(',', $message_definitions) . '
91  );
92  return $definitions[$id];
93  }
94  ';
95  $class_object->addAuxilliaryMethod($code);
96  }
97 
98  $class_object->setConstructorMethodContent($constructor_method_content);
99  $class_source = '';
100 
101  if (strlen($constructor_method_content)) {
102  $class_source .= $class_object->getPHP();
103  }
104 
105  return "<?php\n" . $class_source . "\n?>"; // PHP Code
106  }
Class ilBPMN2ElementLoader.
Class ilWorkflowScaffold.
$code
Definition: example_050.php:99
getMessageNodesFromArray($bpmn2)
determineWorkflowClassName($workflow_name, $bpmn2_array, $process)
getProcessNodeFromArray($bpmn2)
catch(Exception $e) $message
Create styles array
The data for the language used.
$messages
Definition: en-x-test.php:7
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: