Merged in victorsl/processmaker (pull request #621)
ProcessMaker-BE "Process ----> Generate BPMN (Endpoint)"
This commit is contained in:
@@ -447,5 +447,27 @@ class ProcessProxy extends HttpProxyController
|
||||
}
|
||||
$this->rows = $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate BPMN (New record is generated)
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function generateBpmn()
|
||||
{
|
||||
try {
|
||||
$processUid = $_POST["processUid"];
|
||||
|
||||
$workflowBpmn = new \ProcessMaker\Project\Adapter\WorkflowBpmn();
|
||||
|
||||
$projectUid = $workflowBpmn->generateBpmn($processUid, "processUid", $_SESSION["USER_LOGGED"]);
|
||||
|
||||
$this->status = "OK";
|
||||
$this->projectUid = $projectUid;
|
||||
} catch (Exception $e) {
|
||||
$this->status = "ERROR";
|
||||
$this->message = $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,60 +111,13 @@ abstract class Exporter
|
||||
$bpmnStruct["PROCESS"] = \BpmnProcess::getAll($this->prjUid);
|
||||
$bpmnStruct["PROJECT"] = array(\BpmnProjectPeer::retrieveByPK($this->prjUid)->toArray());
|
||||
|
||||
$oProcess = new \Processes();
|
||||
$workflowData = (array) $oProcess->getWorkflowData($this->prjUid);
|
||||
$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"]);
|
||||
$workflow = new \ProcessMaker\Project\Workflow();
|
||||
|
||||
list($workflowData, $workflowFile) = $workflow->getData($this->prjUid);
|
||||
|
||||
$data["bpmn-definition"] = $bpmnStruct;
|
||||
$data["workflow-definition"] = $workflowData;
|
||||
$data["workflow-files"] = array();
|
||||
|
||||
// getting dynaforms
|
||||
foreach ($workflowData["dynaforms"] as $dynaform) {
|
||||
$dynFile = PATH_DYNAFORM . $dynaform['DYN_FILENAME'] . '.xml';
|
||||
$data["workflow-files"]["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)) {
|
||||
$data["workflow-files"]["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 . $this->prjUid;
|
||||
$templatesFiles = Util\Common::rglob("$templatesDir/*", 0, true);
|
||||
|
||||
foreach ($templatesFiles as $templatesFile) {
|
||||
if (is_dir($templatesFile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filename = basename($templatesFile);
|
||||
$data["workflow-files"][$target][] = array(
|
||||
"filename" => $filename,
|
||||
"filepath" => $this->prjUid . PATH_SEP . $filename,
|
||||
"file_content" => file_get_contents($templatesFile)
|
||||
);
|
||||
}
|
||||
}
|
||||
$data["workflow-files"] = $workflowFile;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -315,8 +315,8 @@ abstract class Importer
|
||||
$diagram["events"] = $tables["event"];
|
||||
$diagram["flows"] = $tables["flow"];
|
||||
$diagram["gateways"] = $tables["gateway"];
|
||||
$diagram["data"] = $tables["data"];
|
||||
$diagram["participants"] = $tables["participant"];
|
||||
$diagram["data"] = (isset($tables["data"]))? $tables["data"] : array();
|
||||
$diagram["participants"] = (isset($tables["participant"]))? $tables["participant"] : array();
|
||||
$diagram["lanes"] = array();
|
||||
$diagram["laneset"] = array();
|
||||
$project["diagrams"] = array($diagram);
|
||||
@@ -328,46 +328,16 @@ abstract class Importer
|
||||
|
||||
protected function importWfTables(array $tables)
|
||||
{
|
||||
$tables = (object) $tables;
|
||||
$workflow = new \ProcessMaker\Project\Workflow();
|
||||
|
||||
$processes = new \Processes();
|
||||
|
||||
$processes->createProcessPropertiesFromData($tables);
|
||||
$workflow->createDataByArrayData($tables);
|
||||
}
|
||||
|
||||
protected function importWfFiles(array $workflowFiles)
|
||||
{
|
||||
foreach ($workflowFiles as $target => $files) {
|
||||
switch ($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 = "";
|
||||
}
|
||||
$workflow = new \ProcessMaker\Project\Workflow();
|
||||
|
||||
if (empty($basePath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filename = $basePath . $file["file_path"];
|
||||
$path = dirname($filename);
|
||||
|
||||
if (! is_dir($path)) {
|
||||
Util\Common::mk_dir($path, 0775);
|
||||
}
|
||||
|
||||
file_put_contents($filename, $file["file_content"]);
|
||||
chmod($filename, 0775);
|
||||
}
|
||||
}
|
||||
$workflow->createDataFileByArrayFile($workflowFiles);
|
||||
}
|
||||
|
||||
public function doImport($generateUid = true)
|
||||
@@ -384,63 +354,13 @@ abstract class Importer
|
||||
|
||||
//Import workflow tables
|
||||
if ($generateUid) {
|
||||
//Update TAS_UID
|
||||
foreach ($arrayWorkflowTables["tasks"] as $key1 => $value1) {
|
||||
$taskUid = $arrayWorkflowTables["tasks"][$key1]["TAS_UID"];
|
||||
$result[0]["object"] = "project";
|
||||
$result[0]["old_uid"] = $projectUidOld;
|
||||
$result[0]["new_uid"] = $projectUid;
|
||||
|
||||
foreach ($result as $value2) {
|
||||
$arrayItem = $value2;
|
||||
$workflow = new \ProcessMaker\Project\Workflow();
|
||||
|
||||
if ($arrayItem["old_uid"] == $taskUid) {
|
||||
$arrayWorkflowTables["tasks"][$key1]["TAS_UID_OLD"] = $taskUid;
|
||||
$arrayWorkflowTables["tasks"][$key1]["TAS_UID"] = $arrayItem["new_uid"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Workflow tables
|
||||
$workflowTables = (object)($arrayWorkflowTables);
|
||||
|
||||
$processes = new \Processes();
|
||||
$processes->setProcessGUID($workflowTables, $projectUid);
|
||||
$processes->renewAll($workflowTables);
|
||||
|
||||
$arrayWorkflowTables = (array)($workflowTables);
|
||||
|
||||
//Workflow files
|
||||
foreach ($arrayWorkflowFiles as $key1 => $value1) {
|
||||
$arrayFiles = $value1;
|
||||
|
||||
foreach ($arrayFiles as $key2 => $value2) {
|
||||
$file = $value2;
|
||||
|
||||
$arrayWorkflowFiles[$key1][$key2]["file_path"] = str_replace($projectUidOld, $projectUid, $file["file_path"]);
|
||||
$arrayWorkflowFiles[$key1][$key2]["file_content"] = str_replace($projectUidOld, $projectUid, $file["file_content"]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($arrayWorkflowTables["uid"])) {
|
||||
foreach ($arrayWorkflowTables["uid"] as $key1 => $value1) {
|
||||
$arrayT = $value1;
|
||||
|
||||
foreach ($arrayT as $key2 => $value2) {
|
||||
$uidOld = $key2;
|
||||
$uid = $value2;
|
||||
|
||||
foreach ($arrayWorkflowFiles as $key3 => $value3) {
|
||||
$arrayFiles = $value3;
|
||||
|
||||
foreach ($arrayFiles as $key4 => $value4) {
|
||||
$file = $value4;
|
||||
|
||||
$arrayWorkflowFiles[$key3][$key4]["file_path"] = str_replace($uidOld, $uid, $file["file_path"]);
|
||||
$arrayWorkflowFiles[$key3][$key4]["file_content"] = str_replace($uidOld, $uid, $file["file_content"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
list($arrayWorkflowTables, $arrayWorkflowFiles) = $workflow->updateDataUidByArrayUid($arrayWorkflowTables, $arrayWorkflowFiles, $result);
|
||||
}
|
||||
|
||||
$this->importWfTables($arrayWorkflowTables);
|
||||
|
||||
@@ -932,7 +932,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 +979,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
if ($forceInsert || is_null($dataObject)) {
|
||||
if ($generateUid) {
|
||||
//Event
|
||||
//Participant
|
||||
unset($participantData["BOU_UID"]);
|
||||
|
||||
$uidOld = $participantData["PAR_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();
|
||||
@@ -806,7 +837,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();
|
||||
@@ -888,7 +923,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();
|
||||
@@ -1019,5 +1058,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -193,6 +193,44 @@ class Project extends Api
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /generate-bpmn
|
||||
*
|
||||
* @param array $request_data
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostGenerateBpmn(array $request_data)
|
||||
{
|
||||
try {
|
||||
//Set data
|
||||
$request_data = array_change_key_case($request_data, CASE_UPPER);
|
||||
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition(
|
||||
$request_data,
|
||||
array("PRO_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "processUid")),
|
||||
array("processUid" => "pro_uid"),
|
||||
true
|
||||
);
|
||||
|
||||
//Generate BPMN
|
||||
$workflowBpmn = new \ProcessMaker\Project\Adapter\WorkflowBpmn();
|
||||
|
||||
$projectUid = $workflowBpmn->generateBpmn($request_data["PRO_UID"], "pro_uid", $this->getUserId());
|
||||
|
||||
$arrayData = array_change_key_case(array_merge(array("PRJ_UID" => $projectUid), $request_data), CASE_LOWER);
|
||||
|
||||
$response = $arrayData;
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:prj_uid/dynaforms
|
||||
*
|
||||
|
||||
@@ -342,7 +342,7 @@ accessTokenSetup.application = {
|
||||
sm.selectRow(rowIndex, true);
|
||||
|
||||
var record = grdpnlMain.getSelectionModel().getSelected();
|
||||
console.log(record);
|
||||
|
||||
if (typeof(record) != "undefined") {
|
||||
Ext.MessageBox.confirm(
|
||||
_("ID_CONFIRM"),
|
||||
|
||||
@@ -394,11 +394,10 @@ Ext.onReady(function(){
|
||||
}
|
||||
|
||||
if (rowSelected.data.PROJECT_TYPE == "bpmn"){
|
||||
Ext.getCmp('edit_with_classic_editor').setDisabled(false);
|
||||
Ext.getCmp("mnuGenerateBpmn").setDisabled(true);
|
||||
} else {
|
||||
Ext.getCmp('edit_with_classic_editor').setDisabled(true);
|
||||
Ext.getCmp("mnuGenerateBpmn").setDisabled(false);
|
||||
}
|
||||
|
||||
}, this);
|
||||
processesGrid.on('contextmenu', function (evt) {
|
||||
evt.preventDefault();
|
||||
@@ -435,6 +434,15 @@ Ext.onReady(function(){
|
||||
handler: function () {
|
||||
exportProcess();
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "mnuGenerateBpmn",
|
||||
text: _("ID_GENERATE_BPMN_PROJECT"),
|
||||
iconCls: "button_menu_ext ss_sprite ss_page_white_go",
|
||||
handler: function ()
|
||||
{
|
||||
generateBpmn();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -584,7 +592,7 @@ editProcess = function(typeParam)
|
||||
var rowSelected = processesGrid.getSelectionModel().getSelected();
|
||||
if (!rowSelected) {
|
||||
Ext.Msg.show({
|
||||
title: '',
|
||||
title: _("ID_INFORMATION"),
|
||||
msg: _('ID_NO_SELECTION_WARNING'),
|
||||
buttons: Ext.Msg.INFO,
|
||||
fn: function () {
|
||||
@@ -617,7 +625,7 @@ editNewProcess = function(){
|
||||
location.href = '../designer?pro_uid='+rowSelected.data.PRO_UID
|
||||
} else {
|
||||
Ext.Msg.show({
|
||||
title:'',
|
||||
title: _("ID_INFORMATION"),
|
||||
msg: _('ID_NO_SELECTION_WARNING'),
|
||||
buttons: Ext.Msg.INFO,
|
||||
fn: function(){},
|
||||
@@ -701,7 +709,7 @@ deleteProcess = function(){
|
||||
}
|
||||
} else {
|
||||
Ext.Msg.show({
|
||||
title:'',
|
||||
title: _("ID_INFORMATION"),
|
||||
msg: _('ID_NO_SELECTION_WARNING'),
|
||||
buttons: Ext.Msg.INFO,
|
||||
fn: function(){},
|
||||
@@ -743,7 +751,7 @@ function exportProcess() {
|
||||
}
|
||||
else {
|
||||
Ext.Msg.show({
|
||||
title: "",
|
||||
title: _("ID_INFORMATION"),
|
||||
msg: _("ID_NO_SELECTION_WARNING"),
|
||||
icon: Ext.MessageBox.INFO,
|
||||
buttons: Ext.MessageBox.OK
|
||||
@@ -751,6 +759,60 @@ function exportProcess() {
|
||||
}
|
||||
}
|
||||
|
||||
function generateBpmn()
|
||||
{
|
||||
var record = processesGrid.getSelectionModel().getSelections();
|
||||
|
||||
if (typeof(record) != "undefined") {
|
||||
if (record.length == 1) {
|
||||
var loadMaskGenerateBpmn = new Ext.LoadMask(Ext.getBody(), {msg: _("ID_PROCESSING")});
|
||||
var processUid = record[0].get("PRO_UID");
|
||||
|
||||
loadMaskGenerateBpmn.show();
|
||||
|
||||
Ext.Ajax.request({
|
||||
url: "../processProxy/generateBpmn",
|
||||
method: "POST",
|
||||
params: {
|
||||
processUid: processUid
|
||||
},
|
||||
|
||||
success: function (response, opts)
|
||||
{
|
||||
var dataResponse = Ext.util.JSON.decode(response.responseText);
|
||||
|
||||
if (dataResponse.status) {
|
||||
if (dataResponse.status == "OK") {
|
||||
//processesGrid.store.reload();
|
||||
location.assign("../designer?prj_uid=" + dataResponse.projectUid);
|
||||
} else {
|
||||
Ext.MessageBox.show({
|
||||
title: _("ID_ERROR"),
|
||||
icon: Ext.MessageBox.ERROR,
|
||||
buttons: Ext.MessageBox.OK,
|
||||
msg: dataResponse.message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
loadMaskGenerateBpmn.hide();
|
||||
},
|
||||
failure: function (response, opts)
|
||||
{
|
||||
loadMaskGenerateBpmn.hide();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Ext.MessageBox.show({
|
||||
title: _("ID_INFORMATION"),
|
||||
icon: Ext.MessageBox.INFO,
|
||||
buttons: Ext.MessageBox.OK,
|
||||
msg: _("ID_NO_SELECTION_WARNING")
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
importProcessExistGroup = function()
|
||||
{
|
||||
|
||||
@@ -1191,7 +1253,7 @@ function activeDeactive(){
|
||||
});
|
||||
} else {
|
||||
Ext.Msg.show({
|
||||
title:'',
|
||||
title: _("ID_INFORMATION"),
|
||||
msg: _('ID_NO_SELECTION_WARNING'),
|
||||
buttons: Ext.Msg.INFO,
|
||||
fn: function(){},
|
||||
@@ -1227,7 +1289,7 @@ function enableDisableDebug()
|
||||
});
|
||||
} else {
|
||||
Ext.Msg.show({
|
||||
title:'',
|
||||
title: _("ID_INFORMATION"),
|
||||
msg: _('ID_NO_SELECTION_WARNING'),
|
||||
buttons: Ext.Msg.INFO,
|
||||
fn: function(){},
|
||||
|
||||
Reference in New Issue
Block a user