2014-01-29 17:46:28 -04:00
|
|
|
<?php
|
2014-04-02 17:02:02 -04:00
|
|
|
namespace ProcessMaker\Services\Api;
|
2014-01-29 17:46:28 -04:00
|
|
|
|
|
|
|
|
use \ProcessMaker\Services\Api;
|
|
|
|
|
use \Luracast\Restler\RestException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Group Api Controller
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
*/
|
|
|
|
|
class Group extends Api
|
|
|
|
|
{
|
2015-09-04 16:51:19 -04:00
|
|
|
/**
|
|
|
|
|
* Constructor of the class
|
|
|
|
|
*
|
|
|
|
|
* return void
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$user = new \ProcessMaker\BusinessModel\User();
|
|
|
|
|
|
|
|
|
|
$usrUid = $this->getUserId();
|
|
|
|
|
|
|
|
|
|
if (!$user->checkPermission($usrUid, "PM_USERS")) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION", array($usrUid)));
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-29 17:46:28 -04:00
|
|
|
/**
|
|
|
|
|
* @url GET
|
|
|
|
|
*/
|
PM-3659 "Uso de interface lenta (assignment rules) cuando..." SOLVED
Issue:
Uso de interface lenta (assignment rules) cuando se tienen varios usuarios (40000)
Cause:
No se realizo de manera correcta el paginado de registros
Solution:
> Se a implementado los siguientes end-points:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/available-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-available-assignee/paged
Estos end-points aceptan los siguientes parametros:
/paged?filter={filter}&start={start}&limit={limit}&type={type}
/paged?lfilter={lfilter}&start={start}&limit={limit}&type={type}
/paged?rfilter={rfilter}&start={start}&limit={limit}&type={type}
Donde:
filter: Representa la busqueda de registros que contienen este valor
lfilter: Representa la busqueda de registros que empiezan con este valor
rfilter: Representa la busqueda de registros que terminan con este valor
type: Acepta los siguentes valores: "user", "group"
Ejemplo:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged?start=0&limit=3
<<<<< 200
{
"total": 15,
"start": 0,
"limit": 3,
"filter": "",
"data": [
{
"aas_uid": "60593768854492f8fa43aa2064326562",
"aas_name": "GROUP1 (2 Users)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "11886228656016c9329c898096916123",
"aas_name": "GROUP2 (1 User)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "52242914255f202805bd552031573543",
"aas_name": "user1",
"aas_lastname": "user1",
"aas_username": "user1",
"aas_type": "user"
}
]
}
> Se a mejorado los siguientes end-points:
GET /api/1.0/{workspace}/users?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?rfilter={rfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?rfilter={rfilter}&start={start}&limit={limit}
2015-09-25 15:11:42 -04:00
|
|
|
public function index($filter = null, $lfilter = null, $rfilter = null, $start = null, $limit = null)
|
2014-01-29 17:46:28 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-01-30 14:30:18 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
2014-01-29 17:46:28 -04:00
|
|
|
|
PM-3659 "Uso de interface lenta (assignment rules) cuando..." SOLVED
Issue:
Uso de interface lenta (assignment rules) cuando se tienen varios usuarios (40000)
Cause:
No se realizo de manera correcta el paginado de registros
Solution:
> Se a implementado los siguientes end-points:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/available-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-available-assignee/paged
Estos end-points aceptan los siguientes parametros:
/paged?filter={filter}&start={start}&limit={limit}&type={type}
/paged?lfilter={lfilter}&start={start}&limit={limit}&type={type}
/paged?rfilter={rfilter}&start={start}&limit={limit}&type={type}
Donde:
filter: Representa la busqueda de registros que contienen este valor
lfilter: Representa la busqueda de registros que empiezan con este valor
rfilter: Representa la busqueda de registros que terminan con este valor
type: Acepta los siguentes valores: "user", "group"
Ejemplo:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged?start=0&limit=3
<<<<< 200
{
"total": 15,
"start": 0,
"limit": 3,
"filter": "",
"data": [
{
"aas_uid": "60593768854492f8fa43aa2064326562",
"aas_name": "GROUP1 (2 Users)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "11886228656016c9329c898096916123",
"aas_name": "GROUP2 (1 User)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "52242914255f202805bd552031573543",
"aas_name": "user1",
"aas_lastname": "user1",
"aas_username": "user1",
"aas_type": "user"
}
]
}
> Se a mejorado los siguientes end-points:
GET /api/1.0/{workspace}/users?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?rfilter={rfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?rfilter={rfilter}&start={start}&limit={limit}
2015-09-25 15:11:42 -04:00
|
|
|
$arrayFilterData = array(
|
|
|
|
|
"filter" => (!is_null($filter))? $filter : ((!is_null($lfilter))? $lfilter : ((!is_null($rfilter))? $rfilter : null)),
|
|
|
|
|
"filterOption" => (!is_null($filter))? "" : ((!is_null($lfilter))? "LEFT" : ((!is_null($rfilter))? "RIGHT" : ""))
|
|
|
|
|
);
|
2014-01-29 17:46:28 -04:00
|
|
|
|
PM-3659 "Uso de interface lenta (assignment rules) cuando..." SOLVED
Issue:
Uso de interface lenta (assignment rules) cuando se tienen varios usuarios (40000)
Cause:
No se realizo de manera correcta el paginado de registros
Solution:
> Se a implementado los siguientes end-points:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/available-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-available-assignee/paged
Estos end-points aceptan los siguientes parametros:
/paged?filter={filter}&start={start}&limit={limit}&type={type}
/paged?lfilter={lfilter}&start={start}&limit={limit}&type={type}
/paged?rfilter={rfilter}&start={start}&limit={limit}&type={type}
Donde:
filter: Representa la busqueda de registros que contienen este valor
lfilter: Representa la busqueda de registros que empiezan con este valor
rfilter: Representa la busqueda de registros que terminan con este valor
type: Acepta los siguentes valores: "user", "group"
Ejemplo:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged?start=0&limit=3
<<<<< 200
{
"total": 15,
"start": 0,
"limit": 3,
"filter": "",
"data": [
{
"aas_uid": "60593768854492f8fa43aa2064326562",
"aas_name": "GROUP1 (2 Users)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "11886228656016c9329c898096916123",
"aas_name": "GROUP2 (1 User)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "52242914255f202805bd552031573543",
"aas_name": "user1",
"aas_lastname": "user1",
"aas_username": "user1",
"aas_type": "user"
}
]
}
> Se a mejorado los siguientes end-points:
GET /api/1.0/{workspace}/users?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?rfilter={rfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?rfilter={rfilter}&start={start}&limit={limit}
2015-09-25 15:11:42 -04:00
|
|
|
$response = $group->getGroups($arrayFilterData, null, null, $start, $limit);
|
|
|
|
|
|
|
|
|
|
return $response["data"];
|
2014-01-29 17:46:28 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:grp_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGet($grp_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-01-30 14:30:18 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
2014-01-29 17:46:28 -04:00
|
|
|
|
|
|
|
|
$response = $group->getGroup($grp_uid);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url POST
|
|
|
|
|
*
|
2014-02-10 17:16:44 -04:00
|
|
|
* @param array $request_data
|
2014-01-29 17:46:28 -04:00
|
|
|
*
|
|
|
|
|
* @status 201
|
|
|
|
|
*/
|
2014-02-10 17:16:44 -04:00
|
|
|
public function doPost($request_data)
|
|
|
|
|
{
|
2014-01-29 17:46:28 -04:00
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-01-30 14:30:18 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
2014-01-29 17:46:28 -04:00
|
|
|
|
|
|
|
|
$arrayData = $group->create($request_data);
|
|
|
|
|
|
|
|
|
|
$response = $arrayData;
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url PUT /:grp_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
* @param array $request_data
|
|
|
|
|
*/
|
2014-02-10 17:16:44 -04:00
|
|
|
public function doPut($grp_uid, $request_data)
|
|
|
|
|
{
|
2014-01-29 17:46:28 -04:00
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-01-30 14:30:18 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
2014-01-29 17:46:28 -04:00
|
|
|
|
|
|
|
|
$arrayData = $group->update($grp_uid, $request_data);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url DELETE /:grp_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doDelete($grp_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-01-30 14:30:18 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
2014-01-29 17:46:28 -04:00
|
|
|
|
|
|
|
|
$group->delete($grp_uid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-10 17:16:44 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:grp_uid/users
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGetUsers($grp_uid, $filter = null, $start = null, $limit = null)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-02-10 17:16:44 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
|
|
|
|
|
|
|
|
|
$response = $group->getUsers("USERS", $grp_uid, array("filter" => $filter), null, null, $start, $limit);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:grp_uid/available-users
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGetAvailableUsers($grp_uid, $filter = null, $start = null, $limit = null)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-02-10 17:16:44 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
|
|
|
|
|
|
|
|
|
$response = $group->getUsers("AVAILABLE-USERS", $grp_uid, array("filter" => $filter), null, null, $start, $limit);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-12 09:18:47 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:grp_uid/supervisor-users
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGetSupervisorUsers($grp_uid, $filter = null, $start = null, $limit = null)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
|
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
|
|
|
|
|
|
|
|
|
$response = $group->getUsers("SUPERVISOR", $grp_uid, array("filter" => $filter), null, null, $start, $limit);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-29 17:46:28 -04:00
|
|
|
}
|
|
|
|
|
|