MT-29: Adding a new set of exception handling classes.
This commit is contained in:
@@ -32,7 +32,8 @@ class AssignmentRulesMigrator implements Importable, Exportable
|
|||||||
try {
|
try {
|
||||||
$this->processes->createTaskRows($data);
|
$this->processes->createTaskRows($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ImportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +67,8 @@ class AssignmentRulesMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ExportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
namespace ProcessMaker\BusinessModel\Migrator;
|
namespace ProcessMaker\BusinessModel\Migrator;
|
||||||
|
|
||||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
|
||||||
|
|
||||||
class DBConnectionMigrator implements Importable, Exportable
|
class DBConnectionMigrator implements Importable, Exportable
|
||||||
{
|
{
|
||||||
protected $processes;
|
protected $processes;
|
||||||
@@ -32,7 +30,8 @@ class DBConnectionMigrator implements Importable, Exportable
|
|||||||
try {
|
try {
|
||||||
$this->processes->createDBConnectionsRows($data);
|
$this->processes->createDBConnectionsRows($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ImportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +62,8 @@ class DBConnectionMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ExportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ class DynaformsMigrator implements Importable, Exportable
|
|||||||
try {
|
try {
|
||||||
$this->processes->createDynaformRows($data);
|
$this->processes->createDynaformRows($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ImportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +60,8 @@ class DynaformsMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ExportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: gustav
|
||||||
|
* Date: 3/22/16
|
||||||
|
* Time: 10:06 AM
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace ProcessMaker\BusinessModel\Migrator;
|
||||||
|
|
||||||
|
|
||||||
|
class ExportException extends \Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -56,7 +56,8 @@ class FilesMigrator implements Importable, Exportable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ImportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +89,8 @@ class FilesMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ExportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class GranularExporter
|
|||||||
|
|
||||||
public function export($objectList)
|
public function export($objectList)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$this->beforeExport();
|
$this->beforeExport();
|
||||||
$exportObject = new ExportObjects();
|
$exportObject = new ExportObjects();
|
||||||
$objectList = $exportObject->mapObjectList($objectList);
|
$objectList = $exportObject->mapObjectList($objectList);
|
||||||
@@ -37,6 +38,13 @@ class GranularExporter
|
|||||||
$this->mergeData($migratorData);
|
$this->mergeData($migratorData);
|
||||||
}
|
}
|
||||||
return $this->publish();
|
return $this->publish();
|
||||||
|
} catch (ExportException $e) {
|
||||||
|
return array(
|
||||||
|
'success' => false,
|
||||||
|
'message' => $e->getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function beforeExport()
|
protected function beforeExport()
|
||||||
|
|||||||
@@ -82,11 +82,18 @@ class GranularImporter
|
|||||||
*/
|
*/
|
||||||
public function import($objectList)
|
public function import($objectList)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
foreach ($objectList as $key => $data) {
|
foreach ($objectList as $key => $data) {
|
||||||
$objClass = $this->factory->create($key);
|
$objClass = $this->factory->create($key);
|
||||||
if(is_object($objClass)) {
|
if(is_object($objClass)) {
|
||||||
$migratorData = $objClass->import($data);
|
$migratorData = $objClass->import($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (ExportException $e) {
|
||||||
|
return array(
|
||||||
|
'success' => false,
|
||||||
|
'message' => $e->getMessage()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: gustav
|
||||||
|
* Date: 3/22/16
|
||||||
|
* Time: 10:06 AM
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace ProcessMaker\BusinessModel\Migrator;
|
||||||
|
|
||||||
|
|
||||||
|
class ImportException extends \Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -30,7 +30,8 @@ class InputDocumentsMigrator implements Importable, Exportable
|
|||||||
try {
|
try {
|
||||||
$this->processes->createInputRows($data);
|
$this->processes->createInputRows($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ImportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +62,8 @@ class InputDocumentsMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ExportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ class OutputDocumentsMigrator implements Importable, Exportable
|
|||||||
try {
|
try {
|
||||||
$this->processes->createOutputRows($data);
|
$this->processes->createOutputRows($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ImportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +64,8 @@ class OutputDocumentsMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ExportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,18 +48,19 @@ class PermissionsMigrator implements Importable, Exportable
|
|||||||
public function export($prj_uid)
|
public function export($prj_uid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$processData = new \StdClass();
|
||||||
|
$processData->process = $this->processes->getProcessRow($prj_uid, false);
|
||||||
|
$processData->tasks = $this->processes->getTaskRows($prj_uid);
|
||||||
|
$processData->routes = $this->processes->getRouteRows($prj_uid);
|
||||||
|
$processData->lanes = $this->processes->getLaneRows($prj_uid);
|
||||||
|
$processData->gateways = $this->processes->getGatewayRows($prj_uid);
|
||||||
|
$processData->steps = $this->processes->getStepRows($prj_uid);
|
||||||
|
$processData->taskusers = $this->processes->getTaskUserRows($oData->tasks);
|
||||||
|
$processData->groupwfs = $this->processes->getGroupwfRows($oData->taskusers);
|
||||||
|
$processData->steptriggers = $this->processes->getStepTriggerRows($oData->tasks);
|
||||||
|
$processData->reportTablesVars = $this->processes->getReportTablesVarsRows($prj_uid);
|
||||||
$oData = new \StdClass();
|
$oData = new \StdClass();
|
||||||
$oData->process = $this->processes->getProcessRow($prj_uid, false);
|
$oData->objectPermissions = $this->processes->getObjectPermissionRows($prj_uid, $processData);
|
||||||
$oData->tasks = $this->processes->getTaskRows($prj_uid);
|
|
||||||
$oData->routes = $this->processes->getRouteRows($prj_uid);
|
|
||||||
$oData->lanes = $this->processes->getLaneRows($prj_uid);
|
|
||||||
$oData->gateways = $this->processes->getGatewayRows($prj_uid);
|
|
||||||
$oData->steps = $this->processes->getStepRows($prj_uid);
|
|
||||||
$oData->taskusers = $this->processes->getTaskUserRows($oData->tasks);
|
|
||||||
$oData->groupwfs = $this->processes->getGroupwfRows($oData->taskusers);
|
|
||||||
$oData->steptriggers = $this->processes->getStepTriggerRows($oData->tasks);
|
|
||||||
$oData->reportTablesVars = $this->processes->getReportTablesVarsRows($prj_uid);
|
|
||||||
$oData->objectPermissions = $this->processes->getObjectPermissionRows($prj_uid, $oData);
|
|
||||||
|
|
||||||
$result = array(
|
$result = array(
|
||||||
'workflow-definition' => (array)$oData
|
'workflow-definition' => (array)$oData
|
||||||
@@ -68,7 +69,8 @@ class PermissionsMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ExportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ class ProcessDefinitionMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throwException(new ExportException($e->getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ class ReportTablesMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throwException(new ExportException($e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ class SupervisorsMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throwException(new ExportException($e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ class SupervisorsObjectsMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throwException(new ExportException($e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ class TemplatesMigrator implements Importable, Exportable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ImportException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -92,7 +93,8 @@ class TemplatesMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ExportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ class TriggersMigrator implements Importable, Exportable
|
|||||||
try {
|
try {
|
||||||
$this->processes->createTriggerRows($data);
|
$this->processes->createTriggerRows($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throwException(new ImportException($e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +65,8 @@ class TriggersMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ExportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ class VariablesMigrator implements Importable, Exportable
|
|||||||
try {
|
try {
|
||||||
$this->processes->createProcessVariables($data);
|
$this->processes->createProcessVariables($data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ImportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +74,8 @@ class VariablesMigrator implements Importable, Exportable
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Logger::log($e);
|
\Logger::log($e->getMessage());
|
||||||
|
throw new ExportException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user