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:
Victor Saisa Lopez
2014-02-20 17:16:00 -04:00
parent c3f70c65db
commit 2f0ffae574
9 changed files with 738 additions and 58 deletions

View File

@@ -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;
}
}
}