This commit is contained in:
hjonathan
2017-08-07 13:50:14 -04:00
parent 74889e7a2a
commit 33091008ff
4 changed files with 25 additions and 9 deletions

View File

@@ -1894,7 +1894,7 @@ class Task
} }
} }
public function getValidateSelfService($data) public function hasPendingCases($data)
{ {
$paused = false; $paused = false;
$data = array_change_key_case($data, CASE_LOWER); $data = array_change_key_case($data, CASE_LOWER);

View File

@@ -5,7 +5,7 @@ use ProcessMaker\Project;
class ProjectNotFound extends \RuntimeException class ProjectNotFound extends \RuntimeException
{ {
const EXCEPTION_CODE = 20; const EXCEPTION_CODE = 400;
public function __construct(Project\Handler $obj, $uid, $message = "", \Exception $previous = null) { public function __construct(Project\Handler $obj, $uid, $message = "", \Exception $previous = null) {
$message = empty($message) ? sprintf("Project \"%s\" with UID: %s, does not exist.", get_class($obj), $uid) : $message; $message = empty($message) ? sprintf("Project \"%s\" with UID: %s, does not exist.", get_class($obj), $uid) : $message;

View File

@@ -428,9 +428,13 @@ class Bpmn extends Handler
self::log("Remove Activity: $actUid"); self::log("Remove Activity: $actUid");
$activity = ActivityPeer::retrieveByPK($actUid); $activity = ActivityPeer::retrieveByPK($actUid);
$activity->delete(); if (isset($activity)) {
//TODO if the activity was removed, the related flows to that activity must be removed $activity->delete();
\BpmnFlow::removeAllRelated($actUid);
} else {
throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_DOES_NOT_EXIST", array("act_uid", $actUid)));
}
self::log("Remove Activity Success!"); self::log("Remove Activity Success!");
} catch (\Exception $e) { } catch (\Exception $e) {
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString()); self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());

View File

@@ -136,22 +136,34 @@ class Activity extends Api
/** /**
* This method remove an activity and all related components
* @param string $prj_uid {@min 32} {@max 32} * @param string $prj_uid {@min 32} {@max 32}
* @param string $act_uid {@min 32} {@max 32} * @param string $act_uid {@min 32} {@max 32}
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com> * @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia * @copyright Colosa - Bolivia
* @return array * @return array
* * @access protected
* @class AccessControl {@permission PM_FACTORY}
* @url DELETE /:prj_uid/activity/:act_uid * @url DELETE /:prj_uid/activity/:act_uid
*/ */
public function doDeleteProjectActivity($prj_uid, $act_uid) public function doDeleteProjectActivity($prj_uid, $act_uid)
{ {
try { try {
$task = new \ProcessMaker\BusinessModel\Task(); $task = new \ProcessMaker\BusinessModel\Task();
$task->deleteTask($prj_uid, $act_uid); $task->setFormatFieldNameInUppercase(false);
$task->setArrayParamException(array("taskUid" => "act_uid"));
$response = $task->hasPendingCases(array("act_uid" => $act_uid, "case_type" => "assigned"));
if ($response->result != false) {
$project = new \ProcessMaker\Project\Adapter\BpmnWorkflow();
$prj = $project->load($prj_uid);
$prj->removeActivity($act_uid);
} else {
throw new RestException(403, $response->message);
}
} catch (\Exception $e) { } catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); $resCode = $e->getCode() == 0 ? Api::STAT_APP_EXCEPTION : $e->getCode();
throw new RestException($resCode, $e->getMessage());
} }
} }
@@ -215,7 +227,7 @@ class Activity extends Api
$task->setFormatFieldNameInUppercase(false); $task->setFormatFieldNameInUppercase(false);
$task->setArrayParamException(array("taskUid" => "act_uid")); $task->setArrayParamException(array("taskUid" => "act_uid"));
$response = $task->getValidateSelfService($request_data); $response = $task->hasPendingCases($request_data);
return $response; return $response;
} catch (\Exception $e) { } catch (\Exception $e) {