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

@@ -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