fix in method
This commit is contained in:
@@ -51,7 +51,7 @@ class Derivation
|
||||
protected $flagControl;
|
||||
protected $flagControlMulInstance;
|
||||
private $regexpTaskTypeToInclude;
|
||||
public $flagSanity = false;
|
||||
// public $flagSanity = false;
|
||||
public $node;
|
||||
|
||||
public function __construct()
|
||||
@@ -259,9 +259,7 @@ class Derivation
|
||||
|
||||
//Check Task GATEWAYTOGATEWAY, END-MESSAGE-EVENT, END-EMAIL-EVENT
|
||||
$arrayNextTaskBackup = $arrayNextTask;
|
||||
if ($this->flagSanity) {
|
||||
//$arrayNextTaskBackup = $this->preSanity($arrayNextTask);
|
||||
}
|
||||
|
||||
$arrayNextTask = array();
|
||||
$i = 0;
|
||||
foreach ($arrayNextTaskBackup as $value) {
|
||||
@@ -333,87 +331,6 @@ class Derivation
|
||||
}
|
||||
}
|
||||
|
||||
public function preSanity($arrayNextTask)
|
||||
{
|
||||
$arrayNextTaskResponse = array();
|
||||
if ($arrayNextTask) {
|
||||
$arrayTask = array();
|
||||
$arrayNotTask = array();
|
||||
$regex = "END-MESSAGE-EVENT|END-EMAIL-EVENT|SCRIPT-TASK|INTERMEDIATE-CATCH-TIMER-EVENT|INTERMEDIATE-THROW-EMAIL-EVENT";
|
||||
foreach ($arrayNextTask as $index => $item) {
|
||||
if (($item["NEXT_TASK"]["TAS_UID"] != "-1" &&
|
||||
preg_match("/^(?:" . $regex . ")$/", $item["NEXT_TASK"]["TAS_TYPE"]))
|
||||
) {
|
||||
$arrayNotTask[] = $index;
|
||||
} else {
|
||||
$arrayTask[] = $index;
|
||||
}
|
||||
}
|
||||
if ($arrayTask) {
|
||||
foreach ($arrayNotTask as $item) {
|
||||
unset($arrayNextTask[$item]);
|
||||
}
|
||||
$arrayNextTaskResponse = array_values($arrayNextTask);
|
||||
} else {
|
||||
$pos = array_shift($arrayNotTask);
|
||||
$arrayNextTaskResponse[] = $arrayNextTask[$pos];
|
||||
foreach ($arrayNextTask as $nextTask) {
|
||||
$flag = false;
|
||||
foreach ($arrayNextTaskResponse as $task) {
|
||||
if (!in_array($nextTask['ROU_NEXT_TASK'], $task, true)) {
|
||||
$flag = true;
|
||||
}
|
||||
}
|
||||
if ($flag) {
|
||||
$arrayNextTaskResponse[] = $nextTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $arrayNextTaskResponse;
|
||||
}
|
||||
|
||||
public function postSanity($arrayNextTask)
|
||||
{
|
||||
$arrayNextTaskResponse = array();
|
||||
if ($arrayNextTask) {
|
||||
$arrayTask = array();
|
||||
$arrayNotTask = array();
|
||||
$regex = "GATEWAYTOGATEWAY|END-MESSAGE-EVENT|END-EMAIL-EVENT|INTERMEDIATE-CATCH-TIMER-EVENT|INTERMEDIATE-THROW-EMAIL-EVENT";
|
||||
foreach ($arrayNextTask as $index => $item) {
|
||||
if (($item["NEXT_TASK"]["TAS_UID"] != "-1" &&
|
||||
preg_match("/^(?:" . $regex . ")$/", $item["NEXT_TASK"]["TAS_TYPE"]))
|
||||
|| $item['ROU_TYPE'] == "SEC-JOIN"
|
||||
) {
|
||||
$arrayNotTask[] = $index;
|
||||
} else {
|
||||
$arrayTask[] = $index;
|
||||
}
|
||||
}
|
||||
if ($arrayTask) {
|
||||
foreach ($arrayNotTask as $item) {
|
||||
unset($arrayNextTask[$item]);
|
||||
}
|
||||
$arrayNextTaskResponse = array_values($arrayNextTask);
|
||||
} else {
|
||||
$pos = array_shift($arrayNotTask);
|
||||
$arrayNextTaskResponse[] = $arrayNextTask[$pos];
|
||||
foreach ($arrayNextTask as $nextTask) {
|
||||
$flag = false;
|
||||
foreach ($arrayNextTaskResponse as $task) {
|
||||
if (!in_array($nextTask['ROU_NEXT_TASK'], $task, true)) {
|
||||
$flag = true;
|
||||
}
|
||||
}
|
||||
if ($flag) {
|
||||
$arrayNextTaskResponse[] = $nextTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array_combine(range(1, count($arrayNextTaskResponse)), array_values($arrayNextTaskResponse));
|
||||
}
|
||||
|
||||
/**
|
||||
* getRouteCondition
|
||||
*
|
||||
|
||||
@@ -5,16 +5,16 @@ namespace ProcessMaker\Core;
|
||||
|
||||
class RoutingScreen extends \Derivation
|
||||
{
|
||||
public $convergent = 0;
|
||||
public $divergent = 0;
|
||||
protected $convergent;
|
||||
protected $divergent;
|
||||
public $gateway = array('PARALLEL', 'PARALLEL-BY-EVALUATION');
|
||||
public $isFirst;
|
||||
protected $taskSecJoin;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setRegexpTaskTypeToInclude("GATEWAYTOGATEWAY|END-MESSAGE-EVENT|END-EMAIL-EVENT|INTERMEDIATE-CATCH-TIMER-EVENT|INTERMEDIATE-THROW-EMAIL-EVENT");
|
||||
$this->flagSanity = true;
|
||||
}
|
||||
|
||||
public function mergeDataDerivation($post, $prepareInformation)
|
||||
@@ -45,47 +45,65 @@ class RoutingScreen extends \Derivation
|
||||
|
||||
public function prepareRoutingScreen($arrayData)
|
||||
{
|
||||
$array = $this->postSanity($this->prepareInformation($arrayData));
|
||||
return $array;
|
||||
}
|
||||
|
||||
public function postSanity($arrayInformation)
|
||||
{
|
||||
$information= $this->prepareInformation($arrayData);
|
||||
$response = array();
|
||||
foreach ($arrayInformation as $index => $element) {
|
||||
$this->divergent = 0;
|
||||
$this->convergent = 0;
|
||||
$this->taskSecJoin = array();
|
||||
foreach ($information as $index => $element) {
|
||||
$this->divergent = array();
|
||||
$this->convergent = array();
|
||||
$this->isFirst = true;
|
||||
if ($this->checkElement($this->node[$element['TAS_UID']])) {
|
||||
$response[] = $element;
|
||||
$x = $this->checkElement($this->node[$element['TAS_UID']]);
|
||||
if ($x) {
|
||||
$save = false;
|
||||
foreach ($response as $task) {
|
||||
if (!in_array($element['ROU_NEXT_TASK'], $task, true)) {
|
||||
$save = true;
|
||||
}
|
||||
}
|
||||
if ((!$response || $save)) {
|
||||
$response[] = $element;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count($response) > 1){
|
||||
foreach ($response as $index => $task) {
|
||||
$delete = false;
|
||||
foreach ($this->taskSecJoin as $tj => $type) {
|
||||
if (in_array($tj, $task, true)) {
|
||||
$delete = true;
|
||||
}
|
||||
}
|
||||
if ($delete) {
|
||||
unset($response[$index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return array_combine(range(1, count($response)), array_values($response));
|
||||
//return parent::postSanity($arrayNextTask); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
|
||||
public function checkElement($element)
|
||||
{
|
||||
if (empty($element['in'])) {
|
||||
$x = 1;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
$outElement = $element['out'];
|
||||
foreach ($outElement as $index => $outE) {
|
||||
foreach ($outElement as $indexO => $outE) {
|
||||
if (!$this->isFirst && in_array($outE, $this->gateway)) {
|
||||
$this->divergent++;
|
||||
$this->divergent[$indexO] = $outE;
|
||||
}
|
||||
if ($outE == 'SEC-JOIN' && strpos($indexO, 'itee') === false) {
|
||||
$this->taskSecJoin[$indexO] = $outE;
|
||||
}
|
||||
}
|
||||
$this->isFirst = false;
|
||||
$inElement = $element['in'];
|
||||
foreach ($inElement as $index => $inE) {
|
||||
foreach ($inElement as $indexI => $inE) {
|
||||
if ($inE == 'SEC-JOIN') {
|
||||
$this->convergent++;
|
||||
$this->convergent[$indexI]=$inE;
|
||||
}
|
||||
$this->checkElement($this->node[$index]);
|
||||
$this->checkElement($this->node[$indexI]);
|
||||
}
|
||||
//$this->checkElement($inElement);
|
||||
return $this->convergent == 0 || $this->convergent == $this->divergent;
|
||||
return count($this->convergent) == 0 || count($this->convergent) == count($this->divergent);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user