From 1d8ac3a3a1faa3304b117534136df2374dff10f5 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Fri, 14 Mar 2014 15:33:35 -0400 Subject: [PATCH 1/2] Adicion de cases list para CASES --- workflow/engine/src/BusinessModel/Cases.php | 121 +++++++++++++ .../src/Services/Api/ProcessMaker/Cases.php | 168 ++++++++++++++++++ 2 files changed, 289 insertions(+) create mode 100644 workflow/engine/src/BusinessModel/Cases.php create mode 100644 workflow/engine/src/Services/Api/ProcessMaker/Cases.php diff --git a/workflow/engine/src/BusinessModel/Cases.php b/workflow/engine/src/BusinessModel/Cases.php new file mode 100644 index 000000000..07ddab69a --- /dev/null +++ b/workflow/engine/src/BusinessModel/Cases.php @@ -0,0 +1,121 @@ + + * @copyright Colosa - Bolivia + */ +class Cases +{ + /** + * Get list for Cases + * + * @access public + * @param array $dataList, Data for list + * @return array + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + */ + public function getList($dataList = array()) + { + G::LoadClass("applications"); + + $solrEnabled = false; + $userUid = $dataList["userId"]; + $callback = isset( $dataList["callback"] ) ? $dataList["callback"] : "stcCallback1001"; + $dir = isset( $dataList["dir"] ) ? $dataList["dir"] : "DESC"; + $sort = isset( $dataList["sort"] ) ? $dataList["sort"] : "APP_CACHE_VIEW.APP_NUMBER"; + $start = isset( $dataList["start"] ) ? $dataList["start"] : "0"; + $limit = isset( $dataList["limit"] ) ? $dataList["limit"] : "25"; + $filter = isset( $dataList["filter"] ) ? $dataList["filter"] : ""; + $process = isset( $dataList["process"] ) ? $dataList["process"] : ""; + $category = isset( $dataList["category"] ) ? $dataList["category"] : ""; + $status = isset( $dataList["status"] ) ? strtoupper( $dataList["status"] ) : ""; + $user = isset( $dataList["user"] ) ? $dataList["user"] : ""; + $search = isset( $dataList["search"] ) ? $dataList["search"] : ""; + $action = isset( $dataList["action"] ) ? $dataList["action"] : "todo"; + $type = "extjs"; + $dateFrom = isset( $dataList["dateFrom"] ) ? substr( $dataList["dateFrom"], 0, 10 ) : ""; + $dateTo = isset( $dataList["dateTo"] ) ? substr( $dataList["dateTo"], 0, 10 ) : ""; + $first = isset( $dataList["first"] ) ? true :false; + + if ($action == 'search' || $action == 'to_reassign') { + $userUid = ($user == "CURRENT_USER") ? $userUid : $user; + if ($first) { + $result = array(); + $result['totalCount'] = 0; + $result['data'] = array(); + return $result; + } + } + + if (( + $action == "todo" || $action == "draft" || $action == "paused" || $action == "sent" || + $action == "selfservice" || $action == "unassigned" || $action == "search" + ) && + (($solrConf = \System::solrEnv()) !== false) + ) { + G::LoadClass("AppSolr"); + + $ApplicationSolrIndex = new \AppSolr( + $solrConf["solr_enabled"], + $solrConf["solr_host"], + $solrConf["solr_instance"] + ); + + if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) { + //Check if there are missing records to reindex and reindex them + $ApplicationSolrIndex->synchronizePendingApplications(); + $solrEnabled = true; + } + } + + + if ($solrEnabled) { + $result = $ApplicationSolrIndex->getAppGridData( + $userUid, + $start, + $limit, + $action, + $filter, + $search, + $process, + $status, + $type, + $dateFrom, + $dateTo, + $callback, + $dir, + $sort, + $category + ); + } else { + G::LoadClass("applications"); + $apps = new \Applications(); + $result = $apps->getAll( + $userUid, + $start, + $limit, + $action, + $filter, + $search, + $process, + $status, + $type, + $dateFrom, + $dateTo, + $callback, + $dir, + (strpos($sort, ".") !== false)? $sort : "APP_CACHE_VIEW." . $sort, + $category + ); + } + return $result; + } +} + diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Cases.php b/workflow/engine/src/Services/Api/ProcessMaker/Cases.php new file mode 100644 index 000000000..3c0cb59f2 --- /dev/null +++ b/workflow/engine/src/Services/Api/ProcessMaker/Cases.php @@ -0,0 +1,168 @@ + + * @copyright Colosa - Bolivia + * + * @protected + */ +class Cases extends Api +{ + /** + * Get list Cases To Do + * + * @access public + * @param array $request_data , Data for list + * @return array + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @url GET + */ + public function doGetCasesListToDo($request_data = array()) + { + try { + $request_data['action'] = 'todo'; + $request_data['userId'] = $this->getUserId(); + $oCases = new \BusinessModel\Cases(); + $response = $oCases->getList($request_data); + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * Get list Cases Draft + * + * @access public + * @param array $request_data , Data for list + * @return array + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @url GET /draft + */ + public function doGetCasesListDraft($request_data = array()) + { + try { + $request_data['action'] = 'draft'; + $request_data['userId'] = $this->getUserId(); + $oCases = new \BusinessModel\Cases(); + $response = $oCases->getList($request_data); + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * Get list Cases Participated + * + * @access public + * @param array $request_data , Data for list + * @return array + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @url GET /draft + */ + public function doGetCasesListParticipated($request_data = array()) + { + try { + $request_data['action'] = 'sent'; + $request_data['userId'] = $this->getUserId(); + $oCases = new \BusinessModel\Cases(); + $response = $oCases->getList($request_data); + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * Get list Cases Unassigned + * + * @access public + * @param array $request_data , Data for list + * @return array + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @url GET /draft + */ + public function doGetCasesListUnassigned($request_data = array()) + { + try { + $request_data['action'] = 'unassigned'; + $request_data['userId'] = $this->getUserId(); + $oCases = new \BusinessModel\Cases(); + $response = $oCases->getList($request_data); + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * Get list Cases Paused + * + * @access public + * @param array $request_data , Data for list + * @return array + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @url GET /draft + */ + public function doGetCasesListPaused($request_data = array()) + { + try { + $request_data['action'] = 'paused'; + $request_data['userId'] = $this->getUserId(); + $oCases = new \BusinessModel\Cases(); + $response = $oCases->getList($request_data); + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * Get list Cases Advanced Search + * + * @access public + * @param array $request_data , Data for list + * @return array + * + * @author Brayan Pereyra (Cochalo) + * @copyright Colosa - Bolivia + * + * @url GET /draft + */ + public function doGetCasesListAdvancedSearch($request_data = array()) + { + try { + $request_data['action'] = 'search'; + $request_data['userId'] = $this->getUserId(); + $oCases = new \BusinessModel\Cases(); + $response = $oCases->getList($request_data); + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } +} + From 0741493462773ee143076399b88e43f77bf5a597 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Fri, 14 Mar 2014 15:38:03 -0400 Subject: [PATCH 2/2] Arreglo de urls en CASES --- workflow/engine/src/Services/Api/ProcessMaker/Cases.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Cases.php b/workflow/engine/src/Services/Api/ProcessMaker/Cases.php index 3c0cb59f2..92f9aae48 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Cases.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Cases.php @@ -75,7 +75,7 @@ class Cases extends Api * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia * - * @url GET /draft + * @url GET /participated */ public function doGetCasesListParticipated($request_data = array()) { @@ -100,7 +100,7 @@ class Cases extends Api * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia * - * @url GET /draft + * @url GET /unassigned */ public function doGetCasesListUnassigned($request_data = array()) { @@ -125,7 +125,7 @@ class Cases extends Api * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia * - * @url GET /draft + * @url GET /paused */ public function doGetCasesListPaused($request_data = array()) { @@ -150,7 +150,7 @@ class Cases extends Api * @author Brayan Pereyra (Cochalo) * @copyright Colosa - Bolivia * - * @url GET /draft + * @url GET /advanced-search */ public function doGetCasesListAdvancedSearch($request_data = array()) {