@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
namespace ProcessMaker\BusinessModel\Migrator;
|
namespace ProcessMaker\BusinessModel\Migrator;
|
||||||
|
|
||||||
|
use ProcessMaker\Project\Adapter;
|
||||||
|
|
||||||
class GranularImporter
|
class GranularImporter
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -17,6 +19,7 @@ class GranularImporter
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->factory = new MigratorFactory();
|
$this->factory = new MigratorFactory();
|
||||||
|
$this->bpmn = new Adapter\BpmnWorkflow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,18 +182,52 @@ class GranularImporter
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($generateUid) {
|
if ($generateUid) {
|
||||||
foreach ($objectList as $rowObject) {
|
if(count($objectList) !== 14){
|
||||||
if ($rowObject['name'] === 'PROCESSDEFINITION' && $rowObject['value'] == "replace") {
|
$exception = new ImportException();
|
||||||
return true;
|
$exception->setNameException('To create a new process needs PROCESSDEFINITION');
|
||||||
}
|
throw($exception);
|
||||||
}
|
}
|
||||||
$exception = new ImportException();
|
|
||||||
$exception->setNameException('To create a new process needs PROCESSDEFINITION');
|
|
||||||
throw($exception);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $objectList
|
||||||
|
* @param array $data
|
||||||
|
* @return data
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function regenerateAllUids($data, $generateUid = true)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$newData = array();
|
||||||
|
$arrayBpmnTables = $data["tables"]["bpmn"];
|
||||||
|
$arrayWorkflowTables = $data["tables"]["workflow"];
|
||||||
|
$arrayWorkflowFiles = $data["files"]["workflow"];
|
||||||
|
$result = $this->bpmn->createFromStruct($this->structureBpmnData($arrayBpmnTables), $generateUid);
|
||||||
|
$projectUidOld = $arrayBpmnTables["project"][0]["prj_uid"];
|
||||||
|
$projectUid = ($generateUid)? $result[0]["new_uid"] : $result;
|
||||||
|
if ($generateUid) {
|
||||||
|
$result[0]["object"] = "project";
|
||||||
|
$result[0]["old_uid"] = $projectUidOld;
|
||||||
|
$result[0]["new_uid"] = $projectUid;
|
||||||
|
|
||||||
|
$workflow = new \ProcessMaker\Project\Workflow();
|
||||||
|
|
||||||
|
list($arrayWorkflowTables, $arrayWorkflowFiles) = $workflow->updateDataUidByArrayUid($arrayWorkflowTables, $arrayWorkflowFiles, $result);
|
||||||
|
}
|
||||||
|
$newData['tables']['workflow'] = $arrayWorkflowTables;
|
||||||
|
$newData['files']['workflow'] = $arrayWorkflowFiles;
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'data' => $newData,
|
||||||
|
'new_uid' => $projectUid);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,9 +31,9 @@ class ReportTablesMigrator implements Importable, Exportable
|
|||||||
try {
|
try {
|
||||||
$aReportTablesVars = array();
|
$aReportTablesVars = array();
|
||||||
if ($replace) {
|
if ($replace) {
|
||||||
$this->processes->createReportTables($data, $aReportTablesVars);
|
//Todo Create
|
||||||
} else {
|
} else {
|
||||||
$this->processes->updateReportTables($data, $aReportTablesVars);
|
//Todo addOnlyNew
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$exception = new ImportException($e->getMessage());
|
$exception = new ImportException($e->getMessage());
|
||||||
|
|||||||
@@ -220,12 +220,29 @@ abstract class Importer
|
|||||||
try {
|
try {
|
||||||
if ($objectsToImport !== '') {
|
if ($objectsToImport !== '') {
|
||||||
$granularObj = new \ProcessMaker\BusinessModel\Migrator\GranularImporter();
|
$granularObj = new \ProcessMaker\BusinessModel\Migrator\GranularImporter();
|
||||||
$objectList = $granularObj->loadObjectsListSelected($this->importData, $objectsToImport);
|
$newObjectArray = $objectsToImport;
|
||||||
$processGranulate = $granularObj->validateImportData($objectList, $generateUid);
|
$projectUid = $this->importData['tables']['bpmn']["project"][0]["prj_uid"];
|
||||||
if (sizeof($objectList) > 0 && $processGranulate) {
|
$processGranulate = $granularObj->validateImportData($objectsToImport, $generateUid);
|
||||||
$granularObj->import($objectList);
|
if($generateUid){
|
||||||
return $this->importData['tables']['bpmn']["project"][0]["prj_uid"];
|
$result = $granularObj->regenerateAllUids($this->importData, $generateUid);
|
||||||
|
$this->importData = $result['data'];
|
||||||
|
$projectUid = $result['new_uid'];
|
||||||
|
$newObjectArray = array();
|
||||||
|
$count = 0;
|
||||||
|
foreach ($objectsToImport as $key => $rowObject) {
|
||||||
|
if($rowObject->id != '1'){
|
||||||
|
$newObjectArray[++$count] = $rowObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if(sizeof($newObjectArray)){
|
||||||
|
$objectList = $granularObj->loadObjectsListSelected($this->importData, $newObjectArray);
|
||||||
|
if (sizeof($objectList) > 0 && $processGranulate) {
|
||||||
|
$granularObj->import($objectList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $projectUid;
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
|
|||||||
Reference in New Issue
Block a user