Merge remote-tracking branch 'origin/feature/HOR-3559' into bugfix/HOR-3633-C
This commit is contained in:
@@ -1894,7 +1894,12 @@ class Task
|
||||
}
|
||||
}
|
||||
|
||||
public function getValidateSelfService($data)
|
||||
/**
|
||||
* This method verify if an activity has cases
|
||||
* @param $data
|
||||
* @return \stdclass
|
||||
*/
|
||||
public function hasPendingCases($data)
|
||||
{
|
||||
$paused = false;
|
||||
$data = array_change_key_case($data, CASE_LOWER);
|
||||
|
||||
@@ -5,7 +5,7 @@ use ProcessMaker\Project;
|
||||
|
||||
class ProjectNotFound extends \RuntimeException
|
||||
{
|
||||
const EXCEPTION_CODE = 20;
|
||||
const EXCEPTION_CODE = 400;
|
||||
|
||||
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;
|
||||
|
||||
@@ -1,39 +1,36 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Project;
|
||||
|
||||
use \BpmnProject as Project;
|
||||
use \BpmnProcess as Process;
|
||||
use \BpmnDiagram as Diagram;
|
||||
use \BasePeer;
|
||||
use \BpmnActivity as Activity;
|
||||
use \BpmnBound as Bound;
|
||||
use \BpmnEvent as Event;
|
||||
use \BpmnGateway as Gateway;
|
||||
use \BpmnFlow as Flow;
|
||||
use \BpmnArtifact as Artifact;
|
||||
|
||||
use \BpmnProjectPeer as ProjectPeer;
|
||||
use \BpmnProcessPeer as ProcessPeer;
|
||||
use \BpmnDiagramPeer as DiagramPeer;
|
||||
|
||||
use \BpmnActivityPeer as ActivityPeer;
|
||||
use \BpmnBoundPeer as BoundPeer;
|
||||
use \BpmnEventPeer as EventPeer;
|
||||
use \BpmnGatewayPeer as GatewayPeer;
|
||||
use \BpmnFlowPeer as FlowPeer;
|
||||
use \BpmnArtifactPeer as ArtifactPeer;
|
||||
use \BpmnParticipant as Participant;
|
||||
use \BpmnParticipantPeer as ParticipantPeer;
|
||||
use \BpmnBound as Bound;
|
||||
use \BpmnBoundPeer as BoundPeer;
|
||||
use \BpmnDiagram as Diagram;
|
||||
use \BpmnDiagramPeer as DiagramPeer;
|
||||
use \BpmnEvent as Event;
|
||||
use \BpmnEventPeer as EventPeer;
|
||||
use \BpmnFlow as Flow;
|
||||
use \BpmnFlowPeer as FlowPeer;
|
||||
use \BpmnGateway as Gateway;
|
||||
use \BpmnGatewayPeer as GatewayPeer;
|
||||
use \BpmnLaneset as Laneset;
|
||||
use \BpmnLanesetPeer as LanesetPeer;
|
||||
use \BpmnLane as Lane;
|
||||
use \BpmnLanePeer as LanePeer;
|
||||
|
||||
use \BasePeer;
|
||||
use \BpmnParticipant as Participant;
|
||||
use \BpmnParticipantPeer as ParticipantPeer;
|
||||
use \BpmnProject as Project;
|
||||
use \BpmnProcess as Process;
|
||||
use \BpmnProjectPeer as ProjectPeer;
|
||||
use \BpmnProcessPeer as ProcessPeer;
|
||||
use \Criteria as Criteria;
|
||||
use \Exception;
|
||||
use \G;
|
||||
use \ResultSet as ResultSet;
|
||||
|
||||
use ProcessMaker\Util\Common;
|
||||
use ProcessMaker\Exception;
|
||||
use \ProcessMaker\Util\Common;
|
||||
|
||||
/**
|
||||
* Class Bpmn
|
||||
@@ -428,9 +425,12 @@ class Bpmn extends Handler
|
||||
self::log("Remove Activity: $actUid");
|
||||
|
||||
$activity = ActivityPeer::retrieveByPK($actUid);
|
||||
$activity->delete();
|
||||
//TODO if the activity was removed, the related flows to that activity must be removed
|
||||
|
||||
if (isset($activity)) {
|
||||
$activity->delete();
|
||||
Flow::removeAllRelated($actUid);
|
||||
} else {
|
||||
throw new Exception(G::LoadTranslation("ID_ACTIVITY_DOES_NOT_EXIST", array("act_uid", $actUid)));
|
||||
}
|
||||
self::log("Remove Activity Success!");
|
||||
} catch (\Exception $e) {
|
||||
self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Services\Api\Project;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Exception;
|
||||
use \Luracast\Restler\RestException;
|
||||
use \ProcessMaker\BusinessModel\Task;
|
||||
use \ProcessMaker\Project\Adapter\BpmnWorkflow;
|
||||
use \ProcessMaker\Services\Api;
|
||||
|
||||
/**
|
||||
* Project\Activity Api Controller
|
||||
@@ -136,22 +139,32 @@ class Activity extends Api
|
||||
|
||||
|
||||
/**
|
||||
* This method remove an activity and all related components
|
||||
* @param string $prj_uid {@min 32} {@max 32}
|
||||
* @param string $act_uid {@min 32} {@max 32}
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_FACTORY}
|
||||
* @url DELETE /:prj_uid/activity/:act_uid
|
||||
*/
|
||||
public function doDeleteProjectActivity($prj_uid, $act_uid)
|
||||
{
|
||||
try {
|
||||
$task = new \ProcessMaker\BusinessModel\Task();
|
||||
$task->deleteTask($prj_uid, $act_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
$task = new Task();
|
||||
$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 BpmnWorkflow();
|
||||
$prj = $project->load($prj_uid);
|
||||
$prj->removeActivity($act_uid);
|
||||
} else {
|
||||
throw new RestException(403, $response->message);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$resCode = $e->getCode() == 0 ? Api::STAT_APP_EXCEPTION : $e->getCode();
|
||||
throw new RestException($resCode, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +228,7 @@ class Activity extends Api
|
||||
$task->setFormatFieldNameInUppercase(false);
|
||||
$task->setArrayParamException(array("taskUid" => "act_uid"));
|
||||
|
||||
$response = $task->getValidateSelfService($request_data);
|
||||
$response = $task->hasPendingCases($request_data);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user