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"); $importer->setSourceFromGlobals("PROCESS_FILENAME");
try { 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(); $prjUid = $importer->import();
}
G::LoadClass( 'Process' ); G::LoadClass( 'Process' );
$oProcess = new Process(); $oProcess = new Process();
@@ -129,6 +139,7 @@ if (isset($_FILES["PROCESS_FILENAME"]) &&
"catchMessage" => '', "catchMessage" => '',
"ExistProcessInDatabase" => 0, "ExistProcessInDatabase" => 0,
"ExistGroupsInDatabase" => 0, "ExistGroupsInDatabase" => 0,
"notExistProcessInDatabase" => 0,
"affectedGroups" => '', "affectedGroups" => '',
"sNewProUid" => $prjUid, "sNewProUid" => $prjUid,
"project_type" => 'bpmn', "project_type" => 'bpmn',
@@ -147,9 +158,14 @@ if (isset($_FILES["PROCESS_FILENAME"]) &&
} }
$result = array( $result = array(
"success" => true, "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, "ExistProcessInDatabase" => ($e->getCode() == XmlImporter::IMPORT_STAT_TARGET_ALREADY_EXISTS)? 1 : 0,
"ExistGroupsInDatabase" => $groupsExists, "ExistGroupsInDatabase" => $groupsExists,
"notExistProcessInDatabase" => ($e->getCode() == XmlImporter::IMPORTED_PROJECT_DOES_NOT_EXISTS) ? 1 : 0,
"affectedGroups" => !empty($affectedGroups)? $affectedGroups : '', "affectedGroups" => !empty($affectedGroups)? $affectedGroups : '',
"sNewProUid" => "", "sNewProUid" => "",
"project_type" => "bpmn", "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_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_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 IMPORT_STAT_GROUP_ALREADY_EXISTS = 105; //Error, Group already exists.
const IMPORTED_PROJECT_DOES_NOT_EXISTS = 106;
public abstract function load($filename = null); 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(); $this->prepare();
@@ -93,6 +94,15 @@ abstract class Importer
), ),
self::IMPORT_STAT_TARGET_ALREADY_EXISTS 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; break;
case self::IMPORT_OPTION_OVERWRITE: case self::IMPORT_OPTION_OVERWRITE:
@@ -142,6 +152,11 @@ abstract class Importer
//Import //Import
$name = $this->importData["tables"]["bpmn"]["project"][0]["prj_name"]; $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) { switch ($option) {
case self::IMPORT_OPTION_CREATE_NEW: case self::IMPORT_OPTION_CREATE_NEW:
//Shouldn't generate new UID for all objects //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]; $this->importData["tables"]["workflow"]["process"] = $this->importData["tables"]["workflow"]["process"][0];
//Import //Import
if(!empty($generateUidFromJs)) {
$generateUid = $generateUidFromJs;
}
$result = $this->doImport($generateUid); $result = $this->doImport($generateUid);
//Return //Return

View File

@@ -1289,9 +1289,107 @@ importProcessExistProcess = function()
w.show(); w.show();
}; };
//importProcess = function(){ changeOrKeepUids = function()
// window.location = 'processes_Import'; {
//} 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() importProcess = function()
{ {
@@ -1347,9 +1445,15 @@ importProcess = function()
buttonCfg : { buttonCfg : {
iconCls : 'upload-icon' iconCls : 'upload-icon'
} }
}, {
id: 'generateUid',
name: 'generateUid',
xtype: 'hidden',
value: ''
} }
], ],
buttons : [{ buttons : [{
id: 'buttonUpload',
text : _('ID_UPLOAD'), text : _('ID_UPLOAD'),
handler : function(){ handler : function(){
var arrayMatch = []; var arrayMatch = [];
@@ -1388,6 +1492,13 @@ importProcess = function()
if (resp_.catchMessage == "") { if (resp_.catchMessage == "") {
if (resp_.ExistProcessInDatabase == "0") { 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") { if (resp_.ExistGroupsInDatabase == "0") {
var sNewProUid = resp_.sNewProUid; var sNewProUid = resp_.sNewProUid;
@@ -1413,6 +1524,9 @@ importProcess = function()
} }
} else { } else {
w.close(); w.close();
if (Ext.getCmp('changeOrKeepUidsWindow')) {
Ext.getCmp('changeOrKeepUidsWindow').close();
}
Ext.MessageBox.show({ Ext.MessageBox.show({
title : "", title : "",
@@ -1655,6 +1769,8 @@ function openWindowIfIE(pathDesigner) {
Ext.getCmp('importProcessExistProcessWindow').close(); Ext.getCmp('importProcessExistProcessWindow').close();
if (Ext.getCmp('windowBpmnOptionWindow')) if (Ext.getCmp('windowBpmnOptionWindow'))
Ext.getCmp('windowBpmnOptionWindow').close(); Ext.getCmp('windowBpmnOptionWindow').close();
if (Ext.getCmp('changeOrKeepUidsWindow'))
Ext.getCmp('changeOrKeepUidsWindow').close();
processesGrid.store.reload(); processesGrid.store.reload();
if (winDesigner && winDesigner.closed === false) { if (winDesigner && winDesigner.closed === false) {
if (winDesigner.window.PMDesigner.project.isDirty()) { if (winDesigner.window.PMDesigner.project.isDirty()) {