diff --git a/workflow/engine/classes/model/ProcessCategory.php b/workflow/engine/classes/model/ProcessCategory.php index c293374e3..b0de98507 100755 --- a/workflow/engine/classes/model/ProcessCategory.php +++ b/workflow/engine/classes/model/ProcessCategory.php @@ -54,5 +54,11 @@ class ProcessCategory extends BaseProcessCategory $aRow = $dataset->getRow(); return $aRow; } + + public function exists ($catUid) + { + $oProCat = ProcessCategoryPeer::retrieveByPk( $catUid ); + return (is_object( $oProCat ) && get_class( $oProCat ) == 'ProcessCategory'); + } } diff --git a/workflow/engine/src/BusinessModel/Validator.php b/workflow/engine/src/BusinessModel/Validator.php index 85324878e..de3b01f1c 100644 --- a/workflow/engine/src/BusinessModel/Validator.php +++ b/workflow/engine/src/BusinessModel/Validator.php @@ -171,6 +171,56 @@ class Validator{ return $tri_uid; } + /** + * Validate pro_uid + * + * @param string $pro_uid, Uid for process + * @param string $nameField . Name of field for message + * + * @access public + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @return string + */ + static public function proUid($pro_uid, $nameField = 'pro_uid') + { + $pro_uid = trim($pro_uid); + if ($pro_uid == '') { + throw (new \Exception("The process with $nameField: '' does not exist.")); + } + $oProcess = new \Process(); + if (!($oProcess->exists($pro_uid))) { + throw (new \Exception("The process with $nameField: '$pro_uid' does not exist.")); + } + return $pro_uid; + } + + /** + * Validate cat_uid + * + * @param string $cat_uid, Uid for category + * @param string $nameField . Name of field for message + * + * @access public + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @return string + */ + static public function catUid($cat_uid, $nameField = 'cat_uid') + { + $cat_uid = trim($cat_uid); + if ($cat_uid == '') { + throw (new \Exception("The category with $nameField: '' does not exist.")); + } + $oCategory = new \ProcessCategory(); + if (!($oCategory->exists($cat_uid))) { + throw (new \Exception("The category with $nameField: '$cat_uid' does not exist.")); + } + return $cat_uid; + } + /** * Validate date *