@@ -61,6 +61,10 @@ if (PMLicensedFeatures::getSingleton()->verifyfeature("B0oWlBLY3hHdWY0YUNpZEtFQm
|
||||
$arrayTrigger = $data["tables"]["workflow"]["triggers"];
|
||||
$projectTitle = $data["tables"]["bpmn"]["project"][0]["prj_name"];
|
||||
}
|
||||
if(isset($data['objects'])){
|
||||
$export = new \ProcessMaker\BusinessModel\Migrator\ExportObjects();
|
||||
$objectImport = $export->objectList($data['objects']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -136,15 +140,16 @@ if (isset($_FILES["PROCESS_FILENAME"]) &&
|
||||
$proType = $processData["PRO_TYPE"];
|
||||
|
||||
$result = array(
|
||||
"success" => true,
|
||||
"catchMessage" => '',
|
||||
"ExistProcessInDatabase" => 0,
|
||||
"ExistGroupsInDatabase" => 0,
|
||||
"success" => true,
|
||||
"catchMessage" => '',
|
||||
"ExistProcessInDatabase" => 0,
|
||||
"ExistGroupsInDatabase" => 0,
|
||||
"notExistProcessInDatabase" => 0,
|
||||
"affectedGroups" => '',
|
||||
"sNewProUid" => $prjUid,
|
||||
"project_type" => 'bpmn',
|
||||
"project_type_aux" => $proType
|
||||
"affectedGroups" => '',
|
||||
"sNewProUid" => $prjUid,
|
||||
"project_type" => 'bpmn',
|
||||
"ImportGranularOptions" => '',
|
||||
"project_type_aux" => $proType
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$groupsExists = ($e->getCode() == XmlImporter::IMPORT_STAT_GROUP_ALREADY_EXISTS)? 1 : 0;
|
||||
@@ -164,16 +169,16 @@ if (isset($_FILES["PROCESS_FILENAME"]) &&
|
||||
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,
|
||||
"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",
|
||||
|
||||
"proFileName" => $_FILES["PROCESS_FILENAME"]["name"],
|
||||
"groupBeforeAccion" => "uploadFileNewProcess",
|
||||
"importOption" => 0
|
||||
"affectedGroups" => !empty($affectedGroups)? $affectedGroups : '',
|
||||
"sNewProUid" => '',
|
||||
"project_type" => 'bpmn',
|
||||
"ImportGranularOptions" => $objectImport,
|
||||
"proFileName" => $_FILES["PROCESS_FILENAME"]["name"],
|
||||
"groupBeforeAccion" => 'uploadFileNewProcess',
|
||||
"importOption" => 0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -210,12 +215,26 @@ if (isset($_POST["PRO_FILENAME"]) &&
|
||||
break;
|
||||
}
|
||||
|
||||
//Check the Granular Import selected by User
|
||||
$granularOptions = '';
|
||||
$granularImport = 'NO';
|
||||
if(isset($_POST["granularOptions"])){
|
||||
$granularImport = 'YES';
|
||||
$export = new \ProcessMaker\BusinessModel\Migrator\ExportObjects();
|
||||
$granularOptions = $export->mapObjectList($_POST["granularOptions"]);
|
||||
|
||||
}
|
||||
|
||||
$importer = new XmlImporter();
|
||||
$importer->setData("usr_uid", $_SESSION["USER_LOGGED"]);
|
||||
$importer->setSourceFile(PATH_DOCUMENT . "input" . PATH_SEP . $_POST["PRO_FILENAME"]);
|
||||
|
||||
try {
|
||||
$prjUid = $importer->import($option, $optionGroup);
|
||||
if(version_compare($importer->getVersion(), '3.0', '>')){
|
||||
//To do
|
||||
}
|
||||
|
||||
$prjUid = $importer->import($option, $optionGroup, null, $granularImport,$granularOptions);
|
||||
|
||||
G::LoadClass( 'Process' );
|
||||
$oProcess = new Process();
|
||||
@@ -223,14 +242,15 @@ if (isset($_POST["PRO_FILENAME"]) &&
|
||||
$proType = $processData["PRO_TYPE"];
|
||||
|
||||
$result = array(
|
||||
"success" => true,
|
||||
"catchMessage" => '',
|
||||
"success" => true,
|
||||
"catchMessage" => '',
|
||||
"ExistProcessInDatabase" => 0,
|
||||
"ExistGroupsInDatabase" => 0,
|
||||
"ExistGroupsInDatabase" => '',
|
||||
"sNewProUid" => $prjUid,
|
||||
"project_type" => 'bpmn',
|
||||
"project_type_aux" => $proType
|
||||
"ExistGroupsInDatabase" => 0,
|
||||
"ExistGroupsInDatabase" => '',
|
||||
"sNewProUid" => $prjUid,
|
||||
"project_type" => 'bpmn',
|
||||
"ImportGranularOptions" => '',
|
||||
"project_type_aux" => $proType
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$groupsExists = ($e->getCode() == XmlImporter::IMPORT_STAT_GROUP_ALREADY_EXISTS)? 1 : 0;
|
||||
@@ -244,17 +264,17 @@ if (isset($_POST["PRO_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(),
|
||||
"success" => true,
|
||||
"catchMessage" => (in_array($e->getCode(), array(XmlImporter::IMPORT_STAT_TARGET_ALREADY_EXISTS, XmlImporter::IMPORT_STAT_GROUP_ALREADY_EXISTS)))? "" : $e->getMessage(),
|
||||
"ExistProcessInDatabase" => ($e->getCode() == XmlImporter::IMPORT_STAT_TARGET_ALREADY_EXISTS)? 1 : 0,
|
||||
"ExistGroupsInDatabase" => $groupsExists,
|
||||
"affectedGroups" => !empty($affectedGroups)? $affectedGroups : '',
|
||||
"sNewProUid" => "",
|
||||
"project_type" => "bpmn",
|
||||
|
||||
"proFileName" => $_POST["PRO_FILENAME"],
|
||||
"groupBeforeAccion" => "uploadFileNewProcess",
|
||||
"importOption" => (isset($_POST["IMPORT_OPTION"]))? (int)($_POST["IMPORT_OPTION"]) : 0
|
||||
"affectedGroups" => !empty($affectedGroups)? $affectedGroups : '',
|
||||
"sNewProUid" => '',
|
||||
"project_type" => 'bpmn',
|
||||
"ImportGranularOptions" => $objectImport,
|
||||
"proFileName" => $_POST["PRO_FILENAME"],
|
||||
"groupBeforeAccion" => "uploadFileNewProcess",
|
||||
"importOption" => (isset($_POST["IMPORT_OPTION"]))? (int)($_POST["IMPORT_OPTION"]) : 0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,16 +24,17 @@ class ExportObjects
|
||||
);
|
||||
|
||||
/**
|
||||
* @param string $pro_uid
|
||||
* @param string $objectsEnable
|
||||
* @return mixed|string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function objectList($pro_uid = '')
|
||||
public function objectList($objectsEnable = '')
|
||||
{
|
||||
try {
|
||||
$aObjectsEnable = explode('|', $objectsEnable);
|
||||
foreach ($this->objectsList as $key => $val) {
|
||||
$key++;
|
||||
$grid[] = array('OBJECT_ID' => $key, 'OBJECT_NAME' => $val, 'OBJECT_ACTION' => 0);
|
||||
$grid[] = array('OBJECT_ID' => $key, 'OBJECT_NAME' => $val, 'OBJECT_ENABLE' => in_array(strtoupper(str_replace(' ', '',$val)), $aObjectsEnable) );
|
||||
}
|
||||
|
||||
$r = new \stdclass();
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace ProcessMaker\Importer;
|
||||
use ProcessMaker\Util;
|
||||
use ProcessMaker\Project;
|
||||
use ProcessMaker\Project\Adapter;
|
||||
use ProcessMaker\BusinessModel\Migrator;
|
||||
|
||||
abstract class Importer
|
||||
{
|
||||
@@ -76,7 +77,7 @@ abstract class Importer
|
||||
}
|
||||
}
|
||||
|
||||
public function import($option = self::IMPORT_OPTION_CREATE_NEW, $optionGroup = self::GROUP_IMPORT_OPTION_CREATE_NEW, $generateUidFromJs = null)
|
||||
public function import($option = self::IMPORT_OPTION_CREATE_NEW, $optionGroup = self::GROUP_IMPORT_OPTION_CREATE_NEW, $generateUidFromJs = null, $granularImporter = 'NO', $granularOptions = '')
|
||||
{
|
||||
$this->prepare();
|
||||
|
||||
@@ -169,7 +170,13 @@ abstract class Importer
|
||||
break;
|
||||
case self::IMPORT_OPTION_OVERWRITE:
|
||||
//Shouldn't generate new UID for all objects
|
||||
$this->removeProject();
|
||||
if($granularImporter === 'NO'){
|
||||
$this->removeProject();
|
||||
} else {
|
||||
if(in_array('PROCESSDEFINITION', $granularOptions)){
|
||||
$this->removeProject();
|
||||
}
|
||||
}
|
||||
$name = $this->currentProcessTitle;
|
||||
$generateUid = false;
|
||||
break;
|
||||
@@ -204,6 +211,24 @@ abstract class Importer
|
||||
if(!empty($generateUidFromJs)) {
|
||||
$generateUid = $generateUidFromJs;
|
||||
}
|
||||
|
||||
//Granular Import
|
||||
switch ($granularImporter) {
|
||||
case '':
|
||||
throw new \Exception(\G::LoadTranslation("ID_GRANULAR"),self::IMPORTED_PROJECT_DOES_NOT_EXISTS);
|
||||
break;
|
||||
case 'YES':
|
||||
if($granularOptions === 'YES'){
|
||||
$granularObj = new \ProcessMaker\BusinessModel\Migrator\GranularImporter();
|
||||
$objectList = $granularObj->loadObjectsListSelected($this->importData, $granularOptions);
|
||||
if(sizeof($objectList)>0){
|
||||
$granularObj->import($objectList);
|
||||
}
|
||||
return $this->importData['tables']['bpmn']["project"][0]["prj_uid"];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$result = $this->doImport($generateUid);
|
||||
|
||||
//Return
|
||||
|
||||
@@ -8,7 +8,8 @@ class XmlImporter extends Importer
|
||||
*/
|
||||
protected $dom;
|
||||
protected $root;
|
||||
protected $version = "";
|
||||
protected $version = '';
|
||||
protected $objects = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -129,10 +130,14 @@ class XmlImporter extends Importer
|
||||
);
|
||||
}
|
||||
}
|
||||
//Get the ProcessObject
|
||||
$this->objects = (isset($this->metadata['processObject'])) ? $this->metadata['processObject'] : '';
|
||||
|
||||
return array(
|
||||
"tables" => $tables,
|
||||
"files" => array("workflow" => $wfFiles, "bpmn" => array())
|
||||
"tables" => $tables,
|
||||
"files" => array("workflow" => $wfFiles, "bpmn" => array()),
|
||||
"version" => $this->version,
|
||||
"objects" => $this->objects
|
||||
);
|
||||
}
|
||||
|
||||
@@ -144,5 +149,22 @@ class XmlImporter extends Importer
|
||||
return (string) simplexml_import_dom($node->parentNode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the $version value
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
/**
|
||||
* Gets the $objects value
|
||||
* @return string
|
||||
*/
|
||||
public function getObjects()
|
||||
{
|
||||
return $this->objects;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user