Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
@@ -826,11 +826,17 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
/*
|
||||
* Diagram's Gateways Handling
|
||||
*/
|
||||
$arrayUidGatewayParallel = array();
|
||||
$flagGatewayParallel = false;
|
||||
|
||||
$whiteList = array();
|
||||
|
||||
foreach ($diagram["gateways"] as $i => $gatewayData) {
|
||||
$gatewayData = array_change_key_case($gatewayData, CASE_UPPER);
|
||||
unset($gatewayData["_EXTENDED"]);
|
||||
|
||||
$flagAddOrUpdate = false;
|
||||
|
||||
$gateway = $bwp->getGateway($gatewayData["GAT_UID"]);
|
||||
|
||||
if ($forceInsert || is_null($gateway)) {
|
||||
@@ -849,12 +855,25 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
|
||||
$bwp->addGateway($gatewayData);
|
||||
|
||||
$flagAddOrUpdate = true;
|
||||
} elseif (! $bwp->isEquals($gateway, $gatewayData)) {
|
||||
$bwp->updateGateway($gatewayData["GAT_UID"], $gatewayData);
|
||||
|
||||
$flagAddOrUpdate = true;
|
||||
} else {
|
||||
Util\Logger::log("Update Gateway ({$gatewayData["GAT_UID"]}) Skipped - No changes required");
|
||||
}
|
||||
|
||||
if ($flagAddOrUpdate) {
|
||||
$arrayGatewayData = $bwp->getGateway($gatewayData["GAT_UID"]);
|
||||
|
||||
if ($arrayGatewayData["GAT_TYPE"] == "PARALLEL") {
|
||||
$arrayUidGatewayParallel[] = $gatewayData["GAT_UID"];
|
||||
$flagGatewayParallel = true;
|
||||
}
|
||||
}
|
||||
|
||||
$diagram["gateways"][$i] = $gatewayData;
|
||||
$whiteList[] = $gatewayData["GAT_UID"];
|
||||
}
|
||||
@@ -932,7 +951,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
if ($forceInsert || is_null($dataObject)) {
|
||||
if ($generateUid) {
|
||||
//Event
|
||||
//Data
|
||||
unset($dataObjectData["BOU_UID"]);
|
||||
|
||||
$uidOld = $dataObjectData["DAT_UID"];
|
||||
@@ -979,7 +998,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
if ($forceInsert || is_null($dataObject)) {
|
||||
if ($generateUid) {
|
||||
//Event
|
||||
//Participant
|
||||
unset($participantData["BOU_UID"]);
|
||||
|
||||
$uidOld = $participantData["PAR_UID"];
|
||||
@@ -1013,7 +1032,6 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Diagram's Flows Handling
|
||||
*/
|
||||
@@ -1050,6 +1068,11 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
}
|
||||
}
|
||||
|
||||
//Update condition
|
||||
if ($flagGatewayParallel && $flowData["FLO_ELEMENT_ORIGIN_TYPE"] == "bpmnGateway" && in_array($flowData["FLO_ELEMENT_ORIGIN"], $arrayUidGatewayParallel)) {
|
||||
$flowData["FLO_CONDITION"] = "";
|
||||
}
|
||||
|
||||
$diagram["flows"][$i] = $flowData;
|
||||
$whiteList[] = $flowData["FLO_UID"];
|
||||
}
|
||||
|
||||
@@ -58,13 +58,12 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$bpData["PRJ_AUTHOR"] = $data["USR_UID"];
|
||||
}
|
||||
|
||||
$bp = new Project\Bpmn();
|
||||
$bp->create($bpData);
|
||||
$this->bp = new Project\Bpmn();
|
||||
$this->bp->create($bpData);
|
||||
|
||||
// At this time we will add a default diagram and process
|
||||
$bp->addDiagram();
|
||||
$bp->addProcess();
|
||||
|
||||
$this->bp->addDiagram();
|
||||
$this->bp->addProcess();
|
||||
} catch (\Exception $e) {
|
||||
$prjUid = $this->getUid();
|
||||
$this->remove();
|
||||
@@ -87,11 +86,719 @@ class WorkflowBpmn extends Project\Workflow
|
||||
$this->bp->remove();
|
||||
}
|
||||
|
||||
public function addTask($taskData)
|
||||
{
|
||||
$tasUid = parent::addTask($taskData);
|
||||
public function startTaskEndProcessToBpmnEvent(
|
||||
$objectBpmnType,
|
||||
$objectUid,
|
||||
$objectBouX,
|
||||
$objectBouY,
|
||||
$objectBouWidth,
|
||||
$objectBouHeight,
|
||||
$eventName,
|
||||
$eventType,
|
||||
$condition = ""
|
||||
) {
|
||||
try {
|
||||
$eventBouWidth = 35;
|
||||
$eventBouHeight = $eventBouWidth;
|
||||
|
||||
// logica para bpmn
|
||||
$this->bp->addActivity(array('ACT_UID'=>$tasUid));
|
||||
$eventBouWidth2 = (int)($eventBouWidth / 2);
|
||||
$eventBouHeight2 = (int)($eventBouHeight / 2);
|
||||
|
||||
$eventBouHeight12 = (int)($eventBouWidth / 12);
|
||||
|
||||
//
|
||||
$objectBouWidth2 = (int)($objectBouWidth / 2);
|
||||
$objectBouWidth4 = (int)($objectBouWidth / 4);
|
||||
|
||||
//Event
|
||||
if ($objectBpmnType == "bpmnGateway" && $eventType == "END") {
|
||||
//Gateway
|
||||
$eventBouX = $objectBouX + $objectBouWidth + $objectBouWidth4;
|
||||
$eventBouY = $objectBouY + (int)($objectBouHeight / 2) - $eventBouHeight2;
|
||||
} else {
|
||||
//Activity
|
||||
$eventBouX = $objectBouX + $objectBouWidth2 - $eventBouWidth2;
|
||||
$eventBouY = ($eventType == "START")? $objectBouY - $eventBouHeight - $eventBouHeight2 : $objectBouY + $objectBouHeight + $eventBouHeight2 + $eventBouHeight12;
|
||||
}
|
||||
|
||||
$arrayData = array(
|
||||
"EVN_NAME" => $eventName,
|
||||
"EVN_TYPE" => $eventType,
|
||||
"EVN_MARKER" => "EMPTY",
|
||||
"BOU_X" => $eventBouX,
|
||||
"BOU_Y" => $eventBouY,
|
||||
"BOU_WIDTH" => $eventBouWidth,
|
||||
"BOU_HEIGHT" => $eventBouHeight
|
||||
);
|
||||
|
||||
$eventUid = $this->bp->addEvent($arrayData);
|
||||
|
||||
//Flow
|
||||
if ($objectBpmnType == "bpmnGateway" && $eventType == "END") {
|
||||
//Gateway
|
||||
$flowX1 = $objectBouX + $objectBouWidth;
|
||||
$flowY1 = $objectBouY + (int)($objectBouHeight / 2);
|
||||
$flowX2 = $eventBouX;
|
||||
$flowY2 = $eventBouY + $eventBouHeight2;
|
||||
} else {
|
||||
//Activity
|
||||
$flowX1 = $objectBouX + $objectBouWidth2;
|
||||
$flowY1 = ($eventType == "START")? $objectBouY - $eventBouHeight + $eventBouHeight2 : $objectBouY + $objectBouHeight;
|
||||
$flowX2 = $flowX1;
|
||||
$flowY2 = ($eventType == "START")? $objectBouY : $objectBouY + $objectBouHeight + $eventBouHeight2 + $eventBouHeight12;
|
||||
}
|
||||
|
||||
$arrayData = array(
|
||||
"FLO_TYPE" => "SEQUENCE",
|
||||
"FLO_ELEMENT_ORIGIN" => ($eventType == "START")? $eventUid : $objectUid,
|
||||
"FLO_ELEMENT_ORIGIN_TYPE" => ($eventType == "START")? "bpmnEvent" : $objectBpmnType,
|
||||
"FLO_ELEMENT_DEST" => ($eventType == "START")? $objectUid : $eventUid,
|
||||
"FLO_ELEMENT_DEST_TYPE" => ($eventType == "START")? $objectBpmnType : "bpmnEvent",
|
||||
"FLO_IS_INMEDIATE" => 1,
|
||||
"FLO_CONDITION" => $condition,
|
||||
"FLO_X1" => $flowX1,
|
||||
"FLO_Y1" => $flowY1,
|
||||
"FLO_X2" => $flowX2,
|
||||
"FLO_Y2" => $flowY2,
|
||||
"FLO_STATE" => json_encode(
|
||||
array(
|
||||
array("x" => $flowX1, "y" => $flowY1),
|
||||
array("x" => $flowX1, "y" => $flowY2 - 5),
|
||||
array("x" => $flowX2, "y" => $flowY2 - 5),
|
||||
array("x" => $flowX2, "y" => $flowY2)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$flowUid = $this->bp->addFlow($arrayData);
|
||||
|
||||
//Return
|
||||
return $eventUid;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addTask(array $arrayTaskData)
|
||||
{
|
||||
try {
|
||||
//Task
|
||||
$taskUid = parent::addTask($arrayTaskData);
|
||||
|
||||
//BPMN
|
||||
//Activity
|
||||
$arrayActivityType = array(
|
||||
"NORMAL" => "TASK",
|
||||
"ADHOC" => "TASK",
|
||||
"SUBPROCESS" => "SUB_PROCESS"
|
||||
);
|
||||
|
||||
$activityBouX = (int)($arrayTaskData["TAS_POSX"]);
|
||||
$activityBouY = (int)($arrayTaskData["TAS_POSY"]);
|
||||
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$activityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
|
||||
|
||||
$arrayData = array(
|
||||
"ACT_UID" => $taskUid,
|
||||
"ACT_NAME" => $arrayTaskData["TAS_TITLE"],
|
||||
"ACT_TYPE" => $arrayActivityType[$arrayTaskData["TAS_TYPE"]],
|
||||
"BOU_X" => $activityBouX,
|
||||
"BOU_Y" => $activityBouY,
|
||||
"BOU_WIDTH" => $activityBouWidth,
|
||||
"BOU_HEIGHT" => $activityBouHeight
|
||||
);
|
||||
|
||||
$activityUid = $this->bp->addActivity($arrayData);
|
||||
|
||||
if ($arrayTaskData["TAS_START"] == "TRUE") {
|
||||
$eventUid = $this->startTaskEndProcessToBpmnEvent(
|
||||
"bpmnActivity",
|
||||
$activityUid,
|
||||
$activityBouX,
|
||||
$activityBouY,
|
||||
$activityBouWidth,
|
||||
$activityBouHeight,
|
||||
"",
|
||||
"START"
|
||||
);
|
||||
}
|
||||
|
||||
//Return
|
||||
return $taskUid;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function routeToBpmnGateway(
|
||||
$objectBpmnType,
|
||||
$objectUid,
|
||||
$objectBouX,
|
||||
$objectBouY,
|
||||
$objectBouWidth,
|
||||
$objectBouHeight,
|
||||
$gatewayName,
|
||||
$gatewayType,
|
||||
$gatewayDirection
|
||||
) {
|
||||
try {
|
||||
$gatewayBouWidth = 45;
|
||||
$gatewayBouHeight = $gatewayBouWidth;
|
||||
|
||||
$gatewayBouWidth2 = (int)($gatewayBouWidth / 2);
|
||||
$gatewayBouHeight2 = (int)($gatewayBouHeight / 2);
|
||||
|
||||
//
|
||||
$objectBouWidth2 = (int)($objectBouWidth / 2);
|
||||
$objectBouHeight2 = (int)($objectBouHeight / 2);
|
||||
|
||||
//Gateway
|
||||
$gatewayBouX = $objectBouX + $objectBouWidth2 - $gatewayBouWidth2;
|
||||
$gatewayBouY = ($gatewayDirection == "DIVERGING")? $objectBouY + $objectBouHeight + $gatewayBouHeight2 : $objectBouY - $gatewayBouHeight - $gatewayBouHeight2;
|
||||
|
||||
$arrayData = array(
|
||||
"GAT_NAME" => $gatewayName,
|
||||
"GAT_TYPE" => $gatewayType,
|
||||
"GAT_DIRECTION" => $gatewayDirection,
|
||||
"GAT_DEFAULT_FLOW" => "0",
|
||||
"BOU_X" => $gatewayBouX,
|
||||
"BOU_Y" => $gatewayBouY,
|
||||
"BOU_WIDTH" => $gatewayBouWidth,
|
||||
"BOU_HEIGHT" => $gatewayBouHeight
|
||||
);
|
||||
|
||||
$gatewayUid = $this->bp->addGateway($arrayData);
|
||||
|
||||
//Flow
|
||||
if ($gatewayDirection == "DIVERGING") {
|
||||
$flowX1 = $objectBouX + $objectBouWidth2;
|
||||
$flowY1 = $objectBouY + $objectBouHeight;
|
||||
$flowX2 = $flowX1;
|
||||
$flowY2 = $gatewayBouY;
|
||||
} else {
|
||||
$flowX1 = $objectBouX + $objectBouWidth2;
|
||||
$flowY1 = $gatewayBouY + $gatewayBouHeight;
|
||||
$flowX2 = $flowX1;
|
||||
$flowY2 = $objectBouY;
|
||||
}
|
||||
|
||||
$arrayData = array(
|
||||
"FLO_TYPE" => "SEQUENCE",
|
||||
"FLO_ELEMENT_ORIGIN" => ($gatewayDirection == "DIVERGING")? $objectUid : $gatewayUid,
|
||||
"FLO_ELEMENT_ORIGIN_TYPE" => ($gatewayDirection == "DIVERGING")? $objectBpmnType : "bpmnGateway",
|
||||
"FLO_ELEMENT_DEST" => ($gatewayDirection == "DIVERGING")? $gatewayUid : $objectUid,
|
||||
"FLO_ELEMENT_DEST_TYPE" => ($gatewayDirection == "DIVERGING")? "bpmnGateway" : $objectBpmnType,
|
||||
"FLO_IS_INMEDIATE" => 1,
|
||||
"FLO_CONDITION" => "",
|
||||
"FLO_X1" => $flowX1,
|
||||
"FLO_Y1" => $flowY1,
|
||||
"FLO_X2" => $flowX2,
|
||||
"FLO_Y2" => $flowY2,
|
||||
"FLO_STATE" => json_encode(
|
||||
array(
|
||||
array("x" => $flowX1, "y" => $flowY1),
|
||||
array("x" => $flowX1, "y" => $flowY2 - 5),
|
||||
array("x" => $flowX2, "y" => $flowY2 - 5),
|
||||
array("x" => $flowX2, "y" => $flowY2)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$flowUid = $this->bp->addFlow($arrayData);
|
||||
|
||||
//Return
|
||||
return $gatewayUid;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function routeToBpmnFlow(
|
||||
$objectOriginBpmnType,
|
||||
$objectOriginUid,
|
||||
$objectOriginBouX,
|
||||
$objectOriginBouY,
|
||||
$objectOriginBouWidth,
|
||||
$objectOriginBouHeight,
|
||||
$objectDestBpmnType,
|
||||
$objectDestUid,
|
||||
$objectDestBouX,
|
||||
$objectDestBouY,
|
||||
$objectDestBouWidth,
|
||||
$objectDestBouHeight,
|
||||
$condition = ""
|
||||
) {
|
||||
try {
|
||||
$objectOriginBouWidth2 = (int)($objectOriginBouWidth / 2);
|
||||
$objectDestBouWidth2 = (int)($objectDestBouWidth / 2);
|
||||
|
||||
$flowX1 = $objectOriginBouX + $objectOriginBouWidth2;
|
||||
$flowY1 = $objectOriginBouY + $objectOriginBouHeight;
|
||||
$flowX2 = $objectDestBouX + $objectDestBouWidth2;
|
||||
$flowY2 = $objectDestBouY;
|
||||
|
||||
//Flow
|
||||
$arrayData = array(
|
||||
"FLO_TYPE" => "SEQUENCE",
|
||||
"FLO_ELEMENT_ORIGIN" => $objectOriginUid,
|
||||
"FLO_ELEMENT_ORIGIN_TYPE" => $objectOriginBpmnType,
|
||||
"FLO_ELEMENT_DEST" => $objectDestUid,
|
||||
"FLO_ELEMENT_DEST_TYPE" => $objectDestBpmnType,
|
||||
"FLO_IS_INMEDIATE" => 1,
|
||||
"FLO_CONDITION" => $condition,
|
||||
"FLO_X1" => $flowX1,
|
||||
"FLO_Y1" => $flowY1,
|
||||
"FLO_X2" => $flowX2,
|
||||
"FLO_Y2" => $flowY2,
|
||||
"FLO_STATE" => json_encode(array())
|
||||
);
|
||||
|
||||
$flowUid = $this->bp->addFlow($arrayData);
|
||||
|
||||
//Return
|
||||
return $flowUid;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function addRouteSecJoin($taskUid, $nextTaskUid)
|
||||
{
|
||||
try {
|
||||
//Route
|
||||
$result = parent::addRoute($taskUid, $nextTaskUid, "SEC-JOIN");
|
||||
|
||||
//BPMN
|
||||
$arrayTaskData = $this->getTask($taskUid);
|
||||
|
||||
$activityUid = $arrayTaskData["TAS_UID"];
|
||||
$activityBouX = (int)($arrayTaskData["TAS_POSX"]);
|
||||
$activityBouY = (int)($arrayTaskData["TAS_POSY"]);
|
||||
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$activityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
|
||||
|
||||
$arrayTaskData = $this->getTask($nextTaskUid);
|
||||
|
||||
$nextActivityUid = $arrayTaskData["TAS_UID"];
|
||||
$nextActivityBouX = (int)($arrayTaskData["TAS_POSX"]);
|
||||
$nextActivityBouY = (int)($arrayTaskData["TAS_POSY"]);
|
||||
$nextActivityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$nextActivityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
|
||||
|
||||
$result = $this->bp->getGatewayByDirectionActivityAndFlow("CONVERGING", $nextActivityUid);
|
||||
|
||||
if (!is_array($result)) {
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN . " AS GAT_UID");
|
||||
|
||||
$criteria->add(\BpmnFlowPeer::PRJ_UID, $this->bp->getUid(), \Criteria::EQUAL);
|
||||
$criteria->add(\BpmnFlowPeer::FLO_TYPE, "SEQUENCE", \Criteria::EQUAL);
|
||||
$criteria->add(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE, "bpmnGateway", \Criteria::EQUAL);
|
||||
$criteria->add(\BpmnFlowPeer::FLO_ELEMENT_DEST, $activityUid, \Criteria::EQUAL);
|
||||
$criteria->add(\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE, "bpmnActivity", \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \BpmnFlowPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$gatewayParentUid = "";
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$gatewayParentUid = $row["GAT_UID"];
|
||||
} else {
|
||||
throw new \Exception(\G::LoadTranslation("ID_ROUTE_PARENT_DOES_NOT_EXIST_FOR_ROUTE_SECJOIN"));
|
||||
}
|
||||
|
||||
$arrayGatewayData = $this->bp->getGateway2($gatewayParentUid);
|
||||
|
||||
$gatewayParentType = $arrayGatewayData["GAT_TYPE"];
|
||||
|
||||
$gatewayUid = $this->routeToBpmnGateway(
|
||||
"bpmnActivity",
|
||||
$nextActivityUid,
|
||||
$nextActivityBouX,
|
||||
$nextActivityBouY,
|
||||
$nextActivityBouWidth,
|
||||
$nextActivityBouHeight,
|
||||
"",
|
||||
$gatewayParentType,
|
||||
"CONVERGING"
|
||||
);
|
||||
|
||||
$arrayGatewayData = $this->bp->getGateway2($gatewayUid);
|
||||
} else {
|
||||
$arrayGatewayData = $result;
|
||||
}
|
||||
|
||||
$gatewayUid = $arrayGatewayData["GAT_UID"];
|
||||
$gatewayType = $arrayGatewayData["GAT_TYPE"];
|
||||
$gatewayBouX = $arrayGatewayData["BOU_X"];
|
||||
$gatewayBouY = $arrayGatewayData["BOU_Y"];
|
||||
$gatewayBouWidth = $arrayGatewayData["BOU_WIDTH"];
|
||||
$gatewayBouHeight = $arrayGatewayData["BOU_HEIGHT"];
|
||||
|
||||
$flowUid = $this->routeToBpmnFlow(
|
||||
"bpmnActivity",
|
||||
$activityUid,
|
||||
$activityBouX,
|
||||
$activityBouY,
|
||||
$activityBouWidth,
|
||||
$activityBouHeight,
|
||||
"bpmnGateway",
|
||||
$gatewayUid,
|
||||
$gatewayBouX,
|
||||
$gatewayBouY,
|
||||
$gatewayBouWidth,
|
||||
$gatewayBouHeight
|
||||
);
|
||||
|
||||
//Return
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
$this->removeRouteFromTo($taskUid, $nextTaskUid);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function addRoute($taskUid, $nextTaskUid, $type, $condition = "")
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
if ($type == "SEC-JOIN") {
|
||||
throw new \Exception(\G::LoadTranslation("ID_ROUTE_IS_SECJOIN"));
|
||||
}
|
||||
|
||||
//Route
|
||||
$result = parent::addRoute($taskUid, $nextTaskUid, $type, $condition);
|
||||
|
||||
//BPMN
|
||||
$arrayBpmnGatewayType = array(
|
||||
"EVALUATE" => "EXCLUSIVE",
|
||||
"SELECT" => "COMPLEX",
|
||||
"PARALLEL" => "PARALLEL",
|
||||
"PARALLEL-BY-EVALUATION" => "INCLUSIVE"
|
||||
);
|
||||
|
||||
$arrayTaskData = $this->getTask($taskUid);
|
||||
|
||||
$activityUid = $arrayTaskData["TAS_UID"];
|
||||
$activityBouX = (int)($arrayTaskData["TAS_POSX"]);
|
||||
$activityBouY = (int)($arrayTaskData["TAS_POSY"]);
|
||||
$activityBouWidth = (int)($arrayTaskData["TAS_WIDTH"]);
|
||||
$activityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);
|
||||
|
||||
switch ($type) {
|
||||
case "EVALUATE":
|
||||
case "SELECT":
|
||||
case "PARALLEL":
|
||||
case "PARALLEL-BY-EVALUATION":
|
||||
$result = $this->bp->getGatewayByDirectionActivityAndFlow("DIVERGING", $activityUid);
|
||||
|
||||
if (!is_array($result)) {
|
||||
$gatewayUid = $this->routeToBpmnGateway(
|
||||
"bpmnActivity",
|
||||
$activityUid,
|
||||
$activityBouX,
|
||||
$activityBouY,
|
||||
$activityBouWidth,
|
||||
$activityBouHeight,
|
||||
"",
|
||||
$arrayBpmnGatewayType[$type],
|
||||
"DIVERGING"
|
||||
);
|
||||
|
||||
$arrayGatewayData = $this->bp->getGateway2($gatewayUid);
|
||||
} else {
|
||||
$arrayGatewayData = $result;
|
||||
}
|
||||
|
||||
$gatewayUid = $arrayGatewayData["GAT_UID"];
|
||||
$gatewayType = $arrayGatewayData["GAT_TYPE"];
|
||||
$gatewayBouX = $arrayGatewayData["BOU_X"];
|
||||
$gatewayBouY = $arrayGatewayData["BOU_Y"];
|
||||
$gatewayBouWidth = $arrayGatewayData["BOU_WIDTH"];
|
||||
$gatewayBouHeight = $arrayGatewayData["BOU_HEIGHT"];
|
||||
|
||||
if ($nextTaskUid != "-1") {
|
||||
$arrayTaskData = $this->getTask($nextTaskUid);
|
||||
|
||||
$flowUid = $this->routeToBpmnFlow(
|
||||
"bpmnGateway",
|
||||
$gatewayUid,
|
||||
$gatewayBouX,
|
||||
$gatewayBouY,
|
||||
$gatewayBouWidth,
|
||||
$gatewayBouHeight,
|
||||
"bpmnActivity",
|
||||
$arrayTaskData["TAS_UID"],
|
||||
(int)($arrayTaskData["TAS_POSX"]),
|
||||
(int)($arrayTaskData["TAS_POSY"]),
|
||||
(int)($arrayTaskData["TAS_WIDTH"]),
|
||||
(int)($arrayTaskData["TAS_HEIGHT"]),
|
||||
$condition
|
||||
);
|
||||
} else {
|
||||
$eventUid = $this->startTaskEndProcessToBpmnEvent(
|
||||
"bpmnGateway",
|
||||
$gatewayUid,
|
||||
$gatewayBouX,
|
||||
$gatewayBouY,
|
||||
$gatewayBouWidth,
|
||||
$gatewayBouHeight,
|
||||
"",
|
||||
"END",
|
||||
$condition
|
||||
);
|
||||
}
|
||||
break;
|
||||
case "SEQUENTIAL":
|
||||
if ($nextTaskUid != "-1") {
|
||||
$arrayTaskData = $this->getTask($nextTaskUid);
|
||||
|
||||
$flowUid = $this->routeToBpmnFlow(
|
||||
"bpmnActivity",
|
||||
$activityUid,
|
||||
$activityBouX,
|
||||
$activityBouY,
|
||||
$activityBouWidth,
|
||||
$activityBouHeight,
|
||||
"bpmnActivity",
|
||||
$arrayTaskData["TAS_UID"],
|
||||
(int)($arrayTaskData["TAS_POSX"]),
|
||||
(int)($arrayTaskData["TAS_POSY"]),
|
||||
(int)($arrayTaskData["TAS_WIDTH"]),
|
||||
(int)($arrayTaskData["TAS_HEIGHT"])
|
||||
);
|
||||
} else {
|
||||
$eventUid = $this->startTaskEndProcessToBpmnEvent(
|
||||
"bpmnActivity",
|
||||
$activityUid,
|
||||
$activityBouX,
|
||||
$activityBouY,
|
||||
$activityBouWidth,
|
||||
$activityBouHeight,
|
||||
"",
|
||||
"END"
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//Return
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function addLine($position, $direction = "HORIZONTAL")
|
||||
{
|
||||
try {
|
||||
//Line
|
||||
$swiUid = parent::addLine($position, $direction);
|
||||
|
||||
//BPMN
|
||||
//Artifact
|
||||
$arrayData = array(
|
||||
"ART_UID" => $swiUid,
|
||||
"ART_TYPE" => ($direction == "HORIZONTAL")? "HORIZONTAL_LINE" : "VERTICAL_LINE",
|
||||
"ART_NAME" => "",
|
||||
"BOU_X" => ($direction == "HORIZONTAL")? -6666 : $position,
|
||||
"BOU_Y" => ($direction == "HORIZONTAL")? $position : -6666,
|
||||
"BOU_WIDTH" => 0,
|
||||
"BOU_HEIGHT" => 0
|
||||
);
|
||||
|
||||
$artifactUid = $this->bp->addArtifact($arrayData);
|
||||
|
||||
//Return
|
||||
return $swiUid;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function addText($text, $x, $y)
|
||||
{
|
||||
try {
|
||||
//Line
|
||||
$swiUid = parent::addText($text, $x, $y);
|
||||
|
||||
//BPMN
|
||||
//Artifact
|
||||
$arrayData = array(
|
||||
"ART_UID" => $swiUid,
|
||||
"ART_TYPE" => "TEXT_ANNOTATION",
|
||||
"ART_NAME" => $text,
|
||||
"BOU_X" => $x,
|
||||
"BOU_Y" => $y,
|
||||
"BOU_WIDTH" => 100,
|
||||
"BOU_HEIGHT" => 30
|
||||
);
|
||||
|
||||
$artifactUid = $this->bp->addArtifact($arrayData);
|
||||
|
||||
//Return
|
||||
return $swiUid;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function generateBpmn($processUid, $processUidFieldNameForException, $userUid = "")
|
||||
{
|
||||
$bpmnProjectUid = "";
|
||||
|
||||
try {
|
||||
//Verify data
|
||||
$obj = \ProcessPeer::retrieveByPK($processUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_PROCESS_DOES_NOT_EXIST", array($processUidFieldNameForException, $processUid)));
|
||||
}
|
||||
|
||||
//Verify data
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\BpmnProjectPeer::PRJ_UID);
|
||||
$criteria->add(\BpmnProjectPeer::PRJ_UID, $processUid, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \BpmnProjectPeer::doSelectRS($criteria);
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_PROJECT_IS_BPMN", array($processUidFieldNameForException, $processUid)));
|
||||
}
|
||||
|
||||
//Set data
|
||||
$processUidBk = $processUid;
|
||||
|
||||
list($arrayWorkflowData, $arrayWorkflowFile) = $this->getData($processUid); //Get workflow data
|
||||
|
||||
$arrayWorkflowData["process"] = $arrayWorkflowData["process"][0];
|
||||
|
||||
$arrayWorkflowData["groupwfs"] = array();
|
||||
|
||||
//Create WorkflowBpmn
|
||||
$arrayUid = array();
|
||||
$arrayUid2 = array();
|
||||
|
||||
//Process
|
||||
$arrayProcessData = $arrayWorkflowData["process"];
|
||||
|
||||
unset(
|
||||
$arrayProcessData["PRO_UID"],
|
||||
$arrayProcessData["PRO_UPDATE_DATE"]
|
||||
);
|
||||
|
||||
$arrayProcessData["PRO_PARENT"] = $processUidBk;
|
||||
$arrayProcessData["PRO_TITLE"] = $arrayProcessData["PRO_TITLE"] . " - New version - " . date("M d, H:i:s");
|
||||
$arrayProcessData["PRO_CREATE_USER"] = ($userUid != "")? $userUid : "00000000000000000000000000000001";
|
||||
|
||||
$this->create($arrayProcessData);
|
||||
|
||||
$processUid = $this->getUid();
|
||||
|
||||
$bpmnProjectUid = $processUid;
|
||||
|
||||
//Task
|
||||
foreach ($arrayWorkflowData["tasks"] as $value) {
|
||||
$arrayTaskData = $value;
|
||||
|
||||
$taskUidOld = $arrayTaskData["TAS_UID"];
|
||||
|
||||
//Add
|
||||
unset($arrayTaskData["TAS_UID"]);
|
||||
|
||||
$taskUid = $this->addTask($arrayTaskData);
|
||||
|
||||
//Add new UID
|
||||
$arrayUid["task"][$taskUidOld] = $taskUid;
|
||||
|
||||
$arrayUid2[] = array(
|
||||
"old_uid" => $taskUidOld,
|
||||
"new_uid" => $taskUid
|
||||
);
|
||||
}
|
||||
|
||||
//$arrayWorkflowData["tasks"] = array();
|
||||
|
||||
//Route
|
||||
$arrayRouteSecJoin = array();
|
||||
|
||||
foreach ($arrayWorkflowData["routes"] as $value) {
|
||||
$arrayRouteData = $value;
|
||||
|
||||
$arrayRouteData["TAS_UID"] = $arrayUid["task"][$arrayRouteData["TAS_UID"]];
|
||||
$arrayRouteData["ROU_NEXT_TASK"] = ($arrayRouteData["ROU_NEXT_TASK"] != "-1")? $arrayUid["task"][$arrayRouteData["ROU_NEXT_TASK"]] : $arrayRouteData["ROU_NEXT_TASK"];
|
||||
|
||||
if ($arrayRouteData["ROU_TYPE"] != "SEC-JOIN") {
|
||||
//Add
|
||||
$result = $this->addRoute($arrayRouteData["TAS_UID"], $arrayRouteData["ROU_NEXT_TASK"], $arrayRouteData["ROU_TYPE"], $arrayRouteData["ROU_CONDITION"]);
|
||||
} else {
|
||||
$arrayRouteSecJoin[] = $arrayRouteData;
|
||||
}
|
||||
}
|
||||
|
||||
$arrayWorkflowData["routes"] = array();
|
||||
|
||||
//Route SEC-JOIN
|
||||
foreach ($arrayRouteSecJoin as $value) {
|
||||
$arrayRouteData = $value;
|
||||
|
||||
$result = $this->addRouteSecJoin($arrayRouteData["TAS_UID"], $arrayRouteData["ROU_NEXT_TASK"]);
|
||||
}
|
||||
|
||||
//Lane
|
||||
foreach ($arrayWorkflowData["lanes"] as $value) {
|
||||
$arrayLaneData = $value;
|
||||
|
||||
$swiX = (int)($arrayLaneData["SWI_X"]);
|
||||
$swiY = (int)($arrayLaneData["SWI_Y"]);
|
||||
|
||||
switch ($arrayLaneData["SWI_TYPE"]) {
|
||||
case "TEXT":
|
||||
$swiUid = $this->addText($arrayLaneData["SWI_TEXT"], $swiX, $swiY);
|
||||
break;
|
||||
case "LINE":
|
||||
$direction = (($swiX == 0)? "HORIZONTAL" : "VERTICAL");
|
||||
|
||||
$swiUid = $this->addLine(($direction == "HORIZONTAL")? $swiY : $swiX, $direction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$arrayWorkflowData["lanes"] = array();
|
||||
|
||||
//Data
|
||||
$arrayUid2 = array_merge(
|
||||
array(
|
||||
array(
|
||||
"old_uid" => $processUidBk,
|
||||
"new_uid" => $processUid
|
||||
)
|
||||
),
|
||||
$arrayUid2
|
||||
);
|
||||
|
||||
list($arrayWorkflowData, $arrayWorkflowFile) = $this->updateDataUidByArrayUid($arrayWorkflowData, $arrayWorkflowFile, $arrayUid2);
|
||||
|
||||
$arrayWorkflowData["tasks"] = array();
|
||||
|
||||
$this->createDataByArrayData($arrayWorkflowData);
|
||||
$this->createDataFileByArrayFile($arrayWorkflowFile);
|
||||
|
||||
//Return
|
||||
return $bpmnProjectUid;
|
||||
} catch (\Exception $e) {
|
||||
if ($bpmnProjectUid != "") {
|
||||
$this->remove();
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ use \BpmnParticipant as Participant;
|
||||
use \BpmnParticipantPeer as ParticipantPeer;
|
||||
|
||||
use \BasePeer;
|
||||
use \Criteria as Criteria;
|
||||
use \ResultSet as ResultSet;
|
||||
|
||||
use ProcessMaker\Util\Common;
|
||||
use ProcessMaker\Exception;
|
||||
@@ -557,6 +559,31 @@ class Bpmn extends Handler
|
||||
return $gateway;
|
||||
}
|
||||
|
||||
public function getGateway2($gatewayUid)
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(GatewayPeer::TABLE_NAME . ".*");
|
||||
$criteria->addSelectColumn(BoundPeer::TABLE_NAME . ".*");
|
||||
$criteria->addJoin(GatewayPeer::GAT_UID, BoundPeer::ELEMENT_UID, Criteria::LEFT_JOIN);
|
||||
$criteria->add(GatewayPeer::GAT_UID, $gatewayUid, Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = GatewayPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
//Return
|
||||
return $rsCriteria->getRow();
|
||||
}
|
||||
|
||||
//Return
|
||||
return false;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getGateways($start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
if (is_array($start)) {
|
||||
@@ -724,7 +751,11 @@ class Bpmn extends Handler
|
||||
public function addArtifact($data)
|
||||
{
|
||||
// setting defaults
|
||||
$processUid = $this->getProcess("object")->getProUid();
|
||||
|
||||
$data['ART_UID'] = array_key_exists('ART_UID', $data) ? $data['ART_UID'] : Common::generateUID();
|
||||
$data["PRO_UID"] = $processUid;
|
||||
|
||||
try {
|
||||
self::log("Add Artifact with data: ", $data);
|
||||
$artifact = new Artifact();
|
||||
@@ -805,7 +836,11 @@ class Bpmn extends Handler
|
||||
public function addData($data)
|
||||
{
|
||||
// setting defaults
|
||||
$processUid = $this->getProcess("object")->getProUid();
|
||||
|
||||
$data['DATA_UID'] = array_key_exists('DAT_UID', $data) ? $data['DAT_UID'] : Common::generateUID();
|
||||
$data["PRO_UID"] = $processUid;
|
||||
|
||||
try {
|
||||
self::log("Add BpmnData with data: ", $data);
|
||||
$bpmnData = new \BpmnData();
|
||||
@@ -886,7 +921,11 @@ class Bpmn extends Handler
|
||||
public function addParticipant($data)
|
||||
{
|
||||
// setting defaults
|
||||
$processUid = $this->getProcess("object")->getProUid();
|
||||
|
||||
$data['PAR_UID'] = array_key_exists('PAR_UID', $data) ? $data['PAR_UID'] : Common::generateUID();
|
||||
$data["PRO_UID"] = $processUid;
|
||||
|
||||
try {
|
||||
self::log("Add Participant with data: ", $data);
|
||||
$participant = new Participant();
|
||||
@@ -1017,5 +1056,46 @@ class Bpmn extends Handler
|
||||
$status = $value ? "DISABLED" : "ACTIVE";
|
||||
$this->update(array("PRJ_STATUS" => $status));
|
||||
}
|
||||
|
||||
public function getGatewayByDirectionActivityAndFlow($gatewayDirection, $activityUid)
|
||||
{
|
||||
try {
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
if ($gatewayDirection == "DIVERGING") {
|
||||
$criteria->addSelectColumn(FlowPeer::FLO_ELEMENT_DEST . " AS GAT_UID");
|
||||
|
||||
$criteria->add(FlowPeer::FLO_ELEMENT_ORIGIN, $activityUid, Criteria::EQUAL);
|
||||
$criteria->add(FlowPeer::FLO_ELEMENT_ORIGIN_TYPE, "bpmnActivity", Criteria::EQUAL);
|
||||
$criteria->add(FlowPeer::FLO_ELEMENT_DEST_TYPE, "bpmnGateway", Criteria::EQUAL);
|
||||
} else {
|
||||
//CONVERGING
|
||||
$criteria->addSelectColumn(FlowPeer::FLO_ELEMENT_ORIGIN . " AS GAT_UID");
|
||||
|
||||
$criteria->add(FlowPeer::FLO_ELEMENT_ORIGIN_TYPE, "bpmnGateway", Criteria::EQUAL);
|
||||
$criteria->add(FlowPeer::FLO_ELEMENT_DEST, $activityUid, Criteria::EQUAL);
|
||||
$criteria->add(FlowPeer::FLO_ELEMENT_DEST_TYPE, "bpmnActivity", Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add(FlowPeer::PRJ_UID, $this->prjUid, Criteria::EQUAL);
|
||||
$criteria->add(FlowPeer::FLO_TYPE, "SEQUENCE", Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = FlowPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$gatewayUid = "";
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
$gatewayUid = $row["GAT_UID"];
|
||||
}
|
||||
|
||||
//Return
|
||||
return $this->getGateway2($gatewayUid);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -911,5 +911,253 @@ class Workflow extends Handler
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function addLine($position, $direction = "HORIZONTAL")
|
||||
{
|
||||
try {
|
||||
self::log("Add Line with data: position $position, direction $direction");
|
||||
|
||||
$swimlaneElement = new \SwimlanesElements();
|
||||
|
||||
$swiUid = $swimlaneElement->create(array(
|
||||
"PRO_UID" => $this->proUid,
|
||||
"SWI_TYPE" => "LINE",
|
||||
"SWI_X" => ($direction == "HORIZONTAL")? 0 : $position,
|
||||
"SWI_Y" => ($direction == "HORIZONTAL")? $position : 0
|
||||
));
|
||||
|
||||
self::log("Add Line Success!");
|
||||
|
||||
//Return
|
||||
return $swiUid;
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function addText($text, $x, $y)
|
||||
{
|
||||
try {
|
||||
self::log("Add Text with data: text \"$text\"");
|
||||
|
||||
$swimlaneElement = new \SwimlanesElements();
|
||||
|
||||
$swiUid = $swimlaneElement->create(array(
|
||||
"PRO_UID" => $this->proUid,
|
||||
"SWI_TYPE" => "TEXT",
|
||||
"SWI_TEXT" => $text,
|
||||
"SWI_X" => $x,
|
||||
"SWI_Y" => $y
|
||||
));
|
||||
|
||||
self::log("Add Text Success!");
|
||||
|
||||
//Return
|
||||
return $swiUid;
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function createDataByArrayData(array $arrayData)
|
||||
{
|
||||
try {
|
||||
$processes = new \Processes();
|
||||
|
||||
$processes->createProcessPropertiesFromData((object)($arrayData));
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function createDataFileByArrayFile(array $arrayFile)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayFile as $target => $files) {
|
||||
switch (strtoupper($target)) {
|
||||
case "DYNAFORMS":
|
||||
$basePath = PATH_DYNAFORM;
|
||||
break;
|
||||
case "PUBLIC":
|
||||
$basePath = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP;
|
||||
break;
|
||||
case "TEMPLATES":
|
||||
$basePath = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "mailTemplates" . PATH_SEP;
|
||||
break;
|
||||
default:
|
||||
$basePath = "";
|
||||
}
|
||||
|
||||
if (empty($basePath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filename = $basePath . ((isset($file["file_path"]))? $file["file_path"] : $file["filepath"]);
|
||||
$path = dirname($filename);
|
||||
|
||||
if (!is_dir($path)) {
|
||||
Util\Common::mk_dir($path, 0775);
|
||||
}
|
||||
|
||||
file_put_contents($filename, $file["file_content"]);
|
||||
chmod($filename, 0775);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getData($processUid)
|
||||
{
|
||||
try {
|
||||
$process = new \Processes();
|
||||
|
||||
//Get data
|
||||
$workflowData = (array)($process->getWorkflowData($processUid));
|
||||
$workflowData["process"]["PRO_DYNAFORMS"] = (empty($workflowData["process"]["PRO_DYNAFORMS"]))? "" : serialize($workflowData["process"]["PRO_DYNAFORMS"]);
|
||||
|
||||
$workflowData["process"] = array($workflowData["process"]);
|
||||
$workflowData["processCategory"] = (empty($workflowData["processCategory"]))? array() : array($workflowData["processCategory"]);
|
||||
|
||||
//Get files
|
||||
$workflowFile = array();
|
||||
|
||||
//Getting DynaForms
|
||||
foreach ($workflowData["dynaforms"] as $dynaform) {
|
||||
$dynFile = PATH_DYNAFORM . $dynaform["DYN_FILENAME"] . ".xml";
|
||||
|
||||
$workflowFile["DYNAFORMS"][] = array(
|
||||
"filename" => $dynaform["DYN_TITLE"],
|
||||
"filepath" => $dynaform["DYN_FILENAME"] . ".xml",
|
||||
"file_content" => file_get_contents($dynFile)
|
||||
);
|
||||
|
||||
$htmlFile = PATH_DYNAFORM . $dynaform["DYN_FILENAME"] . ".html";
|
||||
|
||||
if (file_exists($htmlFile)) {
|
||||
$workflowFile["DYNAFORMS"][] = array(
|
||||
"filename" => $dynaform["DYN_FILENAME"] . ".html",
|
||||
"filepath" => $dynaform["DYN_FILENAME"] . ".html",
|
||||
"file_content" => file_get_contents($htmlFile)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Getting templates files
|
||||
$workspaceTargetDirs = array("TEMPLATES" => "mailTemplates", "PUBLIC" => "public");
|
||||
$workspaceDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP;
|
||||
|
||||
foreach ($workspaceTargetDirs as $target => $workspaceTargetDir) {
|
||||
$templatesDir = $workspaceDir . $workspaceTargetDir . PATH_SEP . $processUid;
|
||||
$templatesFiles = Util\Common::rglob("$templatesDir/*", 0, true);
|
||||
|
||||
foreach ($templatesFiles as $templatesFile) {
|
||||
if (is_dir($templatesFile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filename = basename($templatesFile);
|
||||
|
||||
$workflowFile[$target][] = array(
|
||||
"filename" => $filename,
|
||||
"filepath" => $processUid . PATH_SEP . $filename,
|
||||
"file_content" => file_get_contents($templatesFile)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
self::log("Getting Workflow data Success!");
|
||||
|
||||
return array($workflowData, $workflowFile);
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateDataUidByArrayUid(array $arrayWorkflowData, array $arrayWorkflowFile, array $arrayUid)
|
||||
{
|
||||
try {
|
||||
$processUidOld = $arrayUid[0]["old_uid"];
|
||||
$processUid = $arrayUid[0]["new_uid"];
|
||||
|
||||
//Update TAS_UID
|
||||
foreach ($arrayWorkflowData["tasks"] as $key => $value) {
|
||||
$taskUid = $arrayWorkflowData["tasks"][$key]["TAS_UID"];
|
||||
|
||||
foreach ($arrayUid as $value2) {
|
||||
$arrayItem = $value2;
|
||||
|
||||
if ($arrayItem["old_uid"] == $taskUid) {
|
||||
$arrayWorkflowData["tasks"][$key]["TAS_UID_OLD"] = $taskUid;
|
||||
$arrayWorkflowData["tasks"][$key]["TAS_UID"] = $arrayItem["new_uid"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Workflow tables
|
||||
$workflowData = (object)($arrayWorkflowData);
|
||||
|
||||
$processes = new \Processes();
|
||||
$processes->setProcessGUID($workflowData, $processUid);
|
||||
$processes->renewAll($workflowData);
|
||||
|
||||
$arrayWorkflowData = (array)($workflowData);
|
||||
|
||||
//Workflow files
|
||||
foreach ($arrayWorkflowFile as $key => $value) {
|
||||
$arrayFile = $value;
|
||||
|
||||
foreach ($arrayFile as $key2 => $value2) {
|
||||
$file = $value2;
|
||||
|
||||
$arrayWorkflowFile[$key][$key2]["file_path"] = str_replace($processUidOld, $processUid, (isset($file["file_path"]))? $file["file_path"] : $file["filepath"]);
|
||||
$arrayWorkflowFile[$key][$key2]["file_content"] = str_replace($processUidOld, $processUid, $file["file_content"]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($arrayWorkflowData["uid"])) {
|
||||
foreach ($arrayWorkflowData["uid"] as $key => $value) {
|
||||
$arrayT = $value;
|
||||
|
||||
foreach ($arrayT as $key2 => $value2) {
|
||||
$uidOld = $key2;
|
||||
$uid = $value2;
|
||||
|
||||
foreach ($arrayWorkflowFile as $key3 => $value3) {
|
||||
$arrayFile = $value3;
|
||||
|
||||
foreach ($arrayFile as $key4 => $value4) {
|
||||
$file = $value4;
|
||||
|
||||
$arrayWorkflowFile[$key3][$key4]["file_path"] = str_replace($uidOld, $uid, $file["file_path"]);
|
||||
$arrayWorkflowFile[$key3][$key4]["file_content"] = str_replace($uidOld, $uid, $file["file_content"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return array($arrayWorkflowData, $arrayWorkflowFile);
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user