PMCORE-1476
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use ProcessMaker\BusinessModel\EmailEvent;
|
||||
use ProcessMaker\BusinessModel\Variable as BmVariable;
|
||||
use ProcessMaker\Core\System;
|
||||
|
||||
class Processes
|
||||
@@ -1863,8 +1864,21 @@ class Processes
|
||||
$criteria = new Criteria(ProcessVariablesPeer::DATABASE_NAME);
|
||||
$criteria->add(ProcessVariablesPeer::VAR_UID, $row['VAR_UID']);
|
||||
$criteria->add(ProcessVariablesPeer::PRJ_UID, $row['PRJ_UID']);
|
||||
// Load the PRO_ID
|
||||
$process = new Process();
|
||||
if ($process->processExists($row['PRJ_UID'])) {
|
||||
$processRow = $process->load($row['PRJ_UID']);
|
||||
$row['PRO_ID'] = $processRow['PRO_ID'];
|
||||
if (!empty($row['PRO_ID'])) {
|
||||
$criteria->add(ProcessVariablesPeer::PRO_ID, $row['PRO_ID']);
|
||||
}
|
||||
}
|
||||
$criteria->add(ProcessVariablesPeer::VAR_NAME, $row['VAR_NAME']);
|
||||
$criteria->add(ProcessVariablesPeer::VAR_FIELD_TYPE, $row['VAR_FIELD_TYPE']);
|
||||
if (empty($row['VAR_FIELD_TYPE_ID'])) {
|
||||
$row['VAR_FIELD_TYPE_ID'] = BmVariable::$varTypesValues[$row["VAR_FIELD_TYPE"]];
|
||||
}
|
||||
$criteria->add(ProcessVariablesPeer::VAR_FIELD_TYPE_ID, $row['VAR_FIELD_TYPE_ID']);
|
||||
$criteria->add(ProcessVariablesPeer::VAR_FIELD_SIZE, $row['VAR_FIELD_SIZE']);
|
||||
$criteria->add(ProcessVariablesPeer::VAR_LABEL, $row['VAR_LABEL']);
|
||||
$criteria->add(ProcessVariablesPeer::VAR_DBCONNECTION, $row['VAR_DBCONNECTION']);
|
||||
@@ -3609,6 +3623,8 @@ class Processes
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
unset($aRow['VAR_ID']);
|
||||
unset($aRow['PRO_ID']);
|
||||
$aVars[] = $aRow;
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Importer;
|
||||
|
||||
use Process as ModelProcess;
|
||||
use Processes;
|
||||
use ProcessMaker\BusinessModel\Migrator;
|
||||
use ProcessMaker\BusinessModel\Migrator\ImportException;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\ProcessVariables;
|
||||
use ProcessMaker\Project;
|
||||
use ProcessMaker\Project\Adapter;
|
||||
use ProcessMaker\Util;
|
||||
@@ -191,7 +193,7 @@ abstract class Importer
|
||||
}
|
||||
//Shouldn't generate new UID for all objects
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if($objectsToImport === ''){
|
||||
if ($objectsToImport === '') {
|
||||
/*----------------------------------********---------------------------------*/
|
||||
try {
|
||||
$this->verifyIfTheProcessHasStartedCases();
|
||||
@@ -333,7 +335,7 @@ abstract class Importer
|
||||
$diagram = $project->getStruct($projectUid);
|
||||
$res = $project->updateFromStruct($projectUid, $diagram);
|
||||
}
|
||||
$this->updateTheProcessOwner($projectUid);
|
||||
$this->updateProcessInformation($projectUid);
|
||||
return $projectUid;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -342,17 +344,20 @@ abstract class Importer
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
$result = $this->doImport($generateUid);
|
||||
$this->updateTheProcessOwner($result);
|
||||
$this->updateProcessInformation($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This updates the process owner.
|
||||
* This updates information related to the process
|
||||
*
|
||||
* @param string $proUid
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function updateTheProcessOwner(string $proUid): void
|
||||
private function updateProcessInformation(string $proUid): void
|
||||
{
|
||||
// Update the process owner
|
||||
$processOwner = $this->data["usr_uid"];
|
||||
|
||||
$currentProcess = $this->getCurrentProcess();
|
||||
@@ -363,6 +368,17 @@ abstract class Importer
|
||||
$process->update([
|
||||
'PRO_CREATE_USER' => $processOwner
|
||||
]);
|
||||
|
||||
// Update the process Variables with the PRO_ID related
|
||||
$process = new ModelProcess();
|
||||
if ($process->processExists($proUid)) {
|
||||
$processRow = $process->load($proUid);
|
||||
$proId = $processRow['PRO_ID'];
|
||||
$processVar = ProcessVariables::where('PRJ_UID', '=', $proUid);
|
||||
$processVar->update([
|
||||
'PRO_ID' => $proId
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -887,7 +903,7 @@ abstract class Importer
|
||||
$this->importData["tables"]["workflow"]["process"] = $this->importData["tables"]["workflow"]["process"][0];
|
||||
|
||||
$result = $this->doImport(true, false);
|
||||
$this->updateTheProcessOwner($result);
|
||||
$this->updateProcessInformation($result);
|
||||
return ['prj_uid' => $result];
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
|
||||
Reference in New Issue
Block a user