Merged in bugfix/PMC-138 (pull request #7110)
PMC-138 Assigned user lost in case of Custom Import (Promotion Manager) Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -4807,9 +4807,7 @@ class Processes
|
||||
$oData->abeConfiguration = $this->getActionsByEmail($sProUid);
|
||||
$oData->elementTask = $this->getElementTaskRelation($sProUid);
|
||||
$oData->groupwfs = $this->groupwfsMerge($oData->groupwfs, $oData->processUser, "USR_UID");
|
||||
$oData->process["PRO_TYPE_PROCESS"] = "PUBLIC";
|
||||
|
||||
//Return
|
||||
return $oData;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,9 +69,9 @@ class GranularImporter
|
||||
switch ($nameObject) {
|
||||
case 'PROCESSDEFINITION':
|
||||
$objectList['PROCESSDEFINITION']['bpmn'] = isset($data['tables']['bpmn']) ? $this->structureBpmnData
|
||||
($data['tables']['bpmn']) : [];
|
||||
$objectList['PROCESSDEFINITION']['workflow'] = isset($data['tables']['workflow']) ?
|
||||
$data['tables']['workflow'] : [];
|
||||
($data['tables']['bpmn']) : [];
|
||||
$objectList['PROCESSDEFINITION']['workflow'] = isset($data['tables']['workflow']) ?
|
||||
$data['tables']['workflow'] : [];
|
||||
break;
|
||||
case 'ASSIGNMENTRULES':
|
||||
$objectList['ASSIGNMENTRULES']['tasks'] = isset($data['tables']['workflow']['tasks']) ?
|
||||
@@ -165,17 +165,16 @@ class GranularImporter
|
||||
{
|
||||
$project = $tables["project"][0];
|
||||
$diagram = $tables["diagram"][0];
|
||||
$diagram["activities"] = (isset($tables["activity"])) ? $tables["activity"] : array();
|
||||
$diagram["artifacts"] = (isset($tables["artifact"])) ? $tables["artifact"] : array();
|
||||
$diagram["events"] = (isset($tables["event"])) ? $tables["event"] : array();
|
||||
$diagram["flows"] = (isset($tables["flow"])) ? $tables["flow"] : array();
|
||||
$diagram["gateways"] = (isset($tables["gateway"])) ? $tables["gateway"] : array();
|
||||
$diagram["data"] = (isset($tables["data"])) ? $tables["data"] : array();
|
||||
$diagram["participants"] = (isset($tables["participant"])) ? $tables["participant"] : array();
|
||||
$diagram["laneset"] = (isset($tables["laneset"])) ? $tables["laneset"] : array();
|
||||
$diagram["lanes"] = (isset($tables["lane"])) ? $tables["lane"] : array();
|
||||
$diagram["activities"] = (isset($tables["activity"])) ? $tables["activity"] : [];
|
||||
$diagram["artifacts"] = (isset($tables["artifact"])) ? $tables["artifact"] : [];
|
||||
$diagram["events"] = (isset($tables["event"])) ? $tables["event"] : [];
|
||||
$diagram["flows"] = (isset($tables["flow"])) ? $tables["flow"] : [];
|
||||
$diagram["gateways"] = (isset($tables["gateway"])) ? $tables["gateway"] : [];
|
||||
$diagram["data"] = (isset($tables["data"])) ? $tables["data"] : [];
|
||||
$diagram["participants"] = (isset($tables["participant"])) ? $tables["participant"] : [];
|
||||
$diagram["laneset"] = (isset($tables["laneset"])) ? $tables["laneset"] : [];
|
||||
$diagram["lanes"] = (isset($tables["lane"])) ? $tables["lane"] : [];
|
||||
$project["diagrams"] = array($diagram);
|
||||
$project["prj_author"] = isset($this->data["usr_uid"]) ? $this->data["usr_uid"] : "00000000000000000000000000000001";
|
||||
$project["process"] = $tables["process"][0];
|
||||
return $project;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
namespace ProcessMaker\Importer;
|
||||
|
||||
use Processes;
|
||||
use ProcessMaker\Util;
|
||||
use ProcessMaker\Project;
|
||||
use ProcessMaker\Project\Adapter;
|
||||
use ProcessMaker\BusinessModel\Migrator;
|
||||
use ProcessMaker\BusinessModel\Migrator\ImportException;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Project;
|
||||
use ProcessMaker\Project\Adapter;
|
||||
use ProcessMaker\Util;
|
||||
use ProcessMaker\Util\Common;
|
||||
use ProcessPeer;
|
||||
use stdClass;
|
||||
@@ -18,7 +19,7 @@ abstract class Importer
|
||||
protected $filename = "";
|
||||
protected $saveDir = "";
|
||||
protected $metadata = array();
|
||||
protected $prjCreateUser = '';
|
||||
|
||||
/**
|
||||
* Stores the current objects before import.
|
||||
* @var object
|
||||
@@ -332,7 +333,7 @@ abstract class Importer
|
||||
$diagram = $project->getStruct($projectUid);
|
||||
$res = $project->updateFromStruct($projectUid, $diagram);
|
||||
}
|
||||
|
||||
$this->updateTheProcessOwner($projectUid);
|
||||
return $projectUid;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -341,10 +342,28 @@ abstract class Importer
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
$result = $this->doImport($generateUid);
|
||||
|
||||
//Return
|
||||
$this->updateTheProcessOwner($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This updates the process owner.
|
||||
* @param string $proUid
|
||||
* @return void
|
||||
*/
|
||||
private function updateTheProcessOwner(string $proUid): void
|
||||
{
|
||||
$processOwner = $this->data["usr_uid"];
|
||||
|
||||
$currentProcess = $this->getCurrentProcess();
|
||||
if (is_object($currentProcess)) {
|
||||
$processOwner = $currentProcess->process->getProCreateUser();
|
||||
}
|
||||
$process = Process::where('PRO_UID', '=', $proUid);
|
||||
$process->update([
|
||||
'PRO_CREATE_USER' => $processOwner
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare for import, it makes all validations needed
|
||||
@@ -535,19 +554,17 @@ abstract class Importer
|
||||
// Build BPMN project struct
|
||||
$project = $tables["project"][0];
|
||||
$diagram = $tables["diagram"][0];
|
||||
$diagram["activities"] = (isset($tables["activity"]))? $tables["activity"] : array();
|
||||
$diagram["artifacts"] = (isset($tables["artifact"]))? $tables["artifact"] : array();
|
||||
$diagram["events"] = (isset($tables["event"]))? $tables["event"] : array();
|
||||
$diagram["flows"] = (isset($tables["flow"]))? $tables["flow"] : array();
|
||||
$diagram["gateways"] = (isset($tables["gateway"]))? $tables["gateway"]: array();
|
||||
$diagram["data"] = (isset($tables["data"]))? $tables["data"] : array();
|
||||
$diagram["participants"] = (isset($tables["participant"]))? $tables["participant"] : array();
|
||||
$diagram["laneset"] = (isset($tables["laneset"]))? $tables["laneset"] : array();
|
||||
$diagram["lanes"] = (isset($tables["lane"]))? $tables["lane"] : array();
|
||||
$diagram["activities"] = (isset($tables["activity"]))? $tables["activity"] : [];
|
||||
$diagram["artifacts"] = (isset($tables["artifact"]))? $tables["artifact"] : [];
|
||||
$diagram["events"] = (isset($tables["event"]))? $tables["event"] : [];
|
||||
$diagram["flows"] = (isset($tables["flow"]))? $tables["flow"] : [];
|
||||
$diagram["gateways"] = (isset($tables["gateway"]))? $tables["gateway"]: [];
|
||||
$diagram["data"] = (isset($tables["data"]))? $tables["data"] : [];
|
||||
$diagram["participants"] = (isset($tables["participant"]))? $tables["participant"] : [];
|
||||
$diagram["laneset"] = (isset($tables["laneset"]))? $tables["laneset"] : [];
|
||||
$diagram["lanes"] = (isset($tables["lane"]))? $tables["lane"] : [];
|
||||
$project["diagrams"] = array($diagram);
|
||||
$project["prj_author"] = isset($this->data["usr_uid"])? $this->data["usr_uid"]: "00000000000000000000000000000001";
|
||||
$project["process"] = $tables["process"][0];
|
||||
$project["prjCreateUser"] = $this->prjCreateUser;
|
||||
|
||||
return Adapter\BpmnWorkflow::createFromStruct($project, $generateUid);
|
||||
}
|
||||
@@ -839,7 +856,7 @@ abstract class Importer
|
||||
}
|
||||
}
|
||||
|
||||
public function saveAs($prj_uid, $prj_name, $prj_description, $prj_category, $prj_user = '')
|
||||
public function saveAs($prj_uid, $prj_name, $prj_description, $prj_category)
|
||||
{
|
||||
try {
|
||||
$exporter = new \ProcessMaker\Exporter\XmlExporter($prj_uid);
|
||||
@@ -857,7 +874,7 @@ abstract class Importer
|
||||
|
||||
$this->setSourceFile($outputFilename);
|
||||
$this->prepare();
|
||||
$this->prjCreateUser = $prj_user;
|
||||
|
||||
$this->importData["tables"]["bpmn"]["project"][0]["prj_name"] = $prj_name;
|
||||
$this->importData["tables"]["bpmn"]["project"][0]["prj_description"] = $prj_description;
|
||||
$this->importData["tables"]["bpmn"]["diagram"][0]["dia_name"] = $prj_name;
|
||||
@@ -869,7 +886,9 @@ abstract class Importer
|
||||
$this->importData["tables"]["workflow"]["process"][0]["PRO_UPDATE_DATE"] = null;
|
||||
$this->importData["tables"]["workflow"]["process"] = $this->importData["tables"]["workflow"]["process"][0];
|
||||
|
||||
return ['prj_uid' => $this->doImport(true, false)];
|
||||
$result = $this->doImport(true, false);
|
||||
$this->updateTheProcessOwner($result);
|
||||
return ['prj_uid' => $result];
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -99,10 +99,6 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$wpData["PRO_STATUS"] = $data["PRO_STATUS"];
|
||||
}
|
||||
|
||||
if (array_key_exists("PRO_CREATE_USER", $data)) {
|
||||
$wpData["PRO_CREATE_USER"] = $data["PRO_CREATE_USER"];
|
||||
}
|
||||
|
||||
$this->wp = new Project\Workflow();
|
||||
$this->wp->create($wpData);
|
||||
|
||||
@@ -1312,10 +1308,6 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
$data["PRO_STATUS"] = $projectData['pro_status'];
|
||||
}
|
||||
|
||||
if (!empty($projectData['prjCreateUser'])) {
|
||||
$data["PRO_CREATE_USER"] = $projectData['prjCreateUser'];
|
||||
}
|
||||
|
||||
$bwp->create($data);
|
||||
|
||||
$diagramData = $processData = array();
|
||||
|
||||
@@ -277,7 +277,8 @@ class Project extends Api
|
||||
public function doSaveAs($prj_uid, $prj_name, $prj_description = null, $prj_category = null)
|
||||
{
|
||||
$importer = new \ProcessMaker\Importer\XmlImporter();
|
||||
return $importer->saveAs($prj_uid, $prj_name, $prj_description, $prj_category, $this->getUserId());
|
||||
$importer->setData("usr_uid", $this->getUserId());
|
||||
return $importer->saveAs($prj_uid, $prj_name, $prj_description, $prj_category);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -453,7 +453,7 @@ Ext.onReady(function(){
|
||||
color = r.get('PRO_STATUS') == 'ACTIVE'? 'green': 'red';
|
||||
return String.format("<font color='{0}'>{1}</font>", color, v);
|
||||
}},
|
||||
{header: _('ID_PRO_USER'), dataIndex: 'PRO_CREATE_USER_LABEL', width: 150},
|
||||
{header: _('ID_OWNER'), dataIndex: 'PRO_CREATE_USER_LABEL', width: 150},
|
||||
{header: _('ID_PRO_CREATE_DATE'), dataIndex: 'PRO_CREATE_DATE', width: 90},
|
||||
{header: _('ID_INBOX'), dataIndex: 'CASES_COUNT_TO_DO', width: 50, align:'right'},
|
||||
{header: _('ID_DRAFT'), dataIndex: 'CASES_COUNT_DRAFT', width: 50, align:'right'},
|
||||
|
||||
Reference in New Issue
Block a user