ProcessMaker-MA "Trigger Wizard (endpoints)"
- Se han implementado los siguientes Endpoints:
GET /api/1.0/{workspace}/project/{prj_uid}/trigger-wizards
GET /api/1.0/{workspace}/project/{prj_uid}/trigger-wizard/{lib_name}
GET /api/1.0/{workspace}/project/{prj_uid}/trigger-wizard/{lib_name}/{fn_name}
This commit is contained in:
@@ -181,13 +181,13 @@ class DynaForm
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the DynaForm in table DYNAFORM
|
||||
* Verify if doesn't exists the DynaForm in table DYNAFORM
|
||||
*
|
||||
* @param string $dynaFormUid Unique id of DynaForm
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the DynaForm in table DYNAFORM
|
||||
* return void Throw exception if doesn't exists the DynaForm in table DYNAFORM
|
||||
*/
|
||||
public function throwExceptionIfNotExistsDynaForm($dynaFormUid, $processUid, $fieldNameForException)
|
||||
{
|
||||
|
||||
@@ -130,12 +130,12 @@ class Group
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the Group in table GROUP
|
||||
* Verify if doesn't exists the Group in table GROUP
|
||||
*
|
||||
* @param string $groupUid Unique id of Group
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the Group in table GROUP
|
||||
* return void Throw exception if doesn't exists the Group in table GROUP
|
||||
*/
|
||||
public function throwExceptionIfNoExistsGroup($groupUid, $fieldNameForException)
|
||||
{
|
||||
|
||||
@@ -137,13 +137,13 @@ class InputDocument
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the InputDocument in table INPUT_DOCUMENT
|
||||
* Verify if doesn't exists the InputDocument in table INPUT_DOCUMENT
|
||||
*
|
||||
* @param string $inputDocumentUid Unique id of InputDocument
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the InputDocument in table INPUT_DOCUMENT
|
||||
* return void Throw exception if doesn't exists the InputDocument in table INPUT_DOCUMENT
|
||||
*/
|
||||
public function throwExceptionIfNotExistsInputDocument($inputDocumentUid, $processUid, $fieldNameForException)
|
||||
{
|
||||
|
||||
@@ -252,12 +252,12 @@ class Process
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the Process in table PROCESS
|
||||
* Verify if doesn't exists the Process in table PROCESS
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the Process in table PROCESS
|
||||
* return void Throw exception if doesn't exists the Process in table PROCESS
|
||||
*/
|
||||
public function throwExceptionIfNoExistsProcess($processUid, $fieldNameForException)
|
||||
{
|
||||
@@ -275,12 +275,12 @@ class Process
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the User in table USERS
|
||||
* Verify if doesn't exists the User in table USERS
|
||||
*
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the User in table USERS
|
||||
* return void Throw exception if doesn't exists the User in table USERS
|
||||
*/
|
||||
public function throwExceptionIfNoExistsUser($userUid, $fieldNameForException)
|
||||
{
|
||||
@@ -320,12 +320,12 @@ class Process
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the Calendar Definition in table CALENDAR_DEFINITION
|
||||
* Verify if doesn't exists the Calendar Definition in table CALENDAR_DEFINITION
|
||||
*
|
||||
* @param string $calendarDefinitionUid Unique id of Calendar Definition
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the Calendar Definition in table CALENDAR_DEFINITION
|
||||
* return void Throw exception if doesn't exists the Calendar Definition in table CALENDAR_DEFINITION
|
||||
*/
|
||||
public function throwExceptionIfNotExistsCalendarDefinition($calendarDefinitionUid, $fieldNameForException)
|
||||
{
|
||||
@@ -343,12 +343,12 @@ class Process
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the Process Category in table PROCESS_CATEGORY
|
||||
* Verify if doesn't exists the Process Category in table PROCESS_CATEGORY
|
||||
*
|
||||
* @param string $processCategoryUid Unique id of Process Category
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the Process Category in table PROCESS_CATEGORY
|
||||
* return void Throw exception if doesn't exists the Process Category in table PROCESS_CATEGORY
|
||||
*/
|
||||
public function throwExceptionIfNotExistsProcessCategory($processCategoryUid, $fieldNameForException)
|
||||
{
|
||||
@@ -366,12 +366,12 @@ class Process
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the PM Table in table ADDITIONAL_TABLES
|
||||
* Verify if doesn't exists the PM Table in table ADDITIONAL_TABLES
|
||||
*
|
||||
* @param string $additionalTableUid Unique id of PM Table
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the PM Table in table ADDITIONAL_TABLES
|
||||
* return void Throw exception if doesn't exists the PM Table in table ADDITIONAL_TABLES
|
||||
*/
|
||||
public function throwExceptionIfNotExistsPmTable($additionalTableUid, $fieldNameForException)
|
||||
{
|
||||
@@ -389,13 +389,13 @@ class Process
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the Task in table TASK
|
||||
* Verify if doesn't exists the Task in table TASK
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $taskUid Unique id of Task
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the Task in table TASK
|
||||
* return void Throw exception if doesn't exists the Task in table TASK
|
||||
*/
|
||||
public function throwExceptionIfNotExistsTask($processUid, $taskUid, $fieldNameForException)
|
||||
{
|
||||
@@ -423,13 +423,13 @@ class Process
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the Template in Routing Screen Template
|
||||
* Verify if doesn't exists the Template in Routing Screen Template
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $fileName Name template
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the Template in Routing Screen Template
|
||||
* return void Throw exception if doesn't exists the Template in Routing Screen Template
|
||||
*/
|
||||
public function throwExceptionIfNotExistsRoutingScreenTemplate($processUid, $fileName, $fieldNameForException)
|
||||
{
|
||||
@@ -456,40 +456,6 @@ class Process
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exist the Trigger in table TRIGGERS
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $triggerUid Unique id of Trigger
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exist the Trigger in table TRIGGERS
|
||||
*/
|
||||
public function throwExceptionIfNotExistsTrigger($processUid, $triggerUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\TriggersPeer::TRI_UID);
|
||||
|
||||
if ($processUid != "") {
|
||||
$criteria->add(\TriggersPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add(\TriggersPeer::TRI_UID, $triggerUid, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \TriggersPeer::doSelectRS($criteria);
|
||||
|
||||
if (!$rsCriteria->next()) {
|
||||
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $triggerUid), "The trigger with {0}: {1}, does not exist");
|
||||
|
||||
throw (new \Exception($msg));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Process
|
||||
*
|
||||
@@ -530,20 +496,22 @@ class Process
|
||||
$this->throwExceptionIfNotExistsRoutingScreenTemplate($processUid, $arrayData["PRO_DERIVATION_SCREEN_TPL"], $this->arrayFieldNameForException["processDerivationScreenTpl"]);
|
||||
}
|
||||
|
||||
$trigger = new \BusinessModel\Trigger();
|
||||
|
||||
if (isset($arrayData["PRO_TRI_DELETED"]) && $arrayData["PRO_TRI_DELETED"] . "" != "") {
|
||||
$this->throwExceptionIfNotExistsTrigger($processUid, $arrayData["PRO_TRI_DELETED"], $this->arrayFieldNameForException["processTriDeleted"]);
|
||||
$trigger->throwExceptionIfNotExistsTrigger($arrayData["PRO_TRI_DELETED"], $processUid, $this->arrayFieldNameForException["processTriDeleted"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["PRO_TRI_CANCELED"]) && $arrayData["PRO_TRI_CANCELED"] . "" != "") {
|
||||
$this->throwExceptionIfNotExistsTrigger($processUid, $arrayData["PRO_TRI_CANCELED"], $this->arrayFieldNameForException["processTriCanceled"]);
|
||||
$trigger->throwExceptionIfNotExistsTrigger($arrayData["PRO_TRI_CANCELED"], $processUid, $this->arrayFieldNameForException["processTriCanceled"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["PRO_TRI_PAUSED"]) && $arrayData["PRO_TRI_PAUSED"] . "" != "") {
|
||||
$this->throwExceptionIfNotExistsTrigger($processUid, $arrayData["PRO_TRI_PAUSED"], $this->arrayFieldNameForException["processTriPaused"]);
|
||||
$trigger->throwExceptionIfNotExistsTrigger($arrayData["PRO_TRI_PAUSED"], $processUid, $this->arrayFieldNameForException["processTriPaused"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["PRO_TRI_REASSIGNED"]) && $arrayData["PRO_TRI_REASSIGNED"] . "" != "") {
|
||||
$this->throwExceptionIfNotExistsTrigger($processUid, $arrayData["PRO_TRI_REASSIGNED"], $this->arrayFieldNameForException["processTriReassigned"]);
|
||||
$trigger->throwExceptionIfNotExistsTrigger($arrayData["PRO_TRI_REASSIGNED"], $processUid, $this->arrayFieldNameForException["processTriReassigned"]);
|
||||
}
|
||||
|
||||
if (isset($arrayData["PRO_PARENT"])) {
|
||||
@@ -1615,5 +1583,43 @@ class Process
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Libraries
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
*
|
||||
* return array Return an array with all Libraries
|
||||
*/
|
||||
public function getLibraries($processUid)
|
||||
{
|
||||
try {
|
||||
$arrayLibrary = array();
|
||||
|
||||
//Verify data
|
||||
$this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
|
||||
|
||||
//Get data
|
||||
\G::LoadClass("triggerLibrary");
|
||||
|
||||
$triggerWizard = new \BusinessModel\TriggerWizard();
|
||||
$triggerWizard->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase);
|
||||
$triggerWizard->setArrayFieldNameForException($this->arrayFieldNameForException);
|
||||
|
||||
$triggerLibrary = \triggerLibrary::getSingleton();
|
||||
$library = $triggerLibrary->getRegisteredClasses();
|
||||
|
||||
foreach ($library as $key => $value) {
|
||||
$libraryName = (preg_match("/^class\.?(.*)\.pmFunctions\.php$/", $key, $arrayMatch))? ((isset($arrayMatch[1]) && $arrayMatch[1] != "")? $arrayMatch[1] : "pmFunctions") : $key;
|
||||
|
||||
$arrayLibrary[] = $triggerWizard->getLibrary($libraryName);
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayLibrary;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -211,5 +211,62 @@ class Trigger
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if doesn't exists the Trigger in table TRIGGERS
|
||||
*
|
||||
* @param string $triggerUid Unique id of Trigger
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if doesn't exists the Trigger in table TRIGGERS
|
||||
*/
|
||||
public function throwExceptionIfNotExistsTrigger($triggerUid, $processUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\TriggersPeer::TRI_UID);
|
||||
|
||||
if ($processUid != "") {
|
||||
$criteria->add(\TriggersPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add(\TriggersPeer::TRI_UID, $triggerUid, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \TriggersPeer::doSelectRS($criteria);
|
||||
|
||||
if (!$rsCriteria->next()) {
|
||||
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $triggerUid), "The trigger with {0}: {1}, does not exist");
|
||||
|
||||
throw (new \Exception($msg));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if exists the title of a Trigger
|
||||
*
|
||||
* @param string $processUid Unique id of Process
|
||||
* @param string $triggerTitle Title
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
* @param string $triggerUidExclude Unique id of Trigger to exclude
|
||||
*
|
||||
* return void Throw exception if exists the title of a Trigger
|
||||
*/
|
||||
public function throwExceptionIfExistsTitle($processUid, $triggerTitle, $fieldNameForException, $triggerUidExclude = "")
|
||||
{
|
||||
try {
|
||||
if ($this->verifyNameTrigger($processUid, $triggerTitle, $triggerUidExclude)) {
|
||||
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $triggerTitle), "The trigger title with {0}: \"{1}\", already exists");
|
||||
|
||||
throw (new \Exception($msg));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
502
workflow/engine/src/BusinessModel/TriggerWizard.php
Normal file
502
workflow/engine/src/BusinessModel/TriggerWizard.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -419,6 +419,7 @@ class Project extends Api
|
||||
* @url GET /:prj_uid/grid/:grid_uid/variables
|
||||
*
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
* @param string $grid_uid
|
||||
*/
|
||||
public function doGetGridVariables($prj_uid, $grid_uid = "")
|
||||
{
|
||||
@@ -434,5 +435,25 @@ class Project extends Api
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:prj_uid/trigger-wizards
|
||||
*
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetTriggerWizards($prj_uid)
|
||||
{
|
||||
try {
|
||||
$process = new \BusinessModel\Process();
|
||||
$process->setFormatFieldNameInUppercase(false);
|
||||
$process->setArrayFieldNameForException(array("processUid" => "prj_uid", "libraryName" => "lib_name", "methodName" => "fn_name"));
|
||||
|
||||
$response = $process->getLibraries($prj_uid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
namespace Services\Api\ProcessMaker\Project;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Project\TriggerWizard Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class TriggerWizard extends Api
|
||||
{
|
||||
/**
|
||||
* @url GET /:prj_uid/trigger-wizard/:lib_name
|
||||
* @url GET /:prj_uid/trigger-wizard/:lib_name/:fn_name
|
||||
*
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
* @param string $lib_name
|
||||
* @param string $fn_name
|
||||
*/
|
||||
public function doGetTriggerWizard($prj_uid, $lib_name, $fn_name = "")
|
||||
{
|
||||
try {
|
||||
$triggerWizard = new \BusinessModel\TriggerWizard();
|
||||
$triggerWizard->setFormatFieldNameInUppercase(false);
|
||||
$triggerWizard->setArrayFieldNameForException(array("processUid" => "prj_uid", "libraryName" => "lib_name", "methodName" => "fn_name"));
|
||||
|
||||
$response = ($fn_name == "")? $triggerWizard->getLibrary($lib_name) : $triggerWizard->getMethod($lib_name, $fn_name);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:prj_uid/trigger-wizard/:lib_name/:fn_name/:tri_uid
|
||||
*
|
||||
* @param string $prj_uid {@min 32}{@max 32}
|
||||
* @param string $lib_name
|
||||
* @param string $fn_name
|
||||
* @param string $tri_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetTriggerWizardTrigger($prj_uid, $lib_name, $fn_name, $tri_uid)
|
||||
{
|
||||
try {
|
||||
$triggerWizard = new \BusinessModel\TriggerWizard();
|
||||
$triggerWizard->setFormatFieldNameInUppercase(false);
|
||||
$triggerWizard->setArrayFieldNameForException(array("processUid" => "prj_uid", "libraryName" => "lib_name", "methodName" => "fn_name"));
|
||||
|
||||
$response = $triggerWizard->getTrigger($lib_name, $fn_name, $tri_uid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
///**
|
||||
// * @url POST /:prj_uid/dynaform
|
||||
// *
|
||||
// * @param string $prj_uid {@min 32}{@max 32}
|
||||
// * @param array $request_data
|
||||
// *
|
||||
// * @status 201
|
||||
// */
|
||||
//public function doPostDynaForm($prj_uid, $request_data)
|
||||
//{
|
||||
// try {
|
||||
// return $response;
|
||||
// } catch (\Exception $e) {
|
||||
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
// }
|
||||
//}
|
||||
//
|
||||
///**
|
||||
// * @url PUT /:prj_uid/dynaform/:dyn_uid
|
||||
// *
|
||||
// * @param string $dyn_uid {@min 32}{@max 32}
|
||||
// * @param string $prj_uid {@min 32}{@max 32}
|
||||
// * @param array $request_data
|
||||
// */
|
||||
//public function doPutDynaForm($dyn_uid, $prj_uid, $request_data)
|
||||
//{
|
||||
// try {
|
||||
// //
|
||||
// } catch (\Exception $e) {
|
||||
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ debug = 1
|
||||
files-manager = "Services\Api\ProcessMaker\Project\FilesManager"
|
||||
report-Table = "Services\Api\ProcessMaker\Project\ReportTable"
|
||||
sub-process= "Services\Api\ProcessMaker\Project\SubProcess"
|
||||
trigger-wizard = "Services\Api\ProcessMaker\Project\TriggerWizard"
|
||||
|
||||
[alias: projects]
|
||||
project = "Services\Api\ProcessMaker\Project"
|
||||
|
||||
Reference in New Issue
Block a user