BUG-13421 Ordenamiento en el listado de procesos 'Designer'.
Se agregaron validaciones en los files: workflow/engine/classes/model/Process.php y workflow/engine/methods/processes/processesList.php para que se realize el ordenamiento ASC y DESC tomando en cuenta si se encuentra o no habilitado el uso de 'memcache' para listar de una forma mas veloz todos los procesos.
This commit is contained in:
@@ -587,7 +587,7 @@ class Process extends BaseProcess
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllProcesses ($start, $limit, $category = null, $processName = null, $counters = true, $reviewSubProcess = false)
|
||||
public function getAllProcesses ($start, $limit, $category = null, $processName = null, $counters = true, $reviewSubProcess = false, $dir = 'ASC')
|
||||
{
|
||||
require_once PATH_RBAC . "model/RbacUsers.php";
|
||||
require_once "classes/model/ProcessCategory.php";
|
||||
@@ -737,7 +737,11 @@ class Process extends BaseProcess
|
||||
|
||||
$memcache = & PMmemcached::getSingleton( SYS_SYS );
|
||||
if ($memcache->enabled == 0) {
|
||||
usort( $aProcesses, 'ordProcess' );
|
||||
if ($dir=='ASC') {
|
||||
usort( $aProcesses, 'ordProcessAsc' );
|
||||
} else {
|
||||
usort( $aProcesses, 'ordProcessDesc' );
|
||||
}
|
||||
$aProcesses = array_splice($aProcesses, $start, $limit);
|
||||
}
|
||||
|
||||
@@ -847,34 +851,38 @@ class Process extends BaseProcess
|
||||
}
|
||||
}
|
||||
|
||||
public function orderMemcache($dataMemcache, $start, $limit)
|
||||
public function orderMemcache($dataMemcache, $start, $limit, $dir)
|
||||
{
|
||||
usort( $dataMemcache, 'ordProcess' );
|
||||
$dataMemcache = array_splice($dataMemcache, $start, $limit);
|
||||
if ($dir=='ASC') {
|
||||
usort( $dataMemcache, 'ordProcessAsc' );
|
||||
} else {
|
||||
usort( $dataMemcache, 'ordProcessDesc' );
|
||||
}
|
||||
$dataMemcache = array_splice($dataMemcache, $start, $limit);
|
||||
return $dataMemcache;
|
||||
}
|
||||
}
|
||||
|
||||
function ordProcess ($a, $b)
|
||||
{
|
||||
if (isset($_POST['sort'])) {
|
||||
if ($_POST['dir']=='ASC') {
|
||||
if ($a[$_POST['sort']] > $b[$_POST['sort']]) {
|
||||
return 1;
|
||||
} elseif ($a[$_POST['sort']] < $b[$_POST['sort']]) {
|
||||
return - 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if ($a[$_POST['sort']] > $b[$_POST['sort']]) {
|
||||
return - 1;
|
||||
} elseif ($a[$_POST['sort']] < $b[$_POST['sort']]) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
function ordProcessAsc ($a, $b)
|
||||
{
|
||||
if ($a[$_POST['sort']] > $b[$_POST['sort']]) {
|
||||
return 1;
|
||||
} elseif ($a[$_POST['sort']] < $b[$_POST['sort']]) {
|
||||
return - 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function ordProcessDesc ($a, $b)
|
||||
{
|
||||
if ($a[$_POST['sort']] > $b[$_POST['sort']]) {
|
||||
return - 1;
|
||||
} elseif ($a[$_POST['sort']] < $b[$_POST['sort']]) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ require_once 'classes/model/Process.php';
|
||||
|
||||
$start = isset( $_POST['start'] ) ? $_POST['start'] : 0;
|
||||
$limit = isset( $_POST['limit'] ) ? $_POST['limit'] : '';
|
||||
$dir = isset( $_POST['dir'] ) ? $_POST['dir'] : 'ASC';
|
||||
|
||||
$oProcess = new Process();
|
||||
|
||||
@@ -36,15 +37,15 @@ $memcacheUsed = 'not used';
|
||||
$totalCount = 0;
|
||||
if (isset( $_POST['category'] ) && $_POST['category'] !== '<reset>') {
|
||||
if (isset( $_POST['processName'] ))
|
||||
$proData = $oProcess->getAllProcesses( $start, $limit, $_POST['category'], $_POST['processName'] );
|
||||
$proData = $oProcess->getAllProcesses( $start, $limit, $_POST['category'], $_POST['processName'], null, null, $dir);
|
||||
else
|
||||
$proData = $oProcess->getAllProcesses( $start, $limit, $_POST['category'] );
|
||||
$proData = $oProcess->getAllProcesses( $start, $limit, $_POST['category'], null, null, null, $dir );
|
||||
} else {
|
||||
if (isset( $_POST['processName'] )) {
|
||||
$memkey = 'processList-' . $start . '-' . $limit . '-' . $_POST['processName'];
|
||||
$memcacheUsed = 'yes';
|
||||
if (($proData = $memcache->get( $memkey )) === false) {
|
||||
$proData = $oProcess->getAllProcesses( $start, $limit, null, $_POST['processName'] );
|
||||
$proData = $oProcess->getAllProcesses( $start, $limit, null, $_POST['processName'], null, null, $dir );
|
||||
$memcache->set( $memkey, $proData, PMmemcached::ONE_HOUR );
|
||||
$memcacheUsed = 'no';
|
||||
}
|
||||
@@ -53,13 +54,13 @@ if (isset( $_POST['category'] ) && $_POST['category'] !== '<reset>') {
|
||||
$memkeyTotal = $memkey . '-total';
|
||||
$memcacheUsed = 'yes';
|
||||
if (($proData = $memcache->get( $memkey )) === false || ($totalCount = $memcache->get( $memkeyTotal )) === false) {
|
||||
$proData = $oProcess->getAllProcesses( $start, $limit );
|
||||
$proData = $oProcess->getAllProcesses( $start, $limit, null, null, null, null, $dir );
|
||||
$totalCount = $oProcess->getAllProcessesCount();
|
||||
$memcache->set( $memkey, $proData, PMmemcached::ONE_HOUR );
|
||||
$memcache->set( $memkeyTotal, $totalCount, PMmemcached::ONE_HOUR );
|
||||
$memcacheUsed = 'no';
|
||||
} else {
|
||||
$proData = $oProcess->orderMemcache($proData, $start, $limit);
|
||||
$proData = $oProcess->orderMemcache($proData, $start, $limit, $dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user