From 823c5b26049a2dfcfa2cc787ee0803dba59572f1 Mon Sep 17 00:00:00 2001 From: Freddy Daniel Rojas Valda Date: Wed, 22 Jan 2014 16:41:32 -0400 Subject: [PATCH] Se agregan validaciones de project y activity para ASSIGNEE y ASSIGNEE ADHOC --- .../engine/src/BusinessModel/ProjectUser.php | 2 +- workflow/engine/src/BusinessModel/Task.php | 80 +++++++++++++++++++ .../Project/Activity/Assignee.php | 52 ++++++------ 3 files changed, 107 insertions(+), 27 deletions(-) diff --git a/workflow/engine/src/BusinessModel/ProjectUser.php b/workflow/engine/src/BusinessModel/ProjectUser.php index 71e3f95cb..346a52430 100644 --- a/workflow/engine/src/BusinessModel/ProjectUser.php +++ b/workflow/engine/src/BusinessModel/ProjectUser.php @@ -94,7 +94,7 @@ class ProjectUser $tasksLastIndex = count( $taskValue ) - 1; $taskValue = explode( ')', $taskValue[$tasksLastIndex] ); //echo ""; - echo $task['uid'] ." ------ ".$aUsers["tas_uid"]." fin "; + echo $task['uid'] ." ------ ".$aUsers." fin "; //var_dump($aUsers); if (in_array($task['uid'], $aUsers)) { echo "Es mac"; diff --git a/workflow/engine/src/BusinessModel/Task.php b/workflow/engine/src/BusinessModel/Task.php index b7d5b3ee8..b366659f1 100644 --- a/workflow/engine/src/BusinessModel/Task.php +++ b/workflow/engine/src/BusinessModel/Task.php @@ -589,6 +589,14 @@ class Task public function getTaskAssignees($sProcessUID, $sTaskUID, $filter, $start, $limit) { try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' do not correspond to a registered activity')); + } $aUsers = array(); $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); @@ -693,6 +701,14 @@ class Task public function getTaskAvailableAssignee($sProcessUID, $sTaskUID, $filter, $start, $limit) { try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' do not correspond to a registered activity')); + } $iType = 1; $aUsers = array(); $oTasks = new \Tasks(); @@ -788,6 +804,14 @@ class Task public function getTaskAssignee($sProcessUID, $sTaskUID, $sAssigneeUID) { try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' do not correspond to a registered activity')); + } $iType = 1; $aUsers = array(); $sDelimiter = \DBAdapter::getStringDelimiter(); @@ -889,6 +913,14 @@ class Task public function addTaskAssignee($sProcessUID, $sTaskUID, $sAssigneeUID, $assType) { try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' do not correspond to a registered activity')); + } $iType = 1; $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn( \TaskUserPeer::TU_RELATION ); @@ -952,6 +984,14 @@ class Task public function removeTaskAssignee($sProcessUID, $sTaskUID, $sAssigneeUID) { try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' do not correspond to a registered activity')); + } $iType = 1; $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn( \TaskUserPeer::TU_RELATION ); @@ -988,6 +1028,14 @@ class Task public function getTaskAdhocAssignees($sProcessUID, $sTaskUID, $filter, $start, $limit) { try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' do not correspond to a registered activity')); + } $aUsers = array(); $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); @@ -1089,6 +1137,14 @@ class Task public function getTaskAvailableAdhocAssignee($sProcessUID, $sTaskUID, $filter, $start, $limit) { try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' do not correspond to a registered activity')); + } $iType = 2; $aUsers = array(); $oTasks = new \Tasks(); @@ -1184,6 +1240,14 @@ class Task public function getTaskAdhocAssignee($sProcessUID, $sTaskUID, $sAssigneeUID) { try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' do not correspond to a registered activity')); + } $iType = 2; $aUsers = array(); $sDelimiter = \DBAdapter::getStringDelimiter(); @@ -1285,6 +1349,14 @@ class Task public function addTaskAdhocAssignee($sProcessUID, $sTaskUID, $sAssigneeUID, $assType) { try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' do not correspond to a registered activity')); + } $iType = 2; $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn( \TaskUserPeer::TU_RELATION ); @@ -1348,6 +1420,14 @@ class Task public function removeTaskAdhocAssignee($sProcessUID, $sTaskUID, $sAssigneeUID) { try { + $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); + if (is_null($oProcess)) { + throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process')); + } + $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); + if (is_null($oActivity)) { + throw (new \Exception( 'This id for `act_uid`: '. $sTaskUID .' do not correspond to a registered activity')); + } $iType = 2; $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn( \TaskUserPeer::TU_RELATION ); diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php index ecb806369..afa51f9cf 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/Activity/Assignee.php @@ -14,8 +14,8 @@ class Assignee extends Api /** * @url GET /:prjUid/activity/:actUid/assignee * - * @param string $prjUid - * @param string $actUid + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} * @param string $filter * @param int $start * @param int $limit @@ -39,8 +39,8 @@ class Assignee extends Api /** * @url GET /:prjUid/activity/:actUid/available-assignee * - * @param string $prjUid - * @param string $actUid + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} * @param string $filter * @param int $start * @param int $limit @@ -64,9 +64,9 @@ class Assignee extends Api /** * @url GET /:prjUid/activity/:actUid/assignee/:aasUid * - * @param string $prjUid - * @param string $actUid - * @param string $aasUid + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} + * @param string $aasUid {@min 32} {@max 32} * */ public function doGetActivityAssignee($prjUid, $actUid, $aasUid) @@ -87,9 +87,9 @@ class Assignee extends Api /** * @url POST /:prjUid/activity/:actUid/assignee * - * @param string $prjUid - * @param string $actUid - * @param string $aas_uid + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} + * @param string $aas_uid {@min 32} {@max 32} * @param string $aas_type {@choice user,group} * * @status 201 @@ -109,9 +109,9 @@ class Assignee extends Api /** * @url DELETE /:prjUid/activity/:actUid/assignee/:aasUid * - * @param string $prjUid - * @param string $actUid - * @param string $aasUid + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} + * @param string $aasUid {@min 32} {@max 32} * */ public function doDeleteActivityAssignee($prjUid, $actUid, $aasUid) @@ -129,8 +129,8 @@ class Assignee extends Api /** * @url GET /:prjUid/activity/:actUid/adhoc-assignee * - * @param string $prjUid - * @param string $actUid + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} * @param string $filter * @param int $start * @param int $limit @@ -154,8 +154,8 @@ class Assignee extends Api /** * @url GET /:prjUid/activity/:actUid/adhoc-available-assignee * - * @param string $prjUid - * @param string $actUid + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} * @param string $filter * @param int $start * @param int $limit @@ -179,9 +179,9 @@ class Assignee extends Api /** * @url GET /:prjUid/activity/:actUid/adhoc-assignee/:aasUid * - * @param string $prjUid - * @param string $actUid - * @param string $assUid + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} + * @param string $assUid {@min 32} {@max 32} * */ public function doGetActivityAdhocAssignee($prjUid, $actUid, $aasUid) @@ -202,9 +202,9 @@ class Assignee extends Api /** * @url POST /:prjUid/activity/:actUid/adhoc-assignee * - * @param string $prjUid - * @param string $actUid - * @param string $ada_uid + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} + * @param string $ada_uid {@min 32} {@max 32} * @param string $ada_type {@choice user,group} * * @status 201 @@ -224,9 +224,9 @@ class Assignee extends Api /** * @url DELETE /:prjUid/activity/:actUid/adhoc-assignee/:adaUid * - * @param string $prjUid - * @param string $actUid - * @param string $adaUid + * @param string $prjUid {@min 32} {@max 32} + * @param string $actUid {@min 32} {@max 32} + * @param string $adaUid {@min 32} {@max 32} * */ public function doDeleteActivityAdhocAssignee($prjUid, $actUid, $adaUid)