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;
|
$paused = false;
|
||||||
$data = array_change_key_case($data, CASE_LOWER);
|
$data = array_change_key_case($data, CASE_LOWER);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -1,39 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProcessMaker\Project;
|
namespace ProcessMaker\Project;
|
||||||
|
|
||||||
use \BpmnProject as Project;
|
use \BasePeer;
|
||||||
use \BpmnProcess as Process;
|
|
||||||
use \BpmnDiagram as Diagram;
|
|
||||||
use \BpmnActivity as Activity;
|
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 \BpmnArtifact as Artifact;
|
||||||
|
|
||||||
use \BpmnProjectPeer as ProjectPeer;
|
|
||||||
use \BpmnProcessPeer as ProcessPeer;
|
|
||||||
use \BpmnDiagramPeer as DiagramPeer;
|
|
||||||
|
|
||||||
use \BpmnActivityPeer as ActivityPeer;
|
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 \BpmnArtifactPeer as ArtifactPeer;
|
||||||
use \BpmnParticipant as Participant;
|
use \BpmnBound as Bound;
|
||||||
use \BpmnParticipantPeer as ParticipantPeer;
|
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 \BpmnLaneset as Laneset;
|
||||||
use \BpmnLanesetPeer as LanesetPeer;
|
use \BpmnLanesetPeer as LanesetPeer;
|
||||||
use \BpmnLane as Lane;
|
use \BpmnLane as Lane;
|
||||||
use \BpmnLanePeer as LanePeer;
|
use \BpmnLanePeer as LanePeer;
|
||||||
|
use \BpmnParticipant as Participant;
|
||||||
use \BasePeer;
|
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 \Criteria as Criteria;
|
||||||
|
use \Exception;
|
||||||
|
use \G;
|
||||||
use \ResultSet as ResultSet;
|
use \ResultSet as ResultSet;
|
||||||
|
use \ProcessMaker\Util\Common;
|
||||||
use ProcessMaker\Util\Common;
|
|
||||||
use ProcessMaker\Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Bpmn
|
* Class Bpmn
|
||||||
@@ -428,9 +425,12 @@ class Bpmn extends Handler
|
|||||||
self::log("Remove Activity: $actUid");
|
self::log("Remove Activity: $actUid");
|
||||||
|
|
||||||
$activity = ActivityPeer::retrieveByPK($actUid);
|
$activity = ActivityPeer::retrieveByPK($actUid);
|
||||||
|
if (isset($activity)) {
|
||||||
$activity->delete();
|
$activity->delete();
|
||||||
//TODO if the activity was removed, the related flows to that activity must be removed
|
Flow::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());
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProcessMaker\Services\Api\Project;
|
namespace ProcessMaker\Services\Api\Project;
|
||||||
|
|
||||||
use \ProcessMaker\Services\Api;
|
use \Exception;
|
||||||
use \Luracast\Restler\RestException;
|
use \Luracast\Restler\RestException;
|
||||||
|
use \ProcessMaker\BusinessModel\Task;
|
||||||
|
use \ProcessMaker\Project\Adapter\BpmnWorkflow;
|
||||||
|
use \ProcessMaker\Services\Api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project\Activity Api Controller
|
* 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 $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>
|
|
||||||
* @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 Task();
|
||||||
$task->deleteTask($prj_uid, $act_uid);
|
$task->setFormatFieldNameInUppercase(false);
|
||||||
} catch (\Exception $e) {
|
$task->setArrayParamException(array("taskUid" => "act_uid"));
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
||||||
|
$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->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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user