refactorizacion del endpoitn route-case y adicion de un nuevo endpoint

This commit is contained in:
Ronald Quenta
2015-06-24 14:36:06 -04:00
parent e0d18f6342
commit ce0274df93
3 changed files with 75 additions and 38 deletions

View File

@@ -2155,10 +2155,11 @@ class wsBase
* @param string $userId
* @param string $caseId
* @param string $delIndex
* @param array $tasks
* @param bool $bExecuteTriggersBeforeAssignment
* @return $result will return an object
*/
public function derivateCase ($userId, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false)
public function derivateCase ($userId, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks = array())
{
$g = new G();
@@ -2350,48 +2351,51 @@ class wsBase
}
$oDerivation = new Derivation();
$derive = $oDerivation->prepareInformation( $aData );
if (isset( $derive[1] )) {
if ($derive[1]['ROU_TYPE'] == 'SELECT') {
$result = new wsResponse( 21, G::loadTranslation( 'ID_CAN_NOT_ROUTE_CASE_USING_WEBSERVICES' ) );
return $result;
}
if (count($tasks) > 0) {
$nextDelegations = $tasks;
} else {
$result = new wsResponse( 22, G::loadTranslation( 'ID_TASK_DOES_NOT_HAVE_ROUTING_RULE' ) );
$derive = $oDerivation->prepareInformation($aData);
return $result;
}
if (isset($derive[1])) {
if ($derive[1]['ROU_TYPE'] == 'SELECT') {
$result = new wsResponse(21, G::loadTranslation('ID_CAN_NOT_ROUTE_CASE_USING_WEBSERVICES'));
foreach ($derive as $key => $val) {
if ($val['NEXT_TASK']['TAS_ASSIGN_TYPE'] == 'MANUAL') {
$result = new wsResponse( 15, G::loadTranslation( 'ID_TASK_DEFINED_MANUAL_ASSIGNMENT' ) );
return $result;
}
} else {
$result = new wsResponse(22, G::loadTranslation('ID_TASK_DOES_NOT_HAVE_ROUTING_RULE'));
return $result;
}
//Routed to the next task, if end process then not exist user
$nodeNext = array ();
$usrasgdUid = null;
$usrasgdUserName = null;
foreach ($derive as $key => $val) {
if ($val['NEXT_TASK']['TAS_ASSIGN_TYPE'] == 'MANUAL') {
$result = new wsResponse(15, G::loadTranslation('ID_TASK_DEFINED_MANUAL_ASSIGNMENT'));
if (isset( $val['NEXT_TASK']['USER_ASSIGNED'] )) {
$usrasgdUid = $val['NEXT_TASK']['USER_ASSIGNED']['USR_UID'];
$usrasgdUserName = '(' . $val['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME'] . ')';
return $result;
}
//Routed to the next task, if end process then not exist user
$nodeNext = array();
$usrasgdUid = null;
$usrasgdUserName = null;
if (isset($val['NEXT_TASK']['USER_ASSIGNED'])) {
$usrasgdUid = $val['NEXT_TASK']['USER_ASSIGNED']['USR_UID'];
$usrasgdUserName = '(' . $val['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME'] . ')';
}
$nodeNext['TAS_UID'] = $val['NEXT_TASK']['TAS_UID'];
$nodeNext['USR_UID'] = $usrasgdUid;
$nodeNext['TAS_ASSIGN_TYPE'] = $val['NEXT_TASK']['TAS_ASSIGN_TYPE'];
$nodeNext['TAS_DEF_PROC_CODE'] = $val['NEXT_TASK']['TAS_DEF_PROC_CODE'];
$nodeNext['DEL_PRIORITY'] = $appdel['DEL_PRIORITY'];
$nodeNext['TAS_PARENT'] = $val['NEXT_TASK']['TAS_PARENT'];
$nextDelegations[] = $nodeNext;
$varResponse = $varResponse . (($varResponse != '') ? ',' : '') . $val['NEXT_TASK']['TAS_TITLE'] . $usrasgdUserName;
}
$nodeNext['TAS_UID'] = $val['NEXT_TASK']['TAS_UID'];
$nodeNext['USR_UID'] = $usrasgdUid;
$nodeNext['TAS_ASSIGN_TYPE'] = $val['NEXT_TASK']['TAS_ASSIGN_TYPE'];
$nodeNext['TAS_DEF_PROC_CODE'] = $val['NEXT_TASK']['TAS_DEF_PROC_CODE'];
$nodeNext['DEL_PRIORITY'] = $appdel['DEL_PRIORITY'];
$nodeNext['TAS_PARENT'] = $val['NEXT_TASK']['TAS_PARENT'];
$nextDelegations[] = $nodeNext;
$varResponse = $varResponse . (($varResponse != '') ? ',' : '') . $val['NEXT_TASK']['TAS_TITLE'] . $usrasgdUserName;
}
$appFields['DEL_INDEX'] = $delIndex;
if (isset( $derive['TAS_UID'] )) {

View File

@@ -72,6 +72,7 @@ class Light
$newForm[$c]['title'] = $form['obj_title'];
$newForm[$c]['description'] = $form['obj_description'];
$newForm[$c]['stepId'] = $form["step_uid"];
$newForm[$c]['stepMode'] = $form['step_mode'];
$trigger = $this->statusTriggers($step->doGetActivityStepTriggers($form["step_uid"], $tempTreeChild['taskId'], $tempTreeChild['processId']));
$newForm[$c]["triggers"] = $trigger;
$c++;
@@ -333,11 +334,12 @@ class Light
* @param string $applicationUid Unique id of Case
* @param string $userUid Unique id of User
* @param string $delIndex
* @param array $tasks
* @param string $bExecuteTriggersBeforeAssignment
*
* return array Return an array with Task Case
*/
public function updateRouteCase($applicationUid, $userUid, $delIndex)
public function updateRouteCase($applicationUid, $userUid, $delIndex, $tasks)
{
try {
if (!$delIndex) {
@@ -345,7 +347,7 @@ class Light
}
\G::LoadClass('wsBase');
$ws = new \wsBase();
$fields = $ws->derivateCase($userUid, $applicationUid, $delIndex, $bExecuteTriggersBeforeAssignment = false);
$fields = $ws->derivateCase($userUid, $applicationUid, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks);
$array = json_decode(json_encode($fields), true);
if ($array ["status_code"] != 0) {
throw (new \Exception($array ["message"]));
@@ -1080,7 +1082,9 @@ class Light
} else {
$LANG_NAME = $locale['LANGUAGE'];
}
$languagesList[$LANG_ID] = $LANG_NAME;
$languages["L10n"] = $LANG_ID;
$languages["label"] = $LANG_NAME;
$languagesList[] = $languages;
}
$response['listLanguage'] = $languagesList;
return $response;

View File

@@ -505,6 +505,7 @@ class Light extends Api
$pmDynaForm->jsonr($result['formContent']);
$result['index'] = $i;
$result['stepId'] = $activitySteps[$i]["step_uid"];
$result['stepMode'] = $activitySteps[$i]['step_mode'];
$trigger = $oMobile->statusTriggers($step->doGetActivityStepTriggers($activitySteps[$i]["step_uid"], $act_uid, $prj_uid));
$result["triggers"] = $trigger;
$response[] = $result;
@@ -630,18 +631,46 @@ class Light extends Api
return $result;
}
/**
* Return Informaction User for derivate
* assignment Users
*
* @url GET /case/:app_uid/:del_index/assignment
*
* @param string $app_uid {@min 32}{@max 32}
* @param string $del_index
*/
public function doGetPrepareInformation($app_uid, $del_index = null)
{
try {
$oDerivation = new \Derivation();
$aData = array();
$aData['APP_UID'] = $app_uid;
$aData['DEL_INDEX'] = $del_index;
$aData['USER_UID'] = $this->getUserId();
$derive = $oDerivation->prepareInformation( $aData );
if (empty( $derive )) {
throw (new Exception( G::LoadTranslation( 'ID_NO_DERIVATION_RULE' ) ));
}
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
return $derive;
}
/**
* Route Case
* @url PUT /cases/:app_uid/route-case
*
* @param string $app_uid {@min 32}{@max 32}
* @param string $del_index {@from body}
* @param array $tasks {@from body}
*/
public function doPutRouteCase($app_uid, $del_index = null)
public function doPutRouteCase($app_uid, $del_index = null, $tasks = array())
{
try {
$oMobile = new \ProcessMaker\BusinessModel\Light();
$response = $oMobile->updateRouteCase($app_uid, $this->getUserId(), $del_index);
$response = $oMobile->updateRouteCase($app_uid, $this->getUserId(), $del_index, $tasks);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}