Merged in victorsl/processmaker/PM-1700 (pull request #1586)

PM-1700 "Ocurre un error al importar y actualizar un proceso..." SOLVED
This commit is contained in:
Julio Cesar Laura Avendaño
2015-03-05 13:55:46 -04:00
2 changed files with 47 additions and 25 deletions

View File

@@ -2290,14 +2290,16 @@ class Processes
try { try {
$map = array(); $map = array();
foreach ($data->messageType as $key => $value) { if (isset($data->messageType)) {
$record = $value; foreach ($data->messageType as $key => $value) {
$record = $value;
if (isset($record["MSGT_UID"])) { if (isset($record["MSGT_UID"])) {
$newUid = $this->getUnusedMessageTypeUid(); $newUid = $this->getUnusedMessageTypeUid();
$map[$record["MSGT_UID"]] = $newUid; $map[$record["MSGT_UID"]] = $newUid;
$data->messageType[$key]["MSGT_UID"] = $newUid; $data->messageType[$key]["MSGT_UID"] = $newUid;
}
} }
} }
@@ -2344,14 +2346,16 @@ class Processes
try { try {
$map = array(); $map = array();
foreach ($data->messageTypeVariable as $key => $value) { if (isset($data->messageTypeVariable)) {
$record = $value; foreach ($data->messageTypeVariable as $key => $value) {
$record = $value;
if (isset($record["MSGTV_UID"])) { if (isset($record["MSGTV_UID"])) {
$newUid = $this->getUnusedMessageTypeVariableUid(); $newUid = $this->getUnusedMessageTypeVariableUid();
$map[$record["MSGTV_UID"]] = $newUid; $map[$record["MSGTV_UID"]] = $newUid;
$data->messageTypeVariable[$key]["MSGTV_UID"] = $newUid; $data->messageTypeVariable[$key]["MSGTV_UID"] = $newUid;
}
} }
} }

View File

@@ -73,8 +73,7 @@ abstract class Importer
{ {
$this->prepare(); $this->prepare();
$name = $this->importData["tables"]["bpmn"]["project"][0]["prj_name"]; //Verify data
switch ($option) { switch ($option) {
case self::IMPORT_OPTION_CREATE_NEW: case self::IMPORT_OPTION_CREATE_NEW:
if ($this->targetExists()) { if ($this->targetExists()) {
@@ -94,23 +93,12 @@ abstract class Importer
self::IMPORT_STAT_TARGET_ALREADY_EXISTS self::IMPORT_STAT_TARGET_ALREADY_EXISTS
); );
} }
$generateUid = false;
break; break;
case self::IMPORT_OPTION_OVERWRITE: case self::IMPORT_OPTION_OVERWRITE:
$this->removeProject();
// this option shouldn't generate new uid for all objects
$generateUid = false;
break; break;
case self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW: case self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW:
$this->disableProject();
// this option should generate new uid for all objects
$generateUid = true;
$name = "New - " . $name . " - " . date("M d, H:i");
break; break;
case self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW: case self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW:
// this option should generate new uid for all objects
$generateUid = true;
$name = \G::LoadTranslation("ID_COPY_OF") . " - " . $name . " - " . date("M d, H:i");
break; break;
} }
@@ -149,6 +137,36 @@ abstract class Importer
break; break;
} }
//Import
$name = $this->importData["tables"]["bpmn"]["project"][0]["prj_name"];
switch ($option) {
case self::IMPORT_OPTION_CREATE_NEW:
//Shouldn't generate new UID for all objects
$generateUid = false;
break;
case self::IMPORT_OPTION_OVERWRITE:
//Shouldn't generate new UID for all objects
$this->removeProject();
$generateUid = false;
break;
case self::IMPORT_OPTION_DISABLE_AND_CREATE_NEW:
//Should generate new UID for all objects
$this->disableProject();
$name = "New - " . $name . " - " . date("M d, H:i");
$generateUid = true;
break;
case self::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW:
//Should generate new UID for all objects
$name = \G::LoadTranslation("ID_COPY_OF") . " - " . $name . " - " . date("M d, H:i");
$generateUid = true;
break;
}
$this->importData["tables"]["bpmn"]["project"][0]["prj_name"] = $name; $this->importData["tables"]["bpmn"]["project"][0]["prj_name"] = $name;
$this->importData["tables"]["bpmn"]["diagram"][0]["dia_name"] = $name; $this->importData["tables"]["bpmn"]["diagram"][0]["dia_name"] = $name;
$this->importData["tables"]["bpmn"]["process"][0]["pro_name"] = $name; $this->importData["tables"]["bpmn"]["process"][0]["pro_name"] = $name;