MT-10 Export fixes

This commit is contained in:
dheeyi
2016-03-21 13:42:24 -04:00
parent 9ba45e6ce3
commit f92e37141f
14 changed files with 411 additions and 96 deletions

View File

@@ -46,12 +46,25 @@ class DBConnectionMigrator implements Importable, Exportable
// TODO: Implement beforeExport() method.
}
/**
* @param $prj_uid
* @return array
*/
public function export($prj_uid)
{
$oProcess = new \Process();
$oData = new \StdClass();
$oData->dbconnections = $oProcess->getDBConnectionsRows($prj_uid);
return $oData;
try {
$oData = new \StdClass();
$oData->dbconnections = $this->processes->getDBConnectionsRows($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->dbconnections
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()

View File

@@ -43,12 +43,47 @@ class DynaformsMigrator implements Importable, Exportable
// TODO: Implement beforeExport() method.
}
/**
* @param $prj_uid
* @return array
*/
public function export($prj_uid)
{
$oProcess = new \Process();
$oData = new \StdClass();
$oData->dynaforms = $oProcess->getDynaformRows($prj_uid);
return $oData;
try {
$oData = new \StdClass();
$oData->dynaforms = $this->processes->getDynaformRows($prj_uid);
$workflowFile = array();
foreach ($oData->dynaforms as $dynaform) {
$dynFile = PATH_DYNAFORM . $dynaform['DYN_FILENAME'] . '.xml';
$workflowFile['DYNAFORMS'][] = array(
"filename" => $dynaform['DYN_TITLE'],
"filepath" => $dynaform['DYN_FILENAME'] . '.xml',
"file_content" => file_get_contents($dynFile)
);
$htmlFile = PATH_DYNAFORM . $dynaform['DYN_FILENAME'] . '.html';
if (file_exists($htmlFile)) {
$workflowFile['DYNAFORMS'][] = array(
"filename" => $dynaform['DYN_FILENAME'] . '.html',
"filepath" => $dynaform['DYN_FILENAME'] . '.html',
"file_content" => file_get_contents($htmlFile)
);
}
}
$result = array(
'workflow-definition' => (array)$oData->dynaforms,
'workflow-files' => $workflowFile
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()

View File

@@ -54,13 +54,8 @@ class ExportObjects
{
try {
$mapObjectList = array();
foreach ($this->objectsList as $key => $val) {
if(isset($objects[$key])){
if(($key+1) === $objects[$key]){
array_push($mapObjectList, strtoupper(str_replace(' ', '', $val)));
}
}
$key++;
foreach ($objects as $objectId) {
array_push($mapObjectList, strtoupper(str_replace(' ', '', $this->objectsList[$objectId - 1])));
}
return $mapObjectList;
} catch (\Exception $e) {

View File

@@ -0,0 +1,78 @@
<?php
/**
*
*
*
*/
namespace ProcessMaker\BusinessModel\Migrator;
use ProcessMaker\Util;
class FileHandler
{
/**
* @param $prj_uid
* @return array
*/
public function getFilesToExclude($prj_uid)
{
try {
$arrayPublicFileToExclude = array("wsClient.php");
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\WebEntryPeer::WE_DATA);
$criteria->add(\WebEntryPeer::PRO_UID, $prj_uid, \Criteria::EQUAL);
$criteria->add(\WebEntryPeer::WE_METHOD, "WS", \Criteria::EQUAL);
$rsCriteria = \WebEntryPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$arrayPublicFileToExclude[] = $row["WE_DATA"];
$arrayPublicFileToExclude[] = preg_replace("/^(.+)\.php$/", "$1Post.php", $row["WE_DATA"]);
}
return $arrayPublicFileToExclude;
} catch (\Exception $e) {
\Logger::log($e);
}
}
/**
* @param $prj_uid
* @param $arrayPublicFileToExclude
* @param $target
* @return array
*/
public function getTemplatesOrPublicFiles($prj_uid, $arrayPublicFileToExclude = array(), $target)
{
$workflowFile = array();
$workspaceTargetDir = ($target === 'PUBLIC') ? 'public' : 'mailTemplates';
$workspaceDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP;
$templatesDir = $workspaceDir . $workspaceTargetDir . PATH_SEP . $prj_uid;
$templatesFiles = Util\Common::rglob("$templatesDir/*", 0, true);
foreach ($templatesFiles as $templatesFile) {
if (is_dir($templatesFile)) {
continue;
}
$filename = basename($templatesFile);
if ($target == "PUBLIC" && in_array($filename, $arrayPublicFileToExclude)) {
continue;
}
$workflowFile[$target][] = array(
"filename" => $filename,
"filepath" => $prj_uid . PATH_SEP . $filename,
"file_content" => file_get_contents($templatesFile)
);
}
return $workflowFile;
}
}

View File

@@ -8,9 +8,11 @@
namespace ProcessMaker\BusinessModel\Migrator;
use ProcessMaker\BusinessModel\Process;
use Symfony\Component\Config\Definition\Exception\Exception;
use \ProcessMaker\BusinessModel\Migrator\FileHandler;
class FilesMigrator implements Importable
class FilesMigrator implements Importable, Exportable
{
protected $processes;
@@ -40,4 +42,36 @@ class FilesMigrator implements Importable
{
// TODO: Implement afterImport() method.
}
public function beforeExport()
{
// TODO: Implement beforeExport() method.
}
public function export($prj_uid)
{
try {
$oData = new \StdClass();
$oData->publicFiles = $this->processes->getFilesManager($prj_uid, 'PUBLIC');
$fileHandler = new FileHandler();
$arrayPublicFileToExclude = $fileHandler->getFilesToExclude($prj_uid);
$workflowFile = $fileHandler->getTemplatesOrPublicFiles($prj_uid, $arrayPublicFileToExclude, 'PUBLIC');
$result = array(
'workflow-definition' => (array)$oData->publicFiles,
'workflow-files' => $workflowFile
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()
{
// TODO: Implement afterExport() method.
}
}

View File

@@ -75,7 +75,7 @@ class GranularExporter
protected function mergeData($migratorData)
{
$this->data(array_merge_recursive($this->data, $migratorData));
$this->data = array_merge_recursive($this->data, $migratorData);
}
public function publish()

View File

@@ -44,12 +44,25 @@ class InputDocumentsMigrator implements Importable, Exportable
// TODO: Implement beforeExport() method.
}
/**
* @param $prj_uid
* @return array
*/
public function export($prj_uid)
{
$oProcess = new \Process();
$oData = new \StdClass();
$oData->inputs = $oProcess->getInputRows($prj_uid);
return $oData;
try {
$oData = new \StdClass();
$oData->inputs = $this->processes->getInputRows($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->inputs
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()

View File

@@ -46,12 +46,25 @@ class OutputDocumentsMigrator implements Importable, Exportable
// TODO: Implement beforeExport() method.
}
/**
* @param $prj_uid
* @return array
*/
public function export($prj_uid)
{
$oProcess = new \Process();
$oData = new \StdClass();
$oData->outputs = $oProcess->getOutputRows($prj_uid);
return $oData;
try {
$oData = new \StdClass();
$oData->outputs = $this->processes->getOutputRows($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->outputs
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()

View File

@@ -14,6 +14,7 @@ use Symfony\Component\Config\Definition\Exception\Exception;
class ProcessDefinitionMigrator implements Importable, Exportable
{
protected $bpmn;
protected $processes;
/**
* ProcessDefinitionMigrator constructor.
@@ -21,6 +22,7 @@ class ProcessDefinitionMigrator implements Importable, Exportable
public function __construct()
{
$this->bpmn = new Adapter\BpmnWorkflow();
$this->processes = new \Processes();
}
public function beforeImport($data)
@@ -47,66 +49,74 @@ class ProcessDefinitionMigrator implements Importable, Exportable
// TODO: Implement beforeExport() method.
}
/**
* @param $prj_uid
* @return array
*/
public function export($prj_uid)
{
$bpmnStruct["ACTIVITY"] = \BpmnActivity::getAll($prj_uid);
$bpmnStruct["ARTIFACT"] = \BpmnArtifact::getAll($prj_uid);
$bpmnStruct["BOUND"] = \BpmnBound::getAll($prj_uid);
$bpmnStruct["DATA"] = \BpmnData::getAll($prj_uid);
$bpmnStruct["DIAGRAM"] = \BpmnDiagram::getAll($prj_uid);
$bpmnStruct["DOCUMENTATION"] = array();
$bpmnStruct["EVENT"] = \BpmnEvent::getAll($prj_uid);
$bpmnStruct["EXTENSION"] = array();
$bpmnStruct["FLOW"] = \BpmnFlow::getAll($prj_uid, null, null, "", CASE_UPPER, false);
$bpmnStruct["GATEWAY"] = \BpmnGateway::getAll($prj_uid);
$bpmnStruct["LANE"] = \BpmnLane::getAll($prj_uid);
$bpmnStruct["LANESET"] = \BpmnLaneset::getAll($prj_uid);
$bpmnStruct["PARTICIPANT"] = \BpmnParticipant::getAll($prj_uid);
$bpmnStruct["PROCESS"] = \BpmnProcess::getAll($prj_uid);
$bpmnStruct["PROJECT"] = array(\BpmnProjectPeer::retrieveByPK($prj_uid)->toArray());
try {
$bpmnStruct["ACTIVITY"] = \BpmnActivity::getAll($prj_uid);
$bpmnStruct["ARTIFACT"] = \BpmnArtifact::getAll($prj_uid);
$bpmnStruct["BOUND"] = \BpmnBound::getAll($prj_uid);
$bpmnStruct["DATA"] = \BpmnData::getAll($prj_uid);
$bpmnStruct["DIAGRAM"] = \BpmnDiagram::getAll($prj_uid);
$bpmnStruct["DOCUMENTATION"] = array();
$bpmnStruct["EVENT"] = \BpmnEvent::getAll($prj_uid);
$bpmnStruct["EXTENSION"] = array();
$bpmnStruct["FLOW"] = \BpmnFlow::getAll($prj_uid, null, null, "", CASE_UPPER, false);
$bpmnStruct["GATEWAY"] = \BpmnGateway::getAll($prj_uid);
$bpmnStruct["LANE"] = \BpmnLane::getAll($prj_uid);
$bpmnStruct["LANESET"] = \BpmnLaneset::getAll($prj_uid);
$bpmnStruct["PARTICIPANT"] = \BpmnParticipant::getAll($prj_uid);
$bpmnStruct["PROCESS"] = \BpmnProcess::getAll($prj_uid);
$bpmnStruct["PROJECT"] = array(\BpmnProjectPeer::retrieveByPK($prj_uid)->toArray());
$oProcess = new \Processes();
$oData = new \StdClass();
$oData->process = $oProcess->getProcessRow($prj_uid, false);
$oData->tasks = $oProcess->getTaskRows($prj_uid);
$oData->routes = $oProcess->getRouteRows($prj_uid);
$oData->lanes = $oProcess->getLaneRows($prj_uid);
$oData->gateways = $oProcess->getGatewayRows($prj_uid);
$oData->steps = $oProcess->getStepRows($prj_uid);
$oData->taskusers = $oProcess->getTaskUserRows($oData->tasks);
$oData->groupwfs = $oProcess->getGroupwfRows($oData->taskusers);
$oData->steptriggers = $oProcess->getStepTriggerRows($oData->tasks);
$oData->reportTablesVars = $oProcess->getReportTablesVarsRows($prj_uid);
$oData->objectPermissions = $oProcess->getObjectPermissionRows($prj_uid, $oData);
$oData->subProcess = $oProcess->getSubProcessRow($prj_uid);
$oData->caseTracker = $oProcess->getCaseTrackerRow($prj_uid);
$oData->caseTrackerObject = $oProcess->getCaseTrackerObjectRow($prj_uid);
$oData->stage = $oProcess->getStageRow($prj_uid);
$oData->fieldCondition = $oProcess->getFieldCondition($prj_uid);
$oData->event = $oProcess->getEventRow($prj_uid);
$oData->caseScheduler = $oProcess->getCaseSchedulerRow($prj_uid);
$oData->processCategory = $oProcess->getProcessCategoryRow($prj_uid);
$oData->taskExtraProperties = $oProcess->getTaskExtraPropertiesRows($prj_uid);
$oData->processUser = $oProcess->getProcessUser($prj_uid);
$oData->processVariables = $oProcess->getProcessVariables($prj_uid);
$oData->webEntry = $oProcess->getWebEntries($prj_uid);
$oData->webEntryEvent = $oProcess->getWebEntryEvents($prj_uid);
$oData->messageType = $oProcess->getMessageTypes($prj_uid);
$oData->messageTypeVariable = $oProcess->getMessageTypeVariables($prj_uid);
$oData->messageEventDefinition = $oProcess->getMessageEventDefinitions($prj_uid);
$oData->scriptTask = $oProcess->getScriptTasks($prj_uid);
$oData->timerEvent = $oProcess->getTimerEvents($prj_uid);
$oData->emailEvent = $oProcess->getEmailEvent($prj_uid);
$oData->filesManager = $oProcess->getFilesManager($prj_uid);
$oData->abeConfiguration = $oProcess->getActionsByEmail($prj_uid);
$oData->groupwfs = $oProcess->groupwfsMerge($oData->groupwfs, $oData->processUser, "USR_UID");
$oData->process["PRO_TYPE_PROCESS"] = "PUBLIC";
$oData = new \StdClass();
$oData->process = $this->processes->getProcessRow($prj_uid, false);
$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);
$oData->subProcess = $this->processes->getSubProcessRow($prj_uid);
$oData->caseTracker = $this->processes->getCaseTrackerRow($prj_uid);
$oData->caseTrackerObject = $this->processes->getCaseTrackerObjectRow($prj_uid);
$oData->stage = $this->processes->getStageRow($prj_uid);
$oData->fieldCondition = $this->processes->getFieldCondition($prj_uid);
$oData->event = $this->processes->getEventRow($prj_uid);
$oData->caseScheduler = $this->processes->getCaseSchedulerRow($prj_uid);
$oData->processCategory = $this->processes->getProcessCategoryRow($prj_uid);
$oData->taskExtraProperties = $this->processes->getTaskExtraPropertiesRows($prj_uid);
$oData->processUser = $this->processes->getProcessUser($prj_uid);
$oData->webEntry = $this->processes->getWebEntries($prj_uid);
$oData->webEntryEvent = $this->processes->getWebEntryEvents($prj_uid);
$oData->messageType = $this->processes->getMessageTypes($prj_uid);
$oData->messageTypeVariable = $this->processes->getMessageTypeVariables($prj_uid);
$oData->messageEventDefinition = $this->processes->getMessageEventDefinitions($prj_uid);
$oData->scriptTask = $this->processes->getScriptTasks($prj_uid);
$oData->timerEvent = $this->processes->getTimerEvents($prj_uid);
$oData->emailEvent = $this->processes->getEmailEvent($prj_uid);
//$oData->filesManager = $this->processes->getFilesManager($prj_uid);
$oData->abeConfiguration = $this->processes->getActionsByEmail($prj_uid);
$oData->groupwfs = $this->processes->groupwfsMerge($oData->groupwfs, $oData->processUser, "USR_UID");
$oData->process["PRO_TYPE_PROCESS"] = "PUBLIC";
$result = array(
'bpmn-definition' => $bpmnStruct,
'workflow-definition' => (array)$oData
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
$result = array(
'bpmn-definition' => $bpmnStruct,
'workflow-definition' => (array)$oData
);
return $result;
}
public function afterExport()

View File

@@ -10,6 +10,16 @@ namespace ProcessMaker\BusinessModel\Migrator;
class ReportTablesMigrator implements Importable, Exportable
{
protected $processes;
/**
* ReportTablesMigrator constructor.
*/
public function __construct()
{
$this->processes = new \Processes();
}
public function beforeImport($data)
{
// TODO: Implement beforeImport() method.
@@ -30,12 +40,25 @@ class ReportTablesMigrator implements Importable, Exportable
// TODO: Implement beforeExport() method.
}
/**
* @param $prj_uid
* @return array
*/
public function export($prj_uid)
{
$oProcess = new \Processes();
$oData = new \StdClass();
$oData->reportTables = $oProcess->getReportTablesRows($prj_uid);
return $oData;
try {
$oData = new \StdClass();
$oData->reportTables = $this->processes->getReportTablesRows($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->reportTables
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()

View File

@@ -11,6 +11,16 @@ namespace ProcessMaker\BusinessModel\Migrator;
class SupervisorsMigrator implements Importable, Exportable
{
protected $processes;
/**
* SupervisorsMigrator constructor.
*/
public function __construct()
{
$this->processes = new \Processes();
}
public function beforeImport($data)
{
// TODO: Implement beforeImport() method.
@@ -31,12 +41,25 @@ class SupervisorsMigrator implements Importable, Exportable
// TODO: Implement beforeExport() method.
}
/**
* @param $prj_uid
* @return array
*/
public function export($prj_uid)
{
$oProcess = new \Processes();
$oData = new \StdClass();
$oData->stepSupervisor = $oProcess->getStepSupervisorRows($prj_uid);
return $oData;
try {
$oData = new \StdClass();
$oData->stepSupervisor = $this->processes->getStepSupervisorRows($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->stepSupervisor
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()

View File

@@ -10,7 +10,7 @@ namespace ProcessMaker\BusinessModel\Migrator;
use Symfony\Component\Config\Definition\Exception\Exception;
class TemplatesMigrator implements Importable
class TemplatesMigrator implements Importable, Exportable
{
protected $processes;
@@ -72,4 +72,39 @@ class TemplatesMigrator implements Importable
// TODO: Implement afterImport() method.
}
public function beforeExport()
{
// TODO: Implement beforeExport() method.
}
/**
* @param $prj_uid
* @return array
*/
public function export($prj_uid)
{
try {
$oData = new \StdClass();
$arrayExcludeFile = array();
$oData->templates = $this->processes->getFilesManager($prj_uid, 'TEMPLATES');
$fileHandler = new FileHandler();
$workflowFile = $fileHandler->getTemplatesOrPublicFiles($prj_uid, $arrayExcludeFile, 'TEMPLATES');
$result = array(
'workflow-definition' => (array)$oData->templates,
'workflow-files' => $workflowFile
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()
{
// TODO: Implement afterExport() method.
}
}

View File

@@ -46,13 +46,26 @@ class TriggersMigrator implements Importable, Exportable
// TODO: Implement beforeExport() method.
}
/**
* @param $prj_uid
* @return array
*/
public function export($prj_uid)
{
$process = new \Processes();
$oData = new \StdClass();
$oDataTasks = $process->getTaskRows($prj_uid);
$oData->steptriggers = $process->getStepTriggerRows($oDataTasks);
return $oData;
try {
$oData = new \StdClass();
$oDataTasks = $this->processes->getTaskRows($prj_uid);
$oData->steptriggers = $this->processes->getStepTriggerRows($oDataTasks);
$result = array(
'workflow-definition' => (array)$oData->steptriggers
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()

View File

@@ -7,7 +7,7 @@ namespace ProcessMaker\BusinessModel\Migrator;
* @package ProcessMaker\BusinessModel\Migrator
*/
class VariablesMigrator implements Importable
class VariablesMigrator implements Importable, Exportable
{
protected $processes;
@@ -51,4 +51,34 @@ class VariablesMigrator implements Importable
}
public function beforeExport()
{
// TODO: Implement beforeExport() method.
}
/**
* @param $prj_uid
* @return array
*/
public function export($prj_uid)
{
try {
$oData = new \StdClass();
$oData->processVariables = $this->processes->getProcessVariables($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->processVariables
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()
{
// TODO: Implement afterExport() method.
}
}