PM-3844 "0018803: Email Event before parallel gateway..." SOLVED
Issue:
PM-3844: 0018803: Email Event before parallel gateway is not working correctly
PM-3843: 0018806: Email Events after parallel gateway do not execute.
Cause:
Falta validacion para INTERMEDIATE-EVENTS con PARALLEL-GATEWAYS
Solution:
Se completa validacion para INTERMEDIATE-EVENTS con PARALLEL-GATEWAYS, este cambio
afecta a los siguientes elementos:
- INTERMEDIATE-MESSAGE-EVENTS
- END-MESSAGE-EVENTS
- INTERMEDIATE-EMAIL-EVENTS
- END-EMAIL-EVENTS
This commit is contained in:
@@ -222,9 +222,9 @@ try {
|
||||
eprintln("Processing workspace: " . $workflow, "green");
|
||||
|
||||
try {
|
||||
$case = new \ProcessMaker\BusinessModel\Cases();
|
||||
$messageApplication = new \ProcessMaker\BusinessModel\MessageApplication();
|
||||
|
||||
$case->catchMessageEvent(true);
|
||||
$messageApplication->catchMessageEvent(true);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ class Derivation
|
||||
if (trim($arrayRouteData["ROU_CONDITION"]) == "" && $arrayRouteData["ROU_NEXT_TASK"] != "-1") {
|
||||
$arrayTaskData = $task->load($arrayRouteData["ROU_NEXT_TASK"]);
|
||||
|
||||
if ($arrayTaskData["TAS_TYPE"] == "GATEWAYTOGATEWAY") {
|
||||
if ($arrayRouteData["ROU_TYPE"] != "SEC-JOIN" && $arrayTaskData["TAS_TYPE"] == "GATEWAYTOGATEWAY") {
|
||||
$flagAddDelegation = false;
|
||||
}
|
||||
}
|
||||
@@ -728,6 +728,9 @@ class Derivation
|
||||
|
||||
$this->case = new cases();
|
||||
|
||||
$messageApplication = new \ProcessMaker\BusinessModel\MessageApplication();
|
||||
$emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
|
||||
|
||||
//Get data for this DEL_INDEX current
|
||||
$appFields = $this->case->loadCase( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] );
|
||||
|
||||
@@ -751,6 +754,7 @@ class Derivation
|
||||
$currentDelegation["TAS_MI_INSTANCE_VARIABLE"] = $task->getTasMiInstanceVariable();
|
||||
|
||||
$arrayNextDerivation = array();
|
||||
$flagFirstIteration = true;
|
||||
|
||||
foreach ($nextDelegations as $nextDel) {
|
||||
//BpmnEvent - END-MESSAGE-EVENT, END-EMAIL-EVENT
|
||||
@@ -814,15 +818,11 @@ class Derivation
|
||||
switch ($taskDummy->getTasType()) {
|
||||
case "END-MESSAGE-EVENT":
|
||||
//Throw Message-Events - BpmnEvent - END-MESSAGE-EVENT
|
||||
$case = new \ProcessMaker\BusinessModel\Cases();
|
||||
|
||||
$case->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields);
|
||||
$messageApplication->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields, $flagFirstIteration, true);
|
||||
break;
|
||||
case "END-EMAIL-EVENT":
|
||||
//Email Event
|
||||
$emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
|
||||
|
||||
$emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields);
|
||||
//Throw Email-Events - BpmnEvent - END-EMAIL-EVENT
|
||||
$emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields, $flagFirstIteration, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -882,14 +882,10 @@ class Derivation
|
||||
|
||||
if ($canDerivate) {
|
||||
//Throw Message-Events
|
||||
$case = new \ProcessMaker\BusinessModel\Cases();
|
||||
|
||||
$case->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields);
|
||||
$messageApplication->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields, $flagFirstIteration, true);
|
||||
|
||||
//Throw Email-Events
|
||||
$emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
|
||||
|
||||
$emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields);
|
||||
$emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields, $flagFirstIteration, true);
|
||||
|
||||
//Derivate
|
||||
$aSP = (isset($aSP))? $aSP : null;
|
||||
@@ -994,6 +990,13 @@ class Derivation
|
||||
|
||||
switch ($routeType) {
|
||||
case 'SEC-JOIN':
|
||||
//Throw Message-Events
|
||||
$messageApplication->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields, $flagFirstIteration, false);
|
||||
|
||||
//Throw Email-Events
|
||||
$emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields, $flagFirstIteration, false);
|
||||
|
||||
//Close thread
|
||||
$this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );
|
||||
break;
|
||||
default:
|
||||
@@ -1011,6 +1014,7 @@ class Derivation
|
||||
}
|
||||
|
||||
$removeList = false;
|
||||
$flagFirstIteration = false;
|
||||
|
||||
unset($aSP);
|
||||
}
|
||||
|
||||
@@ -2160,224 +2160,6 @@ class Cases
|
||||
return $aField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw Message-Events for the Case
|
||||
*
|
||||
* @param string $elementOriginUid Unique id of Element Origin (unique id of Task)
|
||||
* @param string $elementDestUid Unique id of Element Dest (unique id of Task)
|
||||
* @param array $arrayApplicationData Case data
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function throwMessageEventBetweenElementOriginAndElementDest($elementOriginUid, $elementDestUid, array $arrayApplicationData)
|
||||
{
|
||||
try {
|
||||
//Verify if the Project is BPMN
|
||||
$bpmn = new \ProcessMaker\Project\Bpmn();
|
||||
|
||||
if (!$bpmn->exists($arrayApplicationData["PRO_UID"])) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Element origin and dest
|
||||
$elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation();
|
||||
|
||||
$arrayElement = array(
|
||||
"elementOrigin" => array("uid" => $elementOriginUid, "type" => "bpmnActivity"),
|
||||
"elementDest" => array("uid" => $elementDestUid, "type" => "bpmnActivity")
|
||||
);
|
||||
|
||||
foreach ($arrayElement as $key => $value) {
|
||||
$arrayElementTaskRelationData = $elementTaskRelation->getElementTaskRelationWhere(
|
||||
array(
|
||||
\ElementTaskRelationPeer::PRJ_UID => $arrayApplicationData["PRO_UID"],
|
||||
\ElementTaskRelationPeer::ELEMENT_TYPE => "bpmnEvent",
|
||||
\ElementTaskRelationPeer::TAS_UID => $arrayElement[$key]["uid"]
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
if (!is_null($arrayElementTaskRelationData)) {
|
||||
$arrayElement[$key]["uid"] = $arrayElementTaskRelationData["ELEMENT_UID"];
|
||||
$arrayElement[$key]["type"] = "bpmnEvent";
|
||||
}
|
||||
}
|
||||
|
||||
$elementOriginUid = $arrayElement["elementOrigin"]["uid"];
|
||||
$elementOriginType = $arrayElement["elementOrigin"]["type"];
|
||||
$elementDestUid = $arrayElement["elementDest"]["uid"];
|
||||
$elementDestType = $arrayElement["elementDest"]["type"];
|
||||
|
||||
//Get Message-Events of throw type
|
||||
$arrayEvent = $bpmn->getMessageEventsOfThrowTypeBetweenElementOriginAndElementDest(
|
||||
$elementOriginUid,
|
||||
$elementOriginType,
|
||||
$elementDestUid,
|
||||
$elementDestType
|
||||
);
|
||||
|
||||
//Throw Message-Events
|
||||
$messageApplication = new \ProcessMaker\BusinessModel\MessageApplication();
|
||||
|
||||
foreach ($arrayEvent as $value) {
|
||||
//Message-Application throw
|
||||
$result = $messageApplication->create($arrayApplicationData["APP_UID"], $arrayApplicationData["PRO_UID"], $value[0], $arrayApplicationData);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch Message-Events for the Cases
|
||||
*
|
||||
* @param bool $frontEnd Flag to represent progress bar
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function catchMessageEvent($frontEnd = false)
|
||||
{
|
||||
try {
|
||||
\G::LoadClass("wsBase");
|
||||
|
||||
//Set variables
|
||||
$ws = new \wsBase();
|
||||
$case = new \Cases();
|
||||
|
||||
$messageApplication = new \ProcessMaker\BusinessModel\MessageApplication();
|
||||
$messageApplication->setFrontEnd($frontEnd);
|
||||
|
||||
//Get data
|
||||
$totalMessageEvent = 0;
|
||||
|
||||
$counterStartMessageEvent = 0;
|
||||
$counterIntermediateCatchMessageEvent = 0;
|
||||
$counter = 0;
|
||||
|
||||
$flagFirstTime = false;
|
||||
|
||||
$messageApplication->frontEndShow("START");
|
||||
|
||||
do {
|
||||
$flagNextRecords = false;
|
||||
|
||||
$arrayMessageApplicationUnread = $messageApplication->getMessageApplications(array("messageApplicationStatus" => "UNREAD"), null, null, 0, 1000);
|
||||
|
||||
if (!$flagFirstTime) {
|
||||
$totalMessageEvent = $arrayMessageApplicationUnread["total"];
|
||||
|
||||
$flagFirstTime = true;
|
||||
}
|
||||
|
||||
foreach ($arrayMessageApplicationUnread["data"] as $value) {
|
||||
if ($counter + 1 > $totalMessageEvent) {
|
||||
$flagNextRecords = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$arrayMessageApplicationData = $value;
|
||||
|
||||
$processUid = $arrayMessageApplicationData["PRJ_UID"];
|
||||
$taskUid = $arrayMessageApplicationData["TAS_UID"];
|
||||
|
||||
$messageApplicationUid = $arrayMessageApplicationData["MSGAPP_UID"];
|
||||
$messageApplicationCorrelation = $arrayMessageApplicationData["MSGAPP_CORRELATION"];
|
||||
|
||||
$messageEventDefinitionUserUid = $arrayMessageApplicationData["MSGED_USR_UID"];
|
||||
$messageEventDefinitionCorrelation = $arrayMessageApplicationData["MSGED_CORRELATION"];
|
||||
|
||||
$arrayVariable = $messageApplication->mergeVariables($arrayMessageApplicationData["MSGED_VARIABLES"], $arrayMessageApplicationData["MSGAPP_VARIABLES"]);
|
||||
|
||||
$flagCatched = false;
|
||||
|
||||
switch ($arrayMessageApplicationData["EVN_TYPE"]) {
|
||||
case "START":
|
||||
if ($messageEventDefinitionCorrelation == $messageApplicationCorrelation && $messageEventDefinitionUserUid != "") {
|
||||
//Start and derivate new Case
|
||||
$result = $ws->newCase($processUid, $messageEventDefinitionUserUid, $taskUid, $arrayVariable);
|
||||
|
||||
$arrayResult = json_decode(json_encode($result), true);
|
||||
|
||||
if ($arrayResult["status_code"] == 0) {
|
||||
$applicationUid = $arrayResult["caseId"];
|
||||
|
||||
$result = $ws->derivateCase($messageEventDefinitionUserUid, $applicationUid, 1);
|
||||
|
||||
$flagCatched = true;
|
||||
|
||||
//Counter
|
||||
$counterStartMessageEvent++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "INTERMEDIATE":
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\AppDelegationPeer::APP_UID);
|
||||
$criteria->addSelectColumn(\AppDelegationPeer::DEL_INDEX);
|
||||
$criteria->addSelectColumn(\AppDelegationPeer::USR_UID);
|
||||
|
||||
$criteria->add(\AppDelegationPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
||||
$criteria->add(\AppDelegationPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
|
||||
$criteria->add(\AppDelegationPeer::DEL_THREAD_STATUS, "OPEN", \Criteria::EQUAL);
|
||||
$criteria->add(\AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL);
|
||||
|
||||
$rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$applicationUid = $row["APP_UID"];
|
||||
$delIndex = $row["DEL_INDEX"];
|
||||
$userUid = $row["USR_UID"];
|
||||
|
||||
$arrayApplicationData = $case->loadCase($applicationUid);
|
||||
|
||||
if (\G::replaceDataField($messageEventDefinitionCorrelation, $arrayApplicationData["APP_DATA"]) == $messageApplicationCorrelation) {
|
||||
//"Unpause" and derivate Case
|
||||
$arrayApplicationData["APP_DATA"] = array_merge($arrayApplicationData["APP_DATA"], $arrayVariable);
|
||||
|
||||
$arrayResult = $case->updateCase($applicationUid, $arrayApplicationData);
|
||||
|
||||
$result = $ws->derivateCase($userUid, $applicationUid, $delIndex);
|
||||
|
||||
$flagCatched = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Counter
|
||||
if ($flagCatched) {
|
||||
$counterIntermediateCatchMessageEvent++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//Message-Application catch
|
||||
if ($flagCatched) {
|
||||
$result = $messageApplication->update($messageApplicationUid, array("MSGAPP_STATUS" => "READ"));
|
||||
}
|
||||
|
||||
$counter++;
|
||||
|
||||
//Progress bar
|
||||
$messageApplication->frontEndShow("BAR", "Message-Events (unread): " . $counter . "/" . $totalMessageEvent . " " . $messageApplication->progressBar($totalMessageEvent, $counter));
|
||||
|
||||
$flagNextRecords = true;
|
||||
}
|
||||
} while ($flagNextRecords);
|
||||
|
||||
$messageApplication->frontEndShow("TEXT", "Total Message-Events unread: " . $totalMessageEvent);
|
||||
$messageApplication->frontEndShow("TEXT", "Total cases started: " . $counterStartMessageEvent);
|
||||
$messageApplication->frontEndShow("TEXT", "Total cases continued: " . $counterIntermediateCatchMessageEvent);
|
||||
$messageApplication->frontEndShow("TEXT", "Total Message-Events pending: " . ($totalMessageEvent - ($counterStartMessageEvent + $counterIntermediateCatchMessageEvent)));
|
||||
|
||||
$messageApplication->frontEndShow("END");
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get status info Case
|
||||
*
|
||||
@@ -2507,3 +2289,4 @@ class Cases
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -399,14 +399,17 @@ class EmailEvent
|
||||
* @param string $elementOriginUid Unique id of Element Origin (unique id of Task)
|
||||
* @param string $elementDestUid Unique id of Element Dest (unique id of Task)
|
||||
* @param array $arrayApplicationData Case data
|
||||
* @param bool $flagEventExecuteBeforeGateway Execute event before gateway
|
||||
* @param bool $flagEventExecuteAfterGateway Execute event after gateway
|
||||
*
|
||||
* return void
|
||||
* @return void
|
||||
*/
|
||||
public function emailEventBetweenElementOriginAndElementDest($elementOriginUid, $elementDestUid, array $arrayApplicationData)
|
||||
public function emailEventBetweenElementOriginAndElementDest($elementOriginUid, $elementDestUid, array $arrayApplicationData, $flagEventExecuteBeforeGateway = true, $flagEventExecuteAfterGateway = true)
|
||||
{
|
||||
try {
|
||||
//Verify if the Project is BPMN
|
||||
$bpmn = new \ProcessMaker\Project\Bpmn();
|
||||
|
||||
if (!$bpmn->exists($arrayApplicationData["PRO_UID"])) {
|
||||
return;
|
||||
}
|
||||
@@ -440,18 +443,39 @@ class EmailEvent
|
||||
$elementDestUid = $arrayElement["elementDest"]["uid"];
|
||||
$elementDestType = $arrayElement["elementDest"]["type"];
|
||||
|
||||
//Get Message-Events of throw type
|
||||
$arrayEvent = $bpmn->getEmailEventTypeBetweenElementOriginAndElementDest(
|
||||
//Throw Email-Events
|
||||
$arrayEventType = array("END", "INTERMEDIATE");
|
||||
$arrayEventMarker = array("EMAIL");
|
||||
|
||||
$arrayEventExecute = array("BEFORE" => $flagEventExecuteBeforeGateway, "AFTER" => $flagEventExecuteAfterGateway);
|
||||
$positionEventExecute = "BEFORE";
|
||||
|
||||
$arrayElement = $bpmn->getElementsBetweenElementOriginAndElementDest(
|
||||
$elementOriginUid,
|
||||
$elementOriginType,
|
||||
$elementDestUid,
|
||||
$elementDestType
|
||||
);
|
||||
|
||||
//Email-event
|
||||
foreach ($arrayEvent as $value) {
|
||||
foreach ($arrayElement as $value) {
|
||||
switch ($value[1]) {
|
||||
case "bpmnEvent":
|
||||
$event = \BpmnEventPeer::retrieveByPK($value[0]);
|
||||
|
||||
if (!is_null($event) &&
|
||||
in_array($event->getEvnType(), $arrayEventType) && in_array($event->getEvnMarker(), $arrayEventMarker)
|
||||
) {
|
||||
if ($arrayEventExecute[$positionEventExecute]) {
|
||||
//Email-Event throw
|
||||
$result = $this->sendEmail($arrayApplicationData["APP_UID"], $arrayApplicationData["PRO_UID"], $value[0], $arrayApplicationData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "bpmnGateway":
|
||||
$positionEventExecute = "AFTER";
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@@ -209,76 +209,6 @@ class MessageApplication
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set front end flag
|
||||
*
|
||||
* @param bool $flag Flag
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function setFrontEnd($flag)
|
||||
{
|
||||
try {
|
||||
$this->frontEnd = $flag;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Progress bar
|
||||
*
|
||||
* @param int $total Total
|
||||
* @param int $count Count
|
||||
*
|
||||
* return string Return a string that represent progress bar
|
||||
*/
|
||||
public function progressBar($total, $count)
|
||||
{
|
||||
try {
|
||||
$p = (int)(($count * 100) / $total);
|
||||
$n = (int)($p / 2);
|
||||
|
||||
return "[" . str_repeat("|", $n) . str_repeat(" ", 50 - $n) . "] $p%";
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show front end
|
||||
*
|
||||
* @param string $option Option
|
||||
* @param string $data Data string
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function frontEndShow($option, $data = "")
|
||||
{
|
||||
try {
|
||||
if (!$this->frontEnd) {
|
||||
return;
|
||||
}
|
||||
|
||||
$numc = 100;
|
||||
|
||||
switch ($option) {
|
||||
case "BAR":
|
||||
echo "\r" . "| " . $data . str_repeat(" ", $numc - 2 - strlen($data));
|
||||
break;
|
||||
case "TEXT":
|
||||
echo "\r" . "| " . $data . str_repeat(" ", $numc - 2 - strlen($data)) . "\n";
|
||||
break;
|
||||
default:
|
||||
//START, END
|
||||
echo "\r" . "+" . str_repeat("-", $numc - 2) . "+" . "\n";
|
||||
break;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge and get variables
|
||||
*
|
||||
@@ -423,5 +353,243 @@ class MessageApplication
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw Message-Events for the Case
|
||||
*
|
||||
* @param string $elementOriginUid Unique id of Element Origin (unique id of Task)
|
||||
* @param string $elementDestUid Unique id of Element Dest (unique id of Task)
|
||||
* @param array $arrayApplicationData Case data
|
||||
* @param bool $flagEventExecuteBeforeGateway Execute event before gateway
|
||||
* @param bool $flagEventExecuteAfterGateway Execute event after gateway
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function throwMessageEventBetweenElementOriginAndElementDest($elementOriginUid, $elementDestUid, array $arrayApplicationData, $flagEventExecuteBeforeGateway = true, $flagEventExecuteAfterGateway = true)
|
||||
{
|
||||
try {
|
||||
//Verify if the Project is BPMN
|
||||
$bpmn = new \ProcessMaker\Project\Bpmn();
|
||||
|
||||
if (!$bpmn->exists($arrayApplicationData["PRO_UID"])) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Element origin and dest
|
||||
$elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation();
|
||||
|
||||
$arrayElement = array(
|
||||
"elementOrigin" => array("uid" => $elementOriginUid, "type" => "bpmnActivity"),
|
||||
"elementDest" => array("uid" => $elementDestUid, "type" => "bpmnActivity")
|
||||
);
|
||||
|
||||
foreach ($arrayElement as $key => $value) {
|
||||
$arrayElementTaskRelationData = $elementTaskRelation->getElementTaskRelationWhere(
|
||||
array(
|
||||
\ElementTaskRelationPeer::PRJ_UID => $arrayApplicationData["PRO_UID"],
|
||||
\ElementTaskRelationPeer::ELEMENT_TYPE => "bpmnEvent",
|
||||
\ElementTaskRelationPeer::TAS_UID => $arrayElement[$key]["uid"]
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
if (!is_null($arrayElementTaskRelationData)) {
|
||||
$arrayElement[$key]["uid"] = $arrayElementTaskRelationData["ELEMENT_UID"];
|
||||
$arrayElement[$key]["type"] = "bpmnEvent";
|
||||
}
|
||||
}
|
||||
|
||||
$elementOriginUid = $arrayElement["elementOrigin"]["uid"];
|
||||
$elementOriginType = $arrayElement["elementOrigin"]["type"];
|
||||
$elementDestUid = $arrayElement["elementDest"]["uid"];
|
||||
$elementDestType = $arrayElement["elementDest"]["type"];
|
||||
|
||||
//Throw Message-Events
|
||||
$arrayEventType = array("END", "INTERMEDIATE");
|
||||
$arrayEventMarker = array("MESSAGETHROW");
|
||||
|
||||
$arrayEventExecute = array("BEFORE" => $flagEventExecuteBeforeGateway, "AFTER" => $flagEventExecuteAfterGateway);
|
||||
$positionEventExecute = "BEFORE";
|
||||
|
||||
$arrayElement = $bpmn->getElementsBetweenElementOriginAndElementDest(
|
||||
$elementOriginUid,
|
||||
$elementOriginType,
|
||||
$elementDestUid,
|
||||
$elementDestType
|
||||
);
|
||||
|
||||
foreach ($arrayElement as $value) {
|
||||
switch ($value[1]) {
|
||||
case "bpmnEvent":
|
||||
$event = \BpmnEventPeer::retrieveByPK($value[0]);
|
||||
|
||||
if (!is_null($event) &&
|
||||
in_array($event->getEvnType(), $arrayEventType) && in_array($event->getEvnMarker(), $arrayEventMarker)
|
||||
) {
|
||||
if ($arrayEventExecute[$positionEventExecute]) {
|
||||
//Message-Application throw
|
||||
$result = $this->create($arrayApplicationData["APP_UID"], $arrayApplicationData["PRO_UID"], $value[0], $arrayApplicationData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "bpmnGateway":
|
||||
$positionEventExecute = "AFTER";
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch Message-Events for the Cases
|
||||
*
|
||||
* @param bool $frontEnd Flag to represent progress bar
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function catchMessageEvent($frontEnd = false)
|
||||
{
|
||||
try {
|
||||
\G::LoadClass("wsBase");
|
||||
|
||||
//Set variables
|
||||
$ws = new \wsBase();
|
||||
$case = new \Cases();
|
||||
$common = new \ProcessMaker\Util\Common();
|
||||
|
||||
$common->setFrontEnd($frontEnd);
|
||||
|
||||
//Get data
|
||||
$totalMessageEvent = 0;
|
||||
|
||||
$counterStartMessageEvent = 0;
|
||||
$counterIntermediateCatchMessageEvent = 0;
|
||||
$counter = 0;
|
||||
|
||||
$flagFirstTime = false;
|
||||
|
||||
$common->frontEndShow("START");
|
||||
|
||||
do {
|
||||
$flagNextRecords = false;
|
||||
|
||||
$arrayMessageApplicationUnread = $this->getMessageApplications(array("messageApplicationStatus" => "UNREAD"), null, null, 0, 1000);
|
||||
|
||||
if (!$flagFirstTime) {
|
||||
$totalMessageEvent = $arrayMessageApplicationUnread["total"];
|
||||
|
||||
$flagFirstTime = true;
|
||||
}
|
||||
|
||||
foreach ($arrayMessageApplicationUnread["data"] as $value) {
|
||||
if ($counter + 1 > $totalMessageEvent) {
|
||||
$flagNextRecords = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$arrayMessageApplicationData = $value;
|
||||
|
||||
$processUid = $arrayMessageApplicationData["PRJ_UID"];
|
||||
$taskUid = $arrayMessageApplicationData["TAS_UID"];
|
||||
|
||||
$messageApplicationUid = $arrayMessageApplicationData["MSGAPP_UID"];
|
||||
$messageApplicationCorrelation = $arrayMessageApplicationData["MSGAPP_CORRELATION"];
|
||||
|
||||
$messageEventDefinitionUserUid = $arrayMessageApplicationData["MSGED_USR_UID"];
|
||||
$messageEventDefinitionCorrelation = $arrayMessageApplicationData["MSGED_CORRELATION"];
|
||||
|
||||
$arrayVariable = $this->mergeVariables($arrayMessageApplicationData["MSGED_VARIABLES"], $arrayMessageApplicationData["MSGAPP_VARIABLES"]);
|
||||
|
||||
$flagCatched = false;
|
||||
|
||||
switch ($arrayMessageApplicationData["EVN_TYPE"]) {
|
||||
case "START":
|
||||
if ($messageEventDefinitionCorrelation == $messageApplicationCorrelation && $messageEventDefinitionUserUid != "") {
|
||||
//Start and derivate new Case
|
||||
$result = $ws->newCase($processUid, $messageEventDefinitionUserUid, $taskUid, $arrayVariable);
|
||||
|
||||
$arrayResult = json_decode(json_encode($result), true);
|
||||
|
||||
if ($arrayResult["status_code"] == 0) {
|
||||
$applicationUid = $arrayResult["caseId"];
|
||||
|
||||
$result = $ws->derivateCase($messageEventDefinitionUserUid, $applicationUid, 1);
|
||||
|
||||
$flagCatched = true;
|
||||
|
||||
//Counter
|
||||
$counterStartMessageEvent++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "INTERMEDIATE":
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\AppDelegationPeer::APP_UID);
|
||||
$criteria->addSelectColumn(\AppDelegationPeer::DEL_INDEX);
|
||||
$criteria->addSelectColumn(\AppDelegationPeer::USR_UID);
|
||||
|
||||
$criteria->add(\AppDelegationPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
||||
$criteria->add(\AppDelegationPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
|
||||
$criteria->add(\AppDelegationPeer::DEL_THREAD_STATUS, "OPEN", \Criteria::EQUAL);
|
||||
$criteria->add(\AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL);
|
||||
|
||||
$rsCriteria = \AppDelegationPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$applicationUid = $row["APP_UID"];
|
||||
$delIndex = $row["DEL_INDEX"];
|
||||
$userUid = $row["USR_UID"];
|
||||
|
||||
$arrayApplicationData = $case->loadCase($applicationUid);
|
||||
|
||||
if (\G::replaceDataField($messageEventDefinitionCorrelation, $arrayApplicationData["APP_DATA"]) == $messageApplicationCorrelation) {
|
||||
//"Unpause" and derivate Case
|
||||
$arrayApplicationData["APP_DATA"] = array_merge($arrayApplicationData["APP_DATA"], $arrayVariable);
|
||||
|
||||
$arrayResult = $case->updateCase($applicationUid, $arrayApplicationData);
|
||||
|
||||
$result = $ws->derivateCase($userUid, $applicationUid, $delIndex);
|
||||
|
||||
$flagCatched = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Counter
|
||||
if ($flagCatched) {
|
||||
$counterIntermediateCatchMessageEvent++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//Message-Application catch
|
||||
if ($flagCatched) {
|
||||
$result = $this->update($messageApplicationUid, array("MSGAPP_STATUS" => "READ"));
|
||||
}
|
||||
|
||||
$counter++;
|
||||
|
||||
//Progress bar
|
||||
$common->frontEndShow("BAR", "Message-Events (unread): " . $counter . "/" . $totalMessageEvent . " " . $common->progressBar($totalMessageEvent, $counter));
|
||||
|
||||
$flagNextRecords = true;
|
||||
}
|
||||
} while ($flagNextRecords);
|
||||
|
||||
$common->frontEndShow("TEXT", "Total Message-Events unread: " . $totalMessageEvent);
|
||||
$common->frontEndShow("TEXT", "Total cases started: " . $counterStartMessageEvent);
|
||||
$common->frontEndShow("TEXT", "Total cases continued: " . $counterIntermediateCatchMessageEvent);
|
||||
$common->frontEndShow("TEXT", "Total Message-Events pending: " . ($totalMessageEvent - ($counterStartMessageEvent + $counterIntermediateCatchMessageEvent)));
|
||||
|
||||
$common->frontEndShow("END");
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1371,12 +1371,11 @@ class Bpmn extends Handler
|
||||
}
|
||||
}
|
||||
|
||||
public function getElementsBetweenElementOriginAndElementDest(
|
||||
private function __getElementsBetweenElementOriginAndElementDest(
|
||||
$elementOriginUid,
|
||||
$elementOriginType,
|
||||
$elementDestUid,
|
||||
$elementDestType,
|
||||
$index
|
||||
$elementDestType
|
||||
) {
|
||||
try {
|
||||
if (isset($this->arrayElementOriginChecked[$elementOriginUid]) && $this->arrayElementOriginChecked[$elementOriginUid] == $elementOriginType) {
|
||||
@@ -1388,7 +1387,7 @@ class Bpmn extends Handler
|
||||
|
||||
if ($elementOriginType == $elementDestType && $elementOriginUid == $elementDestUid) {
|
||||
$arrayEvent = array();
|
||||
$arrayEvent[$index] = array($elementDestUid, $elementDestType);
|
||||
array_unshift($arrayEvent, array($elementDestUid, $elementDestType));
|
||||
|
||||
//Return
|
||||
return $arrayEvent;
|
||||
@@ -1403,16 +1402,15 @@ class Bpmn extends Handler
|
||||
foreach ($arrayFlow as $value) {
|
||||
$arrayFlowData = $value->toArray();
|
||||
|
||||
$arrayEvent = $this->getElementsBetweenElementOriginAndElementDest(
|
||||
$arrayEvent = $this->__getElementsBetweenElementOriginAndElementDest(
|
||||
$arrayFlowData["FLO_ELEMENT_DEST"],
|
||||
$arrayFlowData["FLO_ELEMENT_DEST_TYPE"],
|
||||
$elementDestUid,
|
||||
$elementDestType,
|
||||
$index + 1
|
||||
$elementDestType
|
||||
);
|
||||
|
||||
if (!empty($arrayEvent)) {
|
||||
$arrayEvent[$index] = array($elementOriginUid, $elementOriginType);
|
||||
array_unshift($arrayEvent, array($elementOriginUid, $elementOriginType));
|
||||
|
||||
//Return
|
||||
return $arrayEvent;
|
||||
@@ -1429,89 +1427,17 @@ class Bpmn extends Handler
|
||||
}
|
||||
}
|
||||
|
||||
public function getMessageEventsOfThrowTypeBetweenElementOriginAndElementDest(
|
||||
public function getElementsBetweenElementOriginAndElementDest(
|
||||
$elementOriginUid,
|
||||
$elementOriginType,
|
||||
$elementDestUid,
|
||||
$elementDestType
|
||||
) {
|
||||
try {
|
||||
$arrayEventType = array("END", "INTERMEDIATE");
|
||||
$arrayEventMarker = array("MESSAGETHROW");
|
||||
|
||||
$this->arrayElementOriginChecked = array();
|
||||
|
||||
$arrayEventAux = $this->getElementsBetweenElementOriginAndElementDest(
|
||||
$elementOriginUid,
|
||||
$elementOriginType,
|
||||
$elementDestUid,
|
||||
$elementDestType,
|
||||
0
|
||||
);
|
||||
|
||||
ksort($arrayEventAux);
|
||||
|
||||
$arrayEvent = array();
|
||||
|
||||
foreach ($arrayEventAux as $value) {
|
||||
if ($value[1] == "bpmnEvent") {
|
||||
$event = \BpmnEventPeer::retrieveByPK($value[0]);
|
||||
|
||||
if (!is_null($event) &&
|
||||
in_array($event->getEvnType(), $arrayEventType) && in_array($event->getEvnMarker(), $arrayEventMarker)
|
||||
) {
|
||||
$arrayEvent[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayEvent;
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getEmailEventTypeBetweenElementOriginAndElementDest(
|
||||
$elementOriginUid,
|
||||
$elementOriginType,
|
||||
$elementDestUid,
|
||||
$elementDestType
|
||||
) {
|
||||
try {
|
||||
$arrayEventType = array("END", "INTERMEDIATE");
|
||||
$arrayEventMarker = array("EMAIL");
|
||||
|
||||
$this->arrayElementOriginChecked = array();
|
||||
|
||||
$arrayEventAux = $this->getElementsBetweenElementOriginAndElementDest(
|
||||
$elementOriginUid,
|
||||
$elementOriginType,
|
||||
$elementDestUid,
|
||||
$elementDestType,
|
||||
0
|
||||
);
|
||||
|
||||
ksort($arrayEventAux);
|
||||
|
||||
$arrayEvent = array();
|
||||
|
||||
foreach ($arrayEventAux as $value) {
|
||||
if ($value[1] == "bpmnEvent") {
|
||||
$event = \BpmnEventPeer::retrieveByPK($value[0]);
|
||||
|
||||
if (!is_null($event) &&
|
||||
in_array($event->getEvnType(), $arrayEventType) && in_array($event->getEvnMarker(), $arrayEventMarker)
|
||||
) {
|
||||
$arrayEvent[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayEvent;
|
||||
return call_user_func_array(array($this, "__getElementsBetweenElementOriginAndElementDest"), func_get_args());
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user