ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 128 of file class.ilBPMN2Parser.php.

Referenced by parseBPMN2XML().

129  {
130  require_once './Services/WorkflowEngine/classes/parser/class.ilBPMN2ParserUtils.php';
131  $xml_to_array_parser = new ilBPMN2ParserUtils();
132  $bpmn2 = $xml_to_array_parser->load_string( $xml );
133  return $bpmn2;
134  }
Class ilBPMN2ParserUtils.
+ 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 181 of file class.ilBPMN2Parser.php.

Referenced by parseBPMN2XML().

182  {
183  if (!$workflow_name && !count( @$bpmn2_array['children'] ))
184  {
185  $workflow_name = $bpmn2_array['attributes']['id'];
186  }
187 
188  if (!$workflow_name)
189  {
190  $workflow_name = $process['attributes']['id'];
191  return $workflow_name;
192  }
193 
194  if ($workflow_name)
195  {
196  $workflow_name = substr($workflow_name,0,strpos($workflow_name,'.'));
197  }
198  return $workflow_name;
199  }
+ Here is the caller graph for this function:

◆ getMessageNodesFromArray()

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

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

References $messages, and array.

Referenced by parseBPMN2XML().

161  {
162  $messages = array();
163  foreach ((array)@$bpmn2['children'] as $bpmn2_part)
164  {
165  if ($bpmn2_part['name'] == 'message')
166  {
167  $messages[] = $bpmn2_part;
168  break;
169  }
170  }
171  return $messages;
172  }
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 141 of file class.ilBPMN2Parser.php.

References array.

Referenced by parseBPMN2XML().

142  {
143  $process = array();
144  foreach ((array)@$bpmn2['children'] as $bpmn2_part)
145  {
146  if ($bpmn2_part['name'] == 'process')
147  {
148  $process = $bpmn2_part;
149  break;
150  }
151  }
152  return $process;
153  }
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, $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  if(count(@$process['children']))
36  {
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  {
49  if($element['name'] == 'ioSpecification')
50  {
51  foreach($element['children'] as $iospec_element)
52  {
53  $element_object = $loader->load($iospec_element['name']);
54  $constructor_method_content .= $element_object->getPHP($iospec_element, $class_object);
55  }
56 
57  continue;
58  }
59 
60  if($element['name'] == 'sequenceFlow')
61  {
62  $stashed_sequence_flows[] = $element;
63  }
64  else if($element['name'] == 'association')
65  {
66  $stashed_associations[] = $element;
67  }
68  else if($element['name'] == 'extensionElements')
69  {
70  $stashed_process_extensions[] = $element;
71  }
72  else
73  {
74  $element_object = $loader->load($element['name']);
75  $constructor_method_content .= $element_object->getPHP($element, $class_object);
76  }
77  }
78 
79  foreach($stashed_sequence_flows as $element)
80  {
81  $element_object = $loader->load($element['name']);
82  $constructor_method_content .= $element_object->getPHP($element, $class_object);
83  }
84 
85  foreach($stashed_associations as $element)
86  {
87  $element_object = $loader->load($element['name']);
88  $constructor_method_content .= $element_object->getPHP($element, $class_object);
89  }
90  }
91 
92  if(count($messages))
93  {
94  $message_definitions = array();
95  foreach ($messages as $message)
96  {
97  $element_object = $loader->load('messageDefinition');
98  $message_definitions[] = $element_object->getMessageDefinitionArray($message);
99  }
100 
101  $code = '
102  public static function getMessageDefinition($id)
103  {
104  $definitions = array('.implode(',', $message_definitions).'
105  );
106  return $definitions[$id];
107  }
108  ';
109  $class_object->addAuxilliaryMethod($code);
110  }
111 
112  $class_object->setConstructorMethodContent($constructor_method_content);
113  $class_source = '';
114 
115  if (strlen($constructor_method_content))
116  {
117  $class_source .= $class_object->getPHP();
118  }
119 
120  return "<?php\n" . $class_source . "\n?>"; // PHP Code
121  }
Class ilBPMN2ElementLoader.
Class ilWorkflowScaffold.
$code
Definition: example_050.php:99
getMessageNodesFromArray($bpmn2)
determineWorkflowClassName($workflow_name, $bpmn2_array, $process)
getProcessNodeFromArray($bpmn2)
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: