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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user