From 92579d74d0ef34f38942aa986c22357e13c9abd7 Mon Sep 17 00:00:00 2001 From: Wendy Nestor Date: Wed, 2 Apr 2014 14:06:05 -0400 Subject: [PATCH 1/3] eliminacion archivo --- workflow/public_html/testInput.php | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 workflow/public_html/testInput.php diff --git a/workflow/public_html/testInput.php b/workflow/public_html/testInput.php deleted file mode 100644 index ff2a28d51..000000000 --- a/workflow/public_html/testInput.php +++ /dev/null @@ -1,23 +0,0 @@ -'@'.$file, 'inp_doc_uid'=>$inp_doc_uid, 'tas_uid' =>$tas_uid, 'app_doc_comment' =>$app_doc_comment); -curl_setopt($ch, CURLOPT_URL,$url); -curl_setopt($ch, CURLOPT_HTTPHEADER,$headr); -curl_setopt($ch, CURLOPT_POSTFIELDS, $a); -print "

post

"; -print_r($a); -curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); -$postResult = curl_exec($ch); -curl_close($ch); -print "

response var_dump

"; -var_dump($postResult); -print ""; \ No newline at end of file From 0c7f374befa2113e7b54298e3e1eb359708e5b87 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Wed, 2 Apr 2014 14:38:20 -0400 Subject: [PATCH 2/3] Se agrega test unit para cases INPUT DOCUMENTS. Se modifican respuestas de cases INPUT DOCUMENTS. Se modifica test unit de cases OUTPUT DOCUMENTS --- .../src/BusinessModel/ProcessCategory.php | 170 +++++++++++++++++- .../Api/ProcessMaker/ProcessCategory.php | 76 +++++++- workflow/engine/src/Services/api.ini | 8 +- 3 files changed, 249 insertions(+), 5 deletions(-) diff --git a/workflow/engine/src/BusinessModel/ProcessCategory.php b/workflow/engine/src/BusinessModel/ProcessCategory.php index b1009203d..5ceb1502f 100644 --- a/workflow/engine/src/BusinessModel/ProcessCategory.php +++ b/workflow/engine/src/BusinessModel/ProcessCategory.php @@ -96,7 +96,6 @@ class ProcessCategory { try { $criteria = new \Criteria("workflow"); - $criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_UID); $criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_PARENT); $criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_NAME); @@ -232,5 +231,172 @@ class ProcessCategory throw $e; } } -} + /** + * Get a Process Category + * + * @param string $cat_uid Category Id + * + * return array Return an object with the Process Category + */ + public function getCategory($cat_uid) + { + try { + $oProcessCategory = ''; + $process = new \Process(); + $oTotalProcessesByCategory = $process->getAllProcessesByCategory(); + $criteria = $this->getAProcessCategoryCriteria($cat_uid); + $criteriaCount = clone $criteria; + $criteriaCount->clearSelectColumns(); + $criteriaCount->addSelectColumn("COUNT(" . \ProcessCategoryPeer::CATEGORY_UID . ") AS NUM_REC"); + $rsCriteriaCount = \ProcessCategoryPeer::doSelectRS($criteriaCount); + $rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $rsCriteriaCount->next(); + $rsCriteria = \ProcessCategoryPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + while ($rsCriteria->next()) { + $row = $rsCriteria->getRow(); + $row["CATEGORY_TOTAL_PROCESSES"] = (isset($oTotalProcessesByCategory[$row["CATEGORY_UID"]]))? $oTotalProcessesByCategory[$row["CATEGORY_UID"]] : 0; + $oProcessCategory = $this->getProcessCategoryDataFromRecord($row); + } + //Return + if ($oProcessCategory != '') { + return $oProcessCategory; + } else { + throw (new \Exception( 'The Category with cat_uid: '.$cat_uid.' doesn\'t exist!')); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Post Process Category + * + * @param string $cat_name Name of Category + * + * return array + */ + public function addCategory($cat_name) + { + try { + require_once 'classes/model/ProcessCategory.php'; + $catName = trim( $cat_name ); + if ($this->existsName( $cat_name )) { + throw (new \Exception( 'cat_name. Duplicate Process Category name')); + } + $catUid = \G::GenerateUniqueID(); + $pcat = new \ProcessCategory(); + $pcat->setNew( true ); + $pcat->setCategoryUid( $catUid ); + $pcat->setCategoryName( $catName ); + $pcat->save(); + $oProcessCategory = array_change_key_case($this->getCategory( $catUid ), CASE_LOWER); + //Return + return $oProcessCategory; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Put Process Category + * + * @param string $cat_uid Category id + * @param string $cat_name Category Name + * + * return array + */ + public function updateCategory($cat_uid, $cat_name) + { + try { + require_once 'classes/model/ProcessCategory.php'; + $catUID = $cat_uid; + $catName = trim( $cat_name ); + if ($this->existsName( $cat_name )) { + throw (new \Exception( 'cat_name. Duplicate Process Category name')); + } + $pcat = new \ProcessCategory(); + $pcat->setNew( false ); + $pcat->setCategoryUid( $catUID ); + $pcat->setCategoryName( $catName ); + $pcat->save(); + $oProcessCategory = array_change_key_case($this->getCategory( $cat_uid ), CASE_LOWER); + //Return + return $oProcessCategory; + + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Delete Process Category + * + * @param string $cat_uid Category id + * + * return array + */ + public function deleteCategory($cat_uid) + { + try { + require_once 'classes/model/ProcessCategory.php'; + $criteria = $this->getAProcessCategoryCriteria($cat_uid); + $rsCriteria = \ProcessCategoryPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $rsCriteria->next(); + $row = $rsCriteria->getRow(); + if ($row) { + $cat = new \ProcessCategory(); + $cat->setCategoryUid( $cat_uid ); + $cat->delete(); + } else { + throw (new \Exception( 'The Category with cat_uid: '.$cat_uid.' doesn\'t exist!')); + } + + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get criteria for Process Category + * + * return object + */ + public function getAProcessCategoryCriteria($cat_uid) + { + try { + $criteria = new \Criteria("workflow"); + $criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_UID); + $criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_PARENT); + $criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_NAME); + $criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_ICON); + $criteria->add(\ProcessCategoryPeer::CATEGORY_UID, $cat_uid); + return $criteria; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Checks if the name exists + * + * @param string $name Name + * + * return bool Return true if the name exists, false otherwise + */ + public function existsName($name) + { + try { + $criteria = new \Criteria("workflow"); + $criteria->add(\ProcessCategoryPeer::CATEGORY_NAME, $name, \Criteria::EQUAL); + $rsCriteria = \ProcessCategoryPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + $rsCriteria->next(); + return $rsCriteria->getRow(); + } catch (\Exception $e) { + throw $e; + } + } +} diff --git a/workflow/engine/src/Services/Api/ProcessMaker/ProcessCategory.php b/workflow/engine/src/Services/Api/ProcessMaker/ProcessCategory.php index 2fb46ab2a..c8048f173 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/ProcessCategory.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/ProcessCategory.php @@ -14,7 +14,7 @@ class ProcessCategory extends Api private $formatFieldNameInUppercase = false; /** - * @url GET /categories + * @url GET */ public function doGetCategories($filter = null, $start = null, $limit = null) { @@ -29,5 +29,77 @@ class ProcessCategory extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } -} + /** + * @url GET /:cat_uid + * + * @param string $cat_uid {@min 32}{@max 32} + */ + public function doGetCategory($cat_uid) + { + try { + $processCategory = new \BusinessModel\ProcessCategory(); + $processCategory->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase); + + $response = $processCategory->getCategory($cat_uid); + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url POST + * + * @param string $cat_name + * + */ + public function doPostCategory($cat_name) + { + try { + $processCategory = new \BusinessModel\ProcessCategory(); + $response = $processCategory->addCategory($cat_name); + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url PUT /:cat_uid + * + * @param string $cat_uid {@min 32}{@max 32} + * @param string $cat_name + * + */ + public function doPutCategory($cat_uid, $cat_name) + { + try { + $processCategory = new \BusinessModel\ProcessCategory(); + $response = $processCategory->updateCategory($cat_uid, $cat_name); + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url DELETE /:cat_uid + * + * @param string $cat_uid {@min 32}{@max 32} + * + */ + public function doDeleteCategory($cat_uid) + { + try { + $processCategory = new \BusinessModel\ProcessCategory(); + $processCategory->deleteCategory($cat_uid); + + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } +} \ No newline at end of file diff --git a/workflow/engine/src/Services/api.ini b/workflow/engine/src/Services/api.ini index 1d9365fd5..70c69d0cd 100644 --- a/workflow/engine/src/Services/api.ini +++ b/workflow/engine/src/Services/api.ini @@ -65,4 +65,10 @@ debug = 1 [alias: cases] case = "Services\Api\ProcessMaker\Case" input-document = "Services\Api\ProcessMaker\Cases\InputDocument" - output-document = "Services\Api\ProcessMaker\Cases\OutputDocument" \ No newline at end of file + output-document = "Services\Api\ProcessMaker\Cases\OutputDocument" + +[alias: category] + category = "Services\Api\ProcessMaker\ProcessCategory" + +[alias: categories] + category = "Services\Api\ProcessMaker\ProcessCategory" \ No newline at end of file From 7f0373edc1e50dea9bfccccabbf8d6034b8a3b62 Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Wed, 2 Apr 2014 15:31:57 -0400 Subject: [PATCH 3/3] ProcessMaker "Calendar (endpoints)" - Se han implementado los siguientes Endpoints: PUT /api/1.0/{workspace}/calendar/{cal_uid} DELETE /api/1.0/{workspace}/calendar/{cal_uid} --- .../engine/src/BusinessModel/Calendar.php | 136 +++++++++++++++++- .../Services/Api/ProcessMaker/Calendar.php | 35 +++++ 2 files changed, 170 insertions(+), 1 deletion(-) diff --git a/workflow/engine/src/BusinessModel/Calendar.php b/workflow/engine/src/BusinessModel/Calendar.php index 8dd46ee1b..cbb0e3862 100644 --- a/workflow/engine/src/BusinessModel/Calendar.php +++ b/workflow/engine/src/BusinessModel/Calendar.php @@ -273,7 +273,7 @@ class Calendar $this->throwExceptionIfExistsName($arrayData["CAL_NAME"], $this->arrayFieldNameForException["calendarName"]); - if (!(count($arrayData["CAL_WORK_DAYS"]) >= 3)) { + if (isset($arrayData["CAL_WORK_DAYS"]) && count($arrayData["CAL_WORK_DAYS"]) < 3) { throw (new \Exception(\G::LoadTranslation("ID_MOST_AT_LEAST_3_DAY"))); } @@ -294,6 +294,10 @@ class Calendar if (isset($arrayData["CAL_WORK_HOUR"])) { foreach ($arrayData["CAL_WORK_HOUR"] as $value) { + if ($value["DAY"] != "ALL" && !in_array($value["DAY"], $arrayData["CAL_WORK_DAYS"])) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($this->arrayWorkHourFieldNameForException["day"], $this->arrayFieldNameForException["calendarWorkDays"]), "Value specified for \"{0}\" does not exists in \"{1}\""))); + } + $arrayCalendarWorkHour[] = array( "CALENDAR_BUSINESS_DAY" => $this->workDaysReplaceData($value["DAY"]), "CALENDAR_BUSINESS_START" => $value["HOUR_START"], @@ -346,6 +350,136 @@ class Calendar } } + /** + * Update Calendar + * + * @param string $calendarUid Unique id of Calendar + * @param array $arrayData Data + * + * return array Return data of the Calendar updated + */ + public function update($calendarUid, $arrayData) + { + try { + $arrayData = \G::array_change_key_case2($arrayData, CASE_UPPER); + + //Verify data + $process = new \BusinessModel\Process(); + + $this->throwExceptionIfNotExistsCalendar($calendarUid, $this->arrayFieldNameForException["calendarUid"]); + + $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false); + + if (isset($arrayData["CAL_NAME"])) { + $this->throwExceptionIfExistsName($arrayData["CAL_NAME"], $this->arrayFieldNameForException["calendarName"], $calendarUid); + } + + if (isset($arrayData["CAL_WORK_DAYS"]) && count($arrayData["CAL_WORK_DAYS"]) < 3) { + throw (new \Exception(\G::LoadTranslation("ID_MOST_AT_LEAST_3_DAY"))); + } + + if (isset($arrayData["CAL_WORK_HOUR"])) { + foreach ($arrayData["CAL_WORK_HOUR"] as $value) { + $process->throwExceptionIfDataNotMetFieldDefinition($value, $this->arrayWorkHourFieldDefinition, $this->arrayWorkHourFieldNameForException, true); + } + } + + if (isset($arrayData["CAL_HOLIDAY"])) { + foreach ($arrayData["CAL_HOLIDAY"] as $value) { + $process->throwExceptionIfDataNotMetFieldDefinition($value, $this->arrayHolidayFieldDefinition, $this->arrayHolidayFieldNameForException, true); + } + } + + //Set variables + $arrayCalendarData = \G::array_change_key_case2($this->getCalendar($calendarUid), CASE_UPPER); + + $calendarWorkDays = (isset($arrayData["CAL_WORK_DAYS"]))? $arrayData["CAL_WORK_DAYS"] : $arrayCalendarData["CAL_WORK_DAYS"]; + + $arrayCalendarWorkHour = array(); + $arrayAux = (isset($arrayData["CAL_WORK_HOUR"]))? $arrayData["CAL_WORK_HOUR"] : $arrayCalendarData["CAL_WORK_HOUR"]; + + foreach ($arrayAux as $value) { + if (isset($arrayData["CAL_WORK_HOUR"]) && $value["DAY"] != "ALL" && !in_array($value["DAY"], $calendarWorkDays)) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($this->arrayWorkHourFieldNameForException["day"], $this->arrayFieldNameForException["calendarWorkDays"]), "Value specified for \"{0}\" does not exists in \"{1}\""))); + } + + $arrayCalendarWorkHour[] = array( + "CALENDAR_BUSINESS_DAY" => $this->workDaysReplaceData($value["DAY"]), + "CALENDAR_BUSINESS_START" => $value["HOUR_START"], + "CALENDAR_BUSINESS_END" => $value["HOUR_END"] + ); + } + + $arrayCalendarHoliday = array(); + $arrayAux = (isset($arrayData["CAL_HOLIDAY"]))? $arrayData["CAL_HOLIDAY"] : $arrayCalendarData["CAL_HOLIDAY"]; + + foreach ($arrayAux as $value) { + $arrayCalendarHoliday[] = array( + "CALENDAR_HOLIDAY_NAME" => $value["NAME"], + "CALENDAR_HOLIDAY_START" => $value["DATE_START"], + "CALENDAR_HOLIDAY_END" => $value["DATE_END"] + ); + } + + $arrayDataAux = array(); + $arrayDataAux["CALENDAR_UID"] = $calendarUid; + $arrayDataAux["CALENDAR_NAME"] = (isset($arrayData["CAL_NAME"]))? $arrayData["CAL_NAME"] : $arrayCalendarData["CAL_NAME"]; + $arrayDataAux["CALENDAR_DESCRIPTION"] = (isset($arrayData["CAL_DESCRIPTION"]))? $arrayData["CAL_DESCRIPTION"] : $arrayCalendarData["CAL_DESCRIPTION"]; + $arrayDataAux["CALENDAR_WORK_DAYS"] = explode("|", $this->workDaysReplaceData(implode("|", $calendarWorkDays))); + $arrayDataAux["CALENDAR_STATUS"] = (isset($arrayData["CAL_STATUS"]))? $arrayData["CAL_STATUS"] : $arrayCalendarData["CAL_STATUS"]; + + $arrayDataAux["BUSINESS_DAY"] = $arrayCalendarWorkHour; + $arrayDataAux["HOLIDAY"] = $arrayCalendarHoliday; + + //Update + $calendarDefinition = new \CalendarDefinition(); + + $calendarDefinition->saveCalendarInfo($arrayDataAux); + + //Return + if (!$this->formatFieldNameInUppercase) { + $arrayData = \G::array_change_key_case2($arrayData, CASE_LOWER); + } + + return $arrayData; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Delete Calendar + * + * @param string $calendarUid Unique id of Calendar + * + * return void + */ + public function delete($calendarUid) + { + try { + //Verify data + $calendarDefinition = new \CalendarDefinition(); + + $this->throwExceptionIfNotExistsCalendar($calendarUid, $this->arrayFieldNameForException["calendarUid"]); + + $arrayAux = $calendarDefinition->getAllCounterByCalendar("USER"); + $nU = (isset($arrayAux[$calendarUid]))? $arrayAux[$calendarUid] : 0; + $arrayAux = $calendarDefinition->getAllCounterByCalendar("TASK"); + $nT = (isset($arrayAux[$calendarUid]))? $arrayAux[$calendarUid] : 0; + $arrayAux = $calendarDefinition->getAllCounterByCalendar("PROCESS"); + $nP = (isset($arrayAux[$calendarUid]))? $arrayAux[$calendarUid] : 0; + + if ($nU + $nT + $nP > 0) { + throw (new \Exception(\G::LoadTranslation("ID_MSG_CANNOT_DELETE_CALENDAR"))); + } + + //Delete + $calendarDefinition->deleteCalendar($calendarUid); + } catch (\Exception $e) { + throw $e; + } + } + /** * Get criteria for Calendar * diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Calendar.php b/workflow/engine/src/Services/Api/ProcessMaker/Calendar.php index 612b52aae..2a6e3f9bb 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Calendar.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Calendar.php @@ -71,5 +71,40 @@ class Calendar extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } + + /** + * @url PUT /:cal_uid + * + * @param string $cal_uid {@min 32}{@max 32} + * @param array $request_data + */ + public function doPut($cal_uid, $request_data) + { + try { + $calendar = new \BusinessModel\Calendar(); + $calendar->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase); + + $arrayData = $calendar->update($cal_uid, $request_data); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url DELETE /:cal_uid + * + * @param string $cal_uid {@min 32}{@max 32} + */ + public function doDelete($cal_uid) + { + try { + $calendar = new \BusinessModel\Calendar(); + $calendar->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase); + + $calendar->delete($cal_uid); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } }