diff --git a/workflow/engine/classes/class.processes.php b/workflow/engine/classes/class.processes.php index cb2c21e2c..e97ef9260 100755 --- a/workflow/engine/classes/class.processes.php +++ b/workflow/engine/classes/class.processes.php @@ -2600,6 +2600,7 @@ class Processes /** * @param $aStepSupervisor + * @throws Exception */ public function updateStepSupervisorRows ($aStepSupervisor) { @@ -2719,6 +2720,7 @@ class Processes /** * @param $aPermission + * @throws Exception */ public function createObjectPermissionRows ($aPermission) { @@ -2737,6 +2739,7 @@ class Processes /** * @param $aPermission + * @throws Exception */ public function updateObjectPermissionRows ($aPermission) { @@ -3929,7 +3932,7 @@ class Processes * @param array $arrayData * @throws Exception */ - public function updateFilesManager(array $arrayData) + public function updateFilesManager($processUid, array $arrayData) { try { $filesManager = new \ProcessMaker\BusinessModel\FilesManager(); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/AssignmentRulesMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/AssignmentRulesMigrator.php index 49012987f..4478f985d 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/AssignmentRulesMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/AssignmentRulesMigrator.php @@ -27,6 +27,11 @@ class AssignmentRulesMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + * @throws ImportException + */ public function import($data, $replace) { try { diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/DBConnectionMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/DBConnectionMigrator.php index 884f0ae54..bbe9ef452 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/DBConnectionMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/DBConnectionMigrator.php @@ -25,6 +25,10 @@ class DBConnectionMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + */ public function import($data, $replace) { try { @@ -35,7 +39,7 @@ class DBConnectionMigrator implements Importable, Exportable } } catch (\Exception $e) { \Logger::log($e->getMessage()); - throw new ImportException($e->getMessage()); + throwException(new ImportException($e->getMessage())); } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/DynaformsMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/DynaformsMigrator.php index f0a051082..1c3c74fd0 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/DynaformsMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/DynaformsMigrator.php @@ -24,6 +24,10 @@ class DynaformsMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + */ public function import($data, $replace) { try { @@ -32,10 +36,9 @@ class DynaformsMigrator implements Importable, Exportable } else { $this->processes->updateDynaformRows($data); } - } catch (\Exception $e) { \Logger::log($e->getMessage()); - throw new ImportException($e->getMessage()); + throwException(new ImportException($e->getMessage())); } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/FilesMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/FilesMigrator.php index 0486b03fd..03c033a56 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/FilesMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/FilesMigrator.php @@ -29,34 +29,38 @@ class FilesMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + * @throws ImportException + */ public function import($data, $replace) { try { $aTable = $data['TABLE']; foreach ($aTable as $value) { - - if($value['PRF_EDITABLE'] !== 1){ + if ($value['PRF_EDITABLE'] !== 1) { if ($replace) { $this->processes->createFilesManager($value['PRO_UID'], array($value)); } else { - $this->processes->updateFilesManager(array($value)); + $this->processes->updateFilesManager($value['PRO_UID'], array($value)); } } } $aPath = $data['PATH']; foreach ($aPath as $target => $files) { $basePath = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP; - if(strtoupper($target) === 'PUBLIC'){ + if (strtoupper($target) === 'PUBLIC') { foreach ($files as $file) { - $filename = $basePath . ((isset($file["file_path"]))? $file["file_path"] : $file["filepath"]); - $path = dirname($filename); + $filename = $basePath . ((isset($file["file_path"])) ? $file["file_path"] : $file["filepath"]); + $path = dirname($filename); - if (!is_dir($path)) { - Util\Common::mk_dir($path, 0775); - } + if (!is_dir($path)) { + Util\Common::mk_dir($path, 0775); + } - file_put_contents($filename, $file["file_content"]); - chmod($filename, 0775); + file_put_contents($filename, $file["file_content"]); + chmod($filename, 0775); } } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/GranularImporter.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/GranularImporter.php index 69903be8e..be4113a53 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/GranularImporter.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/GranularImporter.php @@ -22,36 +22,37 @@ class GranularImporter /** * Load Objects List Selected */ - public function loadObjectsListSelected($data, $aGranular) { + public function loadObjectsListSelected($data, $aGranular) + { $objectList = array(); - if(in_array('PROCESSDEFINITION', $aGranular)){ + if (in_array('PROCESSDEFINITION', $aGranular)) { $objectList['PROCESSDEFINITION'] = $this->structureBpmnData($data['tables']['bpmn']); } - if(in_array('ASSIGNMENTRULES', $aGranular)){ + if (in_array('ASSIGNMENTRULES', $aGranular)) { $objectList['ASSIGNMENTRULES'] = $data['tables']['workflow']['tasks']; } - if(in_array('VARIABLES', $aGranular)){ + if (in_array('VARIABLES', $aGranular)) { $objectList['VARIABLES'] = $data['tables']['workflow']['processVariables']; } - if(in_array('DYNAFORMS', $aGranular)){ + if (in_array('DYNAFORMS', $aGranular)) { $objectList['DYNAFORMS'] = $data['tables']['workflow']['dynaforms']; } - if(in_array('INPUTDOCUMENTS', $aGranular)){ + if (in_array('INPUTDOCUMENTS', $aGranular)) { $objectList['INPUTDOCUMENTS'] = $data['tables']['workflow']['inputs']; } - if(in_array('OUTPUTDOCUMENTS', $aGranular)){ + if (in_array('OUTPUTDOCUMENTS', $aGranular)) { $objectList['OUTPUTDOCUMENTS'] = $data['tables']['workflow']['outputs']; } - if(in_array('TRIGGERS', $aGranular)){ + if (in_array('TRIGGERS', $aGranular)) { $objectList['TRIGGERS'] = $data['tables']['workflow']['triggers']; } - if(in_array('TEMPLATES', $aGranular)){ + if (in_array('TEMPLATES', $aGranular)) { $objectList['TEMPLATES']['TABLE'] = $data['tables']['workflow']['filesManager']; - $objectList['TEMPLATES']['PATH'] = $data['files']['workflow']; + $objectList['TEMPLATES']['PATH'] = $data['files']['workflow']; } - if(in_array('FILES', $aGranular)){ + if (in_array('FILES', $aGranular)) { $objectList['FILES']['TABLE'] = $data['tables']['workflow']['filesManager']; - $objectList['FILES']['PATH'] = $data['files']['workflow']; + $objectList['FILES']['PATH'] = $data['files']['workflow']; } return $objectList; } @@ -59,21 +60,22 @@ class GranularImporter /** * Update the structure from File */ - public function structureBpmnData(array $tables){ + public function structureBpmnData(array $tables) + { $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(); - $project["diagrams"] = array($diagram); - $project["prj_author"] = isset($this->data["usr_uid"])? $this->data["usr_uid"]: "00000000000000000000000000000001"; - $project["process"] = $tables["process"][0]; + $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(); + $project["diagrams"] = array($diagram); + $project["prj_author"] = isset($this->data["usr_uid"]) ? $this->data["usr_uid"] : "00000000000000000000000000000001"; + $project["process"] = $tables["process"][0]; return $project; } @@ -85,7 +87,7 @@ class GranularImporter try { foreach ($objectList as $key => $data) { $objClass = $this->factory->create($key); - if(is_object($objClass)) { + if (is_object($objClass)) { $migratorData = $objClass->import($data); } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/InputDocumentsMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/InputDocumentsMigrator.php index 24d5a5eaa..8592ff62b 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/InputDocumentsMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/InputDocumentsMigrator.php @@ -25,6 +25,10 @@ class InputDocumentsMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + */ public function import($data, $replace) { try { @@ -33,10 +37,9 @@ class InputDocumentsMigrator implements Importable, Exportable } else { $this->processes->updateInputRows($data); } - } catch (\Exception $e) { \Logger::log($e->getMessage()); - throw new ImportException($e->getMessage()); + throwException(new ImportException($e->getMessage())); } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/OutputDocumentsMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/OutputDocumentsMigrator.php index 7ad2bbbf5..88a90b5f2 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/OutputDocumentsMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/OutputDocumentsMigrator.php @@ -27,6 +27,10 @@ class OutputDocumentsMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + */ public function import($data, $replace) { try { @@ -35,10 +39,9 @@ class OutputDocumentsMigrator implements Importable, Exportable } else { $this->processes->updateOutputRows($data); } - } catch (\Exception $e) { \Logger::log($e->getMessage()); - throw new ImportException($e->getMessage()); + throwException(new ImportException($e->getMessage())); } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/PermissionsMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/PermissionsMigrator.php index b3be41d87..3703aa672 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/PermissionsMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/PermissionsMigrator.php @@ -26,9 +26,22 @@ class PermissionsMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + */ public function import($data, $replace) { - + try { + if ($replace) { + $this->processes->createObjectPermissionsRows($data); + } else { + $this->processes->updateObjectPermissionRows($data); + } + } catch (\Exception $e) { + \Logger::log($e->getMessage()); + throwException(new ImportException($e->getMessage())); + } } public function afterImport($data) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/ProcessDefinitionMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/ProcessDefinitionMigrator.php index a142a3b4b..87cfec374 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/ProcessDefinitionMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/ProcessDefinitionMigrator.php @@ -81,7 +81,8 @@ class ProcessDefinitionMigrator implements Importable, Exportable $oData->tasks = $this->processes->getTaskRows($prj_uid); $oDataTask = new \StdClass(); - $oDataTask->taskusers = $this->processes->getTaskUserRows( $oData->tasks ); + $oDataTask->taskusers = $this->getTaskUserRows($oData->tasks); + $oData->routes = $this->processes->getRouteRows($prj_uid); $oData->lanes = $this->processes->getLaneRows($prj_uid); $oData->gateways = $this->processes->getGatewayRows($prj_uid); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/ReportTablesMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/ReportTablesMigrator.php index 851d2ed4c..5b8f3fded 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/ReportTablesMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/ReportTablesMigrator.php @@ -25,9 +25,23 @@ class ReportTablesMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + */ public function import($data, $replace) { - + try { + $aReportTablesVars = array(); + if ($replace) { + $this->processes->createReportTables($data, $aReportTablesVars); + } else { + $this->processes->updateReportTables($data, $aReportTablesVars); + } + } catch (\Exception $e) { + \Logger::log($e->getMessage()); + throwException(new ImportException($e->getMessage())); + } } public function afterImport($data) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/SupervisorsMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/SupervisorsMigrator.php index 3d363a6d8..a457ce955 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/SupervisorsMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/SupervisorsMigrator.php @@ -26,9 +26,22 @@ class SupervisorsMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + */ public function import($data, $replace) { - + try { + if ($replace) { + $this->processes->createProcessUser($data); + } else { + $this->processes->updateProcessUser($data); + } + } catch (\Exception $e) { + \Logger::log($e->getMessage()); + throwException(new ImportException($e->getMessage())); + } } public function afterImport($data) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/SupervisorsObjectsMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/SupervisorsObjectsMigrator.php index ffd9c967a..0c17b73fd 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/SupervisorsObjectsMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/SupervisorsObjectsMigrator.php @@ -25,9 +25,22 @@ class SupervisorsObjectsMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + */ public function import($data, $replace) { - + try { + if ($replace) { + $this->processes->createStepSupervisorRows($data); + } else { + $this->processes->updateStepSupervisorRows($data); + } + } catch (\Exception $e) { + \Logger::log($e->getMessage()); + throwException(new ImportException($e->getMessage())); + } } public function afterImport($data) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/TemplatesMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/TemplatesMigrator.php index 80fd529aa..d92e5393c 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/TemplatesMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/TemplatesMigrator.php @@ -27,22 +27,30 @@ class TemplatesMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + * @throws ImportException + */ public function import($data, $replace) { try { - //TABLE $aTable = $data['TABLE']; foreach ($aTable as $value) { - if($value['PRF_EDITABLE'] === 1){ - $this->processes->createFilesManager($value['PRO_UID'],array($value)); + if ($value['PRF_EDITABLE'] === 1) { + if ($replace) { + $this->processes->createFilesManager($value['PRO_UID'], array($value)); + } else { + $this->processes->updateFilesManager($value['PRO_UID'], array($value)); + } } } $aPath = $data['PATH']; foreach ($aPath as $target => $files) { $basePath = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'mailTemplates' . PATH_SEP; - if(strtoupper($target) === 'TEMPLATES'){ + if (strtoupper($target) === 'TEMPLATES') { foreach ($files as $file) { - $filename = $basePath . ((isset($file["file_path"]))? $file["file_path"] : $file["filepath"]); + $filename = $basePath . ((isset($file["file_path"])) ? $file["file_path"] : $file["filepath"]); $path = dirname($filename); if (!is_dir($path)) { diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/TriggersMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/TriggersMigrator.php index 69de754a6..4f52b131d 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/TriggersMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/TriggersMigrator.php @@ -27,6 +27,10 @@ class TriggersMigrator implements Importable, Exportable // TODO: Implement beforeImport() method. } + /** + * @param $data + * @param $replace + */ public function import($data, $replace) { try { @@ -35,7 +39,6 @@ class TriggersMigrator implements Importable, Exportable } else { $this->processes->updateTriggerRows($data); } - } catch (\Exception $e) { \Logger::log($e->getMessage()); throwException(new ImportException($e->getMessage())); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/VariablesMigrator.php b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/VariablesMigrator.php index d861a373b..9c0ea59c8 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/VariablesMigrator.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Migrator/VariablesMigrator.php @@ -29,8 +29,9 @@ class VariablesMigrator implements Importable, Exportable } /** - * Imports the process variables * @param $data + * @param $replace + * @throws ImportException */ public function import($data, $replace) {