ProcessMaker-BE "Process ----> Generate BPMN (Endpoint)"
- Se ha implementado el siguiente Endpoint:
POST /api/1.0/{workspace}/project/generate-bpmn
This commit is contained in:
@@ -460,7 +460,7 @@ class ProcessProxy extends HttpProxyController
|
|||||||
|
|
||||||
$workflowBpmn = new \ProcessMaker\Project\Adapter\WorkflowBpmn();
|
$workflowBpmn = new \ProcessMaker\Project\Adapter\WorkflowBpmn();
|
||||||
|
|
||||||
$projectUid = $workflowBpmn->generateBpmn($processUid, "processUid");
|
$projectUid = $workflowBpmn->generateBpmn($processUid, "processUid", $_SESSION["USER_LOGGED"]);
|
||||||
|
|
||||||
$this->status = "OK";
|
$this->status = "OK";
|
||||||
$this->projectUid = $projectUid;
|
$this->projectUid = $projectUid;
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ abstract class Exporter
|
|||||||
$bpmnStruct["PROJECT"] = array(\BpmnProjectPeer::retrieveByPK($this->prjUid)->toArray());
|
$bpmnStruct["PROJECT"] = array(\BpmnProjectPeer::retrieveByPK($this->prjUid)->toArray());
|
||||||
|
|
||||||
$workflow = new \ProcessMaker\Project\Workflow();
|
$workflow = new \ProcessMaker\Project\Workflow();
|
||||||
|
|
||||||
list($workflowData, $workflowFile) = $workflow->getData($this->prjUid);
|
list($workflowData, $workflowFile) = $workflow->getData($this->prjUid);
|
||||||
|
|
||||||
$data["bpmn-definition"] = $bpmnStruct;
|
$data["bpmn-definition"] = $bpmnStruct;
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ abstract class Importer
|
|||||||
const IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW = "project.import.keep_without_changing_and_create_new";
|
const IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW = "project.import.keep_without_changing_and_create_new";
|
||||||
const IMPORT_OPTION_CREATE_NEW = "project.import.create_new";
|
const IMPORT_OPTION_CREATE_NEW = "project.import.create_new";
|
||||||
|
|
||||||
const IMPORT_OPTION_WORKFLOW_TO_BPMN_GENERATE = "project.import.workflow_to_bpmn_generate";
|
|
||||||
|
|
||||||
const GROUP_IMPORT_OPTION_RENAME = "group.import.rename";
|
const GROUP_IMPORT_OPTION_RENAME = "group.import.rename";
|
||||||
const GROUP_IMPORT_OPTION_MERGE_PREEXISTENT = "group.import.merge.preexistent";
|
const GROUP_IMPORT_OPTION_MERGE_PREEXISTENT = "group.import.merge.preexistent";
|
||||||
const GROUP_IMPORT_OPTION_CREATE_NEW = "group.import.create_new";
|
const GROUP_IMPORT_OPTION_CREATE_NEW = "group.import.create_new";
|
||||||
@@ -31,20 +29,6 @@ abstract class Importer
|
|||||||
|
|
||||||
public abstract function load();
|
public abstract function load();
|
||||||
|
|
||||||
/**
|
|
||||||
* Set import data
|
|
||||||
*
|
|
||||||
* @param array $arrayData Data
|
|
||||||
*
|
|
||||||
* return void
|
|
||||||
*/
|
|
||||||
public function setImportData(array $arrayData)
|
|
||||||
{
|
|
||||||
$this->importData = $arrayData;
|
|
||||||
|
|
||||||
$this->validateImportData();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify if exists reserved words SQL
|
* Verify if exists reserved words SQL
|
||||||
*
|
*
|
||||||
@@ -87,16 +71,7 @@ abstract class Importer
|
|||||||
|
|
||||||
public function import($option = self::IMPORT_OPTION_CREATE_NEW, $optionGroup = self::GROUP_IMPORT_OPTION_CREATE_NEW)
|
public function import($option = self::IMPORT_OPTION_CREATE_NEW, $optionGroup = self::GROUP_IMPORT_OPTION_CREATE_NEW)
|
||||||
{
|
{
|
||||||
$generateUid = false;
|
$this->prepare();
|
||||||
|
|
||||||
if ($option != self::IMPORT_OPTION_WORKFLOW_TO_BPMN_GENERATE) {
|
|
||||||
$this->prepare();
|
|
||||||
} else {
|
|
||||||
$generateUid = true;
|
|
||||||
|
|
||||||
$option = "";
|
|
||||||
$optionGroup = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
$name = $this->importData["tables"]["bpmn"]["project"][0]["prj_name"];
|
$name = $this->importData["tables"]["bpmn"]["project"][0]["prj_name"];
|
||||||
|
|
||||||
@@ -353,46 +328,16 @@ abstract class Importer
|
|||||||
|
|
||||||
protected function importWfTables(array $tables)
|
protected function importWfTables(array $tables)
|
||||||
{
|
{
|
||||||
$tables = (object) $tables;
|
$workflow = new \ProcessMaker\Project\Workflow();
|
||||||
|
|
||||||
$processes = new \Processes();
|
$workflow->createDataByArrayData($tables);
|
||||||
|
|
||||||
$processes->createProcessPropertiesFromData($tables);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function importWfFiles(array $workflowFiles)
|
protected function importWfFiles(array $workflowFiles)
|
||||||
{
|
{
|
||||||
foreach ($workflowFiles as $target => $files) {
|
$workflow = new \ProcessMaker\Project\Workflow();
|
||||||
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 = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($basePath)) {
|
$workflow->createDataFileByArrayFile($workflowFiles);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doImport($generateUid = true)
|
public function doImport($generateUid = true)
|
||||||
@@ -409,63 +354,13 @@ abstract class Importer
|
|||||||
|
|
||||||
//Import workflow tables
|
//Import workflow tables
|
||||||
if ($generateUid) {
|
if ($generateUid) {
|
||||||
//Update TAS_UID
|
$result[0]["object"] = "project";
|
||||||
foreach ($arrayWorkflowTables["tasks"] as $key1 => $value1) {
|
$result[0]["old_uid"] = $projectUidOld;
|
||||||
$taskUid = $arrayWorkflowTables["tasks"][$key1]["TAS_UID"];
|
$result[0]["new_uid"] = $projectUid;
|
||||||
|
|
||||||
foreach ($result as $value2) {
|
$workflow = new \ProcessMaker\Project\Workflow();
|
||||||
$arrayItem = $value2;
|
|
||||||
|
|
||||||
if ($arrayItem["old_uid"] == $taskUid) {
|
list($arrayWorkflowTables, $arrayWorkflowFiles) = $workflow->updateDataUidByArrayUid($arrayWorkflowTables, $arrayWorkflowFiles, $result);
|
||||||
$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, (isset($file["file_path"]))? $file["file_path"] : $file["filepath"]);
|
|
||||||
$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"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->importWfTables($arrayWorkflowTables);
|
$this->importWfTables($arrayWorkflowTables);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,8 @@ use \BpmnParticipant as Participant;
|
|||||||
use \BpmnParticipantPeer as ParticipantPeer;
|
use \BpmnParticipantPeer as ParticipantPeer;
|
||||||
|
|
||||||
use \BasePeer;
|
use \BasePeer;
|
||||||
|
use \Criteria as Criteria;
|
||||||
|
use \ResultSet as ResultSet;
|
||||||
|
|
||||||
use ProcessMaker\Util\Common;
|
use ProcessMaker\Util\Common;
|
||||||
use ProcessMaker\Exception;
|
use ProcessMaker\Exception;
|
||||||
@@ -557,6 +559,31 @@ class Bpmn extends Handler
|
|||||||
return $gateway;
|
return $gateway;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getGateway2($gatwayUid)
|
||||||
|
{
|
||||||
|
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, $gatwayUid, 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)
|
public function getGateways($start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
|
||||||
{
|
{
|
||||||
if (is_array($start)) {
|
if (is_array($start)) {
|
||||||
@@ -1031,5 +1058,46 @@ class Bpmn extends Handler
|
|||||||
$status = $value ? "DISABLED" : "ACTIVE";
|
$status = $value ? "DISABLED" : "ACTIVE";
|
||||||
$this->update(array("PRJ_STATUS" => $status));
|
$this->update(array("PRJ_STATUS" => $status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getGatewayByDirectionActivityAndFlow($gatwayDirection, $activityUid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$criteria = new Criteria("workflow");
|
||||||
|
|
||||||
|
if ($gatwayDirection == "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);
|
||||||
|
|
||||||
|
$gatwayUid = "";
|
||||||
|
|
||||||
|
if ($rsCriteria->next()) {
|
||||||
|
$row = $rsCriteria->getRow();
|
||||||
|
|
||||||
|
$gatwayUid = $row["GAT_UID"];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Return
|
||||||
|
return $this->getGateway2($gatwayUid);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -912,6 +912,111 @@ 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)
|
public function getData($processUid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -977,6 +1082,80 @@ class Workflow extends Handler
|
|||||||
return array($workflowData, $workflowFile);
|
return array($workflowData, $workflowFile);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
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;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,20 +194,34 @@ class Project extends Api
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @url POST /process/:pro_uid/generate-bpmn
|
* @url POST /generate-bpmn
|
||||||
*
|
*
|
||||||
* @param string $pro_uid {@min 32}{@max 32}
|
* @param array $request_data
|
||||||
*
|
*
|
||||||
* @status 201
|
* @status 201
|
||||||
*/
|
*/
|
||||||
public function doPostProcessGenerateBpmn($pro_uid)
|
public function doPostGenerateBpmn(array $request_data)
|
||||||
{
|
{
|
||||||
try {
|
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();
|
$workflowBpmn = new \ProcessMaker\Project\Adapter\WorkflowBpmn();
|
||||||
|
|
||||||
$projectUid = $workflowBpmn->generateBpmn($pro_uid, "pro_uid");
|
$projectUid = $workflowBpmn->generateBpmn($request_data["PRO_UID"], "pro_uid", $this->getUserId());
|
||||||
|
|
||||||
$arrayData = array_change_key_case(array("PRJ_UID" => $projectUid), CASE_LOWER);
|
$arrayData = array_change_key_case(array_merge(array("PRJ_UID" => $projectUid), $request_data), CASE_LOWER);
|
||||||
|
|
||||||
$response = $arrayData;
|
$response = $arrayData;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user