Merged in victorsl/processmaker (pull request #71)
ProcessMaker-MA "Project Properties - Step Resources - Assign Task (endpoints & behat)"
This commit is contained in:
@@ -301,3 +301,150 @@ Feature: Project Properties - Step Resources
|
||||
And the type is "array"
|
||||
And the json data is an empty array
|
||||
|
||||
#TRIGGERS OF STEP "ASSIGN TASK"
|
||||
|
||||
#GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/triggers
|
||||
# List assigned Triggers to a Step
|
||||
Scenario: List Triggers assigned to Step "Assign Task" of "Task2"
|
||||
Given that I have a valid access_token
|
||||
And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/triggers"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "array"
|
||||
And the json data is an empty array
|
||||
|
||||
#POST /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger
|
||||
# Assign a Trigger to a Step
|
||||
Scenario: Assign "Trigger Demo1" to Step "Assign Task" of "Task2"
|
||||
Given that I have a valid access_token
|
||||
And POST this data:
|
||||
"""
|
||||
{
|
||||
"tri_uid": "81919273152cd636c665080083928728",
|
||||
"st_type": "BEFORE_ASSIGNMENT",
|
||||
"st_condition": "",
|
||||
"st_position": 1
|
||||
}
|
||||
"""
|
||||
And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 201
|
||||
And the response charset is "UTF-8"
|
||||
|
||||
#POST /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger
|
||||
# Assign a Trigger to a Step
|
||||
Scenario: Assign "Trigger Demo2" to Step "Assign Task" of "Task2"
|
||||
Given that I have a valid access_token
|
||||
And POST this data:
|
||||
"""
|
||||
{
|
||||
"tri_uid": "56359776552cd6378b38e47080912028",
|
||||
"st_type": "BEFORE_ASSIGNMENT",
|
||||
"st_condition": "",
|
||||
"st_position": 2
|
||||
}
|
||||
"""
|
||||
And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 201
|
||||
And the response charset is "UTF-8"
|
||||
|
||||
#PUT /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger/{tri_uid}
|
||||
# Update a Trigger assignation of a Step
|
||||
Scenario: Update "Trigger Demo1" assigned to Step "Assign Task" of "Task2"
|
||||
Given that I have a valid access_token
|
||||
And PUT this data:
|
||||
"""
|
||||
{
|
||||
"st_type": "BEFORE_ASSIGNMENT",
|
||||
"st_condition": "@@FIELD2 == 2"
|
||||
}
|
||||
"""
|
||||
And that I want to update a resource with the key "tgr1" stored in session array
|
||||
And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger/81919273152cd636c665080083928728"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
And that "st_condition" is set to "@@FIELD2 == 2"
|
||||
|
||||
#GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/triggers
|
||||
# List assigned Triggers to a Step
|
||||
Scenario: List Triggers assigned to Step "Assign Task" of "Task2"
|
||||
Given that I have a valid access_token
|
||||
And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/triggers"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "array"
|
||||
And the "tri_uid" property in row 1 equals "56359776552cd6378b38e47080912028"
|
||||
And the "tri_title" property in row 1 equals "Trigger Demo2"
|
||||
And the "tri_description" property in row 1 equals "Description"
|
||||
And the "st_type" property in row 1 equals "BEFORE_ASSIGNMENT"
|
||||
And the "st_condition" property in row 1 equals ""
|
||||
And the "st_position" property in row 1 equals "2"
|
||||
|
||||
#GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/available-triggers/{type}
|
||||
# List available Triggers to assign to a Step
|
||||
Scenario: List available Triggers to assign to Step "Assign Task" of "Task2"
|
||||
Given that I have a valid access_token
|
||||
And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/available-triggers/before-assignment"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "array"
|
||||
And the "tri_uid" property in row 0 equals "57401970252cd6393531551040242546"
|
||||
And the "tri_title" property in row 0 equals "Trigger Demo3"
|
||||
And the "tri_description" property in row 0 equals "Description"
|
||||
And the "tri_type" property in row 0 equals "SCRIPT"
|
||||
And the "tri_webbot" property in row 0 equals ""
|
||||
And the "tri_param" property in row 0 equals ""
|
||||
|
||||
#GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger/{tri_uid}/{type}
|
||||
# Get a single Trigger assigned to a Step
|
||||
Scenario: Get a single Trigger "Trigger Demo1" assigned to Step "Assign Task" of "Task2"
|
||||
Given that I have a valid access_token
|
||||
And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger/81919273152cd636c665080083928728/before-assignment"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "object"
|
||||
And that "tri_uid" is set to "81919273152cd636c665080083928728"
|
||||
And that "tri_title" is set to "Trigger Demo1"
|
||||
And that "tri_description" is set to "Description"
|
||||
And that "st_type" is set to "BEFORE_ASSIGNMENT"
|
||||
And that "st_condition" is set to "@@FIELD2 == 2"
|
||||
And that "st_position" is set to "1"
|
||||
|
||||
#DELETE /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger/{tri_uid}/{type}
|
||||
# Remove a Trigger assignation of a Step
|
||||
Scenario: Remove "Trigger Demo1" assigned to Step "Assign Task" of "Task2"
|
||||
Given that I have a valid access_token
|
||||
And that I want to delete a resource with the key "tgr1" stored in session array
|
||||
And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger/81919273152cd636c665080083928728/before-assignment"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
|
||||
#DELETE /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/trigger/{tri_uid}/{type}
|
||||
# Remove a Trigger assignation of a Step
|
||||
Scenario: Remove "Trigger Demo2" assigned to Step "Assign Task" of "Task2"
|
||||
Given that I have a valid access_token
|
||||
And that I want to delete a resource with the key "tgr2" stored in session array
|
||||
And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/trigger/56359776552cd6378b38e47080912028/before-assignment"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
|
||||
#GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/step/triggers
|
||||
# List assigned Triggers to a Step
|
||||
Scenario: List Triggers assigned to Step "Assign Task" of "Task2"
|
||||
Given that I have a valid access_token
|
||||
And I request "project/16062437052cd6141881e06088349078/activity/89706843252cd9decdcf9b3047762708/step/triggers"
|
||||
And the content type is "application/json"
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "array"
|
||||
And the json data is an empty array
|
||||
|
||||
|
||||
@@ -381,9 +381,11 @@ class Step
|
||||
$rsCriteria = \StepPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$rsCriteria->next();
|
||||
|
||||
return $rsCriteria->getRow();
|
||||
if ($rsCriteria->next()) {
|
||||
return $rsCriteria->getRow();
|
||||
} else {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
@@ -393,20 +395,60 @@ class Step
|
||||
* Get available triggers of a Step
|
||||
*
|
||||
* @param string $stepUid Unique id of Step
|
||||
* @param string $type Type (BEFORE, AFTER)
|
||||
* @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING)
|
||||
* @param string $taskUid Unique id of Task
|
||||
*
|
||||
* return array
|
||||
*/
|
||||
public function getAvailableTriggers($stepUid, $type)
|
||||
public function getAvailableTriggers($stepUid, $type, $taskUid = "")
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$step = new \Step();
|
||||
|
||||
if ($stepUid != "" && !$step->StepExists($stepUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
|
||||
$task = new \Task();
|
||||
|
||||
if ($stepUid == "" && !$task->taskExists($taskUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($taskUid, "TASK"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
|
||||
//Get data
|
||||
$arrayAvailableTrigger = array();
|
||||
|
||||
$trigger = new \BusinessModel\Trigger();
|
||||
|
||||
$arrayDataUid = $this->getDataUids($stepUid);
|
||||
$flagStepAssignTask = 0;
|
||||
|
||||
$processUid = $arrayDataUid["PRO_UID"];
|
||||
if ($stepUid != "") {
|
||||
$arrayDataUid = $this->getDataUids($stepUid);
|
||||
|
||||
$processUid = $arrayDataUid["PRO_UID"];
|
||||
} else {
|
||||
$arrayData = $task->load($taskUid);
|
||||
|
||||
$processUid = $arrayData["PRO_UID"];
|
||||
|
||||
$flagStepAssignTask = 1;
|
||||
|
||||
switch ($type) {
|
||||
case "BEFORE_ASSIGNMENT":
|
||||
$stepUid = "-1";
|
||||
$type = "BEFORE";
|
||||
break;
|
||||
case "BEFORE_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$type = "BEFORE";
|
||||
break;
|
||||
case "AFTER_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$type = "AFTER";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Get Uids
|
||||
$arrayUid = array();
|
||||
@@ -415,6 +457,11 @@ class Step
|
||||
|
||||
$criteria->addSelectColumn(\StepTriggerPeer::TRI_UID);
|
||||
$criteria->add(\StepTriggerPeer::STEP_UID, $stepUid, \Criteria::EQUAL);
|
||||
|
||||
if ($flagStepAssignTask == 1) {
|
||||
$criteria->add(\StepTriggerPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add(\StepTriggerPeer::ST_TYPE, $type, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \StepTriggerPeer::doSelectRS($criteria);
|
||||
@@ -459,21 +506,37 @@ class Step
|
||||
* Get all triggers of a Step
|
||||
*
|
||||
* @param string $stepUid Unique id of Step
|
||||
* @param string $taskUid Unique id of Task
|
||||
*
|
||||
* return array
|
||||
*/
|
||||
public function getTriggers($stepUid)
|
||||
public function getTriggers($stepUid, $taskUid = "")
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$step = new \Step();
|
||||
|
||||
if ($stepUid != "" && !$step->StepExists($stepUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
|
||||
$task = new \Task();
|
||||
|
||||
if ($stepUid == "" && !$task->taskExists($taskUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($taskUid, "TASK"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
|
||||
//Get data
|
||||
$arrayTrigger = array();
|
||||
|
||||
$bmTrigger = new \BusinessModel\Trigger();
|
||||
$bmStepTrigger = new \BusinessModel\Step\Trigger();
|
||||
|
||||
$arrayDataUid = $this->getDataUids($stepUid);
|
||||
if ($stepUid != "") {
|
||||
$arrayDataUid = $this->getDataUids($stepUid);
|
||||
|
||||
$taskUid = $arrayDataUid["TAS_UID"];
|
||||
$taskUid = $arrayDataUid["TAS_UID"];
|
||||
}
|
||||
|
||||
$processMap = new \ProcessMap();
|
||||
$stepTrigger = new \StepTrigger();
|
||||
@@ -495,15 +558,20 @@ class Step
|
||||
$triggerType = $index;
|
||||
$type = $value;
|
||||
|
||||
$flagStepAssignTask = 0;
|
||||
|
||||
switch ($triggerType) {
|
||||
case "BEFORE_ASSIGNMENT":
|
||||
$stepUid = "-1";
|
||||
$flagStepAssignTask = 1;
|
||||
break;
|
||||
case "BEFORE_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$flagStepAssignTask = 1;
|
||||
break;
|
||||
case "AFTER_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$flagStepAssignTask = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -527,6 +595,10 @@ class Step
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
if ($flagStepAssignTask == 1) {
|
||||
$row["ST_TYPE"] = $triggerType;
|
||||
}
|
||||
|
||||
$arrayTrigger[] = $bmStepTrigger->getTriggerDataFromRecord($row);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,14 @@ class Trigger
|
||||
*
|
||||
* @param string $stepUid Unique id of Step
|
||||
* @param string $type Type (BEFORE, AFTER)
|
||||
* @param string $taskUid Unique id of Task
|
||||
* @param string $triggerUid Unique id of Trigger
|
||||
* @param int $position Position
|
||||
* @param string $triggerUidExclude Unique id of Trigger to exclude
|
||||
*
|
||||
* return bool Return true if exists the record in table STEP_TRIGGER, false otherwise
|
||||
*/
|
||||
public function existsRecord($stepUid, $type, $triggerUid, $position = 0, $triggerUidExclude = "")
|
||||
public function existsRecord($stepUid, $type, $taskUid, $triggerUid, $position = 0, $triggerUidExclude = "")
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("workflow");
|
||||
@@ -22,6 +23,7 @@ class Trigger
|
||||
$criteria->addSelectColumn(\StepTriggerPeer::STEP_UID);
|
||||
$criteria->add(\StepTriggerPeer::STEP_UID, $stepUid, \Criteria::EQUAL);
|
||||
$criteria->add(\StepTriggerPeer::ST_TYPE, $type, \Criteria::EQUAL);
|
||||
$criteria->add(\StepTriggerPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
|
||||
|
||||
if ($triggerUid != "") {
|
||||
$criteria->add(\StepTriggerPeer::TRI_UID, $triggerUid, \Criteria::EQUAL);
|
||||
@@ -52,26 +54,53 @@ class Trigger
|
||||
* Assign Trigger to a Step
|
||||
*
|
||||
* @param string $stepUid Unique id of Step
|
||||
* @param string $type Type (BEFORE, AFTER)
|
||||
* @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING)
|
||||
* @param string $taskUid Unique id of Task
|
||||
* @param string $triggerUid Unique id of Trigger
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Data of the Trigger assigned to a Step
|
||||
*/
|
||||
public function create($stepUid, $type, $triggerUid, $arrayData)
|
||||
public function create($stepUid, $type, $taskUid, $triggerUid, $arrayData)
|
||||
{
|
||||
try {
|
||||
$step = new \BusinessModel\Step();
|
||||
$stepUidIni = $stepUid;
|
||||
$typeIni = $type;
|
||||
|
||||
$arrayDataUid = $step->getDataUids($stepUid);
|
||||
$flagStepAssignTask = 0;
|
||||
|
||||
$taskUid = $arrayDataUid["TAS_UID"];
|
||||
if ($stepUid == "") {
|
||||
$flagStepAssignTask = 1;
|
||||
|
||||
switch ($type) {
|
||||
case "BEFORE_ASSIGNMENT":
|
||||
$stepUid = "-1";
|
||||
$type = "BEFORE";
|
||||
break;
|
||||
case "BEFORE_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$type = "BEFORE";
|
||||
break;
|
||||
case "AFTER_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$type = "AFTER";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Verify data
|
||||
$step = new \Step();
|
||||
if ($flagStepAssignTask == 0) {
|
||||
$step = new \Step();
|
||||
|
||||
if (!$step->StepExists($stepUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
if (!$step->StepExists($stepUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
}
|
||||
|
||||
$task = new \Task();
|
||||
|
||||
if (!$task->taskExists($taskUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($taskUid, "TASK"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
|
||||
$trigger = new \Triggers();
|
||||
@@ -80,12 +109,12 @@ class Trigger
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($triggerUid, "TRIGGERS"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
|
||||
if ($this->existsRecord($stepUid, $type, $triggerUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", exists in table {1}")));
|
||||
if ($this->existsRecord($stepUid, $type, $taskUid, $triggerUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $taskUid . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", exists in table {1}")));
|
||||
}
|
||||
|
||||
if (isset($arrayData["st_position"]) && $this->existsRecord($stepUid, $type, "", $arrayData["st_position"])) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["st_position"], $stepUid . ", " . $type . ", " . $arrayData["st_position"], "STEP_TRIGGER"), "The \"{0}\" position for the record \"{1}\", exists in table {2}")));
|
||||
if (isset($arrayData["st_position"]) && $this->existsRecord($stepUid, $type, $taskUid, "", $arrayData["st_position"])) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["st_position"], $stepUid . ", " . $type . ", " . $taskUid . ", " . $arrayData["st_position"], "STEP_TRIGGER"), "The \"{0}\" position for the record \"{1}\", exists in table {2}")));
|
||||
}
|
||||
|
||||
//Create
|
||||
@@ -97,7 +126,7 @@ class Trigger
|
||||
$arrayData["st_position"] = $stepTrigger->getNextPosition($stepUid, $type, $taskUid) - 1;
|
||||
}
|
||||
|
||||
$arrayData = $this->update($stepUid, $type, $triggerUid, $arrayData);
|
||||
$arrayData = $this->update($stepUidIni, $typeIni, $taskUid, $triggerUid, $arrayData);
|
||||
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
@@ -109,26 +138,44 @@ class Trigger
|
||||
* Update Trigger of a Step
|
||||
*
|
||||
* @param string $stepUid Unique id of Step
|
||||
* @param string $type Type (BEFORE, AFTER)
|
||||
* @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING)
|
||||
* @param string $taskUid Unique id of Task
|
||||
* @param string $triggerUid Unique id of Trigger
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Data updated of the Trigger assigned to a Step
|
||||
*/
|
||||
public function update($stepUid, $type, $triggerUid, $arrayData)
|
||||
public function update($stepUid, $type, $taskUid, $triggerUid, $arrayData)
|
||||
{
|
||||
try {
|
||||
$step = new \BusinessModel\Step();
|
||||
$flagStepAssignTask = 0;
|
||||
|
||||
$arrayDataUid = $step->getDataUids($stepUid);
|
||||
if ($stepUid == "") {
|
||||
$flagStepAssignTask = 1;
|
||||
|
||||
$taskUid = $arrayDataUid["TAS_UID"];
|
||||
switch ($type) {
|
||||
case "BEFORE_ASSIGNMENT":
|
||||
$stepUid = "-1";
|
||||
$type = "BEFORE";
|
||||
break;
|
||||
case "BEFORE_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$type = "BEFORE";
|
||||
break;
|
||||
case "AFTER_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$type = "AFTER";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Verify data
|
||||
$step = new \Step();
|
||||
if ($flagStepAssignTask == 0) {
|
||||
$step = new \Step();
|
||||
|
||||
if (!$step->StepExists($stepUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
if (!$step->StepExists($stepUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
}
|
||||
|
||||
$trigger = new \Triggers();
|
||||
@@ -137,8 +184,8 @@ class Trigger
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($triggerUid, "TRIGGERS"), "The UID \"{0}\" doesn't exist in table {1}")));
|
||||
}
|
||||
|
||||
if (isset($arrayData["st_position"]) && $this->existsRecord($stepUid, $type, "", $arrayData["st_position"], $triggerUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["st_position"], $stepUid . ", " . $type . ", " . $arrayData["st_position"], "STEP_TRIGGER"), "The \"{0}\" position for the record \"{1}\", exists in table {2}")));
|
||||
if (isset($arrayData["st_position"]) && $this->existsRecord($stepUid, $type, $taskUid, "", $arrayData["st_position"], $triggerUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["st_position"], $stepUid . ", " . $type . ", " . $taskUid . ", " . $arrayData["st_position"], "STEP_TRIGGER"), "The \"{0}\" position for the record \"{1}\", exists in table {2}")));
|
||||
}
|
||||
|
||||
//Update
|
||||
@@ -171,23 +218,35 @@ class Trigger
|
||||
* Delete Trigger of a Step
|
||||
*
|
||||
* @param string $stepUid Unique id of Step
|
||||
* @param string $type Type (BEFORE, AFTER)
|
||||
* @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING)
|
||||
* @param string $taskUid Unique id of Task
|
||||
* @param string $triggerUid Unique id of Trigger
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function delete($stepUid, $type, $triggerUid)
|
||||
public function delete($stepUid, $type, $taskUid, $triggerUid)
|
||||
{
|
||||
try {
|
||||
$step = new \BusinessModel\Step();
|
||||
|
||||
$arrayDataUid = $step->getDataUids($stepUid);
|
||||
|
||||
$taskUid = $arrayDataUid["TAS_UID"];
|
||||
if ($stepUid == "") {
|
||||
switch ($type) {
|
||||
case "BEFORE_ASSIGNMENT":
|
||||
$stepUid = "-1";
|
||||
$type = "BEFORE";
|
||||
break;
|
||||
case "BEFORE_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$type = "BEFORE";
|
||||
break;
|
||||
case "AFTER_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$type = "AFTER";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Verify data
|
||||
if (!$this->existsRecord($stepUid, $type, $triggerUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", doesn't exist in table {1}")));
|
||||
if (!$this->existsRecord($stepUid, $type, $taskUid, $triggerUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $taskUid . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", doesn't exist in table {1}")));
|
||||
}
|
||||
|
||||
//Get position
|
||||
@@ -234,23 +293,41 @@ class Trigger
|
||||
* Get data of a Trigger
|
||||
*
|
||||
* @param string $stepUid Unique id of Step
|
||||
* @param string $type Type (BEFORE, AFTER)
|
||||
* @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING)
|
||||
* @param string $taskUid Unique id of Task
|
||||
* @param string $triggerUid Unique id of Trigger
|
||||
*
|
||||
* return array Return an array with data of a Trigger
|
||||
*/
|
||||
public function getTrigger($stepUid, $type, $triggerUid)
|
||||
public function getTrigger($stepUid, $type, $taskUid, $triggerUid)
|
||||
{
|
||||
try {
|
||||
$step = new \BusinessModel\Step();
|
||||
$typeIni = $type;
|
||||
|
||||
$arrayDataUid = $step->getDataUids($stepUid);
|
||||
$flagStepAssignTask = 0;
|
||||
|
||||
$taskUid = $arrayDataUid["TAS_UID"];
|
||||
if ($stepUid == "") {
|
||||
$flagStepAssignTask = 1;
|
||||
|
||||
switch ($type) {
|
||||
case "BEFORE_ASSIGNMENT":
|
||||
$stepUid = "-1";
|
||||
$type = "BEFORE";
|
||||
break;
|
||||
case "BEFORE_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$type = "BEFORE";
|
||||
break;
|
||||
case "AFTER_ROUTING":
|
||||
$stepUid = "-2";
|
||||
$type = "AFTER";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Verify data
|
||||
if (!$this->existsRecord($stepUid, $type, $triggerUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", doesn't exist in table {1}")));
|
||||
if (!$this->existsRecord($stepUid, $type, $taskUid, $triggerUid)) {
|
||||
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $taskUid . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", doesn't exist in table {1}")));
|
||||
}
|
||||
|
||||
//Get data
|
||||
@@ -274,6 +351,10 @@ class Trigger
|
||||
|
||||
$row = $rsCriteria->getRow();
|
||||
|
||||
if ($flagStepAssignTask == 1) {
|
||||
$row["ST_TYPE"] = $typeIni;
|
||||
}
|
||||
|
||||
return $this->getTriggerDataFromRecord($row);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
|
||||
@@ -124,6 +124,44 @@ class Step extends Api
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
//Step "Assign Task"
|
||||
|
||||
/**
|
||||
* @url GET /:projectUid/activity/:activityUid/step/triggers
|
||||
*/
|
||||
public function doGetActivityStepAssignTaskTriggers($activityUid, $projectUid)
|
||||
{
|
||||
try {
|
||||
$step = new \BusinessModel\Step();
|
||||
|
||||
$response = $step->getTriggers("", $activityUid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:projectUid/activity/:activityUid/step/available-triggers/:type
|
||||
*
|
||||
* @param string $activityUid
|
||||
* @param string $projectUid
|
||||
* @param string $type {@from body}{@choice before-assignment,before-routing,after-routing}
|
||||
*/
|
||||
public function doGetActivityStepAssignTaskAvailableTriggers($activityUid, $projectUid, $type)
|
||||
{
|
||||
try {
|
||||
$step = new \BusinessModel\Step();
|
||||
|
||||
$response = $step->getAvailableTriggers("", strtoupper(str_replace("-", "_", $type)), $activityUid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class StepPostStructure
|
||||
|
||||
@@ -25,7 +25,7 @@ class Trigger extends Api
|
||||
try {
|
||||
$stepTrigger = new \BusinessModel\Step\Trigger();
|
||||
|
||||
$response = $stepTrigger->getTrigger($stepUid, strtoupper($type), $triggerUid);
|
||||
$response = $stepTrigger->getTrigger($stepUid, strtoupper($type), $activityUid, $triggerUid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
@@ -50,7 +50,7 @@ class Trigger extends Api
|
||||
|
||||
$stepTrigger = new \BusinessModel\Step\Trigger();
|
||||
|
||||
$arrayData = $stepTrigger->create($stepUid, $request_data["st_type"], $request_data["tri_uid"], $request_data);
|
||||
$arrayData = $stepTrigger->create($stepUid, $request_data["st_type"], $activityUid, $request_data["tri_uid"], $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
@@ -72,7 +72,7 @@ class Trigger extends Api
|
||||
|
||||
$stepTrigger = new \BusinessModel\Step\Trigger();
|
||||
|
||||
$arrayData = $stepTrigger->update($stepUid, $request_data["st_type"], $triggerUid, $request_data);
|
||||
$arrayData = $stepTrigger->update($stepUid, $request_data["st_type"], $activityUid, $triggerUid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
@@ -92,7 +92,92 @@ class Trigger extends Api
|
||||
try {
|
||||
$stepTrigger = new \BusinessModel\Step\Trigger();
|
||||
|
||||
$stepTrigger->delete($stepUid, strtoupper($type), $triggerUid);
|
||||
$stepTrigger->delete($stepUid, strtoupper($type), $activityUid, $triggerUid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
//Step "Assign Task"
|
||||
|
||||
/**
|
||||
* @url GET /:projectUid/activity/:activityUid/step/trigger/:triggerUid/:type
|
||||
*
|
||||
* @param string $triggerUid
|
||||
* @param string $activityUid
|
||||
* @param string $projectUid
|
||||
* @param string $type {@from body}{@choice before-assignment,before-routing,after-routing}
|
||||
*/
|
||||
public function doGetActivityStepAssignTaskTrigger($triggerUid, $activityUid, $projectUid, $type)
|
||||
{
|
||||
try {
|
||||
$stepTrigger = new \BusinessModel\Step\Trigger();
|
||||
|
||||
$response = $stepTrigger->getTrigger("", strtoupper(str_replace("-", "_", $type)), $activityUid, $triggerUid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /:projectUid/activity/:activityUid/step/trigger
|
||||
*
|
||||
* @param string $activityUid
|
||||
* @param string $projectUid
|
||||
* @param StepAssignTaskTriggerPostStructure $request_data
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostActivityStepAssignTaskTrigger($activityUid, $projectUid, StepAssignTaskTriggerPostStructure $request_data = null)
|
||||
{
|
||||
try {
|
||||
$request_data = (array)($request_data);
|
||||
|
||||
$stepTrigger = new \BusinessModel\Step\Trigger();
|
||||
|
||||
$arrayData = $stepTrigger->create("", $request_data["st_type"], $activityUid, $request_data["tri_uid"], $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url PUT /:projectUid/activity/:activityUid/step/trigger/:triggerUid
|
||||
*
|
||||
* @param string $triggerUid
|
||||
* @param string $activityUid
|
||||
* @param string $projectUid
|
||||
* @param StepAssignTaskTriggerPutStructure $request_data
|
||||
*/
|
||||
public function doPutActivityStepAssignTaskTrigger($triggerUid, $activityUid, $projectUid, StepAssignTaskTriggerPutStructure $request_data = null)
|
||||
{
|
||||
try {
|
||||
$request_data = (array)($request_data);
|
||||
|
||||
$stepTrigger = new \BusinessModel\Step\Trigger();
|
||||
|
||||
$arrayData = $stepTrigger->update("", $request_data["st_type"], $activityUid, $triggerUid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url DELETE /:projectUid/activity/:activityUid/step/trigger/:triggerUid/:type
|
||||
*
|
||||
* @param string $triggerUid
|
||||
* @param string $activityUid
|
||||
* @param string $projectUid
|
||||
* @param string $type {@from body}{@choice before-assignment,before-routing,after-routing}
|
||||
*/
|
||||
public function doDeleteActivityStepAssignTaskTrigger($triggerUid, $activityUid, $projectUid, $type)
|
||||
{
|
||||
try {
|
||||
$stepTrigger = new \BusinessModel\Step\Trigger();
|
||||
|
||||
$stepTrigger->delete("", strtoupper(str_replace("-", "_", $type)), $activityUid, $triggerUid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
@@ -140,3 +225,44 @@ class StepTriggerPutStructure
|
||||
public $st_position;
|
||||
}
|
||||
|
||||
class StepAssignTaskTriggerPostStructure
|
||||
{
|
||||
/**
|
||||
* @var string {@from body}{@choice BEFORE_ASSIGNMENT,BEFORE_ROUTING,AFTER_ROUTING}{@required true}
|
||||
*/
|
||||
public $st_type;
|
||||
|
||||
/**
|
||||
* @var string {@from body}{@min 32}{@max 32}{@required true}
|
||||
*/
|
||||
public $tri_uid;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $st_condition;
|
||||
|
||||
/**
|
||||
* @var int {@from body}{@min 1}
|
||||
*/
|
||||
public $st_position;
|
||||
}
|
||||
|
||||
class StepAssignTaskTriggerPutStructure
|
||||
{
|
||||
/**
|
||||
* @var string {@from body}{@choice BEFORE_ASSIGNMENT,BEFORE_ROUTING,AFTER_ROUTING}{@required true}
|
||||
*/
|
||||
public $st_type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $st_condition;
|
||||
|
||||
/**
|
||||
* @var int {@from body}{@min 1}
|
||||
*/
|
||||
public $st_position;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user