This commit is contained in:
dheeyi
2016-03-21 15:55:35 -04:00
parent f92e37141f
commit f0469125c3
17 changed files with 160 additions and 37 deletions

View File

@@ -10,7 +10,7 @@ namespace ProcessMaker\BusinessModel\Migrator;
* @package ProcessMaker\BusinessModel\Migrator
*/
class AssignmentRulesMigrator implements Importable
class AssignmentRulesMigrator implements Importable, Exportable
{
protected $processes;
@@ -41,4 +41,38 @@ class AssignmentRulesMigrator implements Importable
// TODO: Implement afterImport() method.
}
public function beforeExport()
{
// TODO: Implement beforeExport() method.
}
public function export($prj_uid)
{
try {
$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->triggers = $this->processes->getTriggerRows($prj_uid);
$oData->taskusers = $this->processes->getTaskUserRows($oData->tasks);
$result = array(
'workflow-definition' => (array)$oData
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()
{
// TODO: Implement afterExport() method.
}
}

View File

@@ -57,7 +57,7 @@ class DBConnectionMigrator implements Importable, Exportable
$oData->dbconnections = $this->processes->getDBConnectionsRows($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->dbconnections
'workflow-definition' => (array)$oData
);
return $result;

View File

@@ -75,7 +75,7 @@ class DynaformsMigrator implements Importable, Exportable
}
$result = array(
'workflow-definition' => (array)$oData->dynaforms,
'workflow-definition' => (array)$oData,
'workflow-files' => $workflowFile
);

View File

@@ -52,14 +52,14 @@ class FilesMigrator implements Importable, Exportable
{
try {
$oData = new \StdClass();
$oData->publicFiles = $this->processes->getFilesManager($prj_uid, 'PUBLIC');
$oData->filesManager = $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-definition' => (array)$oData,
'workflow-files' => $workflowFile
);

View File

@@ -55,7 +55,7 @@ class InputDocumentsMigrator implements Importable, Exportable
$oData->inputs = $this->processes->getInputRows($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->inputs
'workflow-definition' => (array)$oData
);
return $result;

View File

@@ -57,7 +57,7 @@ class OutputDocumentsMigrator implements Importable, Exportable
$oData->outputs = $this->processes->getOutputRows($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->outputs
'workflow-definition' => (array)$oData
);
return $result;

View File

@@ -12,6 +12,14 @@ namespace ProcessMaker\BusinessModel\Migrator;
class PMXGenerator
{
/**
* @var \DOMElement
*/
protected $rootNode;
/**
* @var \DOMDocument
*/
protected $domDocument;
/**
@@ -32,8 +40,8 @@ class PMXGenerator
*/
public function generate($data)
{
$rootNode = $this->domDocument->createElement($data['container_name']);
$rootNode->setAttribute("version", $data['container_name']);
$rootNode = $this->domDocument->createElement($data['container']);
$rootNode->setAttribute("version", $data['container']);
$this->domDocument->appendChild($rootNode);
$metadata = $data["metadata"];
@@ -62,7 +70,7 @@ class PMXGenerator
$recordData = array_change_key_case($recordData, CASE_LOWER);
foreach ($recordData as $key => $value) {
if(is_object($value)){
if (is_object($value)) {
$value = serialize($value);
}
$columnNode = $this->domDocument->createElement($key);
@@ -104,4 +112,17 @@ class PMXGenerator
$rootNode->appendChild($workflowFilesNode);
return $this->domDocument->saveXML($rootNode);
}
/**
* @param $value
* @return mixed
*/
private function getTextNode($value)
{
if (empty($value) || preg_match('/^[\w\s\.\-]+$/', $value, $match)) {
return $this->domDocument->createTextNode($value);
} else {
return $this->domDocument->createCDATASection($value);
}
}
}

View File

@@ -14,7 +14,7 @@ class PMXPublisher
{
public function publish($filename, $data)
{
$parentDir = dirname();
$parentDir = dirname($filename);
if (! is_dir($parentDir)) {
Util\Common::mk_dir($parentDir, 0775);
@@ -28,32 +28,32 @@ class PMXPublisher
return basename($outputFile);
}
public function truncateName($outputFile,$dirName = true)
public function truncateName($outputFile, $dirName = true)
{
$limit = 200;
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$limit = 150;
}
if($dirName) {
if ($dirName) {
if (strlen(basename($outputFile)) >= $limit) {
$lastPos = strrpos(basename($outputFile),'.');
$fileName = substr(basename($outputFile),0,$lastPos);
$newFileName = str_replace(".","_",$fileName);
$newFileName = str_replace(" ","_",$fileName);
$lastPos = strrpos(basename($outputFile), '.');
$fileName = substr(basename($outputFile), 0, $lastPos);
$newFileName = str_replace(".", "_", $fileName);
$newFileName = str_replace(" ", "_", $fileName);
$excess = strlen($newFileName) - $limit;
$newFileName = substr($newFileName,0,strlen($newFileName)-$excess);
$newOutputFile = str_replace($fileName,$newFileName,$outputFile);
$newFileName = substr($newFileName, 0, strlen($newFileName) - $excess);
$newOutputFile = str_replace($fileName, $newFileName, $outputFile);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$newOutputFile = str_replace("/", DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR, $newOutputFile);
$newOutputFile = str_replace("/", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, $newOutputFile);
}
$outputFile = $newOutputFile;
}
} else {
$outputFile = str_replace(".","_",$outputFile);
$outputFile = str_replace(" ","_",$outputFile);
$outputFile = str_replace(".", "_", $outputFile);
$outputFile = str_replace(" ", "_", $outputFile);
if (strlen($outputFile) >= $limit) {
$excess = strlen($outputFile) - $limit;
$newFileName = substr($outputFile,0,strlen($outputFile)-$excess);
$newFileName = substr($outputFile, 0, strlen($outputFile) - $excess);
$outputFile = $newFileName;
}
}

View File

@@ -9,8 +9,18 @@
namespace ProcessMaker\BusinessModel\Migrator;
class PermissionsMigrator implements Importable
class PermissionsMigrator implements Importable, Exportable
{
protected $processes;
/**
* PermissionsMigrator constructor.
*/
public function __construct()
{
$this->processes = new \Processes();
}
public function beforeImport($data)
{
// TODO: Implement beforeImport() method.
@@ -26,4 +36,44 @@ class PermissionsMigrator 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();
$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);
$result = array(
'workflow-definition' => (array)$oData
);
return $result;
} catch (\Exception $e) {
\Logger::log($e);
}
}
public function afterExport()
{
// TODO: Implement afterExport() method.
}
}

View File

@@ -79,11 +79,9 @@ class ProcessDefinitionMigrator implements Importable, Exportable
$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);
@@ -93,7 +91,6 @@ class ProcessDefinitionMigrator implements Importable, Exportable
$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);
@@ -102,7 +99,6 @@ class ProcessDefinitionMigrator implements Importable, Exportable
$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";

View File

@@ -51,7 +51,7 @@ class ReportTablesMigrator implements Importable, Exportable
$oData->reportTables = $this->processes->getReportTablesRows($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->reportTables
'workflow-definition' => (array)$oData
);
return $result;

View File

@@ -49,10 +49,10 @@ class SupervisorsMigrator implements Importable, Exportable
{
try {
$oData = new \StdClass();
$oData->stepSupervisor = $this->processes->getStepSupervisorRows($prj_uid);
$oData->processUser = $this->processes->getProcessUser($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->stepSupervisor
'workflow-definition' => (array)$oData
);
return $result;

View File

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

View File

@@ -86,13 +86,13 @@ class TemplatesMigrator implements Importable, Exportable
try {
$oData = new \StdClass();
$arrayExcludeFile = array();
$oData->templates = $this->processes->getFilesManager($prj_uid, 'TEMPLATES');
$oData->filesManager = $this->processes->getFilesManager($prj_uid, 'TEMPLATES');
$fileHandler = new FileHandler();
$workflowFile = $fileHandler->getTemplatesOrPublicFiles($prj_uid, $arrayExcludeFile, 'TEMPLATES');
$result = array(
'workflow-definition' => (array)$oData->templates,
'workflow-definition' => (array)$oData,
'workflow-files' => $workflowFile
);

View File

@@ -58,7 +58,7 @@ class TriggersMigrator implements Importable, Exportable
$oData->steptriggers = $this->processes->getStepTriggerRows($oDataTasks);
$result = array(
'workflow-definition' => (array)$oData->steptriggers
'workflow-definition' => (array)$oData
);
return $result;

View File

@@ -37,7 +37,7 @@ class VariablesMigrator implements Importable, Exportable
try {
$this->processes->createProcessVariables($data);
} catch (\Exception $e) {
Logger::log($e);
\Logger::log($e);
}
}
@@ -67,7 +67,7 @@ class VariablesMigrator implements Importable, Exportable
$oData->processVariables = $this->processes->getProcessVariables($prj_uid);
$result = array(
'workflow-definition' => (array)$oData->processVariables
'workflow-definition' => (array)$oData
);
return $result;