Merge remote-tracking branch 'pm/3.1-CONTENT' into HOR-1385
This commit is contained in:
@@ -1514,6 +1514,10 @@ class Cases
|
||||
//If exist paused cases
|
||||
$closedTasks[] = $row;
|
||||
$aIndex[] = $row['DEL_INDEX'];
|
||||
$res = $this->GetAllOpenDelegation( array('APP_UID'=>$sAppUid, 'APP_THREAD_PARENT'=>$row['DEL_PREVIOUS']), 'NONE' );
|
||||
foreach ($res as $in) {
|
||||
$aIndex[] = $in['DEL_INDEX'];
|
||||
}
|
||||
$pausedTasks = $this->getReviewedTasksPaused($sAppUid,$aIndex);
|
||||
}
|
||||
}
|
||||
@@ -7067,14 +7071,16 @@ class Cases
|
||||
* @return $aThreads
|
||||
*/
|
||||
|
||||
public function GetAllOpenDelegation($aData)
|
||||
public function GetAllOpenDelegation($aData, $status = 'OPEN')
|
||||
{
|
||||
try {
|
||||
$aThreads = array();
|
||||
$c = new Criteria();
|
||||
$c->add(AppDelegationPeer::APP_UID, $aData['APP_UID']);
|
||||
$c->add(AppDelegationPeer::DEL_PREVIOUS, $aData['APP_THREAD_PARENT']);
|
||||
$c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
|
||||
if($status === 'OPEN'){
|
||||
$c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
|
||||
}
|
||||
$rs = AppDelegationPeer::doSelectRs($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$rs->next();
|
||||
|
||||
@@ -1169,6 +1169,10 @@ class Derivation
|
||||
if(isset($nextDel["ROU_PREVIOUS_TYPE"])){
|
||||
if($nextDel["ROU_PREVIOUS_TYPE"] == "SEC-JOIN"){
|
||||
$arrayOpenThread = $this->case->searchOpenPreviousTasks($nextDel["ROU_PREVIOUS_TASK"], $currentDelegation["APP_UID"]);
|
||||
$arraySiblings = $this->case->getOpenSiblingThreads($nextDel["ROU_PREVIOUS_TASK"], $currentDelegation["APP_UID"], $currentDelegation["DEL_INDEX"], $currentDelegation["TAS_UID"]);
|
||||
if(is_array($arrayOpenThread) && is_array($arraySiblings)){
|
||||
$arrayOpenThread = array_merge($arrayOpenThread, $arraySiblings);
|
||||
}
|
||||
$canDerivate = empty($arrayOpenThread);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1789,5 +1789,28 @@ class PMPluginRegistry
|
||||
return $this->_aOpenReassignCallback;
|
||||
}
|
||||
|
||||
|
||||
public function getPluginsData()
|
||||
{
|
||||
return $this->_aPlugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* The following function method extracts the plugin if exists one
|
||||
* with the same uppercase characters, this is required for the
|
||||
*
|
||||
* @param $code
|
||||
*/
|
||||
public function getPluginByCode($code)
|
||||
{
|
||||
$plugin = false;
|
||||
foreach ($this->_aPlugins as $plugin) {
|
||||
$plugin = (array)$plugin;
|
||||
if (strtoupper($plugin['sNamespace']) == $code) {
|
||||
return (object)$plugin;
|
||||
}
|
||||
}
|
||||
return $plugin;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ class Home extends Controller
|
||||
$dateFrom = null,
|
||||
$dateTo = null,
|
||||
$callback = null,
|
||||
$dir = null,
|
||||
$dir = 'DESC',
|
||||
$sort = "APP_CACHE_VIEW.APP_NUMBER",
|
||||
$category = null)
|
||||
{
|
||||
|
||||
@@ -7,22 +7,31 @@ class ExportObjects
|
||||
* @var array
|
||||
*/
|
||||
protected $objectsList = array(
|
||||
'Process Definition',
|
||||
'Assignment Rules',
|
||||
'Variables',
|
||||
'Dynaforms',
|
||||
'Input Documents',
|
||||
'Output Documents',
|
||||
'Triggers',
|
||||
'Report Tables',
|
||||
'Templates',
|
||||
'Files',
|
||||
'DB Connection',
|
||||
'Permissions',
|
||||
'Supervisors',
|
||||
'Supervisors Objects'
|
||||
'PROCESSDEFINITION' => 'Process Definition',
|
||||
'ASSIGNMENTRULES' => 'Assignment Rules',
|
||||
'VARIABLES' => 'Variables',
|
||||
'DYNAFORMS' => 'Dynaforms',
|
||||
'INPUTDOCUMENTS' => 'Input Documents',
|
||||
'OUTPUTDOCUMENTS' => 'Output Documents',
|
||||
'TRIGGERS' => 'Triggers',
|
||||
'REPORTTABLES' => 'Report Tables',
|
||||
'TEMPLATES' => 'Templates',
|
||||
'FILES' => 'Files',
|
||||
'DBCONNECTION' => 'DB Connection',
|
||||
'PERMISSIONS' => 'Permissions',
|
||||
'SUPERVISORS' => 'Supervisors',
|
||||
'SUPERVISORSOBJECTS' => 'Supervisors Objects'
|
||||
);
|
||||
|
||||
/**
|
||||
* ExportObjects constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->objectsList = array_merge($this->objectsList, $this->processMigrablePlugins());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -51,13 +60,12 @@ class ExportObjects
|
||||
$aObjectsEnable = explode('|', $objectsEnable);
|
||||
foreach ($this->objectsList as $key => $val) {
|
||||
$grid[] = array(
|
||||
'OBJECT_ID' => $key+1,
|
||||
'OBJECT_ID' => strtoupper(str_replace(' ', '',$val)),
|
||||
'OBJECT_NAME' => $val,
|
||||
'OBJECT_ACTION' => 1,
|
||||
'OBJECT_ENABLE' => in_array(strtoupper(str_replace(' ', '',$val)), $aObjectsEnable)
|
||||
);
|
||||
}
|
||||
|
||||
$r = new \stdclass();
|
||||
$r->data = $grid;
|
||||
|
||||
@@ -67,6 +75,21 @@ class ExportObjects
|
||||
}
|
||||
}
|
||||
|
||||
public function processMigrablePlugins()
|
||||
{
|
||||
\G::LoadClass("pluginRegistry");
|
||||
$plugins = array();
|
||||
$registry = \PMPluginRegistry::getSingleton();
|
||||
$data = $registry->getPluginsData();
|
||||
foreach ($data as $detail) {
|
||||
$detail = (array)$detail;
|
||||
if (isset($detail['bIsMigrable']) && $detail['bIsMigrable']) {
|
||||
$plugins[strtoupper($detail['sNamespace'])] = $detail['sNamespace'];
|
||||
}
|
||||
}
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $idObject
|
||||
* @return mixed
|
||||
@@ -75,7 +98,7 @@ class ExportObjects
|
||||
public function getObjectName($idObject)
|
||||
{
|
||||
try {
|
||||
return (str_replace(' ', '', $this->objectsList[$idObject - 1]));
|
||||
return (str_replace(' ', '', $this->objectsList[$idObject]));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
@@ -92,7 +115,7 @@ class ExportObjects
|
||||
try {
|
||||
$mapObjectList = array();
|
||||
foreach ($objects as $objectId) {
|
||||
array_push($mapObjectList, strtoupper(str_replace(' ', '', $this->objectsList[$objectId - 1])));
|
||||
array_push($mapObjectList, strtoupper(str_replace(' ', '', $this->objectsList[$objectId])));
|
||||
}
|
||||
return $mapObjectList;
|
||||
} catch (\Exception $e) {
|
||||
@@ -110,10 +133,9 @@ class ExportObjects
|
||||
try {
|
||||
$idObjectList = array();
|
||||
foreach ($this->objectsList as $key => $val) {
|
||||
$key++;
|
||||
foreach ($objects as $row) {
|
||||
if(strtoupper(str_replace(' ', '', $this->objectsList[$key - 1])) === $row){
|
||||
array_push($idObjectList, $key);
|
||||
if(strtoupper(str_replace(' ', '', $this->objectsList[$key])) === $row){
|
||||
array_push($idObjectList, $row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,10 @@ class GranularExporter
|
||||
$this->beforeExport($objectList);
|
||||
foreach ($objectList as $data) {
|
||||
$migrator = $this->factory->create($data);
|
||||
$migrator->beforeExport();
|
||||
$migratorData = $migrator->export($this->prjuid);
|
||||
$this->mergeData($migratorData);
|
||||
$migrator->afterExport();
|
||||
}
|
||||
return $this->publish();
|
||||
} else {
|
||||
@@ -121,7 +123,8 @@ class GranularExporter
|
||||
$data = array(
|
||||
'bpmn-definition' => $bpnmDefinition,
|
||||
'workflow-definition' => $workflowDefinition,
|
||||
'workflow-files' => []
|
||||
'workflow-files' => [],
|
||||
'plugin-data' => []
|
||||
);
|
||||
|
||||
$data["filename"] = $outputFilename;
|
||||
|
||||
@@ -36,8 +36,16 @@ class GranularImporter
|
||||
$this->exportObjects = new ExportObjects();
|
||||
//create structure
|
||||
foreach ($aGranular as $key => $rowObject) {
|
||||
array_push($listObjectGranular, array("name" => strtoupper($this->exportObjects->getObjectName
|
||||
($rowObject->id)), "data" => "", "value" => $rowObject->action));
|
||||
array_push(
|
||||
$listObjectGranular,
|
||||
array(
|
||||
"name" => strtoupper(
|
||||
$this->exportObjects->getObjectName($rowObject->id)
|
||||
),
|
||||
"data" => [],
|
||||
"value" => $rowObject->action
|
||||
)
|
||||
);
|
||||
}
|
||||
//add data
|
||||
foreach ($listObjectGranular as $key => $rowObject) {
|
||||
@@ -57,9 +65,9 @@ class GranularImporter
|
||||
switch ($nameObject) {
|
||||
case 'PROCESSDEFINITION':
|
||||
$objectList['PROCESSDEFINITION']['bpmn'] = isset($data['tables']['bpmn']) ? $this->structureBpmnData
|
||||
($data['tables']['bpmn']) : '';
|
||||
($data['tables']['bpmn']) : [];
|
||||
$objectList['PROCESSDEFINITION']['workflow'] = isset($data['tables']['workflow']) ?
|
||||
$data['tables']['workflow'] : '';
|
||||
$data['tables']['workflow'] : [];
|
||||
break;
|
||||
case 'ASSIGNMENTRULES':
|
||||
$objectList['ASSIGNMENTRULES']['tasks'] = isset($data['tables']['workflow']['tasks']) ?
|
||||
@@ -127,6 +135,8 @@ class GranularImporter
|
||||
$data['tables']['workflow']['reportTablesFields'] : [];
|
||||
break;
|
||||
default:
|
||||
$objectList[$nameObject] = isset($data['tables']['plugins'][strtolower($nameObject)]) ?
|
||||
$data['tables']['plugins'][strtolower($nameObject)] : '';
|
||||
break;
|
||||
}
|
||||
return $objectList;
|
||||
@@ -170,7 +180,9 @@ class GranularImporter
|
||||
if (is_object($objClass)) {
|
||||
$dataImport = $data['data'][$data['name']];
|
||||
$replace = ($data['value'] == 'replace') ? true : false;
|
||||
$objClass->beforeImport($dataImport);
|
||||
$migratorData = $objClass->import($dataImport, $replace);
|
||||
$objClass->afterImport($dataImport);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -201,10 +213,34 @@ class GranularImporter
|
||||
{
|
||||
try {
|
||||
if (XmlImporter::IMPORT_OPTION_OVERWRITE !== $option) {
|
||||
if (count($objectList) !== count($this->exportObjects->getObjectsList())) {
|
||||
$exception = new ImportException();
|
||||
$exception->setNameException(\G::LoadTranslation('ID_PROCESS_DEFINITION_INCOMPLETE'));
|
||||
throw($exception);
|
||||
$nativeElements = array(
|
||||
'PROCESSDEFINITION',
|
||||
'ASSIGNMENTRULES',
|
||||
'VARIABLES',
|
||||
'DYNAFORMS',
|
||||
'INPUTDOCUMENTS',
|
||||
'OUTPUTDOCUMENTS',
|
||||
'TRIGGERS',
|
||||
'REPORTTABLES',
|
||||
'TEMPLATES',
|
||||
'FILES',
|
||||
'DBCONNECTION',
|
||||
'PERMISSIONS',
|
||||
'SUPERVISORS',
|
||||
'SUPERVISORSOBJECTS'
|
||||
);
|
||||
foreach ($nativeElements as $element) {
|
||||
$found = false;
|
||||
foreach($objectList as $object) {
|
||||
if ($element == $object->id) {
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
$exception = new ImportException();
|
||||
$exception->setNameException(\G::LoadTranslation('ID_PROCESS_DEFINITION_INCOMPLETE'));
|
||||
throw($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -215,7 +251,7 @@ class GranularImporter
|
||||
|
||||
/**
|
||||
* It's very important to import the elements in the right order, if not
|
||||
* chaos will be unleashed, God forgive us all.
|
||||
* some strange behavior will occur during import and export.
|
||||
* @param $objectList
|
||||
*/
|
||||
public function reorderImportOrder($objectList)
|
||||
@@ -242,6 +278,10 @@ class GranularImporter
|
||||
$orderedList[$executionOrder] = $objectList[$objectOrder];
|
||||
}
|
||||
}
|
||||
|
||||
for ($j=count($arrangeList); $j<count($objectList); $j++) {
|
||||
$orderedList[$j] = $objectList[$j];
|
||||
}
|
||||
ksort($orderedList);
|
||||
return $orderedList;
|
||||
}
|
||||
@@ -272,6 +312,7 @@ class GranularImporter
|
||||
list($arrayWorkflowTables, $arrayWorkflowFiles) = $workflow->updateDataUidByArrayUid($arrayWorkflowTables, $arrayWorkflowFiles, $result);
|
||||
}
|
||||
$newData['tables']['workflow'] = $arrayWorkflowTables;
|
||||
$newData['tables']['plugins'] = $data["tables"]["plugins"];
|
||||
$newData['files']['workflow'] = $arrayWorkflowFiles;
|
||||
|
||||
return array(
|
||||
|
||||
@@ -52,6 +52,9 @@ class MigratorFactory
|
||||
case 'PERMISSIONS':
|
||||
$class = new PermissionsMigrator();
|
||||
break;
|
||||
default:
|
||||
$class = new PluginMigratorAdapter($classname);
|
||||
break;
|
||||
}
|
||||
return $class;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,11 @@ class PMXGenerator
|
||||
|
||||
$rootNode->appendChild($metadataNode);
|
||||
|
||||
$dbData = array("BPMN" => $data["bpmn-definition"], "workflow" => $data["workflow-definition"]);
|
||||
$dbData = array(
|
||||
"BPMN" => $data["bpmn-definition"],
|
||||
"workflow" => $data["workflow-definition"],
|
||||
"plugins" => $data["plugin-data"]
|
||||
);
|
||||
foreach ($dbData as $sectionName => $sectionData) {
|
||||
$dataNode = $this->domDocument->createElement("definition");
|
||||
$dataNode->setAttribute("class", $sectionName);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel\Migrator;
|
||||
|
||||
/**
|
||||
* Class PluginMigratorAdapter
|
||||
* @package ProcessMaker\BusinessModel\Migrator
|
||||
*/
|
||||
class PluginMigratorAdapter implements Exportable, Importable
|
||||
{
|
||||
|
||||
private $migrator;
|
||||
|
||||
/**
|
||||
* PluginMigratorAdapter constructor.
|
||||
*/
|
||||
public function __construct($pluginName)
|
||||
{
|
||||
\G::LoadClass('pluginRegistry');
|
||||
$registry = \PMPluginRegistry::getSingleton();
|
||||
$plugin = $registry->getPluginByCode($pluginName);
|
||||
require_once (
|
||||
PATH_PLUGINS.PATH_SEP.
|
||||
$plugin->sPluginFolder.PATH_SEP.
|
||||
'classes'.PATH_SEP.
|
||||
$plugin->sMigratorClassName.'.php'
|
||||
);
|
||||
$this->migrator = new $plugin->sMigratorClassName();
|
||||
}
|
||||
|
||||
public function beforeExport()
|
||||
{
|
||||
return $this->migrator->beforeExport();
|
||||
}
|
||||
|
||||
public function export($prj_uid)
|
||||
{
|
||||
return $this->migrator->export($prj_uid);
|
||||
}
|
||||
|
||||
public function afterExport()
|
||||
{
|
||||
return $this->migrator->afterExport();
|
||||
}
|
||||
|
||||
public function beforeImport($data)
|
||||
{
|
||||
return $this->migrator->beforeImport($data);
|
||||
}
|
||||
|
||||
public function import($data, $replace)
|
||||
{
|
||||
return $this->migrator->import($data, $replace);
|
||||
}
|
||||
|
||||
public function afterImport($data)
|
||||
{
|
||||
return $this->migrator->afterImport($data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,8 +37,6 @@ class ProcessDefinitionMigrator implements Importable, Exportable
|
||||
//Bpmn elements
|
||||
$pjrUid = $this->bpmn->createFromStruct($data['bpmn'], false);
|
||||
//Import workflow elements
|
||||
$this->afterImport($data);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$exception = new ImportException($e->getMessage());
|
||||
$exception->setNameException($this->className);
|
||||
|
||||
@@ -242,7 +242,7 @@ abstract class Importer
|
||||
$newObjectArray = array();
|
||||
$count = 0;
|
||||
foreach ($objectsToImport as $key => $rowObject) {
|
||||
if($rowObject->id != '1'){
|
||||
if($rowObject->id != 'PROCESSDEFINITION'){
|
||||
$newObjectArray[++$count] = $rowObject;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1184,7 +1184,7 @@ function exportImportProcessObjects(typeAction)
|
||||
if(!inArray(row.get('OBJECT_ID'),importProcessGlobal.objectGranularImport)) {
|
||||
store.remove(row);
|
||||
}
|
||||
if(row.get('OBJECT_ID') === 1) { /*process definition*/
|
||||
if(row.get('OBJECT_ID') === "PROCESSDEFINITION") { /*process definition*/
|
||||
row.set("OBJECT_ACTION","2");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user