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"];
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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