Merge branch 'master' of bitbucket.org:colosa/processmaker

This commit is contained in:
Freddy Daniel Rojas Valda
2013-12-13 12:14:51 -04:00
7 changed files with 549 additions and 46 deletions

View File

@@ -3,6 +3,100 @@ namespace BusinessModel;
class Step
{
/**
* Checks if exists the record in table STEP
*
* @param string $taskUid Unique id of Task
* @param string $type Type of Step (DYNAFORM, INPUT_DOCUMENT, OUTPUT_DOCUMENT)
* @param string $objectUid Unique id of Object
* @param int $position Position
* @param string $stepUidExclude Unique id of Step to exclude
*
* return bool Return true if exists the record in table STEP, false otherwise
*/
public function existsRecord($taskUid, $type, $objectUid, $position = 0, $stepUidExclude = "")
{
try {
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\StepPeer::STEP_UID);
$criteria->add(\StepPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
if ($stepUidExclude != "") {
$criteria->add(\StepPeer::STEP_UID, $stepUidExclude, \Criteria::NOT_EQUAL);
}
if ($type != "") {
$criteria->add(\StepPeer::STEP_TYPE_OBJ, $type, \Criteria::EQUAL);
}
if ($objectUid != "") {
$criteria->add(\StepPeer::STEP_UID_OBJ, $objectUid, \Criteria::EQUAL);
}
if ($position > 0) {
$criteria->add(\StepPeer::STEP_POSITION, $position, \Criteria::EQUAL);
}
$rsCriteria = \StepPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) {
return true;
} else {
return false;
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Checks if exists the "Object UID" in the corresponding table
*
* @param string $type Type of Step (DYNAFORM, INPUT_DOCUMENT, OUTPUT_DOCUMENT)
* @param string $objectUid Unique id of Object
*
* return strin Return empty string if $objectUid exists in the corresponding table, return string with data if $objectUid doesn't exist
*/
public function existsObjectUid($type, $objectUid)
{
try {
$msg = "";
switch ($type) {
case "DYNAFORM":
$dynaform = new \Dynaform();
if (!$dynaform->dynaformExists($objectUid)) {
$msg = str_replace(array("{0}", "{1}"), array($objectUid, "DYNAFORM"), "The UID \"{0}\" doesn't exist in table {1}");
}
break;
case "INPUT_DOCUMENT":
$inputdoc = new \InputDocument();
if (!$inputdoc->InputExists($objectUid)) {
$msg = str_replace(array("{0}", "{1}"), array($objectUid, "INPUT_DOCUMENT"), "The UID \"{0}\" doesn't exist in table {1}");
}
break;
case "OUTPUT_DOCUMENT":
$outputdoc = new \OutputDocument();
if (!$outputdoc->OutputExists($objectUid)) {
$msg = str_replace(array("{0}", "{1}"), array($objectUid, "OUTPUT_DOCUMENT"), "The UID \"{0}\" doesn't exist in table {1}");
}
break;
default:
$msg = str_replace(array("{0}", "{1}"), array($objectUid, $type), "The UID \"{0}\" doesn't exist in table {1}");
break;
}
return $msg;
} catch (\Exception $e) {
throw $e;
}
}
/**
* Create Step for a Task
*
@@ -10,11 +104,41 @@ class Step
* @param string $processUid
* @param array $arrayData
*
* return string Unique id of the new Step
* return array Data of the Step created
*/
public function create($taskUid, $processUid, $arrayData)
{
try {
//Verify data
$process = new \Process();
if (!$process->exists($processUid)) {
throw (new \Exception(str_replace(array("{0}", "{1}"), array($processUid, "PROCESS"), "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}")));
}
if (isset($arrayData["step_type_obj"]) && isset($arrayData["step_uid_obj"])) {
$msg = $this->existsObjectUid($arrayData["step_type_obj"], $arrayData["step_uid_obj"]);
if ($msg != "") {
throw (new \Exception($msg));
}
if ($this->existsRecord($taskUid, $arrayData["step_type_obj"], $arrayData["step_uid_obj"])) {
throw (new \Exception(str_replace(array("{0}", "{1}"), array($taskUid . ", " . $arrayData["step_type_obj"] . ", " . $arrayData["step_uid_obj"], "STEP"), "The record \"{0}\", exists in table {1}")));
}
}
if (isset($arrayData["step_position"]) && $this->existsRecord($taskUid, "", "", $arrayData["step_position"])) {
throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["step_position"], $taskUid . ", " . $arrayData["step_position"], "STEP"), "The \"{0}\" position for the record \"{1}\", exists in table {2}")));
}
//Create
$step = new \Step();
$stepUid = $step->create(array("PRO_UID" => $processUid, "TAS_UID" => $taskUid));
@@ -23,9 +147,11 @@ class Step
$arrayData["step_position"] = $step->getNextPosition($taskUid) - 1;
}
$this->update($stepUid, $arrayData);
$arrayData = $this->update($stepUid, $arrayData);
return $stepUid;
$arrayData["step_uid"] = $stepUid;
return $arrayData;
} catch (\Exception $e) {
throw $e;
}
@@ -37,11 +163,39 @@ class Step
* @param string $stepUid
* @param array $arrayData
*
* return void
* return array Data of the Step updated
*/
public function update($stepUid, $arrayData)
{
try {
$arrayDataUid = $this->getDataUids($stepUid);
$taskUid = $arrayDataUid["TAS_UID"];
//Verify data
$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 (isset($arrayData["step_type_obj"]) && isset($arrayData["step_uid_obj"])) {
$msg = $this->existsObjectUid($arrayData["step_type_obj"], $arrayData["step_uid_obj"]);
if ($msg != "") {
throw (new \Exception($msg));
}
if ($this->existsRecord($taskUid, $arrayData["step_type_obj"], $arrayData["step_uid_obj"], 0, $stepUid)) {
throw (new \Exception(str_replace(array("{0}", "{1}"), array($taskUid . ", " . $arrayData["step_type_obj"] . ", " . $arrayData["step_uid_obj"], "STEP"), "The record \"{0}\", exists in table {1}")));
}
}
if (isset($arrayData["step_position"]) && $this->existsRecord($taskUid, "", "", $arrayData["step_position"], $stepUid)) {
throw (new \Exception(str_replace(array("{0}", "{1}", "{2}"), array($arrayData["step_position"], $taskUid . ", " . $arrayData["step_position"], "STEP"), "The \"{0}\" position for the record \"{1}\", exists in table {2}")));
}
//Update
$step = new \Step();
$arrayUpdateData = array();
@@ -69,6 +223,8 @@ class Step
}
$step->update($arrayUpdateData);
return array_change_key_case($arrayUpdateData, CASE_LOWER);
} catch (\Exception $e) {
throw $e;
}
@@ -84,6 +240,13 @@ class Step
public function delete($stepUid)
{
try {
//Verify data
$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}")));
}
//Get position
$criteria = new \Criteria("workflow");

View File

@@ -3,17 +3,62 @@ namespace BusinessModel\Step;
class Trigger
{
/**
* Checks if exists the record in table STEP_TRIGGER
*
* @param string $stepUid Unique id of Step
* @param string $type Type (BEFORE, AFTER)
* @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 = "")
{
try {
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\StepTriggerPeer::STEP_UID);
$criteria->add(\StepTriggerPeer::STEP_UID, $stepUid, \Criteria::EQUAL);
$criteria->add(\StepTriggerPeer::ST_TYPE, $type, \Criteria::EQUAL);
if ($triggerUid != "") {
$criteria->add(\StepTriggerPeer::TRI_UID, $triggerUid, \Criteria::EQUAL);
}
if ($position > 0) {
$criteria->add(\StepTriggerPeer::ST_POSITION, $position, \Criteria::EQUAL);
}
if ($triggerUidExclude != "") {
$criteria->add(\StepTriggerPeer::TRI_UID, $triggerUidExclude, \Criteria::NOT_EQUAL);
}
$rsCriteria = \StepTriggerPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
if ($rsCriteria->next()) {
return true;
} else {
return false;
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Assign Trigger to a Step
*
* @param string $stepUid Unique id of Step
* @param string $triggerUid Unique id of Trigger
* @param string $type Type (BEFORE, AFTER)
* @param string $triggerUid Unique id of Trigger
* @param array $arrayData Data
*
* return void
* return array Data of the Trigger assigned to a Step
*/
public function create($stepUid, $triggerUid, $type, $arrayData)
public function create($stepUid, $type, $triggerUid, $arrayData)
{
try {
$step = new \BusinessModel\Step();
@@ -22,6 +67,27 @@ class Trigger
$taskUid = $arrayDataUid["TAS_UID"];
//Verify data
$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}")));
}
$trigger = new \Triggers();
if (!$trigger->TriggerExists($triggerUid)) {
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 (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}")));
}
//Create
$stepTrigger = new \StepTrigger();
@@ -31,7 +97,9 @@ class Trigger
$arrayData["st_position"] = $stepTrigger->getNextPosition($stepUid, $type, $taskUid) - 1;
}
$this->update($stepUid, $triggerUid, $type, $arrayData);
$arrayData = $this->update($stepUid, $type, $triggerUid, $arrayData);
return $arrayData;
} catch (\Exception $e) {
throw $e;
}
@@ -41,13 +109,13 @@ class Trigger
* Update Trigger of a Step
*
* @param string $stepUid Unique id of Step
* @param string $triggerUid Unique id of Trigger
* @param string $type Type (BEFORE, AFTER)
* @param string $triggerUid Unique id of Trigger
* @param array $arrayData Data
*
* return void
* return array Data updated of the Trigger assigned to a Step
*/
public function update($stepUid, $triggerUid, $type, $arrayData)
public function update($stepUid, $type, $triggerUid, $arrayData)
{
try {
$step = new \BusinessModel\Step();
@@ -56,6 +124,23 @@ class Trigger
$taskUid = $arrayDataUid["TAS_UID"];
//Verify data
$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}")));
}
$trigger = new \Triggers();
if (!$trigger->TriggerExists($triggerUid)) {
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}")));
}
//Update
$stepTrigger = new \StepTrigger();
@@ -75,6 +160,8 @@ class Trigger
}
$stepTrigger->update($arrayUpdateData);
return array_change_key_case($arrayUpdateData, CASE_LOWER);
} catch (\Exception $e) {
throw $e;
}
@@ -84,12 +171,12 @@ class Trigger
* Delete Trigger of a Step
*
* @param string $stepUid Unique id of Step
* @param string $triggerUid Unique id of Trigger
* @param string $type Type (BEFORE, AFTER)
* @param string $triggerUid Unique id of Trigger
*
* return void
*/
public function delete($stepUid, $triggerUid, $type)
public function delete($stepUid, $type, $triggerUid)
{
try {
$step = new \BusinessModel\Step();
@@ -98,6 +185,11 @@ class Trigger
$taskUid = $arrayDataUid["TAS_UID"];
//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}")));
}
//Get position
$stepTrigger = new \StepTrigger();

View File

@@ -79,5 +79,148 @@ class Trigger
throw $e;
}
}
/**
* List of Triggers in process
*
* return array
*/
public function getTriggersCriteria($sProcessUID = '')
{
$criteria = $this->getTriggerCriteria();
$criteria->add(\TriggersPeer::PRO_UID, $sProcessUID);
$criteria->addAscendingOrderByColumn('TRI_TITLE');
$oDataset = \TriggersPeer::doSelectRS($criteria);
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$triggersArray = "";
//$triggersArray[] = array('TRI_UID' => 'char', 'PRO_UID' => 'char', 'TRI_TITLE' => 'char', 'TRI_DESCRIPTION' => 'char');
while ($aRow = $oDataset->getRow()) {
if (($aRow['TRI_TITLE'] == null) || ($aRow['TRI_TITLE'] == "")) {
// There is no transaltion for this Trigger name, try to get/regenerate the label
$triggerObj = $this->getDataTrigger($aRow['TRI_UID']);
$aRow['TRI_TITLE'] = $triggerObj['tri_title'];
$aRow['TRI_DESCRIPTION'] = $triggerObj['tri_description'];
}
$triggersArray[] = array_change_key_case($aRow, CASE_LOWER);
$oDataset->next();
}
return $triggersArray;
}
/**
* Get data for TriggerUid
*
* return array
*/
public function getDataTrigger($sTriggerUID = '')
{
$triggerO = new \Triggers();
$triggerArray = $triggerO->load($sTriggerUID);
if (isset($triggerArray['PRO_UID'])) {
unset($triggerArray['PRO_UID']);
}
$triggerArray = array_change_key_case($triggerArray, CASE_LOWER);
return $triggerArray;
}
/**
* Delete Trigger
*
*/
public function deleteTrigger($sTriggerUID = '')
{
$oTrigger = new \Triggers();
$triggerObj = $oTrigger->load( $sTriggerUID );
$oTrigger->remove( $sTriggerUID );
$oStepTrigger = new \StepTrigger();
$oStepTrigger->removeTrigger( $sTriggerUID );
}
/**
* Save Data for Trigger
*
*/
public function saveTrigger($sProcessUID = '', $dataTrigger = array(), $create = false, $sTriggerUid = '')
{
if ( ($sProcessUID == '') || (count($dataTrigger) == 0) ) {
return false;
}
$dataTrigger = array_change_key_case($dataTrigger, CASE_UPPER);
if ( $create && (isset($dataTrigger['TRI_UID'])) ) {
unset($dataTrigger['TRI_UID']);
}
$dataTrigger= (array)$dataTrigger;
if (isset($dataTrigger['TRI_TYPE']) && $dataTrigger['TRI_TYPE'] == '') {
$dataTrigger['TRI_TYPE'] = 'SCRIPT';
}
if (isset($dataTrigger['TRI_TITLE'])) {
if (!$this->verifyNameTrigger($sProcessUID, $dataTrigger['TRI_TITLE'], $sTriggerUid)) {
throw new \Exception('There is a triggers with the same name in this process');
}
}
$dataTrigger['PRO_UID'] = $sProcessUID;
$oTrigger = new \Triggers();
if ($create) {
$oTrigger->create( $dataTrigger );
$dataTrigger['TRI_UID'] = $oTrigger->getTriUid();
}
$oTrigger->update( $dataTrigger );
if ($create) {
$dataResp = $oTrigger->load( $dataTrigger['TRI_UID'] );
$dataResp = array_change_key_case($dataResp, CASE_LOWER);
if (isset($dataResp['pro_uid'])) {
unset($dataResp['pro_uid']);
}
return $dataResp;
}
}
/**
* Verify name for trigger in process
*
* return boolean
*/
public function verifyNameTrigger($sProcessUID, $sTriggerName, $sTriggerUid = '')
{
$oCriteria = new \Criteria("workflow");
$oCriteria->addSelectColumn( \TriggersPeer::TRI_UID );
$oCriteria->add( \TriggersPeer::PRO_UID, $sProcessUID );
if ($sTriggerUid != '') {
$oCriteria->add( \TriggersPeer::TRI_UID, $sTriggerUid, \Criteria::NOT_EQUAL);
}
$oDataset = \TriggersPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
while ($oDataset->next()) {
$aRow = $oDataset->getRow();
$oCriteria1 = new \Criteria( 'workflow' );
$oCriteria1->addSelectColumn( 'COUNT(*) AS TRIGGERS' );
$oCriteria1->add( \ContentPeer::CON_CATEGORY, 'TRI_TITLE' );
$oCriteria1->add( \ContentPeer::CON_ID, $aRow['TRI_UID'] );
$oCriteria1->add( \ContentPeer::CON_VALUE, $sTriggerName );
$oCriteria1->add( \ContentPeer::CON_LANG, SYS_LANG );
$oDataset1 = \ContentPeer::doSelectRS( $oCriteria1 );
$oDataset1->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
$oDataset1->next();
$aRow1 = $oDataset1->getRow();
if ($aRow1['TRIGGERS']) {
return false;
}
}
return true;
}
}

View File

@@ -43,9 +43,9 @@ class Step extends Api
$step = new \BusinessModel\Step();
$stepUid = $step->create($activityUid, $projectUid, $request_data);
$arrayData = $step->create($activityUid, $projectUid, $request_data);
$response = array("old_uid" => $request_data["step_uid"], "new_uid" => $stepUid);
$response = $arrayData;
return $response;
} catch (\Exception $e) {
@@ -68,7 +68,7 @@ class Step extends Api
$step = new \BusinessModel\Step();
$step->update($stepUid, $request_data);
$arrayData = $step->update($stepUid, $request_data);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
@@ -128,11 +128,6 @@ class Step extends Api
class StepPostStructure
{
/**
* @var string {@from body}{@min 32}{@max 32}
*/
public $step_uid;
/**
* @var string {@from body}{@choice DYNAFORM,INPUT_DOCUMENT,OUTPUT_DOCUMENT}{@required true}
*/

View File

@@ -44,7 +44,7 @@ class Trigger extends Api
$stepTrigger = new \BusinessModel\Step\Trigger();
$stepTrigger->create($stepUid, $request_data["tri_uid"], $request_data["st_type"], $request_data);
$arrayData = $stepTrigger->create($stepUid, $request_data["st_type"], $request_data["tri_uid"], $request_data);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
@@ -66,7 +66,7 @@ class Trigger extends Api
$stepTrigger = new \BusinessModel\Step\Trigger();
$stepTrigger->update($stepUid, $triggerUid, $request_data["st_type"], $request_data);
$arrayData = $stepTrigger->update($stepUid, $request_data["st_type"], $triggerUid, $request_data);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
@@ -86,7 +86,7 @@ class Trigger extends Api
try {
$stepTrigger = new \BusinessModel\Step\Trigger();
$stepTrigger->delete($stepUid, $triggerUid, strtoupper($type));
$stepTrigger->delete($stepUid, strtoupper($type), $triggerUid);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
@@ -95,11 +95,29 @@ class Trigger extends Api
class StepTriggerPostStructure
{
/**
* @var string {@from body}{@choice BEFORE,AFTER}{@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 StepTriggerPutStructure
{
/**
* @var string {@from body}{@choice BEFORE,AFTER}{@required true}
*/
@@ -116,21 +134,3 @@ class StepTriggerPostStructure
public $st_position;
}
class StepTriggerPutStructure
{
/**
* @var string {@from body}{@choice BEFORE,AFTER}
*/
public $st_type;
/**
* @var string
*/
public $st_condition;
/**
* @var int {@from body}{@min 1}
*/
public $st_position;
}

View File

@@ -0,0 +1,109 @@
<?php
namespace Services\Api\ProcessMaker\Project;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
/**
* Project\Activity\Step\Trigger Api Controller
*
* @protected
*/
class Trigger extends Api
{
/**
* @param string $projectUid {@min 1} {@max 32}
*
* @url GET /:projectUid/triggers
*/
public function doGetTriggers($projectUid)
{
try {
$trigger = new \BusinessModel\Trigger();
$response = $trigger->getTriggersCriteria($projectUid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @param string $projectUid {@min 1} {@max 32}
* @param string $triggerUid {@min 1} {@max 32}
*
* @url GET /:projectUid/trigger/:triggerUid
*/
public function doGetTrigger($projectUid, $triggerUid)
{
try {
$trigger = new \BusinessModel\Trigger();
$response = $trigger->getDataTrigger($triggerUid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @param string $projectUid {@min 1} {@max 32}
* @param array $request_data
* @param string $tri_title {@from body} {@min 1}
* @param string $tri_description {@from body}
* @param string $tri_type {@from body} {@choice SCRIPT}
* @param string $tri_webbot {@from body}
* @param string $tri_param {@from body}
*
* @url POST /:projectUid/trigger
*/
public function doPostTrigger($projectUid, $request_data, $tri_title, $tri_description = '', $tri_type = 'SCRIPT', $tri_webbot = '', $tri_param = '')
{
try {
$trigger = new \BusinessModel\Trigger();
$response = $trigger->saveTrigger($projectUid, $request_data, true);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @param string $projectUid {@min 1} {@max 32}
* @param string $triggerUid {@min 1} {@max 32}
* @param array $request_data
* @param string $tri_title {@from body}
* @param string $tri_description {@from body}
* @param string $tri_type {@from body} {@choice SCRIPT}
* @param string $tri_webbot {@from body}
* @param string $tri_param {@from body}
*
* @url PUT /:projectUid/trigger/:triggerUid
*/
public function doPutTrigger($projectUid, $triggerUid, $request_data, $tri_title = '', $tri_description = '', $tri_type = 'SCRIPT', $tri_webbot = '', $tri_param = '')
{
try {
$request_data['tri_uid'] = $triggerUid;
$trigger = new \BusinessModel\Trigger();
$trigger->saveTrigger($projectUid, $request_data, false, $triggerUid);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @param string $projectUid {@min 1} {@max 32}
* @param string $triggerUid {@min 1} {@max 32}
*
* @url DELETE /:projectUid/trigger/:triggerUid
*/
public function doDeleteTrigger($projectUid, $triggerUid)
{
try {
$trigger = new \BusinessModel\Trigger();
$response = $trigger->deleteTrigger($triggerUid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
}

View File

@@ -5,8 +5,8 @@
debug = 1
[api]
version = 1.0
vendor = "ProcessMaker - Michelangelo (Enterprise)"
version = 1.0
vendor = "ProcessMaker - Michelangelo (Enterprise)"
[alias: test]
test2 = "Services\Api\ProcessMaker\Test2"
@@ -15,9 +15,10 @@ debug = 1
[alias: project]
activity = "Services\Api\ProcessMaker\Project\Activity"
step = "Services\Api\ProcessMaker\Project\Activity\Step"
assignee = "Services\Api\ProcessMaker\Project\Activity\Assignee"
assignee = "Services\Api\ProcessMaker\Project\Activity\Assignee"
trigger = "Services\Api\ProcessMaker\Project\Activity\Step\Trigger"
project = "Services\Api\ProcessMaker\Project"
project = "Services\Api\ProcessMaker\Project"
trigger2 = "Services\Api\ProcessMaker\Project\Trigger"
[alias: projects]
project = "Services\Api\ProcessMaker\Project"