PMCORE-3130
This commit is contained in:
69
workflow/engine/src/ProcessMaker/Services/Api/Metrics.php
Normal file
69
workflow/engine/src/ProcessMaker/Services/Api/Metrics.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use Exception;
|
||||
use ProcessMaker\BusinessModel\Cases\Draft;
|
||||
use ProcessMaker\BusinessModel\Cases\Inbox;
|
||||
use ProcessMaker\BusinessModel\Cases\Paused;
|
||||
use ProcessMaker\BusinessModel\Cases\Unassigned;
|
||||
use ProcessMaker\Services\Api;
|
||||
use RBAC;
|
||||
|
||||
class Metrics extends Api
|
||||
{
|
||||
/**
|
||||
* Constructor of the class
|
||||
* Defines the $RBAC definition
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $RBAC;
|
||||
if (!isset($RBAC)) {
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->sSystem = 'PROCESSMAKER';
|
||||
$RBAC->initRBAC();
|
||||
$RBAC->loadUserRolePermission($RBAC->sSystem, $this->getUserId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total cases per process
|
||||
*
|
||||
* @url /process-total-cases
|
||||
*
|
||||
* @param string $caseList
|
||||
* @param int $category
|
||||
* @param bool $topTen
|
||||
* @param array $processes
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*
|
||||
* @class AccessControl {@permission TASK_METRICS_VIEW}
|
||||
*/
|
||||
public function getProcessTotalCases($caseList, $category = null, $topTen = false, $processes = [])
|
||||
{
|
||||
try {
|
||||
switch ($caseList) {
|
||||
case 'inbox':
|
||||
$list = new Inbox();
|
||||
break;
|
||||
case 'draft':
|
||||
$list = new Draft();
|
||||
break;
|
||||
case 'paused':
|
||||
$list = new Paused();
|
||||
break;
|
||||
case 'unassigned':
|
||||
$list = new Unassigned();
|
||||
break;
|
||||
}
|
||||
$result = $list->getCountersByProcesses($category, $topTen, $processes);
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user