Merged in mcuiza/processmaker/HOR-255 (pull request #3763)

HOR-255
This commit is contained in:
Julio Cesar Laura Avendaño
2016-03-01 16:41:55 -04:00
3 changed files with 156 additions and 6 deletions

View File

@@ -117,7 +117,17 @@ if (isset($_FILES["PROCESS_FILENAME"]) &&
$importer->setSourceFromGlobals("PROCESS_FILENAME");
try {
$opt1 = XmlImporter::IMPORT_OPTION_CREATE_NEW;
$opt2 = XmlImporter::GROUP_IMPORT_OPTION_CREATE_NEW;
if($_POST['generateUid'] === 'generate') {
$generateUid = true;
$prjUid = $importer->import($opt1,$opt2,$generateUid);
} elseif($_POST['generateUid'] === 'keep') {
$generateUid = false;
$prjUid = $importer->import($opt1,$opt2,$generateUid);
} else {
$prjUid = $importer->import();
}
G::LoadClass( 'Process' );
$oProcess = new Process();
@@ -129,6 +139,7 @@ if (isset($_FILES["PROCESS_FILENAME"]) &&
"catchMessage" => '',
"ExistProcessInDatabase" => 0,
"ExistGroupsInDatabase" => 0,
"notExistProcessInDatabase" => 0,
"affectedGroups" => '',
"sNewProUid" => $prjUid,
"project_type" => 'bpmn',
@@ -147,9 +158,14 @@ if (isset($_FILES["PROCESS_FILENAME"]) &&
}
$result = array(
"success" => true,
"catchMessage" => (in_array($e->getCode(), array(XmlImporter::IMPORT_STAT_TARGET_ALREADY_EXISTS, XmlImporter::IMPORT_STAT_GROUP_ALREADY_EXISTS)))? "" : $e->getMessage(),
"catchMessage" => (in_array($e->getCode(), array(
XmlImporter::IMPORT_STAT_TARGET_ALREADY_EXISTS,
XmlImporter::IMPORT_STAT_GROUP_ALREADY_EXISTS,
XmlImporter::IMPORTED_PROJECT_DOES_NOT_EXISTS
)))? "" : $e->getMessage(),
"ExistProcessInDatabase" => ($e->getCode() == XmlImporter::IMPORT_STAT_TARGET_ALREADY_EXISTS)? 1 : 0,
"ExistGroupsInDatabase" => $groupsExists,
"notExistProcessInDatabase" => ($e->getCode() == XmlImporter::IMPORTED_PROJECT_DOES_NOT_EXISTS) ? 1 : 0,
"affectedGroups" => !empty($affectedGroups)? $affectedGroups : '',
"sNewProUid" => "",
"project_type" => "bpmn",

View File

@@ -27,6 +27,7 @@ abstract class Importer
const IMPORT_STAT_TARGET_ALREADY_EXISTS = 101; //Error, Target Project already exists.
const IMPORT_STAT_INVALID_SOURCE_FILE = 102; //Error, Invalid file type or the file have corrupt data.
const IMPORT_STAT_GROUP_ALREADY_EXISTS = 105; //Error, Group already exists.
const IMPORTED_PROJECT_DOES_NOT_EXISTS = 106;
public abstract function load($filename = null);
@@ -70,7 +71,7 @@ abstract class Importer
}
}
public function import($option = self::IMPORT_OPTION_CREATE_NEW, $optionGroup = self::GROUP_IMPORT_OPTION_CREATE_NEW)
public function import($option = self::IMPORT_OPTION_CREATE_NEW, $optionGroup = self::GROUP_IMPORT_OPTION_CREATE_NEW, $generateUidFromJs = null)
{
$this->prepare();
@@ -93,6 +94,15 @@ abstract class Importer
),
self::IMPORT_STAT_TARGET_ALREADY_EXISTS
);
} else {
if(is_null($generateUidFromJs)) {
throw new \Exception(
\G::LoadTranslation(
"ID_IMPORTER_PROJECT_DOES_NOT_EXISTS_SET_ACTION_TO_CONTINUE"
),
self::IMPORTED_PROJECT_DOES_NOT_EXISTS
);
}
}
break;
case self::IMPORT_OPTION_OVERWRITE:
@@ -142,6 +152,11 @@ abstract class Importer
//Import
$name = $this->importData["tables"]["bpmn"]["project"][0]["prj_name"];
if (\Process::existsByProTitle($name) && !is_null($generateUidFromJs)) {
$name = $name . ' ' . date('Y-m-d H:i:s');
}
switch ($option) {
case self::IMPORT_OPTION_CREATE_NEW:
//Shouldn't generate new UID for all objects
@@ -181,6 +196,9 @@ abstract class Importer
$this->importData["tables"]["workflow"]["process"] = $this->importData["tables"]["workflow"]["process"][0];
//Import
if(!empty($generateUidFromJs)) {
$generateUid = $generateUidFromJs;
}
$result = $this->doImport($generateUid);
//Return

View File

@@ -1289,9 +1289,107 @@ importProcessExistProcess = function()
w.show();
};
//importProcess = function(){
// window.location = 'processes_Import';
//}
changeOrKeepUids = function()
{
var processFileType = importProcessGlobal.processFileType;
var proFileName = importProcessGlobal.proFileName;
var w = new Ext.Window({
id : 'changeOrKeepUidsWindow',
title : _('ID_IMPORT_PROCESS'),
header : false,
width : 460,
height : 230,
autoHeight : true,
modal : true,
autoScroll : false,
maximizable : false,
resizable : false,
items : [
new Ext.form.FormPanel({
title : _('ID_LAN_UPLOAD_TITLE'),
header : false,
id : 'formUploader',
fileUpload : false,
width : 440,
frame : true,
autoHeight : true,
bodyStyle : 'padding: 10px 10px 0 10px;',
labelWidth : 50,
defaults : {
anchor : '90%',
allowBlank : false,
msgTarget : 'side'
},
items : [
{
xtype : 'box',
autoEl : {
tag : 'div',
html : '<div ><img src="/images/ext/default/window/icon-warning.gif" style="display:inline;float:left;margin-top:20px; margin-right:20px;" /><div style="float:left;display:inline;width:300px;margin-left:5px;"></div><div style="width:300px;" >&nbsp</div></div>'
}
},
{
items: [
{
id: "newUids",
xtype: "radio",
name: "IMPORT_OPTION",
inputValue: "new",
boxLabel: _("ID_CREATE_NEW_PROCESS_UID"),
tabIndex: 3
}
]
},
{
items: [
{
id: "keepUids",
xtype: "radio",
name: "IMPORT_OPTION",
inputValue: "keep",
boxLabel: _("ID_KEEP_PROCESS_UID"),
tabIndex: 1,
checked: "checked"
}
]
}, {
xtype : 'hidden',
name : 'PRO_FILENAME',
value : proFileName
}, {
name : 'processFileType',
xtype : 'hidden',
value : processFileType
}, {
xtype : 'spacer',
height : 10
}
],
buttons:[
{
text : _('ID_SAVE'),
handler : function() {
var opt1 = Ext.getCmp('newUids').getValue();
var opt2 = Ext.getCmp('keepUids').getValue();
if(opt1) {
Ext.getCmp('generateUid').setValue('generate');
} else {
Ext.getCmp('generateUid').setValue('keep');
}
Ext.getCmp('buttonUpload').el.dom.click();
}
}, {
text : _('ID_CANCEL'),
handler : function(){
w.close();
}
}
]
})
]
});
w.show();
};
importProcess = function()
{
@@ -1347,9 +1445,15 @@ importProcess = function()
buttonCfg : {
iconCls : 'upload-icon'
}
}, {
id: 'generateUid',
name: 'generateUid',
xtype: 'hidden',
value: ''
}
],
buttons : [{
id: 'buttonUpload',
text : _('ID_UPLOAD'),
handler : function(){
var arrayMatch = [];
@@ -1388,6 +1492,13 @@ importProcess = function()
if (resp_.catchMessage == "") {
if (resp_.ExistProcessInDatabase == "0") {
if(resp_.notExistProcessInDatabase == "1") {
importProcessGlobal.sNewProUid = resp_.sNewProUid;
importProcessGlobal.proFileName = resp_.proFileName;
importProcessGlobal.groupBeforeAccion = resp_.groupBeforeAccion;
changeOrKeepUids();
return;
}
if (resp_.ExistGroupsInDatabase == "0") {
var sNewProUid = resp_.sNewProUid;
@@ -1413,6 +1524,9 @@ importProcess = function()
}
} else {
w.close();
if (Ext.getCmp('changeOrKeepUidsWindow')) {
Ext.getCmp('changeOrKeepUidsWindow').close();
}
Ext.MessageBox.show({
title : "",
@@ -1655,6 +1769,8 @@ function openWindowIfIE(pathDesigner) {
Ext.getCmp('importProcessExistProcessWindow').close();
if (Ext.getCmp('windowBpmnOptionWindow'))
Ext.getCmp('windowBpmnOptionWindow').close();
if (Ext.getCmp('changeOrKeepUidsWindow'))
Ext.getCmp('changeOrKeepUidsWindow').close();
processesGrid.store.reload();
if (winDesigner && winDesigner.closed === false) {
if (winDesigner.window.PMDesigner.project.isDirty()) {