ProcessMaker-BE "Proceso -----> Generar BPMN (Endpoint)"
- Se ha implementado el siguiente Endpoint:
POST /api/1.0/{workspace}/project/process/{pro_uid}/generate-bpmn
This commit is contained in:
@@ -111,60 +111,12 @@ 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;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ abstract class Importer
|
||||
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_WORKFLOW_TO_BPMN_GENERATE = "project.import.workflow_to_bpmn_generate";
|
||||
|
||||
const GROUP_IMPORT_OPTION_RENAME = "group.import.rename";
|
||||
const GROUP_IMPORT_OPTION_MERGE_PREEXISTENT = "group.import.merge.preexistent";
|
||||
const GROUP_IMPORT_OPTION_CREATE_NEW = "group.import.create_new";
|
||||
@@ -29,6 +31,20 @@ abstract class Importer
|
||||
|
||||
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
|
||||
*
|
||||
@@ -71,7 +87,16 @@ abstract class Importer
|
||||
|
||||
public function import($option = self::IMPORT_OPTION_CREATE_NEW, $optionGroup = self::GROUP_IMPORT_OPTION_CREATE_NEW)
|
||||
{
|
||||
$this->prepare();
|
||||
$generateUid = false;
|
||||
|
||||
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"];
|
||||
|
||||
@@ -315,8 +340,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);
|
||||
@@ -415,7 +440,7 @@ abstract class Importer
|
||||
foreach ($arrayFiles as $key2 => $value2) {
|
||||
$file = $value2;
|
||||
|
||||
$arrayWorkflowFiles[$key1][$key2]["file_path"] = str_replace($projectUidOld, $projectUid, $file["file_path"]);
|
||||
$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"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -926,7 +926,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
if ($forceInsert || is_null($dataObject)) {
|
||||
if ($generateUid) {
|
||||
//Event
|
||||
//Data
|
||||
unset($dataObjectData["BOU_UID"]);
|
||||
|
||||
$uidOld = $dataObjectData["DAT_UID"];
|
||||
@@ -973,7 +973,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
if ($forceInsert || is_null($dataObject)) {
|
||||
if ($generateUid) {
|
||||
//Event
|
||||
//Participant
|
||||
unset($participantData["BOU_UID"]);
|
||||
|
||||
$uidOld = $participantData["PAR_UID"];
|
||||
@@ -993,7 +993,7 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
Util\Logger::log("Update Participant ({$participantData["PAR_UID"]}) Skipped - No changes required");
|
||||
}
|
||||
|
||||
$diagram["participant"][$i] = $participantData;
|
||||
$diagram["participants"][$i] = $participantData;
|
||||
$whiteList[] = $participantData["PAR_UID"];
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -714,7 +714,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();
|
||||
@@ -796,7 +800,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();
|
||||
@@ -878,7 +886,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();
|
||||
|
||||
@@ -911,5 +911,74 @@ class Workflow extends Handler
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -193,6 +193,30 @@ class Project extends Api
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /process/:pro_uid/generate-bpmn
|
||||
*
|
||||
* @param string $pro_uid {@min 32}{@max 32}
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostProcessGenerateBpmn($pro_uid)
|
||||
{
|
||||
try {
|
||||
$workflowBpmn = new \ProcessMaker\Project\Adapter\WorkflowBpmn();
|
||||
|
||||
$projectUid = $workflowBpmn->generateBpmn($pro_uid, "pro_uid");
|
||||
|
||||
$arrayData = array_change_key_case(array("PRJ_UID" => $projectUid), CASE_LOWER);
|
||||
|
||||
$response = $arrayData;
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:prj_uid/dynaforms
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user