Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
},
|
||||
"require-dev":{
|
||||
"guzzle/guzzle":"~3.1.1",
|
||||
"behat/behat":"2.4.*@stable"
|
||||
"behat/behat":"2.4.*@stable",
|
||||
"lisachenko/go-aop-php": "*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,10 +144,12 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
// to add a workflow route
|
||||
// - activity -> activity ==> route
|
||||
// - activity -> gateway -> activity ==> selection, evaluation, parallel or parallel by evaluation route
|
||||
$routeData = self::mapBpmnFlowsToWorkflowRoute($data, $flows, $gateways, $events);
|
||||
$routes = self::mapBpmnFlowsToWorkflowRoute($data, $flows, $gateways, $events);
|
||||
|
||||
if ($routeData !== null) {
|
||||
$this->wp->addRoute($routeData["from"], $routeData["to"], $routeData["type"]);
|
||||
if ($routes !== null) {
|
||||
foreach ($routes as $routeData) {
|
||||
$this->wp->addRoute($routeData["from"], $routeData["to"], $routeData["type"]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -221,6 +223,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
public static function mapBpmnFlowsToWorkflowRoute($flow, $flows, $gateways, $events)
|
||||
{
|
||||
$fromUid = $flow['FLO_ELEMENT_ORIGIN'];
|
||||
$result = array();
|
||||
|
||||
if ($flow['FLO_ELEMENT_ORIGIN_TYPE'] != "bpmnActivity") {
|
||||
// skip flows that comes from a element that is not an Activity
|
||||
@@ -238,84 +241,89 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
switch ($flow['FLO_ELEMENT_DEST_TYPE']) {
|
||||
case 'bpmnActivity':
|
||||
// the most easy case, when the flow is connecting a activity with another activity
|
||||
$result = array("from" => $fromUid, "to" => $flow['FLO_ELEMENT_DEST'], "type" => 'SEQUENTIAL');
|
||||
$result[] = array("from" => $fromUid, "to" => $flow['FLO_ELEMENT_DEST'], "type" => 'SEQUENTIAL');
|
||||
break;
|
||||
case 'bpmnGateway':
|
||||
$gatUid = $flow['FLO_ELEMENT_DEST'];
|
||||
|
||||
// if it is a gateway it can fork one or more routes
|
||||
$gatFlow = self::findInArray($gatUid, "FLO_ELEMENT_ORIGIN", $flows);
|
||||
$gatFlows = self::findInArray($gatUid, "FLO_ELEMENT_ORIGIN", $flows);
|
||||
|
||||
//foreach ($gatFlows as $gatFlow) {
|
||||
switch ($gatFlow['FLO_ELEMENT_DEST_TYPE']) {
|
||||
case 'bpmnActivity':
|
||||
// getting gateway properties
|
||||
$gateway = self::findInArray($gatUid, "GAT_UID", $gateways);
|
||||
foreach ($gatFlows as $gatFlow) {
|
||||
switch ($gatFlow['FLO_ELEMENT_DEST_TYPE']) {
|
||||
case 'bpmnActivity':
|
||||
// getting gateway properties
|
||||
$gateways = self::findInArray($gatUid, "GAT_UID", $gateways);
|
||||
|
||||
switch ($gateway['GAT_TYPE']) {
|
||||
case 'SELECTION':
|
||||
$routeType = 'SELECT';
|
||||
break;
|
||||
case 'EVALUATION':
|
||||
$routeType = 'EVALUATE';
|
||||
break;
|
||||
case 'PARALLEL':
|
||||
$routeType = 'PARALLEL';
|
||||
break;
|
||||
case 'PARALLEL_EVALUATION':
|
||||
$routeType = 'PARALLEL-BY-EVALUATION';
|
||||
break;
|
||||
case 'PARALLEL_JOIN':
|
||||
$routeType = 'SEC-JOIN';
|
||||
break;
|
||||
default:
|
||||
throw new \LogicException(sprintf("Unsupported Gateway type: %s", $gateway['GAT_TYPE']));
|
||||
}
|
||||
if (! empty($gateways)) {
|
||||
$gateway = $gateways[0];
|
||||
|
||||
$result = array("from" => $fromUid, "to" => $gatFlow['FLO_ELEMENT_DEST'], "type" => $routeType);
|
||||
break;
|
||||
default:
|
||||
// for processmaker is only allowed flows between "gateway -> activity"
|
||||
// any another flow is considered invalid
|
||||
throw new \LogicException(sprintf(
|
||||
"For ProcessMaker is only allowed flows between \"gateway -> activity\" " . PHP_EOL .
|
||||
"Given: bpmnGateway -> " . $gatFlow['FLO_ELEMENT_DEST_TYPE']
|
||||
));
|
||||
switch ($gateway['GAT_TYPE']) {
|
||||
case 'SELECTION':
|
||||
$routeType = 'SELECT';
|
||||
break;
|
||||
case 'EVALUATION':
|
||||
$routeType = 'EVALUATE';
|
||||
break;
|
||||
case 'PARALLEL':
|
||||
$routeType = 'PARALLEL';
|
||||
break;
|
||||
case 'PARALLEL_EVALUATION':
|
||||
$routeType = 'PARALLEL-BY-EVALUATION';
|
||||
break;
|
||||
case 'PARALLEL_JOIN':
|
||||
$routeType = 'SEC-JOIN';
|
||||
break;
|
||||
default:
|
||||
throw new \LogicException(sprintf("Unsupported Gateway type: %s", $gateway['GAT_TYPE']));
|
||||
}
|
||||
|
||||
$result[] = array("from" => $fromUid, "to" => $gatFlow['FLO_ELEMENT_DEST'], "type" => $routeType);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// for processmaker is only allowed flows between "gateway -> activity"
|
||||
// any another flow is considered invalid
|
||||
throw new \LogicException(sprintf(
|
||||
"For ProcessMaker is only allowed flows between \"gateway -> activity\" " . PHP_EOL .
|
||||
"Given: bpmnGateway -> " . $gatFlow['FLO_ELEMENT_DEST_TYPE']
|
||||
));
|
||||
}
|
||||
}
|
||||
//}
|
||||
break;
|
||||
case 'bpmnEvent':
|
||||
$evnUid = $flow['FLO_ELEMENT_DEST'];
|
||||
$event = self::findInArray($evnUid, "EVN_UID", $events);
|
||||
$events = self::findInArray($evnUid, "EVN_UID", $events);
|
||||
|
||||
switch ($event['EVN_TYPE']) {
|
||||
case 'END':
|
||||
$routeType = 'SEQUENTIAL';
|
||||
$result = array("from" => $fromUid, "to" => "-1", "type" => $routeType);
|
||||
break;
|
||||
default:
|
||||
throw new \LogicException("Invalid connection to Event object type");
|
||||
if (! empty($events)) {
|
||||
$event = $events[0];
|
||||
|
||||
switch ($event['EVN_TYPE']) {
|
||||
case 'END':
|
||||
$routeType = 'SEQUENTIAL';
|
||||
$result[] = array("from" => $fromUid, "to" => "-1", "type" => $routeType);
|
||||
break;
|
||||
default:
|
||||
throw new \LogicException("Invalid connection to Event object type");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
return empty($result) ? null : $result;
|
||||
}
|
||||
|
||||
protected static function findInArray($value, $key, $list)
|
||||
{
|
||||
$result = array();
|
||||
|
||||
foreach ($list as $item) {
|
||||
if (! array_key_exists($key, $item)) {
|
||||
throw new \Exception("Error: key: $key does not exist in array: " . print_r($item, true));
|
||||
}
|
||||
if ($item[$key] == $value) {
|
||||
return $item;
|
||||
if (array_key_exists($key, $item) && $item[$key] == $value) {
|
||||
$result[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function remove()
|
||||
|
||||
@@ -314,19 +314,15 @@ class Bpmn extends Handler
|
||||
}
|
||||
}
|
||||
|
||||
public function getEvent($evnUid)
|
||||
public function getEvent($evnUid, $retType = 'array')
|
||||
{
|
||||
if (empty($this->events) || ! array_key_exists($evnUid, $this->activities)) {
|
||||
$event = EventPeer::retrieveByPK($evnUid);
|
||||
$event = EventPeer::retrieveByPK($evnUid);
|
||||
|
||||
if (! is_object($event)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->events[$evnUid] = $event;
|
||||
if ($retType != "object" && ! empty($activity)) {
|
||||
$event = $event->toArray();
|
||||
}
|
||||
|
||||
return $this->events[$evnUid];
|
||||
return $event;
|
||||
}
|
||||
|
||||
public function getEvents($start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
|
||||
|
||||
@@ -282,14 +282,14 @@ class Workflow extends Handler
|
||||
}
|
||||
//if ($delete || $type == 0 || $type == 5 || $type == 8) {
|
||||
if ($delete || $type == 'SEQUENTIAL' || $type == 'SEC-JOIN' || $type == 'DISCRIMINATOR') {
|
||||
$oTasks = new Tasks();
|
||||
//$oTasks = new Tasks();
|
||||
|
||||
$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
|
||||
//$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid);
|
||||
//$oTasks->deleteAllGatewayOfTask($this->proUid, $fromTasUid);
|
||||
}
|
||||
|
||||
$result = $this->saveNewPattern($this->proUid, $fromTasUid, $toTasUid, $type, $delete);
|
||||
self::log("Add Route Success!");
|
||||
self::log("Add Route Success! -> ", $result);
|
||||
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -17,6 +17,12 @@ class Logger
|
||||
protected function __construct()
|
||||
{
|
||||
$this->logFile = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'processmaker.log';
|
||||
|
||||
if (! file_exists($this->logFile)) {
|
||||
file_put_contents($this->logFile, "");
|
||||
chmod($this->logFile, 0777);
|
||||
}
|
||||
|
||||
$this->fp = fopen($this->logFile, "a+");
|
||||
}
|
||||
|
||||
@@ -40,8 +46,8 @@ class Logger
|
||||
|
||||
fwrite($this->fp, "- " . date('Y-m-d H:i:s') . " " . $arg . PHP_EOL);
|
||||
}
|
||||
if (count($args) > 1)
|
||||
fwrite($this->fp, PHP_EOL);
|
||||
//if (count($args) > 1)
|
||||
// fwrite($this->fp, PHP_EOL);
|
||||
}
|
||||
|
||||
public static function log()
|
||||
|
||||
@@ -884,6 +884,20 @@ try {
|
||||
$RBAC = &RBAC::getSingleton( PATH_DATA, session_id() );
|
||||
$RBAC->sSystem = 'PROCESSMAKER';
|
||||
|
||||
|
||||
// if (\System::isDebugMode()) {
|
||||
// $applicationAspectKernel = \Kernel\ApplicationAspectKernel::getInstance();
|
||||
// $applicationAspectKernel->init(array(
|
||||
// 'debug' => true, // Use 'false' for production mode
|
||||
// // Cache directory
|
||||
// 'cacheDir' => sys_get_temp_dir() . DIRECTORY_SEPARATOR, // Adjust this path if needed
|
||||
// // Include paths restricts the directories where aspects should be applied, or empty for all source files
|
||||
// 'includePaths' => array(
|
||||
// PATH_HOME . 'engine/src/'
|
||||
// )
|
||||
// ));
|
||||
// }
|
||||
|
||||
// define and send Headers for all pages
|
||||
if (! defined( 'EXECUTE_BY_CRON' )) {
|
||||
header( "Expires: " . gmdate( "D, d M Y H:i:s", mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - 1, date( 'Y' ) ) ) . " GMT" );
|
||||
|
||||
Reference in New Issue
Block a user