From 38afd81af91f27c803ca42c38c46120d2ef34940 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Mon, 17 Mar 2014 09:09:29 -0400 Subject: [PATCH 1/9] Se modifica la clase class.processes y class.wsBase. Se agregan metodos a la clase CASES. (caseInfo, taskCase, newCase, newCaseImpersonate, reassignCase). --- workflow/engine/classes/class.processes.php | 62 ++-- workflow/engine/classes/class.wsBase.php | 72 ++--- workflow/engine/src/BusinessModel/Cases.php | 271 ++++++++++++++++++ .../src/Services/Api/ProcessMaker/Cases.php | 116 ++++++++ 4 files changed, 454 insertions(+), 67 deletions(-) diff --git a/workflow/engine/classes/class.processes.php b/workflow/engine/classes/class.processes.php index 490a19ee2..7a00a291a 100755 --- a/workflow/engine/classes/class.processes.php +++ b/workflow/engine/classes/class.processes.php @@ -24,38 +24,38 @@ * Coral Gables, FL, 33134, USA, or email info@colosa.com. */ -require_once 'classes/model/Content.php'; -require_once 'classes/model/Process.php'; -require_once 'classes/model/Task.php'; -require_once 'classes/model/Route.php'; -require_once 'classes/model/SwimlanesElements.php'; -require_once 'classes/model/InputDocument.php'; -require_once 'classes/model/ObjectPermission.php'; -require_once 'classes/model/OutputDocument.php'; -require_once 'classes/model/Step.php'; -require_once 'classes/model/StepTrigger.php'; -require_once 'classes/model/Dynaform.php'; -require_once 'classes/model/Triggers.php'; -require_once 'classes/model/Groupwf.php'; -require_once 'classes/model/ReportTable.php'; -require_once 'classes/model/ReportVar.php'; -require_once 'classes/model/DbSource.php'; -require_once 'classes/model/StepSupervisor.php'; -require_once 'classes/model/SubProcess.php'; -require_once 'classes/model/CaseTracker.php'; -require_once 'classes/model/CaseTrackerObject.php'; -require_once 'classes/model/Stage.php'; -require_once 'classes/model/TaskUser.php'; -require_once 'classes/model/FieldCondition.php'; -require_once 'classes/model/Event.php'; -require_once 'classes/model/CaseScheduler.php'; -require_once 'classes/model/ProcessCategory.php'; -require_once 'classes/model/Configuration.php'; +//require_once 'classes/model/Content.php'; +//require_once 'classes/model/Process.php'; +//require_once 'classes/model/Task.php'; +//require_once 'classes/model/Route.php'; +//require_once 'classes/model/SwimlanesElements.php'; +//require_once 'classes/model/InputDocument.php'; +//require_once 'classes/model/ObjectPermission.php'; +//require_once 'classes/model/OutputDocument.php'; +//require_once 'classes/model/Step.php'; +//require_once 'classes/model/StepTrigger.php'; +//require_once 'classes/model/Dynaform.php'; +//require_once 'classes/model/Triggers.php'; +//require_once 'classes/model/Groupwf.php'; +//require_once 'classes/model/ReportTable.php'; +//require_once 'classes/model/ReportVar.php'; +//require_once 'classes/model/DbSource.php'; +//require_once 'classes/model/StepSupervisor.php'; +//require_once 'classes/model/SubProcess.php'; +//require_once 'classes/model/CaseTracker.php'; +//require_once 'classes/model/CaseTrackerObject.php'; +//require_once 'classes/model/Stage.php'; +//require_once 'classes/model/TaskUser.php'; +//require_once 'classes/model/FieldCondition.php'; +//require_once 'classes/model/Event.php'; +//require_once 'classes/model/CaseScheduler.php'; +//require_once 'classes/model/ProcessCategory.php'; +//require_once 'classes/model/Configuration.php'; -G::LoadClass( 'tasks' ); -G::LoadClass( 'reportTables' ); -G::LoadClass( 'processMap' ); -G::LoadThirdParty( 'pear/json', 'class.json' ); +//G::LoadClass( 'tasks' ); +//G::LoadClass( 'reportTables' ); +//G::LoadClass( 'processMap' ); +//G::LoadThirdParty( 'pear/json', 'class.json' ); class Processes { diff --git a/workflow/engine/classes/class.wsBase.php b/workflow/engine/classes/class.wsBase.php index 3ef625110..806dbff6e 100755 --- a/workflow/engine/classes/class.wsBase.php +++ b/workflow/engine/classes/class.wsBase.php @@ -25,43 +25,43 @@ */ //It works with the table CONFIGURATION in a WF dataBase -require_once ("classes/model/Application.php"); -require_once ("classes/model/AppCacheView.php"); -require_once ("classes/model/AppDelegation.php"); -require_once ("classes/model/AppDocument.php"); -require_once ("classes/model/AppDelay.php"); -require_once ("classes/model/AppNotes.php"); -require_once ("classes/model/AppThread.php"); -require_once ("classes/model/Department.php"); -require_once ("classes/model/Dynaform.php"); -require_once ("classes/model/Groupwf.php"); -require_once ("classes/model/InputDocument.php"); -require_once ("classes/model/Language.php"); -require_once ("classes/model/OutputDocument.php"); -require_once ("classes/model/Process.php"); -require_once ("classes/model/ReportTable.php"); -require_once ("classes/model/ReportVar.php"); -require_once ("classes/model/Route.php"); -require_once ("classes/model/Step.php"); -require_once ("classes/model/StepTrigger.php"); -require_once ("classes/model/Task.php"); -require_once ("classes/model/TaskUser.php"); -require_once ("classes/model/Triggers.php"); -require_once ("classes/model/Users.php"); -require_once ("classes/model/Session.php"); -require_once ("classes/model/Content.php"); -G::LoadClass( "ArrayPeer" ); -G::LoadClass( "BasePeer" ); +//require_once ("classes/model/Application.php"); +//require_once ("classes/model/AppCacheView.php"); +//require_once ("classes/model/AppDelegation.php"); +//require_once ("classes/model/AppDocument.php"); +//require_once ("classes/model/AppDelay.php"); +//require_once ("classes/model/AppNotes.php"); +//require_once ("classes/model/AppThread.php"); +//require_once ("classes/model/Department.php"); +//require_once ("classes/model/Dynaform.php"); +//require_once ("classes/model/Groupwf.php"); +//require_once ("classes/model/InputDocument.php"); +//require_once ("classes/model/Language.php"); +//require_once ("classes/model/OutputDocument.php"); +//require_once ("classes/model/Process.php"); +//require_once ("classes/model/ReportTable.php"); +//require_once ("classes/model/ReportVar.php"); +//require_once ("classes/model/Route.php"); +//require_once ("classes/model/Step.php"); +//require_once ("classes/model/StepTrigger.php"); +//require_once ("classes/model/Task.php"); +//require_once ("classes/model/TaskUser.php"); +//require_once ("classes/model/Triggers.php"); +//require_once ("classes/model/Users.php"); +//require_once ("classes/model/Session.php"); +//require_once ("classes/model/Content.php"); +//G::LoadClass( "ArrayPeer" ); +//G::LoadClass( "BasePeer" ); G::LoadClass( 'case' ); -G::LoadClass( 'derivation' ); -G::LoadClass( 'groups' ); -G::LoadClass( 'sessions' ); -G::LoadClass( 'processes' ); -G::LoadClass( 'processMap' ); -G::LoadClass( 'pmScript' ); -G::LoadClass( 'spool' ); -G::LoadClass( 'tasks' ); -G::LoadClass( 'wsResponse' ); +//G::LoadClass( 'derivation' ); +//G::LoadClass( 'groups' ); +//G::LoadClass( 'sessions' ); +//G::LoadClass( 'processes' ); +//G::LoadClass( 'processMap' ); +//G::LoadClass( 'pmScript' ); +//G::LoadClass( 'spool' ); +//G::LoadClass( 'tasks' ); +//G::LoadClass( 'wsResponse' ); /** * Copyright (C) 2009 COLOSA diff --git a/workflow/engine/src/BusinessModel/Cases.php b/workflow/engine/src/BusinessModel/Cases.php index 07ddab69a..db8136c41 100644 --- a/workflow/engine/src/BusinessModel/Cases.php +++ b/workflow/engine/src/BusinessModel/Cases.php @@ -117,5 +117,276 @@ class Cases } return $result; } + + /** + * Get data of a Case + * + * @param string $caseUid Unique id of Case + * @param string $userUid Unique id of User + * + * return array Return an array with data of Case Info + */ + public function getCaseInfo($caseUid, $userUid) + { + try { + $solrEnabled = 0; + if (($solrEnv = \System::solrEnv()) !== false) { + \G::LoadClass("AppSolr"); + $appSolr = new \AppSolr( + $solrEnv["solr_enabled"], + $solrEnv["solr_host"], + $solrEnv["solr_instance"] + ); + if ($appSolr->isSolrEnabled() && $solrEnv["solr_enabled"] == true) { + //Check if there are missing records to reindex and reindex them + $appSolr->synchronizePendingApplications(); + $solrEnabled = 1; + } + } + if ($solrEnabled == 1) { + try { + \G::LoadClass("searchIndex"); + $arrayData = array(); + $delegationIndexes = array(); + $columsToInclude = array("APP_UID"); + $solrSearchText = null; + //Todo + $solrSearchText = $solrSearchText . (($solrSearchText != null)? " OR " : null) . "(APP_STATUS:TO_DO AND APP_ASSIGNED_USERS:" . $userUid . ")"; + $delegationIndexes[] = "APP_ASSIGNED_USER_DEL_INDEX_" . $userUid . "_txt"; + //Draft + $solrSearchText = $solrSearchText . (($solrSearchText != null)? " OR " : null) . "(APP_STATUS:DRAFT AND APP_DRAFT_USER:" . $userUid . ")"; + //Index is allways 1 + $solrSearchText = "($solrSearchText)"; + //Add del_index dynamic fields to list of resulting columns + $columsToIncludeFinal = array_merge($columsToInclude, $delegationIndexes); + $solrRequestData = \Entity_SolrRequestData::createForRequestPagination( + array( + "workspace" => $solrEnv["solr_instance"], + "startAfter" => 0, + "pageSize" => 1000, + "searchText" => $solrSearchText, + "numSortingCols" => 1, + "sortCols" => array("APP_NUMBER"), + "sortDir" => array(strtolower("DESC")), + "includeCols" => $columsToIncludeFinal, + "resultFormat" => "json" + ) + ); + //Use search index to return list of cases + $searchIndex = new \BpmnEngine_Services_SearchIndex($appSolr->isSolrEnabled(), $solrEnv["solr_host"]); + //Execute query + $solrQueryResult = $searchIndex->getDataTablePaginatedList($solrRequestData); + //Get the missing data from database + $arrayApplicationUid = array(); + foreach ($solrQueryResult->aaData as $i => $data) { + $arrayApplicationUid[] = $data["APP_UID"]; + } + $aaappsDBData = $appSolr->getListApplicationDelegationData($arrayApplicationUid); + foreach ($solrQueryResult->aaData as $i => $data) { + //Initialize array + $delIndexes = array(); //Store all the delegation indexes + //Complete empty values + $applicationUid = $data["APP_UID"]; //APP_UID + //Get all the indexes returned by Solr as columns + for($i = count($columsToInclude); $i <= count($data) - 1; $i++) { + if (is_array($data[$columsToIncludeFinal[$i]])) { + foreach ($data[$columsToIncludeFinal[$i]] as $delIndex) { + $delIndexes[] = $delIndex; + } + } + } + //Verify if the delindex is an array + //if is not check different types of repositories + //the delegation index must always be defined. + if (count($delIndexes) == 0) { + $delIndexes[] = 1; // the first default index + } + //Remove duplicated + $delIndexes = array_unique($delIndexes); + //Get records + foreach ($delIndexes as $delIndex) { + $aRow = array(); + //Copy result values to new row from Solr server + $aRow["APP_UID"] = $data["APP_UID"]; + //Get delegation data from DB + //Filter data from db + $indexes = $appSolr->aaSearchRecords($aaappsDBData, array( + "APP_UID" => $applicationUid, + "DEL_INDEX" => $delIndex + )); + foreach ($indexes as $index) { + $row = $aaappsDBData[$index]; + } + if(!isset($row)) + { + continue; + } + $aRow["APP_NUMBER"] = $row["APP_NUMBER"]; + $aRow["APP_STATUS"] = $row["APP_STATUS"]; + $aRow["PRO_UID"] = $row["PRO_UID"]; + $aRow["DEL_INDEX"] = $row["DEL_INDEX"]; + $arrayData[] = array( + "guid" => $aRow["APP_UID"], + "name" => $aRow["APP_NUMBER"], + "status" => $aRow["APP_STATUS"], + "delIndex" => $aRow["DEL_INDEX"], + "processId" => $aRow["PRO_UID"] + ); + } + } + $case = array(); + for ($i = 0; $i<=count($arrayData)-1; $i++) { + if ($arrayData[$i]["guid"] == $caseUid) { + $case = $arrayData[$i]; + } + } + return $case; + } catch (\InvalidIndexSearchTextException $e) { + $arrayData = array(); + $arrayData[] = array ( + "guid" => $e->getMessage(), + "name" => $e->getMessage(), + "status" => $e->getMessage(), + "delIndex" => $e->getMessage(), + "processId" => $e->getMessage() + ); + return $arrayData; + } + } else { + $arrayData = array(); + $criteria = new \Criteria("workflow"); + $criteria->addSelectColumn(\AppCacheViewPeer::APP_UID); + $criteria->addSelectColumn(\AppCacheViewPeer::DEL_INDEX); + $criteria->addSelectColumn(\AppCacheViewPeer::APP_NUMBER); + $criteria->addSelectColumn(\AppCacheViewPeer::APP_STATUS); + $criteria->addSelectColumn(\AppCacheViewPeer::PRO_UID); + $criteria->add(\AppCacheViewPeer::USR_UID, $userUid); + $criteria->add(\AppCacheViewPeer::APP_UID, $caseUid); + $criteria->add( + //ToDo - getToDo() + $criteria->getNewCriterion(\AppCacheViewPeer::APP_STATUS, "TO_DO", \CRITERIA::EQUAL)->addAnd( + $criteria->getNewCriterion(\AppCacheViewPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL))->addAnd( + $criteria->getNewCriterion(\AppCacheViewPeer::APP_THREAD_STATUS, "OPEN"))->addAnd( + $criteria->getNewCriterion(\AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN")) + )->addOr( + //Draft - getDraft() + $criteria->getNewCriterion(\AppCacheViewPeer::APP_STATUS, "DRAFT", \CRITERIA::EQUAL)->addAnd( + $criteria->getNewCriterion(\AppCacheViewPeer::APP_THREAD_STATUS, "OPEN"))->addAnd( + $criteria->getNewCriterion(\AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN")) + ); + $criteria->addDescendingOrderByColumn(\AppCacheViewPeer::APP_NUMBER); + $rsCriteria = \AppCacheViewPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + while ($rsCriteria->next()) { + $row = $rsCriteria->getRow(); + $arrayData[] = array( + "guid" => $row["APP_UID"], + "name" => $row["APP_NUMBER"], + "status" => $row["APP_STATUS"], + "delIndex" => $row["DEL_INDEX"], + "processId" => $row["PRO_UID"] + ); + } + return $arrayData; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data Task Case + * + * @param string $caseUid Unique id of Case + * + * return array Return an array with Task Case + */ + public function getTaskCase($caseUid) + { + try { + \G::LoadClass('wsBase'); + $ws = new \wsBase(); + $fields = $ws->taskCase($caseUid); + //Return + return $fields; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Add New Case + * + * @param string $prjUid Unique id of Project + * @param string $actUid Unique id of Activity + * @param string $caseUid Unique id of Case + * @param array $variables + * + * return array Return an array with Task Case + */ + public function addCase($prjUid, $actUid, $userUid, $variables) + { + try { + \G::LoadClass('wsBase'); + $ws = new \wsBase(); + if ($variables) { + $variables = array_shift($variables); + } + $fields = $ws->newCase($prjUid, $userUid, $actUid, $variables); + //Return + return $fields; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Add New Case Impersonate + * + * @param string $prjUid Unique id of Project + * @param string $usrUid Unique id of User + * @param string $caseUid Unique id of Case + * @param array $variables + * + * return array Return an array with Task Case + */ + public function addCaseImpersonate($prjUid, $usrUid, $caseUid, $variables) + { + try { + \G::LoadClass('wsBase'); + $ws = new \wsBase(); + $fields = $ws->newCaseImpersonate($prjUid, $usrUid, $variables, '1352844695225ff5fe54de2005407079'); + //Return + return $fields; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Reassign Case + * + * @param string $caseUid Unique id of Case + * @param string $userUid Unique id of User + * @param string $delIndex + * @param string $userUidSource Unique id of User Source + * @param string $userUid $userUidTarget id of User Target + * + * return array Return an array with Task Case + */ + + public function updateReassignCase($caseUid, $userUid, $delIndex, $userUidSource, $userUidTarget) + { + try { + \G::LoadClass('wsBase'); + $ws = new \wsBase(); + $fields = $ws->reassignCase($userUid, $caseUid, $delIndex, $userUidSource, $userUidTarget); + //Return + return $fields; + } catch (\Exception $e) { + throw $e; + } + } + } diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Cases.php b/workflow/engine/src/Services/Api/ProcessMaker/Cases.php index 92f9aae48..34f0e83a5 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Cases.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Cases.php @@ -164,5 +164,121 @@ class Cases extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } + + /** + * @url GET /:cas_uid + * + * @param string $cas_uid {@min 32}{@max 32} + */ + public function doGetCaseInfo($cas_uid) + { + try { + $userUid = $this->getUserId(); + $cases = new \BusinessModel\Cases(); + $arrayData = $cases->getCaseInfo($cas_uid, $userUid); + $response = $arrayData; + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url GET /:cas_uid/current-task + * + * @param string $cas_uid {@min 32}{@max 32} + */ + public function doGetTaskCase($cas_uid) + { + try { + $cases = new \BusinessModel\Cases(); + $arrayData = $cases->getTaskCase($cas_uid); + $response = $arrayData; + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url POST + * + * @param string $prj_uid {@from body} {@min 32}{@max 32} + * @param string $act_uid {@from body} {@min 32}{@max 32} + * @param array $variables {@from body} + * + */ + public function doPostCase($prj_uid, $act_uid, $variables=null) + { + try { + $userUid = $this->getUserId(); + $cases = new \BusinessModel\Cases(); + $arrayData = $cases->addCase($prj_uid, $act_uid, $userUid, $variables); + $response = $arrayData; + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url POST /impersonate + * + * @param string $prj_uid {@from body} {@min 32}{@max 32} + * @param string $usr_uid {@from body} {@min 32}{@max 32} + * @param string $act_uid {@from body} {@min 32}{@max 32} + * @param array $variables {@from body} + */ + public function doPostCaseImpersonate($prj_uid, $usr_uid, $act_uid, $variables) + { + try { + $cases = new \BusinessModel\Cases(); + $arrayData = $cases->addCaseImpersonate($prj_uid, $usr_uid, $act_uid, $variables); + $response = $arrayData; + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url PUT /:cas_uid/reassign-case + * + * @param string $del_index {@from body} + * @param string $usr_uid_source {@from body} {@min 32}{@max 32} + * @param string $usr_uid_target {@from body} {@min 32}{@max 32} + */ + public function doPutReassignCase($cas_uid, $del_index, $usr_uid_source, $usr_uid_target) + { + try { + $userUid = $this->getUserId(); + $cases = new \BusinessModel\Cases(); + $arrayData = $cases->updateReassignCase($cas_uid, $userUid, $del_index, $usr_uid_source, $usr_uid_target); + $response = $arrayData; + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url PUT /:cas_uid/route-case + * + * @param string $del_index {@from body} + * @param string $usr_uid_source {@from body} {@min 32}{@max 32} + * @param string $usr_uid_target {@from body} {@min 32}{@max 32} + */ + public function doPutRouteCase($cas_uid, $del_index, $usr_uid_source, $usr_uid_target) + { + try { + $userUid = $this->getUserId(); + $cases = new \BusinessModel\Cases(); + $arrayData = $cases->updateRouteCase($cas_uid, $userUid, $del_index, $usr_uid_source, $usr_uid_target); + $response = $arrayData; + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } } From 736275c791d0e13ab81f59d745f6dcfba58207f5 Mon Sep 17 00:00:00 2001 From: Erik Amaru Ortiz Date: Mon, 17 Mar 2014 09:48:23 -0400 Subject: [PATCH 2/9] Some changes on WebApplications class and app.php file --- framework/src/Maveriks/WebApplication.php | 4 ---- workflow/public_html/app.php | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/framework/src/Maveriks/WebApplication.php b/framework/src/Maveriks/WebApplication.php index 8353d0e1c..47adb07e2 100644 --- a/framework/src/Maveriks/WebApplication.php +++ b/framework/src/Maveriks/WebApplication.php @@ -73,10 +73,6 @@ class WebApplication public function run($type = "") { switch ($type) { - case self::REDIRECT_DEFAULT: - //TODO we can set a configurable redirect url - header("location: /sys/en/neoclassic/login/login"); - break; case self::SERVICE_API: $request = $this->parseApiRequestUri(); $this->loadEnvironment($request["workspace"]); diff --git a/workflow/public_html/app.php b/workflow/public_html/app.php index 88584ea3f..c0134146c 100644 --- a/workflow/public_html/app.php +++ b/workflow/public_html/app.php @@ -38,7 +38,7 @@ try { //$loader->add($rootDir . "workflow/engine/classes/model/"); $loader->add($rootDir . 'workflow/engine/src/'); - // and vendors to autoloader + // add vendors to autoloader $loader->add($rootDir . 'vendor/luracast/restler/vendor', "Luracast"); $loader->add($rootDir . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2"); $loader->addClass("Bootstrap", $rootDir . 'gulliver/system/class.bootstrap.php'); @@ -67,7 +67,10 @@ try { break; case Maveriks\WebApplication::RUNNING_DEFAULT: - $app->run(Maveriks\WebApplication::REDIRECT_DEFAULT); + $response = new Maveriks\Http\Response("", 302); + //TODO compose this def url with configuration data from env.ini + $response->setHeader("location", "/sys/en/neoclassic/login/login"); + $response->send(); break; } From 9a6308b619513dc64d68936bacc66e1ec3320d58 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Mon, 17 Mar 2014 10:45:49 -0400 Subject: [PATCH 3/9] Se adiciona el estado (sch_state) en metodo PUT para CASE SCHEDULER. --- workflow/engine/src/BusinessModel/CaseScheduler.php | 11 +++++++++-- .../Api/ProcessMaker/Project/CaseScheduler.php | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/workflow/engine/src/BusinessModel/CaseScheduler.php b/workflow/engine/src/BusinessModel/CaseScheduler.php index 90d99e737..a8be2f63d 100644 --- a/workflow/engine/src/BusinessModel/CaseScheduler.php +++ b/workflow/engine/src/BusinessModel/CaseScheduler.php @@ -622,8 +622,15 @@ class CaseScheduler $oCaseScheduler = new \CaseScheduler(); $aData['SCH_UID'] = $sSchUID; $aData['PRO_UID'] = $sProcessUID; - $aData['SCH_STATE'] = 'ACTIVE'; - $aData['SCH_LAST_STATE'] = 'CREATED'; // 'ACTIVE'; + if ($aData['SCH_STATE'] == "" || $aData['SCH_STATE'] == null) { + throw (new \Exception( '`sch_state` can`t be null')); + } else { + if ($aData['SCH_STATE'] == 'ACTIVE') { + $aData['SCH_LAST_STATE'] = 'CREATED'; + } else { + $aData['SCH_LAST_STATE'] = 'ACTIVE'; + } + } $aData['USR_UID'] = $userUID; $aData['SCH_DEL_USER_UID'] = $aData['USR_UID']; $sTimeTmp = $aData['SCH_START_TIME']; diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/CaseScheduler.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/CaseScheduler.php index ee02526dd..0a34c2732 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/CaseScheduler.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/CaseScheduler.php @@ -159,7 +159,7 @@ class CaseSchedulerStructure public $sch_last_run_time; /** - * @var string {@from body} {@min 0} {@max 15} + * @var string {@from body} {@choice ACTIVE,INACTIVE} */ public $sch_state; From 7826483bed4c47297a2a4f8eae84471a2d9553b5 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Mon, 17 Mar 2014 10:54:03 -0400 Subject: [PATCH 4/9] Se adiciona el estado (sch_state) en metodo PUT para CASE SCHEDULER. Cambios en BEHAT. --- .../basic_sequence_case_scheduler.feature | 3 ++- .../main_tests_case_scheduler.feature | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/features/backend/projects/case_scheduler/basic_sequence_case_scheduler.feature b/features/backend/projects/case_scheduler/basic_sequence_case_scheduler.feature index e3a48c3a4..c72ee983f 100644 --- a/features/backend/projects/case_scheduler/basic_sequence_case_scheduler.feature +++ b/features/backend/projects/case_scheduler/basic_sequence_case_scheduler.feature @@ -66,7 +66,8 @@ Feature: Case Scheduler Resources "sch_start_day_opt_2": "", "sch_months": "1|6|12", "sch_repeat_every": "", - "sch_repeat_until": "" + "sch_repeat_until": "", + "sch_state": "ACTIVE" } """ And that I want to update a resource with the key "sch_uid" stored in session array diff --git a/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature b/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature index b6d74f0a0..a0c3c7082 100644 --- a/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature +++ b/features/backend/projects/case_scheduler/main_tests_case_scheduler.feature @@ -113,7 +113,8 @@ Feature: Case Scheduler Main Tests "sch_start_day_opt_1": "", "sch_months": "", "sch_start_day_opt_2": "", - "sch_repeat_every": "" + "sch_repeat_every": "", + "sch_state": "" } """ And that I want to update a resource with the key "sch_uid" stored in session array as variable "sch_uid_" @@ -124,12 +125,12 @@ Feature: Case Scheduler Main Tests Examples: - | test_description | sch_uid_number | sch_del_user_name | sch_del_user_pass | tas_uid | sch_name | sch_option | sch_start_date | sch_end_date | sch_start_time | sch_week_days | sch_start_day | sch_start_day_opt_1 | sch_months | sch_start_day_opt_2 | sch_repeat_every | - | Update Daily | 1 | admin | admin | 1352844695225ff5fe54de2005407079 | Update Case Scheduler-Daily 123@#$ | 1 | 2014-02-30 | 2014-03-20 | 12:30 | | | | | | | - | Update Weekly, sch_week_days=monday | 2 | admin | admin | 1352844695225ff5fe54de2005407079 | Update Case Scheduler-Weekly monday 345%$# | 2 | 2014-03-20 | 2014-04-20 | 08:30 | 2 | | | | | | - | Update Monthly and day of month, day of month=1, of the month(s)=3,4 | 4 | admin | admin | 1352844695225ff5fe54de2005407079 | Update Case Scheduler-Monthly 567&^% 1 | 3 | 2014-04-21 | 2014-05-18 | 18:30 | | 1 | 18 | 3\|4\|5 | | | - | Update One time only | 12 | admin | admin | 1352844695225ff5fe54de2005407079 | Update Case Scheduler-One Time only 678%$@ | 4 | | | 20:30 | | | | | | | - | Update Every | 13 | admin | admin | 1352844695225ff5fe54de2005407079 | Update Case Scheduler-Every 987&%@ | 5 | | | | | | | | | 18.30 | + | test_description | sch_uid_number | sch_del_user_name | sch_del_user_pass | tas_uid | sch_name | sch_option | sch_start_date | sch_end_date | sch_start_time | sch_week_days | sch_start_day | sch_start_day_opt_1 | sch_months | sch_start_day_opt_2 | sch_repeat_every |sch_state | + | Update Daily | 1 | admin | admin | 1352844695225ff5fe54de2005407079 | Update Case Scheduler-Daily 123@#$ | 1 | 2014-02-30 | 2014-03-20 | 12:30 | | | | | | |ACTIVE | + | Update Weekly, sch_week_days=monday | 2 | admin | admin | 1352844695225ff5fe54de2005407079 | Update Case Scheduler-Weekly monday 345%$# | 2 | 2014-03-20 | 2014-04-20 | 08:30 | 2 | | | | | |ACTIVE | + | Update Monthly and day of month, day of month=1, of the month(s)=3,4 | 4 | admin | admin | 1352844695225ff5fe54de2005407079 | Update Case Scheduler-Monthly 567&^% 1 | 3 | 2014-04-21 | 2014-05-18 | 18:30 | | 1 | 18 | 3\|4\|5 | | |ACTIVE | + | Update One time only | 12 | admin | admin | 1352844695225ff5fe54de2005407079 | Update Case Scheduler-One Time only 678%$@ | 4 | | | 20:30 | | | | | | |ACTIVE | + | Update Every | 13 | admin | admin | 1352844695225ff5fe54de2005407079 | Update Case Scheduler-Every 987&%@ | 5 | | | | | | | | | 18.30 |ACTIVE | Scenario Outline: Get a single case scheduler of a project and check some properties From 0d8a96946c956394abab2da7e274b00935934be1 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Mon, 17 Mar 2014 11:12:00 -0400 Subject: [PATCH 5/9] Se quita caracter especial en mensajes de error en CASE SCHEDULER --- .../src/BusinessModel/CaseScheduler.php | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/workflow/engine/src/BusinessModel/CaseScheduler.php b/workflow/engine/src/BusinessModel/CaseScheduler.php index a8be2f63d..ecca9db2e 100644 --- a/workflow/engine/src/BusinessModel/CaseScheduler.php +++ b/workflow/engine/src/BusinessModel/CaseScheduler.php @@ -246,7 +246,7 @@ class CaseScheduler $oCriteria->add( \UsersPeer::USR_USERNAME, $sWS_USER ); $userIsAssigned = \GroupUserPeer::doCount( $oCriteria ); if (! ($userIsAssigned >= 1)) { - throw (new \Exception( "The User `" . $sWS_USER . "` doesn't have the activity `" . $sTASKS . "` assigned")); + throw (new \Exception( "The User \'" . $sWS_USER . "\' doesn't have the activity \'" . $sTASKS . "\' assigned")); } } $oDataset = \TaskUserPeer::doSelectRS($oCriteria); @@ -290,7 +290,7 @@ class CaseScheduler throw (new \Exception( 'Task not found for id: '. $aData['TAS_UID'])); } if ($aData['SCH_NAME']=='') { - throw (new \Exception( '`sch_name` can`t be empty')); + throw (new \Exception( '\'sch_name\' can\'t be empty')); } if ($this->existsName($sProcessUID, $aData['SCH_NAME'])) { throw (new \Exception( 'Duplicate Case Scheduler name')); @@ -304,23 +304,23 @@ class CaseScheduler if ($sOption != '5') { $pattern="/^([0-1][0-9]|[2][0-3])[\:]([0-5][0-9])$/"; if (!preg_match($pattern, $aData['SCH_START_TIME'])) { - throw (new \Exception( 'Invalid value specified for `sch_start_time`. Expecting time in HH:MM format (The time can not be increased to 23:59)')); + throw (new \Exception( 'Invalid value specified for \'sch_start_time\'. Expecting time in HH:MM format (The time can not be increased to 23:59)')); } } $patternDate="/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/"; if ($sOption == '1' || $sOption == '2' || $sOption == '3') { if (!preg_match($patternDate, $aData['SCH_START_DATE'])) { - throw (new \Exception( 'Invalid value specified for `sch_start_date`. Expecting date in `YYYY-MM-DD` format, such as `2014-01-01`')); + throw (new \Exception( 'Invalid value specified for \'sch_start_date\'. Expecting date in \'YYYY-MM-DD\' format, such as \'2014-01-01\'')); } } if ($sOption == '1' || $sOption == '2' || $sOption == '3') { if (!preg_match($patternDate, $aData['SCH_END_DATE'])) { - throw (new \Exception( 'Invalid value specified for `sch_end_date`. Expecting date in `YYYY-MM-DD` format, such as `2014-01-01`')); + throw (new \Exception( 'Invalid value specified for \'sch_end_date\'. Expecting date in \'YYYY-MM-DD\' format, such as \'2014-01-01\'')); } } if ($sOption == '1' || $sOption == '2' || $sOption == '3') { if ($aData['SCH_START_DATE'] == "") { - throw (new \Exception( '`sch_start_date` can`t be null')); + throw (new \Exception( '\'sch_start_date\' can\'t be null')); } } if ($sOption == '2') { @@ -368,7 +368,7 @@ class CaseScheduler break; case '2': // If the option is zero, set by default 1 if ($aData['SCH_WEEK_DAYS'] == "") { - throw (new \Exception( '`sch_week_days` can`t be null')); + throw (new \Exception( '\'sch_week_days\' can\'t be null')); } else { $weeks = $aData['SCH_WEEK_DAYS']; $weeks = explode("|", $weeks); @@ -376,7 +376,7 @@ class CaseScheduler if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7") { $aData['SCH_WEEK_DAYS'] = $aData['SCH_WEEK_DAYS']; } else { - throw (new \Exception( 'Invalid value specified for `sch_week_days`')); + throw (new \Exception( 'Invalid value specified for \'sch_week_days\'')); } } } @@ -397,50 +397,50 @@ class CaseScheduler case '3': $nStartDay = $aData['SCH_START_DAY']; if ($nStartDay == "") { - throw (new \Exception( '`sch_start_day` can`t be null')); + throw (new \Exception( '\'sch_start_day\' can\'t be null')); } if ($nStartDay == 1) { if ($aData['SCH_START_DAY_OPT_1'] == "") { - throw (new \Exception( '`sch_start_day_opt_1` can`t be null')); + throw (new \Exception( '\'sch_start_day_opt_1\' can\'t be null')); } $temp = $aData['SCH_START_DAY_OPT_1']; $temp = (int)$temp; if ($temp >= 1 && $temp <= 31) { $aData['SCH_START_DAY_OPT_1'] = $aData['SCH_START_DAY_OPT_1']; } else { - throw (new \Exception( 'Invalid value specified for `sch_start_day_opt_1`. Must be between 1 and 31')); + throw (new \Exception( 'Invalid value specified for \'sch_start_day_opt_1\'. Must be between 1 and 31')); } $aData['SCH_START_DAY'] = $nStartDay . '|' . $aData['SCH_START_DAY_OPT_1']; } else { if ($aData['SCH_START_DAY_OPT_2'] == "") { - throw (new \Exception( '`sch_start_day_opt_2` can`t be null')); + throw (new \Exception( '\'sch_start_day_opt_2\' can\'t be null')); } $aData['SCH_START_DAY'] = $nStartDay . '|' . $aData['SCH_START_DAY_OPT_2']; $optionTwo = $aData['SCH_START_DAY_OPT_2']{0}; if ($optionTwo == "1" || $optionTwo == "2" || $optionTwo == "3" || $optionTwo == "4" || $optionTwo == "5") { $aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for `sch_start_day_opt_2`')); + throw (new \Exception( 'Invalid value specified for \'sch_start_day_opt_2\'')); } $pipelineTwo = $aData['SCH_START_DAY_OPT_2']{1}; if ($pipelineTwo == "|") { $aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for `sch_start_day_opt_2`')); + throw (new \Exception( 'Invalid value specified for \'sch_start_day_opt_2\'')); } $dayTwo = $aData['SCH_START_DAY_OPT_2']{2}; if ($dayTwo == "1" || $dayTwo == "2" || $dayTwo == "3" || $dayTwo == "4" || $dayTwo == "5" || $dayTwo == "6" || $dayTwo == "7") { $aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for `sch_start_day_opt_2`')); + throw (new \Exception( 'Invalid value specified for \'sch_start_day_opt_2\'')); } } if ($nStartDay == "") { - throw (new \Exception( '`sch_start_day` can`t be null')); + throw (new \Exception( '\'sch_start_day\' can\'t be null')); } $sMonths = ''; if ($aData['SCH_MONTHS'] == "") { - throw (new \Exception( '`sch_months` can`t be null')); + throw (new \Exception( '\'sch_months\' can\'t be null')); } if (! empty( $aData['SCH_MONTHS'] )) { $aMonths = $aData['SCH_MONTHS']; @@ -449,7 +449,7 @@ class CaseScheduler if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7"|| $row == "8" || $row == "9" || $row == "10"|| $row == "11" || $row == "12") { $aData['SCH_MONTHS'] = $aData['SCH_MONTHS']; } else { - throw (new \Exception( 'Invalid value specified for `sch_months`')); + throw (new \Exception( 'Invalid value specified for \'sch_months\'')); } } } @@ -508,11 +508,11 @@ class CaseScheduler $aData['SCH_START_TIME'] = time(); $aData['SCH_START_DATE'] = $aData['SCH_START_TIME']; if ($aData['SCH_REPEAT_EVERY'] == "") { - throw (new \Exception( '`sch_repeat_every` can`t be null')); + throw (new \Exception( '\'sch_repeat_every\' can\'t be null')); } $patternHour="/^([0-1][0-9]|[2][0-3])[\.]([0-5][0-9])$/"; if (!preg_match($patternHour, $aData['SCH_REPEAT_EVERY'])) { - throw (new \Exception( 'Invalid value specified for `sch_repeat_every`. Expecting time in HH.MM format')); + throw (new \Exception( 'Invalid value specified for \'sch_repeat_every\'. Expecting time in HH.MM format')); } $nextRun = $aData['SCH_REPEAT_EVERY'] * 60 * 60; $aData['SCH_REPEAT_EVERY'] = $aData['SCH_REPEAT_EVERY']; @@ -581,7 +581,7 @@ class CaseScheduler throw (new \Exception( 'Task not found for id: '. $aData['TAS_UID'])); } if ($aData['SCH_NAME']=='') { - throw (new \Exception( '`sch_name` can`t be empty')); + throw (new \Exception( '\'sch_name\' can\'t be empty')); } if ($this->existsNameUpdate($sSchUID, $aData['SCH_NAME'])) { throw (new \Exception( 'Duplicate Case Scheduler name')); @@ -595,23 +595,23 @@ class CaseScheduler if ($sOption != '5') { $pattern="/^([0-1][0-9]|[2][0-3])[\:]([0-5][0-9])$/"; if (!preg_match($pattern, $aData['SCH_START_TIME'])) { - throw (new \Exception( 'Invalid value specified for `sch_start_time`. Expecting time in HH:MM format (The time can not be increased to 23:59)')); + throw (new \Exception( 'Invalid value specified for \'sch_start_time\'. Expecting time in HH:MM format (The time can not be increased to 23:59)')); } } $patternDate="/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/"; if ($sOption == '1' || $sOption == '2' || $sOption == '3') { if (!preg_match($patternDate, $aData['SCH_START_DATE'])) { - throw (new \Exception( 'Invalid value specified for `sch_start_date`. Expecting date in `YYYY-MM-DD` format, such as `2014-01-01`')); + throw (new \Exception( 'Invalid value specified for \'sch_start_date\'. Expecting date in \'YYYY-MM-DD\' format, such as \'2014-01-01\'')); } } if ($sOption == '1' || $sOption == '2' || $sOption == '3') { if (!preg_match($patternDate, $aData['SCH_END_DATE'])) { - throw (new \Exception( 'Invalid value specified for `sch_end_date`. Expecting date in `YYYY-MM-DD` format, such as `2014-01-01`')); + throw (new \Exception( 'Invalid value specified for \'sch_end_date\'. Expecting date in \'YYYY-MM-DD\' format, such as \'2014-01-01\'')); } } if ($sOption == '1' || $sOption == '2' || $sOption == '3') { if ($aData['SCH_START_DATE'] == "") { - throw (new \Exception( '`sch_start_date` can`t be null')); + throw (new \Exception( '\'sch_start_date\' can\'t be null')); } } if ($sOption == '2') { @@ -623,7 +623,7 @@ class CaseScheduler $aData['SCH_UID'] = $sSchUID; $aData['PRO_UID'] = $sProcessUID; if ($aData['SCH_STATE'] == "" || $aData['SCH_STATE'] == null) { - throw (new \Exception( '`sch_state` can`t be null')); + throw (new \Exception( '\'sch_state\' can\'t be null')); } else { if ($aData['SCH_STATE'] == 'ACTIVE') { $aData['SCH_LAST_STATE'] = 'CREATED'; @@ -666,7 +666,7 @@ class CaseScheduler break; case '2': // If the option is zero, set by default 1 if ($aData['SCH_WEEK_DAYS'] == "") { - throw (new \Exception( '`sch_week_days` can`t be null')); + throw (new \Exception( '\'sch_week_days\' can\'t be null')); } else { $weeks = $aData['SCH_WEEK_DAYS']; $weeks = explode("|", $weeks); @@ -674,7 +674,7 @@ class CaseScheduler if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7") { $aData['SCH_WEEK_DAYS'] = $aData['SCH_WEEK_DAYS']; } else { - throw (new \Exception( 'Invalid value specified for `sch_week_days`')); + throw (new \Exception( 'Invalid value specified for \'sch_week_days\'')); } } } @@ -695,50 +695,50 @@ class CaseScheduler case '3': $nStartDay = $aData['SCH_START_DAY']; if ($nStartDay == "") { - throw (new \Exception( '`sch_start_day` can`t be null')); + throw (new \Exception( '\'sch_start_day\' can\'t be null')); } if ($nStartDay == 1) { if ($aData['SCH_START_DAY_OPT_1'] == "") { - throw (new \Exception( '`sch_start_day_opt_1` can`t be null')); + throw (new \Exception( '\'sch_start_day_opt_1\' can\'t be null')); } $temp = $aData['SCH_START_DAY_OPT_1']; $temp = (int)$temp; if ($temp >= 1 && $temp <= 31) { $aData['SCH_START_DAY_OPT_1'] = $aData['SCH_START_DAY_OPT_1']; } else { - throw (new \Exception( 'Invalid value specified for `sch_start_day_opt_1`. Must be between 1 and 31')); + throw (new \Exception( 'Invalid value specified for \'sch_start_day_opt_1\'. Must be between 1 and 31')); } $aData['SCH_START_DAY'] = $nStartDay . '|' . $aData['SCH_START_DAY_OPT_1']; } else { if ($aData['SCH_START_DAY_OPT_2'] == "") { - throw (new \Exception( '`sch_start_day_opt_2` can`t be null')); + throw (new \Exception( '\'sch_start_day_opt_2\' can\'t be null')); } $aData['SCH_START_DAY'] = $nStartDay . '|' . $aData['SCH_START_DAY_OPT_2']; $optionTwo = $aData['SCH_START_DAY_OPT_2']{0}; if ($optionTwo == "1" || $optionTwo == "2" || $optionTwo == "3" || $optionTwo == "4" || $optionTwo == "5") { $aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for `sch_start_day_opt_2`')); + throw (new \Exception( 'Invalid value specified for \'sch_start_day_opt_2\'')); } $pipelineTwo = $aData['SCH_START_DAY_OPT_2']{1}; if ($pipelineTwo == "|") { $aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for `sch_start_day_opt_2`')); + throw (new \Exception( 'Invalid value specified for \'sch_start_day_opt_2\'')); } $dayTwo = $aData['SCH_START_DAY_OPT_2']{2}; if ($dayTwo == "1" || $dayTwo == "2" || $dayTwo == "3" || $dayTwo == "4" || $dayTwo == "5" || $dayTwo == "6" || $dayTwo == "7") { $aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for `sch_start_day_opt_2`')); + throw (new \Exception( 'Invalid value specified for \'sch_start_day_opt_2\'')); } } if ($nStartDay == "") { - throw (new \Exception( '`sch_start_day` can`t be null')); + throw (new \Exception( '\'sch_start_day\' can\'t be null')); } $sMonths = ''; if ($aData['SCH_MONTHS'] == "") { - throw (new \Exception( '`sch_months` can`t be null')); + throw (new \Exception( '\'sch_months\' can\'t be null')); } if (! empty( $aData['SCH_MONTHS'] )) { $aMonths = $aData['SCH_MONTHS']; @@ -747,7 +747,7 @@ class CaseScheduler if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7"|| $row == "8" || $row == "9" || $row == "10"|| $row == "11" || $row == "12") { $aData['SCH_MONTHS'] = $aData['SCH_MONTHS']; } else { - throw (new \Exception( 'Invalid value specified for `sch_months`')); + throw (new \Exception( 'Invalid value specified for \'sch_months\'')); } } } @@ -806,11 +806,11 @@ class CaseScheduler $aData['SCH_START_TIME'] = time(); $aData['SCH_START_DATE'] = $aData['SCH_START_TIME']; if ($aData['SCH_REPEAT_EVERY'] == "") { - throw (new \Exception( '`sch_repeat_every` can`t be null')); + throw (new \Exception( '\'sch_repeat_every\' can\'t be null')); } $patternHour="/^([0-1][0-9]|[2][0-3])[\.]([0-5][0-9])$/"; if (!preg_match($patternHour, $aData['SCH_REPEAT_EVERY'])) { - throw (new \Exception( 'Invalid value specified for `sch_repeat_every`. Expecting time in HH.MM format')); + throw (new \Exception( 'Invalid value specified for \'sch_repeat_every\'. Expecting time in HH.MM format')); } $nextRun = $aData['SCH_REPEAT_EVERY'] * 60 * 60; $aData['SCH_REPEAT_EVERY'] = $aData['SCH_REPEAT_EVERY']; From 257c38e4ab2efce9b44c8bd0c1542de42c99eb00 Mon Sep 17 00:00:00 2001 From: Erik Amaru Ortiz Date: Mon, 17 Mar 2014 11:09:48 -0400 Subject: [PATCH 6/9] updating pm-bootstrap for unit tests env --- workflow/engine/src/Tests/pm-bootstrap.php | 33 +++++++++------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/workflow/engine/src/Tests/pm-bootstrap.php b/workflow/engine/src/Tests/pm-bootstrap.php index f3a8bdca9..88249a291 100644 --- a/workflow/engine/src/Tests/pm-bootstrap.php +++ b/workflow/engine/src/Tests/pm-bootstrap.php @@ -8,6 +8,20 @@ * * @author Erik Amaru Ortiz */ + +require $rootDir . "framework/src/Maveriks/Util/ClassLoader.php"; + +$loader = Maveriks\Util\ClassLoader::getInstance(); +$loader->add($rootDir . 'framework/src/', "Maveriks"); +$loader->add($rootDir . 'workflow/engine/src/', "ProcessMaker"); +$loader->add($rootDir . 'workflow/engine/src/'); + +// add vendors to autoloader +$loader->add($rootDir . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2"); +$loader->addClass("Bootstrap", $rootDir . 'gulliver/system/class.bootstrap.php'); + +$loader->addModelClassPath($rootDir . "workflow/engine/classes/model/"); + $config = parse_ini_file(__DIR__ . DIRECTORY_SEPARATOR . "config.ini"); $workspace = $config['workspace']; @@ -54,27 +68,8 @@ define('PATH_RBAC_MSSQL_DATA', PATH_RBAC_CORE . 'data' . PATH_SEP . 'mssql' . PA define('PATH_CONTROLLERS', PATH_CORE . 'controllers' . PATH_SEP); define('PATH_SERVICES_REST', PATH_CORE . 'services' . PATH_SEP . 'rest' . PATH_SEP); -require_once PATH_GULLIVER . PATH_SEP . 'class.bootstrap.php'; - -spl_autoload_register(array("Bootstrap", "autoloadClass")); - -Bootstrap::registerClass("G", PATH_GULLIVER . "class.g.php"); -Bootstrap::registerClass("System", PATH_HOME . "engine/classes/class.system.php"); - -// define autoloading for others -Bootstrap::registerClass("wsBase", PATH_HOME . "engine/classes/class.wsBase.php"); -Bootstrap::registerClass('Xml_Node', PATH_GULLIVER . "class.xmlDocument.php"); -Bootstrap::registerClass('XmlForm_Field_TextPM', PATH_HOME . "engine/classes/class.XmlForm_Field_TextPM.php"); -Bootstrap::registerClass('XmlForm_Field_SimpleText', PATH_GULLIVER . "class.xmlformExtension.php"); -Bootstrap::registerClass('XmlForm_Field', PATH_GULLIVER . "class.xmlform.php"); - -Bootstrap::LoadThirdParty("smarty/libs", "Smarty.class"); - Bootstrap::registerSystemClasses(); -Bootstrap::registerDir('src', PATH_HOME . 'engine/src/'); -Bootstrap::registerDir('model', PATH_CORE . 'classes' . PATH_SEP . 'model'); - $config = System::getSystemConfiguration(); define('DEBUG_SQL_LOG', $config['debug_sql']); From 7d293ab7652d14b4c4e591d6b84194b919796d97 Mon Sep 17 00:00:00 2001 From: Erik Amaru Ortiz Date: Mon, 17 Mar 2014 11:13:29 -0400 Subject: [PATCH 7/9] updating pm-bootstrap for unit tests env 2 --- workflow/engine/src/Tests/pm-bootstrap.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/workflow/engine/src/Tests/pm-bootstrap.php b/workflow/engine/src/Tests/pm-bootstrap.php index 88249a291..fa47764a4 100644 --- a/workflow/engine/src/Tests/pm-bootstrap.php +++ b/workflow/engine/src/Tests/pm-bootstrap.php @@ -9,6 +9,13 @@ * @author Erik Amaru Ortiz */ +$config = parse_ini_file(__DIR__ . DIRECTORY_SEPARATOR . "config.ini"); + +$workspace = $config['workspace']; +$lang = $config['lang']; +$processMakerHome = $config['pm_home_dir']; +$rootDir = realpath($processMakerHome) . DIRECTORY_SEPARATOR; + require $rootDir . "framework/src/Maveriks/Util/ClassLoader.php"; $loader = Maveriks\Util\ClassLoader::getInstance(); @@ -22,13 +29,6 @@ $loader->addClass("Bootstrap", $rootDir . 'gulliver/system/class.bootstrap.php') $loader->addModelClassPath($rootDir . "workflow/engine/classes/model/"); -$config = parse_ini_file(__DIR__ . DIRECTORY_SEPARATOR . "config.ini"); - -$workspace = $config['workspace']; -$lang = $config['lang']; -$processMakerHome = $config['pm_home_dir']; -$rootDir = realpath($processMakerHome) . DIRECTORY_SEPARATOR; - define('SYS_LANG', $lang); define('PATH_SEP', DIRECTORY_SEPARATOR); From c14b204bf762cae304bc9eb31f15ae25d08a0fce Mon Sep 17 00:00:00 2001 From: Erik Amaru Ortiz Date: Mon, 17 Mar 2014 11:22:45 -0400 Subject: [PATCH 8/9] Refactoring pm-bootstrap for unit tests environment --- workflow/engine/src/Tests/pm-bootstrap.php | 112 +-------------------- 1 file changed, 3 insertions(+), 109 deletions(-) diff --git a/workflow/engine/src/Tests/pm-bootstrap.php b/workflow/engine/src/Tests/pm-bootstrap.php index fa47764a4..86807a5ee 100644 --- a/workflow/engine/src/Tests/pm-bootstrap.php +++ b/workflow/engine/src/Tests/pm-bootstrap.php @@ -29,112 +29,6 @@ $loader->addClass("Bootstrap", $rootDir . 'gulliver/system/class.bootstrap.php') $loader->addModelClassPath($rootDir . "workflow/engine/classes/model/"); -define('SYS_LANG', $lang); -define('PATH_SEP', DIRECTORY_SEPARATOR); - -define('PATH_TRUNK', $rootDir . PATH_SEP); -define('PATH_OUTTRUNK', realpath($rootDir . '/../') . PATH_SEP); -define('PATH_HOME', $rootDir . PATH_SEP . 'workflow' . PATH_SEP); - -define('PATH_HTML', PATH_HOME . 'public_html' . PATH_SEP); -define('PATH_RBAC_HOME', PATH_TRUNK . 'rbac' . PATH_SEP); -define('PATH_GULLIVER_HOME', PATH_TRUNK . 'gulliver' . PATH_SEP); -define('PATH_GULLIVER', PATH_GULLIVER_HOME . 'system' . PATH_SEP); //gulliver system classes -define('PATH_GULLIVER_BIN', PATH_GULLIVER_HOME . 'bin' . PATH_SEP); //gulliver bin classes -define('PATH_TEMPLATE', PATH_GULLIVER_HOME . 'templates' . PATH_SEP); -define('PATH_THIRDPARTY', PATH_GULLIVER_HOME . 'thirdparty' . PATH_SEP); -define('PATH_RBAC', PATH_RBAC_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP); //to enable rbac version 2 -define('PATH_RBAC_CORE', PATH_RBAC_HOME . 'engine' . PATH_SEP); -define('PATH_CORE', PATH_HOME . 'engine' . PATH_SEP); -define('PATH_SKINS', PATH_CORE . 'skins' . PATH_SEP); -define('PATH_SKIN_ENGINE', PATH_CORE . 'skinEngine' . PATH_SEP); -define('PATH_METHODS', PATH_CORE . 'methods' . PATH_SEP); -define('PATH_XMLFORM', PATH_CORE . 'xmlform' . PATH_SEP); -define('PATH_CONFIG', PATH_CORE . 'config' . PATH_SEP); -define('PATH_PLUGINS', PATH_CORE . 'plugins' . PATH_SEP); -define('PATH_HTMLMAIL', PATH_CORE . 'html_templates' . PATH_SEP); -define('PATH_TPL', PATH_CORE . 'templates' . PATH_SEP); -define('PATH_TEST', PATH_CORE . 'test' . PATH_SEP); -define('PATH_FIXTURES', PATH_TEST . 'fixtures' . PATH_SEP); -define('PATH_RTFDOCS', PATH_CORE . 'rtf_templates' . PATH_SEP); -define('PATH_DYNACONT', PATH_CORE . 'content' . PATH_SEP . 'dynaform' . PATH_SEP); -define('SYS_UPLOAD_PATH', PATH_HOME . "public_html/files/" ); -define('PATH_UPLOAD', PATH_HTML . 'files' . PATH_SEP); -define('PATH_WORKFLOW_MYSQL_DATA', PATH_CORE . 'data' . PATH_SEP . 'mysql' . PATH_SEP); -define('PATH_RBAC_MYSQL_DATA', PATH_RBAC_CORE . 'data' . PATH_SEP . 'mysql' . PATH_SEP); -define('FILE_PATHS_INSTALLED', PATH_CORE . 'config' . PATH_SEP . 'paths_installed.php' ); -define('PATH_WORKFLOW_MSSQL_DATA', PATH_CORE . 'data' . PATH_SEP . 'mssql' . PATH_SEP); -define('PATH_RBAC_MSSQL_DATA', PATH_RBAC_CORE . 'data' . PATH_SEP . 'mssql' . PATH_SEP); -define('PATH_CONTROLLERS', PATH_CORE . 'controllers' . PATH_SEP); -define('PATH_SERVICES_REST', PATH_CORE . 'services' . PATH_SEP . 'rest' . PATH_SEP); - -Bootstrap::registerSystemClasses(); - -$config = System::getSystemConfiguration(); - -define('DEBUG_SQL_LOG', $config['debug_sql']); -define('DEBUG_TIME_LOG', $config['debug_time']); -define('DEBUG_CALENDAR_LOG', $config['debug_calendar']); -define('MEMCACHED_ENABLED', $config['memcached']); -define('MEMCACHED_SERVER', $config['memcached_server']); -define('TIME_ZONE', $config['time_zone']); - - -// set include path -set_include_path( - PATH_CORE . PATH_SEPARATOR . - PATH_THIRDPARTY . PATH_SEPARATOR . - PATH_THIRDPARTY . 'pear' . PATH_SEPARATOR . - PATH_RBAC_CORE . PATH_SEPARATOR . - get_include_path() -); - - -/* - * Setting Up Workspace - */ - -// include the server installed configuration -require_once FILE_PATHS_INSTALLED; - -define('SYS_SYS', $workspace); - -// defining system constant when a valid server environment exists -define( 'PATH_LANGUAGECONT', PATH_DATA . "META-INF" . PATH_SEP ); -define( 'PATH_CUSTOM_SKINS', PATH_DATA . 'skins' . PATH_SEP ); -define( 'PATH_TEMPORAL', PATH_C . 'dynEditor/' ); -define( 'PATH_DB', PATH_DATA . 'sites' . PATH_SEP ); - -$workspaceDir = PATH_DB . $workspace; - -// smarty constants -define( 'PATH_SMARTY_C', PATH_C . 'smarty' . PATH_SEP . 'c' ); -define( 'PATH_SMARTY_CACHE', PATH_C . 'smarty' . PATH_SEP . 'cache' ); - - -//***************** PM Paths DATA ************************** -define('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/'); -define('PATH_DOCUMENT', PATH_DATA_SITE . 'files/'); -define('PATH_DATA_MAILTEMPLATES', PATH_DATA_SITE . 'mailTemplates/'); -define('PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/'); -define('PATH_DATA_REPORTS', PATH_DATA_SITE . 'reports/'); -define('PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/'); -define('PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles' . PATH_SEP); -define('PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies' . PATH_SEP); - -if (is_file(PATH_DATA_SITE.PATH_SEP . '.server_info')) { - $SERVER_INFO = file_get_contents(PATH_DATA_SITE.PATH_SEP.'.server_info'); - $SERVER_INFO = unserialize($SERVER_INFO); - - define('SERVER_NAME', $SERVER_INFO ['SERVER_NAME']); - define('SERVER_PORT', $SERVER_INFO ['SERVER_PORT']); -} else { - echo "WARNING! No server info found!"; -} - -// create memcached singleton -Bootstrap::LoadClass( 'memcached' ); -//$memcache = PMmemcached::getSingleton( SYS_SYS ); - -Propel::init(PATH_CONFIG . "databases.php"); - +$app = new Maveriks\WebApplication(); +$app->setRootDir($rootDir); +$app->loadEnvironment($workspace); From 4a12be66c82bede4438e2d184c1ebbf46ef24cf0 Mon Sep 17 00:00:00 2001 From: Erik Amaru Ortiz Date: Mon, 17 Mar 2014 11:54:09 -0400 Subject: [PATCH 9/9] Updating for main processmaker script --- framework/src/Maveriks/WebApplication.php | 8 +- workflow/engine/bin/cli.php | 113 +++++++++++------- .../engine/bin/tasks/cliBrowserCacheFiles.php | 2 +- workflow/engine/bin/tasks/cliHotfix.php | 2 +- workflow/engine/bin/tasks/cliPlugins.php | 4 +- workflow/engine/bin/tasks/cliRake.php | 2 +- workflow/engine/bin/tasks/cliUpgrade.php | 2 +- workflow/engine/bin/tasks/cliWorkspaces.php | 20 ++-- 8 files changed, 90 insertions(+), 63 deletions(-) diff --git a/framework/src/Maveriks/WebApplication.php b/framework/src/Maveriks/WebApplication.php index 47adb07e2..4e07b40db 100644 --- a/framework/src/Maveriks/WebApplication.php +++ b/framework/src/Maveriks/WebApplication.php @@ -232,7 +232,7 @@ class WebApplication ); } - public function loadEnvironment($workspace) + public function loadEnvironment($workspace = "") { $lang = "en"; @@ -326,6 +326,10 @@ class WebApplication define("PATH_TEMPORAL", PATH_C . "dynEditor/"); define("PATH_DB", PATH_DATA . "sites" . PATH_SEP); + if (empty($workspace)) { + return true; + } + define("SYS_SYS", $workspace); if (! file_exists( PATH_DB . SYS_SYS . "/db.php" )) { @@ -367,5 +371,7 @@ class WebApplication //$memcache = PMmemcached::getSingleton( SYS_SYS ); \Propel::init(PATH_CONFIG . "databases.php"); + + return true; } } \ No newline at end of file diff --git a/workflow/engine/bin/cli.php b/workflow/engine/bin/cli.php index e3047d28e..963e9b3d4 100755 --- a/workflow/engine/bin/cli.php +++ b/workflow/engine/bin/cli.php @@ -25,59 +25,80 @@ * @author Alexandre Rosenfeld */ - /* Windows supports both / and \ as path separators, so use the Unix separator - * for maximum compatibility. - */ - define('PATH_SEP', '/'); +// /* Windows supports both / and \ as path separators, so use the Unix separator +// * for maximum compatibility. +// */ +// define('PATH_SEP', '/'); +// +// define('PATH_HOME', WORKFLOW_PATH ); +// define('PATH_TRUNK', PROCESSMAKER_PATH ); +// define('PATH_OUTTRUNK', realpath(PROCESSMAKER_PATH.'/..') ); +// +///* Most definitions (including the G class) is done in paths.php +// * This mostly simulates a sysGeneric.php call. +// */ +//if (file_exists(PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths_installed.php")) { +// require_once(PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths_installed.php"); +//} +// +//require_once (PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths.php"); +// +//require_once (PATH_THIRDPARTY . "pake" . PATH_SEP . "pakeFunction.php"); +//require_once (PATH_THIRDPARTY . "pake" . PATH_SEP . "pakeGetopt.class.php"); +//require_once (PATH_CORE . "config" . PATH_SEP . "environments.php"); +//require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.system.php"); +// +//require_once (PATH_GULLIVER . "class.bootstrap.php"); +// +//spl_autoload_register(array("Bootstrap", "autoloadClass")); +// +//Bootstrap::registerSystemClasses(); +// +//$config = System::getSystemConfiguration(PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "env.ini"); +// +// $e_all = defined('E_DEPRECATED') ? E_ALL & ~E_DEPRECATED : E_ALL; +// $e_all = defined('E_STRICT') ? E_ALL & ~E_STRICT : $e_all; +// $e_all = $e_all & E_WARNING; // show warning +// $e_all = $e_all & ~E_NOTICE; // don't notices +// +// // Do not change any of these settings directly, use env.ini instead +// ini_set('display_errors', $config['debug']); +// ini_set('error_reporting', $e_all); +// ini_set('short_open_tag', 'On'); +// ini_set('default_charset', "UTF-8"); +// ini_set('memory_limit', $config['memory_limit']); +// ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']); +// ini_set('date.timezone', $config['time_zone']); +// +// define ('DEBUG_SQL_LOG', $config['debug_sql']); +// define ('DEBUG_TIME_LOG', $config['debug_time']); +// define ('DEBUG_CALENDAR_LOG', $config['debug_calendar']); +// define ('MEMCACHED_ENABLED', $config['memcached']); +// define ('MEMCACHED_SERVER', $config['memcached_server']); +// define ('TIME_ZONE', $config['time_zone']); - define('PATH_HOME', WORKFLOW_PATH ); - define('PATH_TRUNK', PROCESSMAKER_PATH ); - define('PATH_OUTTRUNK', realpath(PROCESSMAKER_PATH.'/..') ); +$rootDir = PROCESSMAKER_PATH; +require $rootDir . "framework/src/Maveriks/Util/ClassLoader.php"; -/* Most definitions (including the G class) is done in paths.php - * This mostly simulates a sysGeneric.php call. - */ -if (file_exists(PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths_installed.php")) { - require_once(PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths_installed.php"); -} +$loader = Maveriks\Util\ClassLoader::getInstance(); +$loader->add($rootDir . 'framework/src/', "Maveriks"); +$loader->add($rootDir . 'workflow/engine/src/', "ProcessMaker"); +$loader->add($rootDir . 'workflow/engine/src/'); -require_once (PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths.php"); +// add vendors to autoloader +$loader->add($rootDir . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2"); +$loader->addClass("Bootstrap", $rootDir . 'gulliver/system/class.bootstrap.php'); -require_once (PATH_THIRDPARTY . "pake" . PATH_SEP . "pakeFunction.php"); -require_once (PATH_THIRDPARTY . "pake" . PATH_SEP . "pakeGetopt.class.php"); -require_once (PATH_CORE . "config" . PATH_SEP . "environments.php"); -require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.system.php"); +$loader->addModelClassPath($rootDir . "workflow/engine/classes/model/"); -require_once (PATH_GULLIVER . "class.bootstrap.php"); +$app = new Maveriks\WebApplication(); +$app->setRootDir($rootDir); +$app->loadEnvironment(); -spl_autoload_register(array("Bootstrap", "autoloadClass")); +require PATH_THIRDPARTY . "pake" . PATH_SEP . "pakeFunction.php"; +require PATH_THIRDPARTY . "pake" . PATH_SEP . "pakeGetopt.class.php"; -Bootstrap::registerSystemClasses(); - -$config = System::getSystemConfiguration(PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "env.ini"); - - $e_all = defined('E_DEPRECATED') ? E_ALL & ~E_DEPRECATED : E_ALL; - $e_all = defined('E_STRICT') ? E_ALL & ~E_STRICT : $e_all; - $e_all = $e_all & E_WARNING; // show warning - $e_all = $e_all & ~E_NOTICE; // don't notices - - // Do not change any of these settings directly, use env.ini instead - ini_set('display_errors', $config['debug']); - ini_set('error_reporting', $e_all); - ini_set('short_open_tag', 'On'); - ini_set('default_charset', "UTF-8"); - ini_set('memory_limit', $config['memory_limit']); - ini_set('soap.wsdl_cache_enabled', $config['wsdl_cache']); - ini_set('date.timezone', $config['time_zone']); - - define ('DEBUG_SQL_LOG', $config['debug_sql']); - define ('DEBUG_TIME_LOG', $config['debug_time']); - define ('DEBUG_CALENDAR_LOG', $config['debug_calendar']); - define ('MEMCACHED_ENABLED', $config['memcached']); - define ('MEMCACHED_SERVER', $config['memcached_server']); - define ('TIME_ZONE', $config['time_zone']); - - G::LoadClass("cli"); +G::LoadClass("cli"); // trap -V before pake if (in_array('-v', $argv) || in_array('-V', $argv) || in_array('--version', $argv)) diff --git a/workflow/engine/bin/tasks/cliBrowserCacheFiles.php b/workflow/engine/bin/tasks/cliBrowserCacheFiles.php index 5009de68c..c03802a0a 100644 --- a/workflow/engine/bin/tasks/cliBrowserCacheFiles.php +++ b/workflow/engine/bin/tasks/cliBrowserCacheFiles.php @@ -8,7 +8,7 @@ CLI::taskDescription(<<