ProcessMaker "Calendar (endpoints)"

- Se han implementado los siguientes Endpoints:
    GET  /api/1.0/{workspace}/calendar/{cal_uid}
    POST /api/1.0/{workspace}/calendar
This commit is contained in:
Victor Saisa Lopez
2014-04-01 17:30:02 -04:00
parent 4f244bdd09
commit 539aa22fc5
11 changed files with 469 additions and 85 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -360,7 +360,7 @@ class DynaForm
//Verify data
$process = new \BusinessModel\Process();
$process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
@@ -507,7 +507,7 @@ class DynaForm
//Verify data
$process = new \BusinessModel\Process();
$process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
@@ -542,7 +542,7 @@ class DynaForm
$dynaFormUidCopyImport = $arrayData["COPY_IMPORT"]["DYN_UID"];
//Verify data
$process->throwExceptionIfNoExistsProcess($processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID"));
$process->throwExceptionIfNotExistsProcess($processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID"));
$this->throwExceptionIfNotExistsDynaForm($dynaFormUidCopyImport, $processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID"));
@@ -710,7 +710,7 @@ class DynaForm
//Verify data
$process = new \BusinessModel\Process();
$process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);

View File

@@ -137,7 +137,7 @@ class Group
*
* return void Throw exception if doesn't exists the Group in table GROUP
*/
public function throwExceptionIfNoExistsGroup($groupUid, $fieldNameForException)
public function throwExceptionIfNotExistsGroup($groupUid, $fieldNameForException)
{
try {
$group = new \Groupwf();
@@ -229,7 +229,7 @@ class Group
//Verify data
$process = new \BusinessModel\Process();
$this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);
@@ -268,7 +268,7 @@ class Group
{
try {
//Verify data
$this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
//Delete
$group = new \Groupwf();
@@ -340,7 +340,7 @@ class Group
//Verif data
if ($groupUid != "") {
$this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
}
//Get data
@@ -387,7 +387,7 @@ class Group
//Verif data
if ($groupUid != "") {
$this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
}
//Get data
@@ -555,7 +555,7 @@ class Group
{
try {
//Verify data
$this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
//Get data
$arrayTotalUsersByGroup = $this->getTotalUsersByGroup($groupUid);
@@ -673,7 +673,7 @@ class Group
//Verify data
$process = new \BusinessModel\Process();
$this->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$this->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException);

View File

@@ -147,11 +147,11 @@ class User
$process = new \BusinessModel\Process();
$group = new \BusinessModel\Group();
$group->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$group->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
$process->throwExceptionIfNoExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
$process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
$this->throwExceptionIfExistsGroupUser($groupUid, $arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
@@ -188,9 +188,9 @@ class User
$process = new \BusinessModel\Process();
$group = new \BusinessModel\Group();
$group->throwExceptionIfNoExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$group->throwExceptionIfNotExistsGroup($groupUid, $this->arrayFieldNameForException["groupUid"]);
$process->throwExceptionIfNoExistsUser($userUid, $this->arrayFieldNameForException["userUid"]);
$process->throwExceptionIfNotExistsUser($userUid, $this->arrayFieldNameForException["userUid"]);
$this->throwExceptionIfNotExistsGroupUser($groupUid, $userUid, $this->arrayFieldNameForException["userUid"]);

View File

@@ -211,7 +211,7 @@ class InputDocument
//Verify data
$process = new \BusinessModel\Process();
$process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);

View File

@@ -214,7 +214,7 @@ class Process
//
} else {
$eregDate = "[1-9]\d{3}\-(?:0[1-9]|1[012])\-(?:[0][1-9]|[12][0-9]|3[01])";
$eregHour = "(?:[0-1]\d|2[0-3])\:(?:[0-5]\d)\:(?:[0-5]\d)";
$eregHour = "(?:[0-1]\d|2[0-3])\:(?:[0-5]\d)(?:\:[0-5]\d)?";
$eregDatetime = $eregDate . "\s" . $eregHour;
switch ($arrayFieldDefinition[$fieldName]["type"]) {
@@ -237,14 +237,50 @@ class Process
}
break;
case 2:
//type
switch ($arrayFieldDefinition[$fieldName]["type"]) {
case "array":
//type
if (!is_array($fieldValue)) {
if ((!preg_match("/^\s*array\s*\(.*\)\s*$/", $fieldValue)) && $fieldValue != '') {
if ($fieldValue != "" && !preg_match("/^\s*array\s*\(.*\)\s*$/", $fieldValue)) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "The \"{0}\" attribute is not array")));
}
}
//empty
if (!$arrayFieldDefinition[$fieldName]["empty"]) {
$arrayAux = array();
if (is_array($fieldValue)) {
$arrayAux = $fieldValue;
}
if (is_string($fieldValue) && trim($fieldValue) . "" != "") {
eval("\$arrayAux = $fieldValue;");
}
if (count($arrayAux) == 0) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "The \"{0}\" attribute is empty")));
}
}
//defaultValues
if (count($arrayFieldDefinition[$fieldName]["defaultValues"]) > 0) {
$arrayAux = array();
if (is_array($fieldValue)) {
$arrayAux = $fieldValue;
}
if (is_string($fieldValue) && trim($fieldValue) . "" != "") {
eval("\$arrayAux = $fieldValue;");
}
foreach ($arrayAux as $value) {
if (!in_array($value, $arrayFieldDefinition[$fieldName]["defaultValues"])) {
throw (new \Exception(str_replace(array("{0}"), array($fieldNameAux), "Invalid value specified for \"{0}\"")));
}
}
}
break;
}
break;
@@ -287,7 +323,7 @@ class Process
*
* return void Throw exception if doesn't exists the Process in table PROCESS
*/
public function throwExceptionIfNoExistsProcess($processUid, $fieldNameForException)
public function throwExceptionIfNotExistsProcess($processUid, $fieldNameForException)
{
try {
$process = new \Process();
@@ -310,7 +346,7 @@ class Process
*
* return void Throw exception if doesn't exists the User in table USERS
*/
public function throwExceptionIfNoExistsUser($userUid, $fieldNameForException)
public function throwExceptionIfNotExistsUser($userUid, $fieldNameForException)
{
try {
$user = new \Users();
@@ -347,29 +383,6 @@ class Process
}
}
/**
* 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 exists the Calendar Definition in table CALENDAR_DEFINITION
*/
public function throwExceptionIfNotExistsCalendarDefinition($calendarDefinitionUid, $fieldNameForException)
{
try {
$obj = \CalendarDefinitionPeer::retrieveByPK($calendarDefinitionUid);
if (!(is_object($obj) && get_class($obj) == "CalendarDefinition")) {
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $calendarDefinitionUid), "The calendar definition with {0}: {1}, does not exist");
throw (new \Exception($msg));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if doesn't exists the Process Category in table PROCESS_CATEGORY
*
@@ -498,7 +511,7 @@ class Process
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
//Verify data
$this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$this->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);
@@ -507,7 +520,9 @@ class Process
}
if (isset($arrayData["PRO_CALENDAR"]) && $arrayData["PRO_CALENDAR"] . "" != "") {
$this->throwExceptionIfNotExistsCalendarDefinition($arrayData["PRO_CALENDAR"], $this->arrayFieldNameForException["processCalendar"]);
$calendar = new \BusinessModel\Calendar();
$calendar->throwExceptionIfNotExistsCalendar($arrayData["PRO_CALENDAR"], $this->arrayFieldNameForException["processCalendar"]);
}
if (isset($arrayData["PRO_CATEGORY"]) && $arrayData["PRO_CATEGORY"] . "" != "") {
@@ -543,11 +558,11 @@ class Process
}
if (isset($arrayData["PRO_PARENT"])) {
$this->throwExceptionIfNoExistsProcess($arrayData["PRO_PARENT"], $this->arrayFieldNameForException["processParent"]);
$this->throwExceptionIfNotExistsProcess($arrayData["PRO_PARENT"], $this->arrayFieldNameForException["processParent"]);
}
if (isset($arrayData["PRO_CREATE_USER"]) && $arrayData["PRO_CREATE_USER"] . "" != "") {
$this->throwExceptionIfNoExistsUser($arrayData["PRO_CREATE_USER"], $this->arrayFieldNameForException["processCreateUser"]);
$this->throwExceptionIfNotExistsUser($arrayData["PRO_CREATE_USER"], $this->arrayFieldNameForException["processCreateUser"]);
}
//Update
@@ -598,7 +613,7 @@ class Process
{
try {
//Verify data
$this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
//Get data
//Load Process
@@ -1372,7 +1387,7 @@ class Process
$arrayDynaForm = array();
//Verify data
$this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
//Get data
$dynaForm = new \BusinessModel\DynaForm();
@@ -1413,7 +1428,7 @@ class Process
$arrayInputDocument = array();
//Verify data
$this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
//Get data
$inputDocument = new \BusinessModel\InputDocument();
@@ -1545,7 +1560,7 @@ class Process
$arrayVariable = array();
//Verify data
$this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
//Get data
switch ($option) {
@@ -1602,7 +1617,7 @@ class Process
$arrayLibrary = array();
//Verify data
$this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
//Get data
\G::LoadClass("triggerLibrary");

View File

@@ -196,7 +196,7 @@ class Step
*
* return void Throw exception if doesn't exist the Step in table STEP
*/
public function throwExceptionIfNoExistsStep($stepUid)
public function throwExceptionIfNotExistsStep($stepUid)
{
$step = new \Step();
@@ -217,7 +217,7 @@ class Step
*
* return void Throw exception if doesn't exist the Task in table TASK
*/
public function throwExceptionIfNoExistsTask($taskUid)
public function throwExceptionIfNotExistsTask($taskUid)
{
$task = new \Task();
@@ -238,7 +238,7 @@ class Step
*
* return void Throw exception if doesn't exist the Process in table PROCESS
*/
public function throwExceptionIfNoExistsProcess($processUid)
public function throwExceptionIfNotExistsProcess($processUid)
{
$process = new \Process();
@@ -269,9 +269,9 @@ class Step
unset($arrayData["STEP_UID"]);
//Verify data
$this->throwExceptionIfNoExistsTask($taskUid);
$this->throwExceptionIfNotExistsTask($taskUid);
$this->throwExceptionIfNoExistsProcess($processUid);
$this->throwExceptionIfNotExistsProcess($processUid);
if (!isset($arrayData["STEP_TYPE_OBJ"])) {
throw (new \Exception(str_replace(array("{0}"), array($this->arrayParamException["stepTypeObj"]), "The \"{0}\" attribute is not defined")));
@@ -361,7 +361,7 @@ class Step
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
//Verify data
$this->throwExceptionIfNoExistsStep($stepUid);
$this->throwExceptionIfNotExistsStep($stepUid);
//Load Step
$step = new \Step();
@@ -460,7 +460,7 @@ class Step
{
try {
//Verify data
$this->throwExceptionIfNoExistsStep($stepUid);
$this->throwExceptionIfNotExistsStep($stepUid);
//Get position
$criteria = new \Criteria("workflow");
@@ -503,7 +503,7 @@ class Step
$step->setArrayParamException($this->arrayParamException);
//Verify data
$this->throwExceptionIfNoExistsTask($taskUid);
$this->throwExceptionIfNotExistsTask($taskUid);
//Get data
$criteria = new \Criteria("workflow");
@@ -544,7 +544,7 @@ class Step
$arrayStep = array();
//Verify data
$this->throwExceptionIfNoExistsStep($stepUid);
$this->throwExceptionIfNotExistsStep($stepUid);
//Get data
//Call plugin
@@ -642,11 +642,11 @@ class Step
//Verify data
if ($stepUid != "") {
$this->throwExceptionIfNoExistsStep($stepUid);
$this->throwExceptionIfNotExistsStep($stepUid);
}
if ($stepUid == "") {
$this->throwExceptionIfNoExistsTask($taskUid);
$this->throwExceptionIfNotExistsTask($taskUid);
}
//Get data
@@ -757,11 +757,11 @@ class Step
//Verify data
if ($stepUid != "") {
$this->throwExceptionIfNoExistsStep($stepUid);
$this->throwExceptionIfNotExistsStep($stepUid);
}
if ($stepUid == "") {
$this->throwExceptionIfNoExistsTask($taskUid);
$this->throwExceptionIfNotExistsTask($taskUid);
}
//Get data

View File

@@ -70,7 +70,7 @@ class Task
*
* return void Throw exception if doesn't exist the Task in table TASK
*/
public function throwExceptionIfNoExistsTask($taskUid)
public function throwExceptionIfNotExistsTask($taskUid)
{
$task = new \Task();
@@ -438,7 +438,7 @@ class Task
$arrayAvailableStep = array();
//Verify data
$this->throwExceptionIfNoExistsTask($taskUid);
$this->throwExceptionIfNotExistsTask($taskUid);
//Load Task
$task = new \Task();
@@ -641,7 +641,7 @@ class Task
$step->setArrayParamException($this->arrayParamException);
//Verify data
$this->throwExceptionIfNoExistsTask($taskUid);
$this->throwExceptionIfNotExistsTask($taskUid);
//Get data
$criteria = new \Criteria("workflow");

View File

@@ -676,7 +676,7 @@ class TriggerWizard
$this->throwExceptionIfNotExistsMethodInLibrary($libraryName, $methodName, $this->arrayFieldNameForException["libraryName"], $this->arrayFieldNameForException["methodName"]);
$process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);

View File

@@ -151,7 +151,7 @@ class WebEntry
//Verify data
$process = new \BusinessModel\Process();
$process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
if ($taskUid != "") {
$process->throwExceptionIfNotExistsTask($processUid, $taskUid, $this->arrayFieldNameForException["taskUid"]);
@@ -279,7 +279,7 @@ class WebEntry
//Verify data
$process = new \BusinessModel\Process();
$process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);

View File

@@ -29,5 +29,47 @@ class Calendar extends Api
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url GET /:cal_uid
*
* @param string $cal_uid {@min 32}{@max 32}
*/
public function doGet($cal_uid)
{
try {
$calendar = new \BusinessModel\Calendar();
$calendar->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase);
$response = $calendar->getCalendar($cal_uid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url POST
*
* @param array $request_data
*
* @status 201
*/
public function doPost($request_data)
{
try {
$calendar = new \BusinessModel\Calendar();
$calendar->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase);
$arrayData = $calendar->create($request_data);
$response = $arrayData;
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
}