Merged in victorsl/processmaker (pull request #71)

ProcessMaker-MA "Project Properties - Step Resources - Assign Task (endpoints & behat)"
This commit is contained in:
erik ao
2014-01-14 09:35:37 -04:00
5 changed files with 518 additions and 54 deletions

View File

@@ -301,3 +301,150 @@ Feature: Project Properties - Step Resources
And the type is "array" And the type is "array"
And the json data is an empty 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

View File

@@ -381,9 +381,11 @@ class Step
$rsCriteria = \StepPeer::doSelectRS($criteria); $rsCriteria = \StepPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$rsCriteria->next(); if ($rsCriteria->next()) {
return $rsCriteria->getRow(); 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) { } catch (\Exception $e) {
throw $e; throw $e;
} }
@@ -393,20 +395,60 @@ class Step
* Get available triggers of a Step * Get available triggers of a Step
* *
* @param string $stepUid Unique id of 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 * return array
*/ */
public function getAvailableTriggers($stepUid, $type) public function getAvailableTriggers($stepUid, $type, $taskUid = "")
{ {
try { 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(); $arrayAvailableTrigger = array();
$trigger = new \BusinessModel\Trigger(); $trigger = new \BusinessModel\Trigger();
$flagStepAssignTask = 0;
if ($stepUid != "") {
$arrayDataUid = $this->getDataUids($stepUid); $arrayDataUid = $this->getDataUids($stepUid);
$processUid = $arrayDataUid["PRO_UID"]; $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 //Get Uids
$arrayUid = array(); $arrayUid = array();
@@ -415,6 +457,11 @@ class Step
$criteria->addSelectColumn(\StepTriggerPeer::TRI_UID); $criteria->addSelectColumn(\StepTriggerPeer::TRI_UID);
$criteria->add(\StepTriggerPeer::STEP_UID, $stepUid, \Criteria::EQUAL); $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); $criteria->add(\StepTriggerPeer::ST_TYPE, $type, \Criteria::EQUAL);
$rsCriteria = \StepTriggerPeer::doSelectRS($criteria); $rsCriteria = \StepTriggerPeer::doSelectRS($criteria);
@@ -459,21 +506,37 @@ class Step
* Get all triggers of a Step * Get all triggers of a Step
* *
* @param string $stepUid Unique id of Step * @param string $stepUid Unique id of Step
* @param string $taskUid Unique id of Task
* *
* return array * return array
*/ */
public function getTriggers($stepUid) public function getTriggers($stepUid, $taskUid = "")
{ {
try { 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 //Get data
$arrayTrigger = array(); $arrayTrigger = array();
$bmTrigger = new \BusinessModel\Trigger(); $bmTrigger = new \BusinessModel\Trigger();
$bmStepTrigger = new \BusinessModel\Step\Trigger(); $bmStepTrigger = new \BusinessModel\Step\Trigger();
if ($stepUid != "") {
$arrayDataUid = $this->getDataUids($stepUid); $arrayDataUid = $this->getDataUids($stepUid);
$taskUid = $arrayDataUid["TAS_UID"]; $taskUid = $arrayDataUid["TAS_UID"];
}
$processMap = new \ProcessMap(); $processMap = new \ProcessMap();
$stepTrigger = new \StepTrigger(); $stepTrigger = new \StepTrigger();
@@ -495,15 +558,20 @@ class Step
$triggerType = $index; $triggerType = $index;
$type = $value; $type = $value;
$flagStepAssignTask = 0;
switch ($triggerType) { switch ($triggerType) {
case "BEFORE_ASSIGNMENT": case "BEFORE_ASSIGNMENT":
$stepUid = "-1"; $stepUid = "-1";
$flagStepAssignTask = 1;
break; break;
case "BEFORE_ROUTING": case "BEFORE_ROUTING":
$stepUid = "-2"; $stepUid = "-2";
$flagStepAssignTask = 1;
break; break;
case "AFTER_ROUTING": case "AFTER_ROUTING":
$stepUid = "-2"; $stepUid = "-2";
$flagStepAssignTask = 1;
break; break;
} }
@@ -527,6 +595,10 @@ class Step
while ($rsCriteria->next()) { while ($rsCriteria->next()) {
$row = $rsCriteria->getRow(); $row = $rsCriteria->getRow();
if ($flagStepAssignTask == 1) {
$row["ST_TYPE"] = $triggerType;
}
$arrayTrigger[] = $bmStepTrigger->getTriggerDataFromRecord($row); $arrayTrigger[] = $bmStepTrigger->getTriggerDataFromRecord($row);
} }
} }

View File

@@ -8,13 +8,14 @@ class Trigger
* *
* @param string $stepUid Unique id of Step * @param string $stepUid Unique id of Step
* @param string $type Type (BEFORE, AFTER) * @param string $type Type (BEFORE, AFTER)
* @param string $taskUid Unique id of Task
* @param string $triggerUid Unique id of Trigger * @param string $triggerUid Unique id of Trigger
* @param int $position Position * @param int $position Position
* @param string $triggerUidExclude Unique id of Trigger to exclude * @param string $triggerUidExclude Unique id of Trigger to exclude
* *
* return bool Return true if exists the record in table STEP_TRIGGER, false otherwise * 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 { try {
$criteria = new \Criteria("workflow"); $criteria = new \Criteria("workflow");
@@ -22,6 +23,7 @@ class Trigger
$criteria->addSelectColumn(\StepTriggerPeer::STEP_UID); $criteria->addSelectColumn(\StepTriggerPeer::STEP_UID);
$criteria->add(\StepTriggerPeer::STEP_UID, $stepUid, \Criteria::EQUAL); $criteria->add(\StepTriggerPeer::STEP_UID, $stepUid, \Criteria::EQUAL);
$criteria->add(\StepTriggerPeer::ST_TYPE, $type, \Criteria::EQUAL); $criteria->add(\StepTriggerPeer::ST_TYPE, $type, \Criteria::EQUAL);
$criteria->add(\StepTriggerPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
if ($triggerUid != "") { if ($triggerUid != "") {
$criteria->add(\StepTriggerPeer::TRI_UID, $triggerUid, \Criteria::EQUAL); $criteria->add(\StepTriggerPeer::TRI_UID, $triggerUid, \Criteria::EQUAL);
@@ -52,27 +54,54 @@ class Trigger
* Assign Trigger to a Step * Assign Trigger to a Step
* *
* @param string $stepUid Unique id of 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 string $triggerUid Unique id of Trigger
* @param array $arrayData Data * @param array $arrayData Data
* *
* return array Data of the Trigger assigned to a Step * 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 { 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 //Verify data
if ($flagStepAssignTask == 0) {
$step = new \Step(); $step = new \Step();
if (!$step->StepExists($stepUid)) { if (!$step->StepExists($stepUid)) {
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}"))); 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(); $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}"))); 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)) { if ($this->existsRecord($stepUid, $type, $taskUid, $triggerUid)) {
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", exists in table {1}"))); 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"])) { 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 . ", " . $arrayData["st_position"], "STEP_TRIGGER"), "The \"{0}\" position for the record \"{1}\", exists in table {2}"))); 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 //Create
@@ -97,7 +126,7 @@ class Trigger
$arrayData["st_position"] = $stepTrigger->getNextPosition($stepUid, $type, $taskUid) - 1; $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; return $arrayData;
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -109,27 +138,45 @@ class Trigger
* Update Trigger of a Step * Update Trigger of a Step
* *
* @param string $stepUid Unique id of 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 string $triggerUid Unique id of Trigger
* @param array $arrayData Data * @param array $arrayData Data
* *
* return array Data updated of the Trigger assigned to a Step * 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 { 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 //Verify data
if ($flagStepAssignTask == 0) {
$step = new \Step(); $step = new \Step();
if (!$step->StepExists($stepUid)) { if (!$step->StepExists($stepUid)) {
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}"))); throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid, "STEP"), "The UID \"{0}\" doesn't exist in table {1}")));
} }
}
$trigger = new \Triggers(); $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}"))); 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)) { 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 . ", " . $arrayData["st_position"], "STEP_TRIGGER"), "The \"{0}\" position for the record \"{1}\", exists in table {2}"))); 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 //Update
@@ -171,23 +218,35 @@ class Trigger
* Delete Trigger of a Step * Delete Trigger of a Step
* *
* @param string $stepUid Unique id of 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 string $triggerUid Unique id of Trigger
* *
* return void * return void
*/ */
public function delete($stepUid, $type, $triggerUid) public function delete($stepUid, $type, $taskUid, $triggerUid)
{ {
try { try {
$step = new \BusinessModel\Step(); if ($stepUid == "") {
switch ($type) {
$arrayDataUid = $step->getDataUids($stepUid); case "BEFORE_ASSIGNMENT":
$stepUid = "-1";
$taskUid = $arrayDataUid["TAS_UID"]; $type = "BEFORE";
break;
case "BEFORE_ROUTING":
$stepUid = "-2";
$type = "BEFORE";
break;
case "AFTER_ROUTING":
$stepUid = "-2";
$type = "AFTER";
break;
}
}
//Verify data //Verify data
if (!$this->existsRecord($stepUid, $type, $triggerUid)) { if (!$this->existsRecord($stepUid, $type, $taskUid, $triggerUid)) {
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", doesn't exist in table {1}"))); 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 //Get position
@@ -234,23 +293,41 @@ class Trigger
* Get data of a Trigger * Get data of a Trigger
* *
* @param string $stepUid Unique id of 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 string $triggerUid Unique id of Trigger
* *
* return array Return an array with data of a 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 { 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 //Verify data
if (!$this->existsRecord($stepUid, $type, $triggerUid)) { if (!$this->existsRecord($stepUid, $type, $taskUid, $triggerUid)) {
throw (new \Exception(str_replace(array("{0}", "{1}"), array($stepUid . ", " . $type . ", " . $triggerUid, "STEP_TRIGGER"), "The record \"{0}\", doesn't exist in table {1}"))); 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 //Get data
@@ -274,6 +351,10 @@ class Trigger
$row = $rsCriteria->getRow(); $row = $rsCriteria->getRow();
if ($flagStepAssignTask == 1) {
$row["ST_TYPE"] = $typeIni;
}
return $this->getTriggerDataFromRecord($row); return $this->getTriggerDataFromRecord($row);
} catch (\Exception $e) { } catch (\Exception $e) {
throw $e; throw $e;

View File

@@ -124,6 +124,44 @@ class Step extends Api
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); 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 class StepPostStructure

View File

@@ -25,7 +25,7 @@ class Trigger extends Api
try { try {
$stepTrigger = new \BusinessModel\Step\Trigger(); $stepTrigger = new \BusinessModel\Step\Trigger();
$response = $stepTrigger->getTrigger($stepUid, strtoupper($type), $triggerUid); $response = $stepTrigger->getTrigger($stepUid, strtoupper($type), $activityUid, $triggerUid);
return $response; return $response;
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -50,7 +50,7 @@ class Trigger extends Api
$stepTrigger = new \BusinessModel\Step\Trigger(); $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) { } catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
} }
@@ -72,7 +72,7 @@ class Trigger extends Api
$stepTrigger = new \BusinessModel\Step\Trigger(); $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) { } catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
} }
@@ -92,7 +92,92 @@ class Trigger extends Api
try { try {
$stepTrigger = new \BusinessModel\Step\Trigger(); $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) { } catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
} }
@@ -140,3 +225,44 @@ class StepTriggerPutStructure
public $st_position; 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;
}