Merge remote-tracking branch 'upstream/MT-10' into MT-10
This commit is contained in:
@@ -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") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$exception = new ImportException();
|
$exception = new ImportException();
|
||||||
$exception->setNameException('To create a new process needs PROCESSDEFINITION');
|
$exception->setNameException('To create a new process needs PROCESSDEFINITION');
|
||||||
throw($exception);
|
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());
|
||||||
@@ -61,8 +61,8 @@ class ReportTablesMigrator implements Importable, Exportable
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$oData = new \StdClass();
|
$oData = new \StdClass();
|
||||||
$oData->reportTables = $this->processes->getReportTables($prj_uid);
|
$oDataReportTables = $this->processes->getReportTables($prj_uid);
|
||||||
$oData->reportTablesVars = $this->processes->getReportTablesVar($prj_uid);
|
$oData->reportContent[0] = $this->getData($oDataReportTables);
|
||||||
|
|
||||||
$result = array(
|
$result = array(
|
||||||
'workflow-definition' => (array)$oData
|
'workflow-definition' => (array)$oData
|
||||||
@@ -82,4 +82,74 @@ class ReportTablesMigrator implements Importable, Exportable
|
|||||||
// TODO: Implement afterExport() method.
|
// TODO: Implement afterExport() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $oDataReportTables
|
||||||
|
* @return array
|
||||||
|
* @throws ExportException
|
||||||
|
*/
|
||||||
|
public function getData($oDataReportTables)
|
||||||
|
{
|
||||||
|
$oData = array();
|
||||||
|
$at = new \AdditionalTables();
|
||||||
|
try {
|
||||||
|
\G::LoadCLass('net');
|
||||||
|
$net = new \NET(\G::getIpAddress());
|
||||||
|
\G::LoadClass("system");
|
||||||
|
$META = " \n-----== ProcessMaker Open Source Private Tables ==-----\n" . " @Ver: 1.0 Oct-2009\n" . " @Processmaker version: " . \System::getVersion() . "\n" . " -------------------------------------------------------\n" . " @Export Date: " . date("l jS \of F Y h:i:s A") . "\n" . " @Server address: " . getenv('SERVER_NAME') . " (" . getenv('SERVER_ADDR') . ")\n" . " @Client address: " . $net->hostname . "\n" . " @Workspace: " . SYS_SYS . "\n" . " @Export trace back:\n\n";
|
||||||
|
$EXPORT_TRACEBACK = Array();
|
||||||
|
foreach ($oDataReportTables as $table) {
|
||||||
|
$tableRecord = $at->load($table['ADD_TAB_UID']);
|
||||||
|
$tableData = $at->getAllData($table['ADD_TAB_UID'], null, null, false);
|
||||||
|
$table['ADD_TAB_NAME'] = $tableRecord['ADD_TAB_NAME'];
|
||||||
|
$rows = $tableData['rows'];
|
||||||
|
$count = $tableData['count'];
|
||||||
|
array_push($EXPORT_TRACEBACK, Array('uid' => $table['ADD_TAB_UID'], 'name' => $table['ADD_TAB_NAME'],
|
||||||
|
'num_regs' => $tableData['count'], 'schema' => 'yes', 'data' => 'no'));
|
||||||
|
}
|
||||||
|
$sTrace = "TABLE UID TABLE NAME\tREGS\tSCHEMA\tDATA\n";
|
||||||
|
foreach ($EXPORT_TRACEBACK as $row) {
|
||||||
|
$sTrace .= "{$row['uid']}\t{$row['name']}\t\t{$row['num_regs']}\t{$row['schema']}\t{$row['data']}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$META .= $sTrace;
|
||||||
|
$PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP;
|
||||||
|
$filenameOnly = strtolower('SYS-' . SYS_SYS . "_" . date("Y-m-d") . '_' . date("Hi") . ".pmt");
|
||||||
|
$filename = $PUBLIC_ROOT_PATH . $filenameOnly;
|
||||||
|
$fp = fopen($filename, "wb");
|
||||||
|
|
||||||
|
$bytesSaved = 0;
|
||||||
|
$bufferType = '@META';
|
||||||
|
$fsData = sprintf("%09d", strlen($META));
|
||||||
|
$fsbufferType = sprintf("%09d", strlen($bufferType));
|
||||||
|
$bytesSaved += fwrite($fp, $fsbufferType);
|
||||||
|
$bytesSaved += fwrite($fp, $bufferType);
|
||||||
|
$bytesSaved += fwrite($fp, $fsData);
|
||||||
|
$bytesSaved += fwrite($fp, $META);
|
||||||
|
|
||||||
|
foreach ($oDataReportTables as $table) {
|
||||||
|
$oAdditionalTables = new \AdditionalTables();
|
||||||
|
$aData = $oAdditionalTables->load($table['ADD_TAB_UID'], true);
|
||||||
|
$bufferType = '@SCHEMA';
|
||||||
|
$SDATA = serialize($aData);
|
||||||
|
$fsUid = sprintf("%09d", strlen($table['ADD_TAB_UID']));
|
||||||
|
$fsData = sprintf("%09d", strlen($SDATA));
|
||||||
|
$fsbufferType = sprintf("%09d", strlen($bufferType));
|
||||||
|
$bytesSaved += fwrite($fp, $fsbufferType);
|
||||||
|
$bytesSaved += fwrite($fp, $bufferType);
|
||||||
|
$bytesSaved += fwrite($fp, $fsUid);
|
||||||
|
$bytesSaved += fwrite($fp, $table['ADD_TAB_UID']);
|
||||||
|
$bytesSaved += fwrite($fp, $fsData);
|
||||||
|
$bytesSaved += fwrite($fp, $SDATA);
|
||||||
|
}
|
||||||
|
$oData['REPORTDATA'] = file_get_contents($filename);
|
||||||
|
fclose($fp);
|
||||||
|
return $oData;
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$exception = new ExportException($e->getMessage());
|
||||||
|
$exception->setNameException($this->className);
|
||||||
|
throw($exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -220,13 +220,30 @@ 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"];
|
||||||
|
$processGranulate = $granularObj->validateImportData($objectsToImport, $generateUid);
|
||||||
|
if($generateUid){
|
||||||
|
$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) {
|
if (sizeof($objectList) > 0 && $processGranulate) {
|
||||||
$granularObj->import($objectList);
|
$granularObj->import($objectList);
|
||||||
return $this->importData['tables']['bpmn']["project"][0]["prj_uid"];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $projectUid;
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1039,8 +1039,8 @@ function exportImportProcessObjects(typeAction)
|
|||||||
storeActionField = new Ext.data.ArrayStore({
|
storeActionField = new Ext.data.ArrayStore({
|
||||||
fields: ['value', 'text'],
|
fields: ['value', 'text'],
|
||||||
data: [
|
data: [
|
||||||
[1, _('ID_UPDATE')],
|
[1, _('ID_ADD_TO_EXISTING')],
|
||||||
[2, _('ID_OVERWRITE')]
|
[2, _('ID_REPLACE_ALL')]
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
checkBoxSelMod = new Ext.grid.CheckboxSelectionModel();
|
checkBoxSelMod = new Ext.grid.CheckboxSelectionModel();
|
||||||
@@ -1083,7 +1083,8 @@ function exportImportProcessObjects(typeAction)
|
|||||||
store: storeActionField,
|
store: storeActionField,
|
||||||
triggerAction: 'all',
|
triggerAction: 'all',
|
||||||
valueField: 'value',
|
valueField: 'value',
|
||||||
lazyRender: true
|
lazyRender: true,
|
||||||
|
disabled: false
|
||||||
}),
|
}),
|
||||||
renderer: function(value) {
|
renderer: function(value) {
|
||||||
var recordIndex = storeActionField.find('value', value);
|
var recordIndex = storeActionField.find('value', value);
|
||||||
@@ -1110,9 +1111,18 @@ function exportImportProcessObjects(typeAction)
|
|||||||
if(!inArray(row.get('OBJECT_ID'),importProcessGlobal.objectGranularImport)) {
|
if(!inArray(row.get('OBJECT_ID'),importProcessGlobal.objectGranularImport)) {
|
||||||
store.remove(row);
|
store.remove(row);
|
||||||
}
|
}
|
||||||
|
if(row.get('OBJECT_ID') === 1) { /*process definition*/
|
||||||
|
row.set("OBJECT_ACTION","2");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
beforeedit: function(editor, e, eOpts) {
|
||||||
|
var row = editor.record;
|
||||||
|
if(row.get('OBJECT_ID') === 1) { /*process definition*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1403,10 +1413,11 @@ importProcessExistGroup = function()
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: function(o, resp) {
|
failure: function(o, resp) {
|
||||||
|
var msg = resp.result.msg ? resp.result.msg : resp.response.responseText;
|
||||||
w.close();
|
w.close();
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title : _('ID_ERROR'),
|
title : _('ID_ERROR'),
|
||||||
msg : resp.result.msg,
|
msg : msg,
|
||||||
buttons : Ext.MessageBox.OK,
|
buttons : Ext.MessageBox.OK,
|
||||||
animEl : 'mb9',
|
animEl : 'mb9',
|
||||||
fn : function(){},
|
fn : function(){},
|
||||||
@@ -1602,10 +1613,11 @@ importProcessExistProcess = function()
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure : function(o, resp) {
|
failure : function(o, resp) {
|
||||||
|
var msg = resp.result.msg ? resp.result.msg : resp.response.responseText;
|
||||||
w.close();
|
w.close();
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title : _('ID_ERROR'),
|
title : _('ID_ERROR'),
|
||||||
msg : resp.result.msg,
|
msg : msg,
|
||||||
buttons : Ext.MessageBox.OK,
|
buttons : Ext.MessageBox.OK,
|
||||||
animEl : 'mb9',
|
animEl : 'mb9',
|
||||||
fn : function(){},
|
fn : function(){},
|
||||||
@@ -1893,11 +1905,11 @@ importProcess = function()
|
|||||||
},
|
},
|
||||||
failure : function(o, resp)
|
failure : function(o, resp)
|
||||||
{
|
{
|
||||||
|
var msg = resp.catchMessage ? resp.catchMessage : resp.response.responseText;
|
||||||
w.close();
|
w.close();
|
||||||
|
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title : "",
|
title : "",
|
||||||
msg : resp.catchMessage,
|
msg : msg,
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
animEl : "mb9",
|
animEl : "mb9",
|
||||||
fn : function(){},
|
fn : function(){},
|
||||||
@@ -2015,10 +2027,11 @@ importProcessBpmnSubmit = function () {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
failure: function (o, resp) {
|
failure: function (o, resp) {
|
||||||
|
var msg = resp.catchMessage ? resp.catchMessage : resp.response.responseText;
|
||||||
Ext.getCmp('importProcessWindow').close();
|
Ext.getCmp('importProcessWindow').close();
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: '',
|
title: '',
|
||||||
msg: resp.catchMessage,
|
msg: msg,
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
animEl: 'mb9',
|
animEl: 'mb9',
|
||||||
fn: function () {
|
fn: function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user