diff --git a/workflow/engine/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php
index 68b364007..88d00fcf4 100755
--- a/workflow/engine/methods/cases/cases_Step.php
+++ b/workflow/engine/methods/cases/cases_Step.php
@@ -1,10 +1,10 @@
alreadyRouted($_SESSION['APPLICATION'],$_SESSION['INDEX']) ) {
+if( $delegation->alreadyRouted($_SESSION['APPLICATION'],$_SESSION['INDEX']) ) {
G::header('location: ../cases/casesListExtJs');
die();
-}
+}
if (!isset($_SESSION['USER_LOGGED'])) {
G::SendTemporalMessage( 'ID_LOGIN_AGAIN', 'warning', 'labels' );
@@ -959,6 +959,12 @@ try {
$title = htmlentities($aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TITLE'], ENT_QUOTES, 'UTF-8');
$aFields['TASK'][$sKey]['NEXT_TASK']['TAS_TITLE'] = $title;
+ if (!preg_match("/\-1$/", $aFields["TASK"][$sKey]["NEXT_TASK"]["TAS_UID"]) &&
+ $aFields["TASK"][$sKey]["NEXT_TASK"]["TAS_TYPE"] == "INTERMEDIATE-CATCH-MESSAGE-EVENT"
+ ) {
+ $aFields["TASK"][$sKey]["NEXT_TASK"]["TAS_TITLE"] = G::LoadTranslation("ID_ROUTE_TO_TASK_INTERMEDIATE_CATCH_MESSAGE_EVENT");
+ }
+
$G_PUBLISH->AddContent( 'smarty', $tplFile, '', '', $aFields );
/*
if (isset( $aFields['TASK'][1]['NEXT_TASK']['USER_ASSIGNED'])){
@@ -1026,13 +1032,13 @@ try {
}
//Add content content step - End
} catch (Exception $e) {
- //Check if the process is BPMN
+ //Check if the process is BPMN
if(isset($oProcessFieds['PRO_BPMN']) && $oProcessFieds['PRO_BPMN'] == 1){
- G::SendTemporalMessage( G::LoadTranslation( 'ID_BPMN_PROCESS_DEF_PROBLEM' ), 'error', 'string', 3, 100 );
+ G::SendTemporalMessage( G::LoadTranslation( 'ID_BPMN_PROCESS_DEF_PROBLEM' ), 'error', 'string', 3, 100 );
}else{
G::SendTemporalMessage( G::LoadTranslation( 'ID_PROCESS_DEF_PROBLEM' ), 'error', 'string', 3, 100 );
- }
-
+ }
+
$aMessage = array ();
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH = new Publisher();
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php
index 20d26716a..200b166ff 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php
@@ -1970,4 +1970,130 @@ 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 {
+ //Element origin and dest
+ $messageEventTaskRelation = new \ProcessMaker\BusinessModel\MessageEventTaskRelation();
+
+ $arrayElement = array(
+ "elementOrigin" => array("uid" => $elementOriginUid, "type" => "bpmnActivity"),
+ "elementDest" => array("uid" => $elementDestUid, "type" => "bpmnActivity")
+ );
+
+ foreach ($arrayElement as $key => $value) {
+ $arrayMessageEventTaskRelationData = $messageEventTaskRelation->getMessageEventTaskRelationWhere(
+ array(
+ \MessageEventTaskRelationPeer::PRJ_UID => $arrayApplicationData["PRO_UID"],
+ \MessageEventTaskRelationPeer::TAS_UID => $arrayElement[$key]["uid"]
+ ),
+ true
+ );
+
+ if (!is_null($arrayMessageEventTaskRelationData)) {
+ $arrayElement[$key]["uid"] = $arrayMessageEventTaskRelationData["EVN_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
+ $bpmn = new \ProcessMaker\Project\Bpmn();
+
+ $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();
+
+ //Get data
+ $messageApplication = new \ProcessMaker\BusinessModel\MessageApplication();
+
+ $arrayMessageApplicationUnread = $messageApplication->getMessageApplications(array("messageApplicationStatus" => "UNREAD"));
+
+ foreach ($arrayMessageApplicationUnread["data"] as $value) {
+ $arrayMessageApplicationData = $value;
+
+ $processUid = $arrayMessageApplicationData["PRJ_UID"];
+ $taskUid = $arrayMessageApplicationData["TAS_UID"];
+
+ $messageApplicationUid = $arrayMessageApplicationData["MSGAPP_UID"];
+ $messageApplicationCorrelation = $arrayMessageApplicationData["MSGAPP_CORRELATION"];
+
+ $messageEventDefinitionUserUid = $arrayMessageApplicationData["MSGED_USR_UID"];
+ $messageEventDefinitionVariables = $arrayMessageApplicationData["MSGED_VARIABLES"];
+ $messageEventDefinitionCorrelation = $arrayMessageApplicationData["MSGED_CORRELATION"];
+
+ switch ($arrayMessageApplicationData["EVN_TYPE"]) {
+ case "START":
+ if ($messageApplicationCorrelation == $messageEventDefinitionCorrelation &&
+ $messageEventDefinitionUserUid != ""
+ ) {
+ //Start and derivate new Case
+ //$result = $ws->newCase($processUid, $messageEventDefinitionUserUid, $taskUid, array("NAME1" => "value1"));
+ $result = $ws->newCase($processUid, $messageEventDefinitionUserUid, $taskUid, array());
+
+ $arrayResult = json_decode(json_encode($result), true);
+
+ if ($arrayResult["status_code"] == 0) {
+ $applicationUid = $arrayResult["caseId"];
+
+ $result = $ws->derivateCase($messageEventDefinitionUserUid, $applicationUid, 1);
+
+ //Message-Application catch
+ $result = $messageApplication->update($messageApplicationUid, array("MSGAPP_STATUS" => "READ"));
+ }
+ }
+ break;
+ case "INTERMEDIATE":
+ break;
+ }
+ }
+ } catch (\Exception $e) {
+ throw $e;
+ }
+ }
}
+
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/MessageApplication.php b/workflow/engine/src/ProcessMaker/BusinessModel/MessageApplication.php
new file mode 100644
index 000000000..154924754
--- /dev/null
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/MessageApplication.php
@@ -0,0 +1,328 @@
+ "START",
+ "limit" => "LIMIT"
+ );
+
+ /**
+ * Verify if exists the Message-Application
+ *
+ * @param string $messageApplicationUid Unique id of Message-Application
+ *
+ * return bool Return true if exists the Message-Application, false otherwise
+ */
+ public function exists($messageApplicationUid)
+ {
+ try {
+ $obj = \MessageApplicationPeer::retrieveByPK($messageApplicationUid);
+
+ return (!is_null($obj))? true : false;
+ } catch (\Exception $e) {
+ throw $e;
+ }
+ }
+
+ /**
+ * Create Message-Application for the Case
+ *
+ * @param string $applicationUid Unique id of Case
+ * @param string $projectUid Unique id of Project
+ * @param string $eventUidThrow Unique id of Event (throw)
+ * @param array $arrayApplicationData Case data
+ *
+ * return bool Return true if been created, false otherwise
+ */
+ public function create($applicationUid, $projectUid, $eventUidThrow, array $arrayApplicationData)
+ {
+ try {
+ $flagCreate = true;
+
+ //Set data
+ //Message-Event-Relation - Get unique id of Event (catch)
+ $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();
+
+ $arrayMessageEventRelationData = $messageEventRelation->getMessageEventRelationWhere(
+ array(
+ \MessageEventRelationPeer::PRJ_UID => $projectUid,
+ \MessageEventRelationPeer::EVN_UID_THROW => $eventUidThrow
+ ),
+ true
+ );
+
+ if (!is_null($arrayMessageEventRelationData)) {
+ $eventUidCatch = $arrayMessageEventRelationData["EVN_UID_CATCH"];
+ } else {
+ $flagCreate = false;
+ }
+
+ //Message-Application - Get data ($eventUidThrow)
+ $messageEventDefinition = new \ProcessMaker\BusinessModel\MessageEventDefinition();
+
+ if ($messageEventDefinition->existsEvent($projectUid, $eventUidThrow)) {
+ $arrayMessageEventDefinitionData = $messageEventDefinition->getMessageEventDefinitionByEvent($projectUid, $eventUidThrow, true);
+
+ $arrayMessageApplicationVariables = $arrayMessageEventDefinitionData["MSGED_VARIABLES"];
+ $messageApplicationCorrelation = \G::replaceDataField($arrayMessageEventDefinitionData["MSGED_CORRELATION"], $arrayApplicationData["APP_DATA"]);
+
+ foreach ($arrayMessageApplicationVariables as $key => $value) {
+ $arrayMessageApplicationVariables[$key] = \G::replaceDataField($value, $arrayApplicationData["APP_DATA"]);
+ }
+ } else {
+ $flagCreate = false;
+ }
+
+ if (!$flagCreate) {
+ //Return
+ return false;
+ }
+
+ //Create
+ $cnn = \Propel::getConnection("workflow");
+
+ try {
+ $messageApplication = new \MessageApplication();
+
+ $messageApplicationUid = \ProcessMaker\Util\Common::generateUID();
+
+ $messageApplication->setMsgappUid($messageApplicationUid);
+ $messageApplication->setAppUid($applicationUid);
+ $messageApplication->setPrjUid($projectUid);
+ $messageApplication->setEvnUidThrow($eventUidThrow);
+ $messageApplication->setEvnUidCatch($eventUidCatch);
+ $messageApplication->setMsgappVariables(serialize($arrayMessageApplicationVariables));
+ $messageApplication->setMsgappCorrelation($messageApplicationCorrelation);
+ $messageApplication->setMsgappThrowDate("now");
+
+ if ($messageApplication->validate()) {
+ $cnn->begin();
+
+ $result = $messageApplication->save();
+
+ $cnn->commit();
+
+ //Return
+ return true;
+ } else {
+ $msg = "";
+
+ foreach ($messageApplication->getValidationFailures() as $validationFailure) {
+ $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
+ }
+
+ throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
+ }
+ } catch (\Exception $e) {
+ $cnn->rollback();
+
+ throw $e;
+ }
+ } catch (\Exception $e) {
+ throw $e;
+ }
+ }
+
+ /**
+ * Update Message-Application
+ *
+ * @param string $messageApplicationUid Unique id of Message-Application
+ * @param array $arrayData Data
+ *
+ * return bool Return true if been updated, false otherwise
+ */
+ public function update($messageApplicationUid, array $arrayData)
+ {
+ try {
+ //Verify data
+ if (!$this->exists($messageApplicationUid)) {
+ //Return
+ return false;
+ }
+
+ //Update
+ $cnn = \Propel::getConnection("workflow");
+
+ try {
+ $messageApplication = \MessageApplicationPeer::retrieveByPK($messageApplicationUid);
+
+ $messageApplication->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
+
+ $messageApplication->setMsgappCatchDate("now");
+
+ if ($messageApplication->validate()) {
+ $cnn->begin();
+
+ $result = $messageApplication->save();
+
+ $cnn->commit();
+
+ //Return
+ return true;
+ } else {
+ $msg = "";
+
+ foreach ($messageApplication->getValidationFailures() as $validationFailure) {
+ $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
+ }
+
+ throw new \Exception(\G::LoadTranslation("ID_REGISTRY_CANNOT_BE_UPDATED") . (($msg != "")? "\n" . $msg : ""));
+ }
+ } catch (\Exception $e) {
+ $cnn->rollback();
+
+ throw $e;
+ }
+ } catch (\Exception $e) {
+ throw $e;
+ }
+ }
+
+ /**
+ * Get criteria for Message-Application
+ *
+ * return object
+ */
+ public function getMessageApplicationCriteria()
+ {
+ try {
+ $criteria = new \Criteria("workflow");
+
+ $criteria->addSelectColumn(\MessageApplicationPeer::MSGAPP_UID);
+ $criteria->addSelectColumn(\MessageApplicationPeer::APP_UID);
+ $criteria->addSelectColumn(\MessageApplicationPeer::PRJ_UID);
+ $criteria->addSelectColumn(\MessageApplicationPeer::EVN_UID_THROW);
+ $criteria->addSelectColumn(\MessageApplicationPeer::EVN_UID_CATCH);
+ $criteria->addSelectColumn(\MessageApplicationPeer::MSGAPP_VARIABLES);
+ $criteria->addSelectColumn(\MessageApplicationPeer::MSGAPP_CORRELATION);
+ $criteria->addSelectColumn(\MessageApplicationPeer::MSGAPP_THROW_DATE);
+ $criteria->addSelectColumn(\MessageApplicationPeer::MSGAPP_CATCH_DATE);
+ $criteria->addSelectColumn(\MessageApplicationPeer::MSGAPP_STATUS);
+
+ return $criteria;
+ } catch (\Exception $e) {
+ throw $e;
+ }
+ }
+
+ /**
+ * Get all Message-Applications
+ *
+ * @param array $arrayFilterData Data of the filters
+ * @param string $sortField Field name to sort
+ * @param string $sortDir Direction of sorting (ASC, DESC)
+ * @param int $start Start
+ * @param int $limit Limit
+ *
+ * return array Return an array with all Message-Applications
+ */
+ public function getMessageApplications($arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
+ {
+ try {
+ $arrayMessageApplication = array();
+
+ //Verify data
+ $process = new \ProcessMaker\BusinessModel\Process();
+
+ $process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);
+
+ //Get data
+ if (!is_null($limit) && $limit . "" == "0") {
+ return $arrayMessageApplication;
+ }
+
+ //SQL
+ $criteria = $this->getMessageApplicationCriteria();
+
+ $criteria->addSelectColumn(\BpmnEventPeer::EVN_UID);
+ $criteria->addSelectColumn(\BpmnEventPeer::EVN_TYPE);
+ $criteria->addSelectColumn(\BpmnEventPeer::EVN_MARKER);
+ $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_USR_UID);
+ $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_VARIABLES);
+ $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_CORRELATION);
+ $criteria->addSelectColumn(\MessageEventTaskRelationPeer::TAS_UID);
+
+ $arrayEventType = array("START", "INTERMEDIATE");
+ $arrayEventMarker = array("MESSAGECATCH");
+
+ $criteria->addJoin(\MessageApplicationPeer::EVN_UID_CATCH, \BpmnEventPeer::EVN_UID, \Criteria::INNER_JOIN);
+ $criteria->add(\BpmnEventPeer::EVN_TYPE, $arrayEventType, \Criteria::IN);
+ $criteria->add(\BpmnEventPeer::EVN_MARKER, $arrayEventMarker, \Criteria::IN);
+
+ $criteria->addJoin(\MessageApplicationPeer::EVN_UID_CATCH, \MessageEventDefinitionPeer::EVN_UID, \Criteria::INNER_JOIN);
+
+ $criteria->addJoin(\MessageApplicationPeer::EVN_UID_CATCH, \MessageEventTaskRelationPeer::EVN_UID, \Criteria::INNER_JOIN);
+
+ if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["messageApplicationStatus"]) && trim($arrayFilterData["messageApplicationStatus"]) != "") {
+ $criteria->add(\MessageApplicationPeer::MSGAPP_STATUS, $arrayFilterData["messageApplicationStatus"], \Criteria::EQUAL);
+ }
+
+ //Number records total
+ $criteriaCount = clone $criteria;
+
+ $criteriaCount->clearSelectColumns();
+ $criteriaCount->addSelectColumn("COUNT(" . \MessageApplicationPeer::MSGAPP_UID . ") AS NUM_REC");
+
+ $rsCriteriaCount = \MessageApplicationPeer::doSelectRS($criteriaCount);
+ $rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
+
+ $rsCriteriaCount->next();
+ $row = $rsCriteriaCount->getRow();
+
+ $numRecTotal = $row["NUM_REC"];
+
+ //SQL
+ if (!is_null($sortField) && trim($sortField) != "") {
+ $sortField = strtoupper($sortField);
+
+ if (in_array($sortField, array("MSGAPP_THROW_DATE", "MSGAPP_CATCH_DATE", "MSGAPP_STATUS"))) {
+ $sortField = \MessageApplicationPeer::TABLE_NAME . "." . $sortField;
+ } else {
+ $sortField = \MessageApplicationPeer::MSGAPP_THROW_DATE;
+ }
+ } else {
+ $sortField = \MessageApplicationPeer::MSGAPP_THROW_DATE;
+ }
+
+ if (!is_null($sortDir) && trim($sortDir) != "" && strtoupper($sortDir) == "DESC") {
+ $criteria->addDescendingOrderByColumn($sortField);
+ } else {
+ $criteria->addAscendingOrderByColumn($sortField);
+ }
+
+ if (!is_null($start)) {
+ $criteria->setOffset((int)($start));
+ }
+
+ if (!is_null($limit)) {
+ $criteria->setLimit((int)($limit));
+ }
+
+ $rsCriteria = \MessageApplicationPeer::doSelectRS($criteria);
+ $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
+
+ while ($rsCriteria->next()) {
+ $row = $rsCriteria->getRow();
+
+ $row["MSGAPP_VARIABLES"] = unserialize($row["MSGAPP_VARIABLES"]);
+ $row["MSGED_VARIABLES"] = unserialize($row["MSGED_VARIABLES"]);
+
+ $arrayMessageApplication[] = $row;
+ }
+
+ //Return
+ return array(
+ "total" => $numRecTotal,
+ "start" => (int)((!is_null($start))? $start : 0),
+ "limit" => (int)((!is_null($limit))? $limit : 0),
+ "filter" => (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["messageApplicationStatus"]))? $arrayFilterData["messageApplicationStatus"] : "",
+ "data" => $arrayMessageApplication
+ );
+ } catch (\Exception $e) {
+ throw $e;
+ }
+ }
+}
+
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventDefinition.php b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventDefinition.php
index 8c8bb4ec3..3cffb6c0c 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventDefinition.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventDefinition.php
@@ -220,9 +220,7 @@ class MessageEventDefinition
}
if (isset($arrayData["MSGT_UID"]) && $arrayData["MSGT_UID"] . "" != "") {
- if (!$messageType->exists($arrayData["MSGT_UID"])) {
- throw new \Exception(\G::LoadTranslation("ID_MESSAGE_TYPE_NOT_EXIST", array($this->arrayFieldNameForException["messageTypeUid"], $arrayData["MSGT_UID"])));
- }
+ $messageType->throwExceptionIfNotExistsMessageType($arrayData["MSGT_UID"], $this->arrayFieldNameForException["messageTypeUid"]);
}
$flagCheckData = false;
@@ -335,7 +333,7 @@ class MessageEventDefinition
$bpmnEvent = \BpmnEventPeer::retrieveByPK($arrayData["EVN_UID"]);
//Event - START-MESSAGE-EVENT
- if (is_null($bpmnEvent) && $bpmnEvent->getEvnType() == "START" && $bpmnEvent->getEvnMarker() == "MESSAGECATCH") {
+ if (!is_null($bpmnEvent) && $bpmnEvent->getEvnType() == "START" && $bpmnEvent->getEvnMarker() == "MESSAGECATCH") {
//Message-Event-Task-Relation - Get Task
$messageEventTaskRelation = new \ProcessMaker\BusinessModel\MessageEventTaskRelation();
@@ -438,7 +436,7 @@ class MessageEventDefinition
$bpmnEvent = \BpmnEventPeer::retrieveByPK($arrayMessageEventDefinitionData["EVN_UID"]);
//Event - START-MESSAGE-EVENT
- if (is_null($bpmnEvent) && $bpmnEvent->getEvnType() == "START" && $bpmnEvent->getEvnMarker() == "MESSAGECATCH") {
+ if (!is_null($bpmnEvent) && $bpmnEvent->getEvnType() == "START" && $bpmnEvent->getEvnMarker() == "MESSAGECATCH") {
//Message-Event-Task-Relation - Get Task
$messageEventTaskRelation = new \ProcessMaker\BusinessModel\MessageEventTaskRelation();
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventRelation.php b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventRelation.php
index ac81b1fec..60fb8c132 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventRelation.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventRelation.php
@@ -322,7 +322,11 @@ class MessageEventRelation
$criteria = new \Criteria("workflow");
foreach ($arrayCondition as $key => $value) {
- $criteria->add($key, $value, \Criteria::EQUAL);
+ if (is_array($value)) {
+ $criteria->add($key, $value[0], $value[1]);
+ } else {
+ $criteria->add($key, $value, \Criteria::EQUAL);
+ }
}
$result = \MessageEventRelationPeer::doDelete($criteria);
@@ -404,5 +408,44 @@ class MessageEventRelation
throw $e;
}
}
+
+ /**
+ * Get data of a Message-Event-Relation
+ *
+ * @param array $arrayCondition Conditions
+ * @param bool $flagGetRecord Value that set the getting
+ *
+ * return array Return an array with data of a Message-Event-Relation, otherwise null
+ */
+ public function getMessageEventRelationWhere(array $arrayCondition, $flagGetRecord = false)
+ {
+ try {
+ //Get data
+ $criteria = $this->getMessageEventRelationCriteria();
+
+ foreach ($arrayCondition as $key => $value) {
+ if (is_array($value)) {
+ $criteria->add($key, $value[0], $value[1]);
+ } else {
+ $criteria->add($key, $value, \Criteria::EQUAL);
+ }
+ }
+
+ $rsCriteria = \MessageEventRelationPeer::doSelectRS($criteria);
+ $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
+
+ if ($rsCriteria->next()) {
+ $row = $rsCriteria->getRow();
+
+ //Return
+ return (!$flagGetRecord)? $this->getMessageEventRelationDataFromRecord($row) : $row;
+ } else {
+ //Return
+ return null;
+ }
+ } catch (\Exception $e) {
+ throw $e;
+ }
+ }
}
diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventTaskRelation.php b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventTaskRelation.php
index dda7620de..5fbb5c322 100644
--- a/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventTaskRelation.php
+++ b/workflow/engine/src/ProcessMaker/BusinessModel/MessageEventTaskRelation.php
@@ -231,7 +231,11 @@ class MessageEventTaskRelation
$criteria = new \Criteria("workflow");
foreach ($arrayCondition as $key => $value) {
- $criteria->add($key, $value, \Criteria::EQUAL);
+ if (is_array($value)) {
+ $criteria->add($key, $value[0], $value[1]);
+ } else {
+ $criteria->add($key, $value, \Criteria::EQUAL);
+ }
}
$result = \MessageEventTaskRelationPeer::doDelete($criteria);
@@ -320,7 +324,7 @@ class MessageEventTaskRelation
* @param array $arrayCondition Conditions
* @param bool $flagGetRecord Value that set the getting
*
- * return array Return an array with data of a Message-Event-Task-Relation
+ * return array Return an array with data of a Message-Event-Task-Relation, otherwise null
*/
public function getMessageEventTaskRelationWhere(array $arrayCondition, $flagGetRecord = false)
{
@@ -329,7 +333,11 @@ class MessageEventTaskRelation
$criteria = $this->getMessageEventTaskRelationCriteria();
foreach ($arrayCondition as $key => $value) {
- $criteria->add($key, $value, \Criteria::EQUAL);
+ if (is_array($value)) {
+ $criteria->add($key, $value[0], $value[1]);
+ } else {
+ $criteria->add($key, $value, \Criteria::EQUAL);
+ }
}
$rsCriteria = \MessageEventTaskRelationPeer::doSelectRS($criteria);
diff --git a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php
index 996af7a58..82dba105b 100755
--- a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php
+++ b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php
@@ -24,10 +24,10 @@ class BpmnWorkflow extends Project\Bpmn
private $arrayTaskAttribute = array(
"gateway-to-gateway" => array("type" => "GATEWAYTOGATEWAY", "prefix" => "gtg-"),
- "start-message-event" => array("type" => "START-MESSAGE-EVENT", "prefix" => "sme-"),
"end-message-event" => array("type" => "END-MESSAGE-EVENT", "prefix" => "eme-"),
- "intermediate-start-message-event" => array("type" => "INTERMEDIATE-START-MESSAGE-EVENT", "prefix" => "isme-"),
- "intermediate-end-message-event" => array("type" => "INTERMEDIATE-END-MESSAGE-EVENT", "prefix" => "ieme-")
+ "start-message-event" => array("type" => "START-MESSAGE-EVENT", "prefix" => "sme-"),
+ "intermediate-throw-message-event" => array("type" => "INTERMEDIATE-THROW-MESSAGE-EVENT", "prefix" => "itme-"),
+ "intermediate-catch-message-event" => array("type" => "INTERMEDIATE-CATCH-MESSAGE-EVENT", "prefix" => "icme-")
);
private $arrayMessageEventTaskRelation = array();
@@ -599,9 +599,9 @@ class BpmnWorkflow extends Project\Bpmn
));
if ($elementType == "bpmnEvent" &&
- in_array($key, array("start-message-event", "end-message-event", "intermediate-start-message-event"))
+ in_array($key, array("end-message-event", "start-message-event", "intermediate-catch-message-event"))
) {
- if ($key == "intermediate-start-message-event") {
+ if ($key == "intermediate-catch-message-event") {
//Task - User
//Assign to admin
$task = new \Tasks();
@@ -681,6 +681,7 @@ class BpmnWorkflow extends Project\Bpmn
//Flows
$arrayFlow = \BpmnFlow::findAllBy(array(
+ \BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $gatewayUid,
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnGateway"
));
@@ -770,21 +771,26 @@ class BpmnWorkflow extends Project\Bpmn
if (!is_null($arrayEventData) &&
in_array($arrayEventData["EVN_TYPE"], $arrayEventType) && in_array($arrayEventData["EVN_MARKER"], $arrayEventMarker)
) {
- //Event - INTERMEDIATE-START-MESSAGE-EVENT
+ //Event - INTERMEDIATE-CATCH-MESSAGE-EVENT
if ($arrayEventData["EVN_TYPE"] == "INTERMEDIATE" && $arrayEventData["EVN_MARKER"] == "MESSAGECATCH") {
$taskUid = $this->createTaskByElement(
$eventUid,
"bpmnEvent",
- "intermediate-start-message-event"
+ "intermediate-catch-message-event"
);
$result = $this->wp->addRoute($activityUid, $taskUid, $routeType, $routeCondition, $routeDefault);
$activityUid = $taskUid;
+
+ $routeType = "SEQUENTIAL";
+ $routeCondition = "";
+ $routeDefault = 0;
}
//Flows
$arrayFlow = \BpmnFlow::findAllBy(array(
+ \BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $eventUid,
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent"
));
@@ -795,7 +801,7 @@ class BpmnWorkflow extends Project\Bpmn
switch ($arrayFlowData["FLO_ELEMENT_DEST_TYPE"]) {
case "bpmnActivity":
//Event ----> Activity
- $result = $this->wp->addRoute($activityUid, $arrayFlowData["FLO_ELEMENT_DEST"], "SEQUENTIAL");
+ $result = $this->wp->addRoute($activityUid, $arrayFlowData["FLO_ELEMENT_DEST"], $routeType, $routeCondition, $routeDefault);
break;
case "bpmnGateway":
//Event ----> Gateway
@@ -814,7 +820,7 @@ class BpmnWorkflow extends Project\Bpmn
//$event->getEvnMarker(): EMPTY or MESSAGETHROW
switch ($event->getEvnMarker()) {
case "EMPTY":
- $result = $this->wp->addRoute($activityUid, -1, "SEQUENTIAL");
+ $result = $this->wp->addRoute($activityUid, -1, $routeType, $routeCondition, $routeDefault);
break;
case "MESSAGETHROW":
$taskUid = $this->createTaskByElement(
@@ -823,13 +829,13 @@ class BpmnWorkflow extends Project\Bpmn
"end-message-event"
);
- $result = $this->wp->addRoute($activityUid, $taskUid, "SEQUENTIAL");
+ $result = $this->wp->addRoute($activityUid, $taskUid, $routeType, $routeCondition, $routeDefault);
$result = $this->wp->addRoute($taskUid, -1, "SEQUENTIAL");
break;
}
break;
case "INTERMEDIATE":
- $this->mapBpmnEventToWorkflowRoutes($activityUid, $arrayFlowData["FLO_ELEMENT_DEST"]);
+ $this->mapBpmnEventToWorkflowRoutes($activityUid, $arrayFlowData["FLO_ELEMENT_DEST"], $routeType, $routeCondition, $routeDefault);
break;
}
}
@@ -865,6 +871,7 @@ class BpmnWorkflow extends Project\Bpmn
//Flows
$arrayFlow = \BpmnFlow::findAllBy(array(
+ \BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $activity["ACT_UID"],
\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnActivity"
));
@@ -926,9 +933,7 @@ class BpmnWorkflow extends Project\Bpmn
foreach ($this->getEvents() as $value) {
$event = $value;
- if (!isset($this->arrayMessageEventTaskRelation[$event["EVN_UID"]]) &&
- in_array($event["EVN_TYPE"], $arrayEventType) && in_array($event["EVN_MARKER"], $arrayEventMarker)
- ) {
+ if (in_array($event["EVN_TYPE"], $arrayEventType) && in_array($event["EVN_MARKER"], $arrayEventMarker)) {
switch ($event["EVN_TYPE"]) {
case "START":
$taskUid = $this->createTaskByElement(
@@ -1737,13 +1742,14 @@ class BpmnWorkflow extends Project\Bpmn
public function createMessageEventRelationByBpmnFlow(\BpmnFlow $bpmnFlow)
{
try {
+ $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();
+
$messageEventRelationUid = "";
if ($bpmnFlow->getFloType() == "MESSAGE" &&
- $bpmnFlow->getFloElementOriginType() == "bpmnEvent" && $bpmnFlow->getFloElementDestType() == "bpmnEvent"
+ $bpmnFlow->getFloElementOriginType() == "bpmnEvent" && $bpmnFlow->getFloElementDestType() == "bpmnEvent" &&
+ !$messageEventRelation->existsEventRelation($bpmnFlow->getPrjUid(), $bpmnFlow->getFloElementOrigin(), $bpmnFlow->getFloElementDest())
) {
- $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();
-
$arrayResult = $messageEventRelation->create(
$bpmnFlow->getPrjUid(),
array(
diff --git a/workflow/engine/src/ProcessMaker/Project/Bpmn.php b/workflow/engine/src/ProcessMaker/Project/Bpmn.php
index 5903db89e..dcaced7a0 100755
--- a/workflow/engine/src/ProcessMaker/Project/Bpmn.php
+++ b/workflow/engine/src/ProcessMaker/Project/Bpmn.php
@@ -1340,5 +1340,95 @@ class Bpmn extends Handler
throw $oException;
}
}
+
+ public function getElementsBetweenElementOriginAndElementDest(
+ $elementOriginUid,
+ $elementOriginType,
+ $elementDestUid,
+ $elementDestType,
+ $index
+ ) {
+ try {
+ if ($elementOriginType == $elementDestType && $elementOriginUid == $elementDestUid) {
+ $arrayEvent = array();
+ $arrayEvent[$index] = array($elementDestUid, $elementDestType);
+
+ //Return
+ return $arrayEvent;
+ } else {
+ //Flows
+ $arrayFlow = \BpmnFlow::findAllBy(array(
+ \BpmnFlowPeer::FLO_TYPE => array("MESSAGE", \Criteria::NOT_EQUAL),
+ \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $elementOriginUid,
+ \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => $elementOriginType
+ ));
+
+ foreach ($arrayFlow as $value) {
+ $arrayFlowData = $value->toArray();
+
+ $arrayEvent = $this->getElementsBetweenElementOriginAndElementDest(
+ $arrayFlowData["FLO_ELEMENT_DEST"],
+ $arrayFlowData["FLO_ELEMENT_DEST_TYPE"],
+ $elementDestUid,
+ $elementDestType,
+ $index + 1
+ );
+
+ if (count($arrayEvent) > 0) {
+ $arrayEvent[$index] = array($elementOriginUid, $elementOriginType);
+
+ //Return
+ return $arrayEvent;
+ }
+ }
+
+ //Return
+ return array();
+ }
+ } catch (\Exception $e) {
+ throw $e;
+ }
+ }
+
+ public function getMessageEventsOfThrowTypeBetweenElementOriginAndElementDest(
+ $elementOriginUid,
+ $elementOriginType,
+ $elementDestUid,
+ $elementDestType
+ ) {
+ try {
+ $arrayEventType = array("END", "INTERMEDIATE");
+ $arrayEventMarker = array("MESSAGETHROW");
+
+ $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) {
+ throw $e;
+ }
+ }
}
diff --git a/workflow/engine/templates/cases/cases_ScreenDerivation.html b/workflow/engine/templates/cases/cases_ScreenDerivation.html
index c266f84f3..6cb5122e2 100755
--- a/workflow/engine/templates/cases/cases_ScreenDerivation.html
+++ b/workflow/engine/templates/cases/cases_ScreenDerivation.html
@@ -61,10 +61,17 @@
{/if}
{if $PROCESS.ERROR eq '' }
-
- | {$NEXT_TASK_LABEL}: |
- {$data.NEXT_TASK.TAS_TITLE}{$data.NEXT_TASK.TAS_HIDDEN_FIELD} |
-
+ {if $data.NEXT_TASK.TAS_TYPE != "INTERMEDIATE-CATCH-MESSAGE-EVENT"}
+
+ | {$NEXT_TASK_LABEL}: |
+ {$data.NEXT_TASK.TAS_TITLE}{$data.NEXT_TASK.TAS_HIDDEN_FIELD} |
+
+ {else}
+
+ |
+ {$data.NEXT_TASK.TAS_TITLE}{$data.NEXT_TASK.TAS_HIDDEN_FIELD} |
+
+ {/if}
{/if}
{if not $data.NEXT_TASK.ROU_FINISH_FLAG }
{if $data.NEXT_TASK.TAS_NEXT eq 'STATIC_MI' || $data.NEXT_TASK.TAS_NEXT eq 'CANCEL_MI'}
@@ -79,10 +86,17 @@
{/if}
{if $data.NEXT_TASK.TAS_NEXT eq ''}
{if $data.NEXT_TASK.USR_UID neq ''}
-
- | {$EMPLOYEE}: |
- {$data.NEXT_TASK.USR_UID}{$data.NEXT_TASK.USR_HIDDEN_FIELD} |
-
+ {if $data.NEXT_TASK.TAS_TYPE != "INTERMEDIATE-CATCH-MESSAGE-EVENT"}
+
+ | {$EMPLOYEE}: |
+ {$data.NEXT_TASK.USR_UID}{$data.NEXT_TASK.USR_HIDDEN_FIELD} |
+
+ {else}
+
+ |
+ {$data.NEXT_TASK.USR_HIDDEN_FIELD} |
+
+ {/if}
{/if}
{/if}
{if $data.NEXT_TASK.TAS_TRANSFER_FLY eq 'true'}