From 1e5b7fdc8cbc8ff4683d0ac727557d7134bc6e9a Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Mon, 21 Apr 2014 17:03:04 -0400 Subject: [PATCH 01/11] Cambio de nombre a la funcion postProjectWsUserCanStartTask --- workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php | 2 +- .../src/ProcessMaker/Services/Api/Project/ProjectUsers.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php index 964c5cb34..0c1880ca0 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php @@ -209,7 +209,7 @@ class ProjectUser * * @access public */ - public function postProjectWsUserCanStartTask($sProcessUID, $sActivityUID, $oData) + public function projectWsUserCanStartTask($sProcessUID, $sActivityUID, $oData) { try { $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project/ProjectUsers.php b/workflow/engine/src/ProcessMaker/Services/Api/Project/ProjectUsers.php index 8cbccf45c..6d048cdcd 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Project/ProjectUsers.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project/ProjectUsers.php @@ -81,7 +81,7 @@ class ProjectUsers extends Api try { $request_data = (array)($request_data); $user = new \ProcessMaker\BusinessModel\ProjectUser(); - $objectData = $user->postProjectWsUserCanStartTask($prj_uid, $act_uid, $request_data); + $objectData = $user->projectWsUserCanStartTask($prj_uid, $act_uid, $request_data); //Response $response = $objectData; } catch (\Exception $e) { From 35d0a04026a59c3f1fd68a17db21f43858a441e4 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Tue, 22 Apr 2014 10:37:10 -0400 Subject: [PATCH 02/11] Ajustes en validaciones de Cases Output documents --- .../BusinessModel/Cases/OutputDocument.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php index 94d472c7d..2ae7c8a7e 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php @@ -56,10 +56,6 @@ class OutputDocument public function getCasesOutputDocument($applicationUid, $userUid, $applicationDocumentUid) { try { - $oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, 1 ); - if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') { - throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!')); - } $sApplicationUID = $applicationUid; $sUserUID = $userUid; \G::LoadClass('case'); @@ -84,6 +80,10 @@ class OutputDocument $docrow['app_doc_index'] = $row['APP_DOC_INDEX']; $docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK']; if ($docrow['app_doc_uid'] == $applicationDocumentUid) { + $oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $row['DOC_VERSION'] ); + if (is_null( $oAppDocument )) { + throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!')); + } $result = $docrow; } } @@ -269,6 +269,11 @@ class OutputDocument } } $g->sessionVarRestore(); + $oAppDocument = \AppDocumentPeer::retrieveByPK( $aFields['APP_DOC_UID'], $lastDocVersion); + if ($oAppDocument->getAppDocStatus() == 'DELETED') { + $oAppDocument->setAppDocStatus('ACTIVE'); + $oAppDocument->save(); + } $response = $this->getCasesOutputDocument($applicationUid, $userUid, $aFields['APP_DOC_UID']); return $response; } catch (\Exception $e) { From 6f21d60b975c668b01d90a3101934e8748e81955 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Tue, 22 Apr 2014 11:11:03 -0400 Subject: [PATCH 03/11] Fix checkstyle warnings --- .../BusinessModel/CaseScheduler.php | 2 - .../src/ProcessMaker/BusinessModel/Cases.php | 7 ++- .../BusinessModel/Cases/InputDocument.php | 49 +++++++++---------- .../BusinessModel/Cases/OutputDocument.php | 1 + .../BusinessModel/OutputDocument.php | 6 +-- .../BusinessModel/ProcessSupervisor.php | 1 + .../src/ProcessMaker/BusinessModel/User.php | 1 - .../Services/Api/Cases/InputDocument.php | 1 + .../Services/Api/Cases/OutputDocument.php | 2 +- .../Services/Api/Project/OutputDocuments.php | 2 +- 10 files changed, 33 insertions(+), 39 deletions(-) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php b/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php index 8c0abd98f..a6bfff44d 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php @@ -310,7 +310,6 @@ class CaseScheduler $sDaysPerformTask = ''; $sWeeks = ''; $sMonths = ''; - $sMonths = ''; $sStartDay = ''; $nSW = 0; $aData['SCH_DAYS_PERFORM_TASK'] = ''; @@ -609,7 +608,6 @@ class CaseScheduler $sDaysPerformTask = ''; $sWeeks = ''; $sMonths = ''; - $sMonths = ''; $sStartDay = ''; $nSW = 0; $aData['SCH_DAYS_PERFORM_TASK'] = ''; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index d4d3adb5c..2a04fbb03 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -276,7 +276,7 @@ class Cases //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++) { + for ($i = count($columsToInclude); $i <= count($data) - 1; $i++) { if (is_array($data[$columsToIncludeFinal[$i]])) { foreach ($data[$columsToIncludeFinal[$i]] as $delIndex) { $delIndexes[] = $delIndex; @@ -305,8 +305,7 @@ class Cases foreach ($indexes as $index) { $row = $aaappsDBData[$index]; } - if(!isset($row)) - { + if (!isset($row)) { continue; } \G::LoadClass('wsBase'); @@ -501,7 +500,7 @@ class Cases $oDataset->next(); } //Return - if(empty($result)) { + if (empty($result)) { throw (new \Exception('Incorrect or unavailable information about this case: ' .$applicationUid)); } else { return $result; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php index 7cb818936..eeb849e07 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php @@ -187,33 +187,28 @@ class InputDocument $_FILES["form"]["error"] = 0; } if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { - $appDocUid = $case->addInputDocument( - $inputDocumentUid, - $appDocUid, - $docVersion, - $appDocType, - $appDocComment, - '', - $applicationUid, - $delIndex, - $taskUid, - $userUid, - "xmlform", - $_FILES["form"]["name"], - $_FILES["form"]["error"], - $_FILES["form"]["tmp_name"] - ); - } - //Trigger - Execute after - Start - $arrayField["APP_DATA"] = $case->executeTriggers( - $taskUid, - "INPUT_DOCUMENT", - $inputDocumentUid, - "AFTER", - $arrayField["APP_DATA"] - ); - //Trigger - Execute after - End - + $appDocUid = $case->addInputDocument($inputDocumentUid, + $appDocUid, + $docVersion, + $appDocType, + $appDocComment, + '', + $applicationUid, + $delIndex, + $taskUid, + $userUid, + "xmlform", + $_FILES["form"]["name"], + $_FILES["form"]["error"], + $_FILES["form"]["tmp_name"]); + } + //Trigger - Execute after - Start + $arrayField["APP_DATA"] = $case->executeTriggers ($taskUid, + "INPUT_DOCUMENT", + $inputDocumentUid, + "AFTER", + $arrayField["APP_DATA"]); + //Trigger - Execute after - End //Save data $arrayData = array(); $arrayData["APP_NUMBER"] = $arrayField["APP_NUMBER"]; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php index 2ae7c8a7e..8237f74dd 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php @@ -633,3 +633,4 @@ class OutputDocument } } } + diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/OutputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/OutputDocument.php index 6c66ecf53..5c08340a9 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/OutputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/OutputDocument.php @@ -267,7 +267,7 @@ class OutputDocument $aData['out_doc_pdf_security_open_password'] = \G::encrypt( $aData['out_doc_pdf_security_open_password'], $outDocUid ); $aData['out_doc_pdf_security_owner_password'] = \G::encrypt( $aData['out_doc_pdf_security_owner_password'], $outDocUid ); } - $this->updateOutputDocument($sProcessUID, $aData, $outDocUid, 1); + $this->updateOutputDocument($sProcessUID, $aData, 1, $outDocUid); //Return unset($aData["PRO_UID"]); $aData = array_change_key_case($aData, CASE_LOWER); @@ -287,7 +287,7 @@ class OutputDocument * * @access public */ - public function updateOutputDocument($sProcessUID, $aData, $sOutputDocumentUID = '', $sFlag) + public function updateOutputDocument($sProcessUID, $aData, $sFlag, $sOutputDocumentUID = '') { $oConnection = \Propel::getConnection(\OutputDocumentPeer::DATABASE_NAME); $pemission = $aData['out_doc_pdf_security_permissions']; @@ -309,7 +309,7 @@ class OutputDocument if (isset($aData['OUT_DOC_TITLE'])) { $uid = $this->titleExists($sProcessUID, $aData["OUT_DOC_TITLE"]); if ($uid != '') { - if ($uid != $sOutputDocumentUID && $sFlag == 0) { + if ($uid != $sOutputDocumentUID && $sFlag == 0) { throw (new \Exception(\G::LoadTranslation("ID_OUTPUT_NOT_SAVE"))); } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php index 55ec244f9..a7d0bd9ed 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php @@ -1031,3 +1031,4 @@ class ProcessSupervisor $oCriteria->save(); } } + diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/User.php b/workflow/engine/src/ProcessMaker/BusinessModel/User.php index dc5090d87..266fde82d 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/User.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/User.php @@ -207,7 +207,6 @@ class User public function create($arrayData) { try { - global $RBAC; require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php"); $arrayData = array_change_key_case($arrayData, CASE_UPPER); $form = $arrayData; diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/Services/Api/Cases/InputDocument.php index 642cf5a4d..dd54979c2 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Cases/InputDocument.php @@ -81,3 +81,4 @@ class InputDocument extends Api } } } + diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Cases/OutputDocument.php b/workflow/engine/src/ProcessMaker/Services/Api/Cases/OutputDocument.php index 20d2d4fb3..8ad620f2a 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Cases/OutputDocument.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Cases/OutputDocument.php @@ -78,4 +78,4 @@ class OutputDocument extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } -} \ No newline at end of file +} diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project/OutputDocuments.php b/workflow/engine/src/ProcessMaker/Services/Api/Project/OutputDocuments.php index 524130d9a..708fb8718 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Project/OutputDocuments.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project/OutputDocuments.php @@ -86,7 +86,7 @@ class OutputDocuments extends Api try { $request_data = (array)($request_data); $outputDocument = new \ProcessMaker\BusinessModel\OutputDocument(); - $arrayData = $outputDocument->updateOutputDocument($prjUid, $request_data, $outputDocumentUid, 0); + $outputDocument->updateOutputDocument($prjUid, $request_data, 0, $outputDocumentUid); } catch (\Exception $e) { //Response throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); From 53609cf48f2c27d7a96175ace07bbd9d65566421 Mon Sep 17 00:00:00 2001 From: Wendy Nestor Date: Tue, 22 Apr 2014 12:35:45 -0400 Subject: [PATCH 04/11] Modificaciones a los features case actions y cases lists --- .../main_tests_cases_actions.feature | 1 - .../negative_tests_cases_actions.feature | 39 ++++++++++--------- .../main_tests_cases_lists_1_6.feature | 12 +++--- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/features/backend/application_cases/case_actions/main_tests_cases_actions.feature b/features/backend/application_cases/case_actions/main_tests_cases_actions.feature index fcb2d1ff1..bff401527 100644 --- a/features/backend/application_cases/case_actions/main_tests_cases_actions.feature +++ b/features/backend/application_cases/case_actions/main_tests_cases_actions.feature @@ -240,7 +240,6 @@ Scenario Outline: Route a case to the next task in the process Given PUT this data: """ { - "case_uid": "", "del_index": "1" } """ diff --git a/features/backend/application_cases/case_actions/negative_tests_cases_actions.feature b/features/backend/application_cases/case_actions/negative_tests_cases_actions.feature index 0858a1365..4b6c0054e 100644 --- a/features/backend/application_cases/case_actions/negative_tests_cases_actions.feature +++ b/features/backend/application_cases/case_actions/negative_tests_cases_actions.feature @@ -54,7 +54,7 @@ Scenario Outline: Create a new case Impersonate (Negative Test) Scenario Outline: Create a case, derivate and cancel. then try do pause or route - #Create case +#Create case Given POST this data: """ { @@ -67,7 +67,7 @@ Scenario Outline: Create a case, derivate and cancel. then try do pause or route Then the response status code should be 200 And store "app_uid" in session array as variable "app_uid_" - #Send some variables +#Send some variables And PUT this data: """ { @@ -81,7 +81,8 @@ Scenario Outline: Create a case, derivate and cancel. then try do pause or route And the content type is "application/json" And the response charset is "UTF-8" And the type is "object" - #Cancel case + +#Cancel case And PUT this data: """ { @@ -94,7 +95,7 @@ Scenario Outline: Create a case, derivate and cancel. then try do pause or route And the response charset is "UTF-8" And the type is "object" - #Route case: it should not allow +#Route case: it should not allow And PUT this data: """ { @@ -106,7 +107,7 @@ Scenario Outline: Create a case, derivate and cancel. then try do pause or route Then the response status code should be 400 And the response status message should have the following text "" - #Pause case +#Pause case And PUT this data: """ { @@ -117,22 +118,22 @@ Scenario Outline: Create a case, derivate and cancel. then try do pause or route Then the response status code should be 400 And the response status message should have the following text "" - #Delete case - And PUT this data: - """ - { - - } - """ - - And that I want to delete a resource with the key "app_uid" stored in session array as variable "app_uid_" + Examples: + | Description | case_number | pro_uid | tas_uid | error_message_route | error_message_pause | + | Create new case with process "Derivation rules - sequential" | 1 | 99209594750ec27ea338927000421575 | 68707275350ec281ada1c95068712556 | This case delegation is already closed | This case delegation is already closed | + + +#Delete case + + Scenario Outline: Delete a case created previously in this script + Given that I want to delete a resource with the key "app_uid" stored in session array as variable "app_uid_" And I request "cases" - Then the response status code should be 200 And the content type is "application/json" + Then the response status code should be 200 And the response charset is "UTF-8" And the type is "object" - - Examples: - | Description | case_number | pro_uid | tas_uid | error_message_route | error_message_pause | - | Create new case with process "Derivation rules - sequential" | 1 | 99209594750ec27ea338927000421575 | 68707275350ec281ada1c95068712556 | This case delegation is already closed | This case delegation is already closed | \ No newline at end of file + Examples: + + | app_uid_number | + | 1 | \ No newline at end of file diff --git a/features/backend/application_cases/cases_lists_1-6/main_tests_cases_lists_1_6.feature b/features/backend/application_cases/cases_lists_1-6/main_tests_cases_lists_1_6.feature index 9b7278738..9371f9ffd 100644 --- a/features/backend/application_cases/cases_lists_1-6/main_tests_cases_lists_1_6.feature +++ b/features/backend/application_cases/cases_lists_1-6/main_tests_cases_lists_1_6.feature @@ -292,13 +292,13 @@ Scenario Outline: Get paging of list Participated | high number for start | 1000 | 1 | 0 | 200 | | high number for start | 1000 | 0 | 0 | 200 | | empty result | 1 | 0 | 30 | 200 | - | empty string | 1 | 10000 | 30 | 200 | + | empty string | 1 | 10000 | 57 | 200 | | invalid start | b | 25 | 25 | 200 | | invalid limit | 1 | c | 30 | 200 | | start equals zero | 0 | 20 | 20 | 200 | | search 0 | 0 | 0 | 30 | 200 | - | search 0 | 0 | 100 | 30 | 200 | - | negative numbers in start | -10 | 25 | 15 | 200 | + | search 0 | 0 | 100 | 57 | 200 | + | negative numbers in start | -10 | 25 | 25 | 200 | | negative numbers in limit | 1 | -25 | 25 | 200 | | real numbers | 0.0 | 1.0 | 1 | 200 | | real numbers in start | 0.0 | 12 | 12 | 200 | @@ -610,13 +610,13 @@ Scenario Outline: Get paging of list Advanced Search | high number for start | 1000 | 1 | 0 | 200 | | high number for start | 1000 | 0 | 0 | 200 | | empty result | 1 | 0 | 30 | 200 | - | empty string | 1 | 10000 | 30 | 200 | + | empty string | 1 | 10000 | 57 | 200 | | invalid start | b | 25 | 25 | 200 | | invalid limit | 1 | c | 30 | 200 | | start equals zero | 0 | 20 | 20 | 200 | | search 0 | 0 | 0 | 30 | 200 | - | search 0 | 0 | 100 | 30 | 200 | - | negative numbers in start | -10 | 25 | 15 | 200 | + | search 0 | 0 | 100 | 57 | 200 | + | negative numbers in start | -10 | 25 | 25 | 200 | | negative numbers in limit | 1 | -25 | 25 | 200 | | real numbers | 0.0 | 1.0 | 1 | 200 | | real numbers in start | 0.0 | 12 | 12 | 200 | From 6feb09522777ed05fcc2ea915026b1520f2fef92 Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Tue, 22 Apr 2014 13:11:32 -0400 Subject: [PATCH 05/11] ProcessMaker-BE "Web Entry, adapt for save data in database (endpoints)" - Se han implementado los siguientes Endpoints: GET /api/1.0/{workspace}/project/{prj_uid}/web-entries GET /api/1.0/{workspace}/project/{prj_uid}/web-entry/{we_uid} POST /api/1.0/{workspace}/project/{prj_uid}/web-entry PUT /api/1.0/{workspace}/project/{prj_uid}/web-entry/{we_uid} DELETE /api/1.0/{workspace}/project/{prj_uid}/web-entry/{we_uid} --- workflow/engine/classes/model/WebEntry.php | 6 + .../engine/classes/model/WebEntryPeer.php | 6 + .../classes/model/map/WebEntryMapBuilder.php | 94 ++ .../engine/classes/model/om/BaseWebEntry.php | 1196 +++++++++++++++++ .../classes/model/om/BaseWebEntryPeer.php | 622 +++++++++ workflow/engine/config/schema.xml | 31 +- workflow/engine/data/mssql/schema.sql | 48 + workflow/engine/data/mysql/schema.sql | 26 + workflow/engine/data/oracle/schema.sql | 27 + .../ProcessMaker/BusinessModel/Calendar.php | 4 +- .../ProcessMaker/BusinessModel/Process.php | 33 - .../ProcessMaker/BusinessModel/WebEntry.php | 827 ++++++++---- .../src/ProcessMaker/Services/Api/Project.php | 20 - .../Services/Api/Project/WebEntry.php | 83 +- 14 files changed, 2678 insertions(+), 345 deletions(-) create mode 100644 workflow/engine/classes/model/WebEntry.php create mode 100644 workflow/engine/classes/model/WebEntryPeer.php create mode 100644 workflow/engine/classes/model/map/WebEntryMapBuilder.php create mode 100644 workflow/engine/classes/model/om/BaseWebEntry.php create mode 100644 workflow/engine/classes/model/om/BaseWebEntryPeer.php diff --git a/workflow/engine/classes/model/WebEntry.php b/workflow/engine/classes/model/WebEntry.php new file mode 100644 index 000000000..ed31eba88 --- /dev/null +++ b/workflow/engine/classes/model/WebEntry.php @@ -0,0 +1,6 @@ +dbMap !== null); + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public function getDatabaseMap() + { + return $this->dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @return void + * @throws PropelException + */ + public function doBuild() + { + $this->dbMap = Propel::getDatabaseMap('workflow'); + + $tMap = $this->dbMap->addTable('WEB_ENTRY'); + $tMap->setPhpName('WebEntry'); + + $tMap->setUseIdGenerator(false); + + $tMap->addPrimaryKey('WE_UID', 'WeUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('PRO_UID', 'ProUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('TAS_UID', 'TasUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('DYN_UID', 'DynUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('USR_UID', 'UsrUid', 'string', CreoleTypes::VARCHAR, false, 32); + + $tMap->addColumn('WE_METHOD', 'WeMethod', 'string', CreoleTypes::VARCHAR, false, 4); + + $tMap->addColumn('WE_INPUT_DOCUMENT_ACCESS', 'WeInputDocumentAccess', 'int', CreoleTypes::INTEGER, false, null); + + $tMap->addColumn('WE_DATA', 'WeData', 'string', CreoleTypes::LONGVARCHAR, false, null); + + $tMap->addColumn('WE_CREATE_USR_UID', 'WeCreateUsrUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('WE_UPDATE_USR_UID', 'WeUpdateUsrUid', 'string', CreoleTypes::VARCHAR, false, 32); + + $tMap->addColumn('WE_CREATE_DATE', 'WeCreateDate', 'int', CreoleTypes::TIMESTAMP, true, null); + + $tMap->addColumn('WE_UPDATE_DATE', 'WeUpdateDate', 'int', CreoleTypes::TIMESTAMP, false, null); + + } // doBuild() + +} // WebEntryMapBuilder diff --git a/workflow/engine/classes/model/om/BaseWebEntry.php b/workflow/engine/classes/model/om/BaseWebEntry.php new file mode 100644 index 000000000..751978577 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseWebEntry.php @@ -0,0 +1,1196 @@ +we_uid; + } + + /** + * Get the [pro_uid] column value. + * + * @return string + */ + public function getProUid() + { + + return $this->pro_uid; + } + + /** + * Get the [tas_uid] column value. + * + * @return string + */ + public function getTasUid() + { + + return $this->tas_uid; + } + + /** + * Get the [dyn_uid] column value. + * + * @return string + */ + public function getDynUid() + { + + return $this->dyn_uid; + } + + /** + * Get the [usr_uid] column value. + * + * @return string + */ + public function getUsrUid() + { + + return $this->usr_uid; + } + + /** + * Get the [we_method] column value. + * + * @return string + */ + public function getWeMethod() + { + + return $this->we_method; + } + + /** + * Get the [we_input_document_access] column value. + * + * @return int + */ + public function getWeInputDocumentAccess() + { + + return $this->we_input_document_access; + } + + /** + * Get the [we_data] column value. + * + * @return string + */ + public function getWeData() + { + + return $this->we_data; + } + + /** + * Get the [we_create_usr_uid] column value. + * + * @return string + */ + public function getWeCreateUsrUid() + { + + return $this->we_create_usr_uid; + } + + /** + * Get the [we_update_usr_uid] column value. + * + * @return string + */ + public function getWeUpdateUsrUid() + { + + return $this->we_update_usr_uid; + } + + /** + * Get the [optionally formatted] [we_create_date] column value. + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the integer unix timestamp will be returned. + * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). + * @throws PropelException - if unable to convert the date/time to timestamp. + */ + public function getWeCreateDate($format = 'Y-m-d H:i:s') + { + + if ($this->we_create_date === null || $this->we_create_date === '') { + return null; + } elseif (!is_int($this->we_create_date)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->we_create_date); + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse value of [we_create_date] as date/time value: " . + var_export($this->we_create_date, true)); + } + } else { + $ts = $this->we_create_date; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Get the [optionally formatted] [we_update_date] column value. + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the integer unix timestamp will be returned. + * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). + * @throws PropelException - if unable to convert the date/time to timestamp. + */ + public function getWeUpdateDate($format = 'Y-m-d H:i:s') + { + + if ($this->we_update_date === null || $this->we_update_date === '') { + return null; + } elseif (!is_int($this->we_update_date)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->we_update_date); + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse value of [we_update_date] as date/time value: " . + var_export($this->we_update_date, true)); + } + } else { + $ts = $this->we_update_date; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Set the value of [we_uid] column. + * + * @param string $v new value + * @return void + */ + public function setWeUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->we_uid !== $v) { + $this->we_uid = $v; + $this->modifiedColumns[] = WebEntryPeer::WE_UID; + } + + } // setWeUid() + + /** + * Set the value of [pro_uid] column. + * + * @param string $v new value + * @return void + */ + public function setProUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->pro_uid !== $v) { + $this->pro_uid = $v; + $this->modifiedColumns[] = WebEntryPeer::PRO_UID; + } + + } // setProUid() + + /** + * Set the value of [tas_uid] column. + * + * @param string $v new value + * @return void + */ + public function setTasUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->tas_uid !== $v) { + $this->tas_uid = $v; + $this->modifiedColumns[] = WebEntryPeer::TAS_UID; + } + + } // setTasUid() + + /** + * Set the value of [dyn_uid] column. + * + * @param string $v new value + * @return void + */ + public function setDynUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->dyn_uid !== $v) { + $this->dyn_uid = $v; + $this->modifiedColumns[] = WebEntryPeer::DYN_UID; + } + + } // setDynUid() + + /** + * Set the value of [usr_uid] column. + * + * @param string $v new value + * @return void + */ + public function setUsrUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->usr_uid !== $v || $v === '') { + $this->usr_uid = $v; + $this->modifiedColumns[] = WebEntryPeer::USR_UID; + } + + } // setUsrUid() + + /** + * Set the value of [we_method] column. + * + * @param string $v new value + * @return void + */ + public function setWeMethod($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->we_method !== $v || $v === 'HTML') { + $this->we_method = $v; + $this->modifiedColumns[] = WebEntryPeer::WE_METHOD; + } + + } // setWeMethod() + + /** + * Set the value of [we_input_document_access] column. + * + * @param int $v new value + * @return void + */ + public function setWeInputDocumentAccess($v) + { + + // Since the native PHP type for this column is integer, + // we will cast the input value to an int (if it is not). + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->we_input_document_access !== $v || $v === 0) { + $this->we_input_document_access = $v; + $this->modifiedColumns[] = WebEntryPeer::WE_INPUT_DOCUMENT_ACCESS; + } + + } // setWeInputDocumentAccess() + + /** + * Set the value of [we_data] column. + * + * @param string $v new value + * @return void + */ + public function setWeData($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->we_data !== $v || $v === '') { + $this->we_data = $v; + $this->modifiedColumns[] = WebEntryPeer::WE_DATA; + } + + } // setWeData() + + /** + * Set the value of [we_create_usr_uid] column. + * + * @param string $v new value + * @return void + */ + public function setWeCreateUsrUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->we_create_usr_uid !== $v || $v === '') { + $this->we_create_usr_uid = $v; + $this->modifiedColumns[] = WebEntryPeer::WE_CREATE_USR_UID; + } + + } // setWeCreateUsrUid() + + /** + * Set the value of [we_update_usr_uid] column. + * + * @param string $v new value + * @return void + */ + public function setWeUpdateUsrUid($v) + { + + // Since the native PHP type for this column is string, + // we will cast the input to a string (if it is not). + if ($v !== null && !is_string($v)) { + $v = (string) $v; + } + + if ($this->we_update_usr_uid !== $v || $v === '') { + $this->we_update_usr_uid = $v; + $this->modifiedColumns[] = WebEntryPeer::WE_UPDATE_USR_UID; + } + + } // setWeUpdateUsrUid() + + /** + * Set the value of [we_create_date] column. + * + * @param int $v new value + * @return void + */ + public function setWeCreateDate($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse date/time value for [we_create_date] from input: " . + var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->we_create_date !== $ts) { + $this->we_create_date = $ts; + $this->modifiedColumns[] = WebEntryPeer::WE_CREATE_DATE; + } + + } // setWeCreateDate() + + /** + * Set the value of [we_update_date] column. + * + * @param int $v new value + * @return void + */ + public function setWeUpdateDate($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse date/time value for [we_update_date] from input: " . + var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->we_update_date !== $ts) { + $this->we_update_date = $ts; + $this->modifiedColumns[] = WebEntryPeer::WE_UPDATE_DATE; + } + + } // setWeUpdateDate() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (1-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. + * @param int $startcol 1-based offset column which indicates which restultset column to start with. + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate(ResultSet $rs, $startcol = 1) + { + try { + + $this->we_uid = $rs->getString($startcol + 0); + + $this->pro_uid = $rs->getString($startcol + 1); + + $this->tas_uid = $rs->getString($startcol + 2); + + $this->dyn_uid = $rs->getString($startcol + 3); + + $this->usr_uid = $rs->getString($startcol + 4); + + $this->we_method = $rs->getString($startcol + 5); + + $this->we_input_document_access = $rs->getInt($startcol + 6); + + $this->we_data = $rs->getString($startcol + 7); + + $this->we_create_usr_uid = $rs->getString($startcol + 8); + + $this->we_update_usr_uid = $rs->getString($startcol + 9); + + $this->we_create_date = $rs->getTimestamp($startcol + 10, null); + + $this->we_update_date = $rs->getTimestamp($startcol + 11, null); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 12; // 12 = WebEntryPeer::NUM_COLUMNS - WebEntryPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating WebEntry object", $e); + } + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param Connection $con + * @return void + * @throws PropelException + * @see BaseObject::setDeleted() + * @see BaseObject::isDeleted() + */ + public function delete($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(WebEntryPeer::DATABASE_NAME); + } + + try { + $con->begin(); + WebEntryPeer::doDelete($this, $con); + $this->setDeleted(true); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * wraps the doSave() worker method in a transaction. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update + * @throws PropelException + * @see doSave() + */ + public function save($con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getConnection(WebEntryPeer::DATABASE_NAME); + } + + try { + $con->begin(); + $affectedRows = $this->doSave($con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Stores the object in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param Connection $con + * @return int The number of rows affected by this insert/update and any referring + * @throws PropelException + * @see save() + */ + protected function doSave($con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + + // If this object has been modified, then save it to the database. + if ($this->isModified()) { + if ($this->isNew()) { + $pk = WebEntryPeer::doInsert($this, $con); + $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which + // should always be true here (even though technically + // BasePeer::doInsert() can insert multiple rows). + + $this->setNew(false); + } else { + $affectedRows += WebEntryPeer::doUpdate($this, $con); + } + $this->resetModified(); // [HL] After being saved an object is no longer 'modified' + } + + $this->alreadyInSave = false; + } + return $affectedRows; + } // doSave() + + /** + * Array of ValidationFailed objects. + * @var array ValidationFailed[] + */ + protected $validationFailures = array(); + + /** + * Gets any ValidationFailed objects that resulted from last call to validate(). + * + * + * @return array ValidationFailed[] + * @see validate() + */ + public function getValidationFailures() + { + return $this->validationFailures; + } + + /** + * Validates the objects modified field values and all objects related to this table. + * + * If $columns is either a column name or an array of column names + * only those columns are validated. + * + * @param mixed $columns Column name or an array of column names. + * @return boolean Whether all columns pass validation. + * @see doValidate() + * @see getValidationFailures() + */ + public function validate($columns = null) + { + $res = $this->doValidate($columns); + if ($res === true) { + $this->validationFailures = array(); + return true; + } else { + $this->validationFailures = $res; + return false; + } + } + + /** + * This function performs the validation work for complex object models. + * + * In addition to checking the current object, all related objects will + * also be validated. If all pass then true is returned; otherwise + * an aggreagated array of ValidationFailed objects will be returned. + * + * @param array $columns Array of column names to validate. + * @return mixed true if all validations pass; + array of ValidationFailed objects otherwise. + */ + protected function doValidate($columns = null) + { + if (!$this->alreadyInValidation) { + $this->alreadyInValidation = true; + $retval = null; + + $failureMap = array(); + + + if (($retval = WebEntryPeer::doValidate($this, $columns)) !== true) { + $failureMap = array_merge($failureMap, $retval); + } + + + + $this->alreadyInValidation = false; + } + + return (!empty($failureMap) ? $failureMap : true); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return mixed Value of field. + */ + public function getByName($name, $type = BasePeer::TYPE_PHPNAME) + { + $pos = WebEntryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->getByPosition($pos); + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch($pos) { + case 0: + return $this->getWeUid(); + break; + case 1: + return $this->getProUid(); + break; + case 2: + return $this->getTasUid(); + break; + case 3: + return $this->getDynUid(); + break; + case 4: + return $this->getUsrUid(); + break; + case 5: + return $this->getWeMethod(); + break; + case 6: + return $this->getWeInputDocumentAccess(); + break; + case 7: + return $this->getWeData(); + break; + case 8: + return $this->getWeCreateUsrUid(); + break; + case 9: + return $this->getWeUpdateUsrUid(); + break; + case 10: + return $this->getWeCreateDate(); + break; + case 11: + return $this->getWeUpdateDate(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = BasePeer::TYPE_PHPNAME) + { + $keys = WebEntryPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getWeUid(), + $keys[1] => $this->getProUid(), + $keys[2] => $this->getTasUid(), + $keys[3] => $this->getDynUid(), + $keys[4] => $this->getUsrUid(), + $keys[5] => $this->getWeMethod(), + $keys[6] => $this->getWeInputDocumentAccess(), + $keys[7] => $this->getWeData(), + $keys[8] => $this->getWeCreateUsrUid(), + $keys[9] => $this->getWeUpdateUsrUid(), + $keys[10] => $this->getWeCreateDate(), + $keys[11] => $this->getWeUpdateDate(), + ); + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name peer name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return void + */ + public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) + { + $pos = WebEntryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch($pos) { + case 0: + $this->setWeUid($value); + break; + case 1: + $this->setProUid($value); + break; + case 2: + $this->setTasUid($value); + break; + case 3: + $this->setDynUid($value); + break; + case 4: + $this->setUsrUid($value); + break; + case 5: + $this->setWeMethod($value); + break; + case 6: + $this->setWeInputDocumentAccess($value); + break; + case 7: + $this->setWeData($value); + break; + case 8: + $this->setWeCreateUsrUid($value); + break; + case 9: + $this->setWeUpdateUsrUid($value); + break; + case 10: + $this->setWeCreateDate($value); + break; + case 11: + $this->setWeUpdateDate($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, + * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) + { + $keys = WebEntryPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) { + $this->setWeUid($arr[$keys[0]]); + } + + if (array_key_exists($keys[1], $arr)) { + $this->setProUid($arr[$keys[1]]); + } + + if (array_key_exists($keys[2], $arr)) { + $this->setTasUid($arr[$keys[2]]); + } + + if (array_key_exists($keys[3], $arr)) { + $this->setDynUid($arr[$keys[3]]); + } + + if (array_key_exists($keys[4], $arr)) { + $this->setUsrUid($arr[$keys[4]]); + } + + if (array_key_exists($keys[5], $arr)) { + $this->setWeMethod($arr[$keys[5]]); + } + + if (array_key_exists($keys[6], $arr)) { + $this->setWeInputDocumentAccess($arr[$keys[6]]); + } + + if (array_key_exists($keys[7], $arr)) { + $this->setWeData($arr[$keys[7]]); + } + + if (array_key_exists($keys[8], $arr)) { + $this->setWeCreateUsrUid($arr[$keys[8]]); + } + + if (array_key_exists($keys[9], $arr)) { + $this->setWeUpdateUsrUid($arr[$keys[9]]); + } + + if (array_key_exists($keys[10], $arr)) { + $this->setWeCreateDate($arr[$keys[10]]); + } + + if (array_key_exists($keys[11], $arr)) { + $this->setWeUpdateDate($arr[$keys[11]]); + } + + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(WebEntryPeer::DATABASE_NAME); + + if ($this->isColumnModified(WebEntryPeer::WE_UID)) { + $criteria->add(WebEntryPeer::WE_UID, $this->we_uid); + } + + if ($this->isColumnModified(WebEntryPeer::PRO_UID)) { + $criteria->add(WebEntryPeer::PRO_UID, $this->pro_uid); + } + + if ($this->isColumnModified(WebEntryPeer::TAS_UID)) { + $criteria->add(WebEntryPeer::TAS_UID, $this->tas_uid); + } + + if ($this->isColumnModified(WebEntryPeer::DYN_UID)) { + $criteria->add(WebEntryPeer::DYN_UID, $this->dyn_uid); + } + + if ($this->isColumnModified(WebEntryPeer::USR_UID)) { + $criteria->add(WebEntryPeer::USR_UID, $this->usr_uid); + } + + if ($this->isColumnModified(WebEntryPeer::WE_METHOD)) { + $criteria->add(WebEntryPeer::WE_METHOD, $this->we_method); + } + + if ($this->isColumnModified(WebEntryPeer::WE_INPUT_DOCUMENT_ACCESS)) { + $criteria->add(WebEntryPeer::WE_INPUT_DOCUMENT_ACCESS, $this->we_input_document_access); + } + + if ($this->isColumnModified(WebEntryPeer::WE_DATA)) { + $criteria->add(WebEntryPeer::WE_DATA, $this->we_data); + } + + if ($this->isColumnModified(WebEntryPeer::WE_CREATE_USR_UID)) { + $criteria->add(WebEntryPeer::WE_CREATE_USR_UID, $this->we_create_usr_uid); + } + + if ($this->isColumnModified(WebEntryPeer::WE_UPDATE_USR_UID)) { + $criteria->add(WebEntryPeer::WE_UPDATE_USR_UID, $this->we_update_usr_uid); + } + + if ($this->isColumnModified(WebEntryPeer::WE_CREATE_DATE)) { + $criteria->add(WebEntryPeer::WE_CREATE_DATE, $this->we_create_date); + } + + if ($this->isColumnModified(WebEntryPeer::WE_UPDATE_DATE)) { + $criteria->add(WebEntryPeer::WE_UPDATE_DATE, $this->we_update_date); + } + + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(WebEntryPeer::DATABASE_NAME); + + $criteria->add(WebEntryPeer::WE_UID, $this->we_uid); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getWeUid(); + } + + /** + * Generic method to set the primary key (we_uid column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setWeUid($key); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of WebEntry (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false) + { + + $copyObj->setProUid($this->pro_uid); + + $copyObj->setTasUid($this->tas_uid); + + $copyObj->setDynUid($this->dyn_uid); + + $copyObj->setUsrUid($this->usr_uid); + + $copyObj->setWeMethod($this->we_method); + + $copyObj->setWeInputDocumentAccess($this->we_input_document_access); + + $copyObj->setWeData($this->we_data); + + $copyObj->setWeCreateUsrUid($this->we_create_usr_uid); + + $copyObj->setWeUpdateUsrUid($this->we_update_usr_uid); + + $copyObj->setWeCreateDate($this->we_create_date); + + $copyObj->setWeUpdateDate($this->we_update_date); + + + $copyObj->setNew(true); + + $copyObj->setWeUid(NULL); // this is a pkey column, so set to default value + + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return WebEntry Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + return $copyObj; + } + + /** + * Returns a peer instance associated with this om. + * + * Since Peer classes are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + * + * @return WebEntryPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new WebEntryPeer(); + } + return self::$peer; + } +} + diff --git a/workflow/engine/classes/model/om/BaseWebEntryPeer.php b/workflow/engine/classes/model/om/BaseWebEntryPeer.php new file mode 100644 index 000000000..882af8dc7 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseWebEntryPeer.php @@ -0,0 +1,622 @@ + array ('WeUid', 'ProUid', 'TasUid', 'DynUid', 'UsrUid', 'WeMethod', 'WeInputDocumentAccess', 'WeData', 'WeCreateUsrUid', 'WeUpdateUsrUid', 'WeCreateDate', 'WeUpdateDate', ), + BasePeer::TYPE_COLNAME => array (WebEntryPeer::WE_UID, WebEntryPeer::PRO_UID, WebEntryPeer::TAS_UID, WebEntryPeer::DYN_UID, WebEntryPeer::USR_UID, WebEntryPeer::WE_METHOD, WebEntryPeer::WE_INPUT_DOCUMENT_ACCESS, WebEntryPeer::WE_DATA, WebEntryPeer::WE_CREATE_USR_UID, WebEntryPeer::WE_UPDATE_USR_UID, WebEntryPeer::WE_CREATE_DATE, WebEntryPeer::WE_UPDATE_DATE, ), + BasePeer::TYPE_FIELDNAME => array ('WE_UID', 'PRO_UID', 'TAS_UID', 'DYN_UID', 'USR_UID', 'WE_METHOD', 'WE_INPUT_DOCUMENT_ACCESS', 'WE_DATA', 'WE_CREATE_USR_UID', 'WE_UPDATE_USR_UID', 'WE_CREATE_DATE', 'WE_UPDATE_DATE', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 + */ + private static $fieldKeys = array ( + BasePeer::TYPE_PHPNAME => array ('WeUid' => 0, 'ProUid' => 1, 'TasUid' => 2, 'DynUid' => 3, 'UsrUid' => 4, 'WeMethod' => 5, 'WeInputDocumentAccess' => 6, 'WeData' => 7, 'WeCreateUsrUid' => 8, 'WeUpdateUsrUid' => 9, 'WeCreateDate' => 10, 'WeUpdateDate' => 11, ), + BasePeer::TYPE_COLNAME => array (WebEntryPeer::WE_UID => 0, WebEntryPeer::PRO_UID => 1, WebEntryPeer::TAS_UID => 2, WebEntryPeer::DYN_UID => 3, WebEntryPeer::USR_UID => 4, WebEntryPeer::WE_METHOD => 5, WebEntryPeer::WE_INPUT_DOCUMENT_ACCESS => 6, WebEntryPeer::WE_DATA => 7, WebEntryPeer::WE_CREATE_USR_UID => 8, WebEntryPeer::WE_UPDATE_USR_UID => 9, WebEntryPeer::WE_CREATE_DATE => 10, WebEntryPeer::WE_UPDATE_DATE => 11, ), + BasePeer::TYPE_FIELDNAME => array ('WE_UID' => 0, 'PRO_UID' => 1, 'TAS_UID' => 2, 'DYN_UID' => 3, 'USR_UID' => 4, 'WE_METHOD' => 5, 'WE_INPUT_DOCUMENT_ACCESS' => 6, 'WE_DATA' => 7, 'WE_CREATE_USR_UID' => 8, 'WE_UPDATE_USR_UID' => 9, 'WE_CREATE_DATE' => 10, 'WE_UPDATE_DATE' => 11, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) + ); + + /** + * @return MapBuilder the map builder for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getMapBuilder() + { + include_once 'classes/model/map/WebEntryMapBuilder.php'; + return BasePeer::getMapBuilder('classes.model.map.WebEntryMapBuilder'); + } + /** + * Gets a map (hash) of PHP names to DB column names. + * + * @return array The PHP to DB name map for this peer + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this. + */ + public static function getPhpNameMap() + { + if (self::$phpNameMap === null) { + $map = WebEntryPeer::getTableMap(); + $columns = $map->getColumns(); + $nameMap = array(); + foreach ($columns as $column) { + $nameMap[$column->getPhpName()] = $column->getColumnName(); + } + self::$phpNameMap = $nameMap; + } + return self::$phpNameMap; + } + /** + * Translates a fieldname to another type + * + * @param string $name field name + * @param string $fromType One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @param string $toType One of the class type constants + * @return string translated name of the field. + */ + static public function translateFieldName($name, $fromType, $toType) + { + $toNames = self::getFieldNames($toType); + $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null; + if ($key === null) { + throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true)); + } + return $toNames[$key]; + } + + /** + * Returns an array of of field names. + * + * @param string $type The type of fieldnames to return: + * One of the class type constants TYPE_PHPNAME, + * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM + * @return array A list of field names + */ + + static public function getFieldNames($type = BasePeer::TYPE_PHPNAME) + { + if (!array_key_exists($type, self::$fieldNames)) { + throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.'); + } + return self::$fieldNames[$type]; + } + + /** + * Convenience method which changes table.column to alias.column. + * + * Using this method you can maintain SQL abstraction while using column aliases. + * + * $c->addAlias("alias1", TablePeer::TABLE_NAME); + * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); + * + * @param string $alias The alias for the current table. + * @param string $column The column name for current table. (i.e. WebEntryPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(WebEntryPeer::TABLE_NAME.'.', $alias.'.', $column); + } + + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param criteria object containing the columns to add. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria) + { + + $criteria->addSelectColumn(WebEntryPeer::WE_UID); + + $criteria->addSelectColumn(WebEntryPeer::PRO_UID); + + $criteria->addSelectColumn(WebEntryPeer::TAS_UID); + + $criteria->addSelectColumn(WebEntryPeer::DYN_UID); + + $criteria->addSelectColumn(WebEntryPeer::USR_UID); + + $criteria->addSelectColumn(WebEntryPeer::WE_METHOD); + + $criteria->addSelectColumn(WebEntryPeer::WE_INPUT_DOCUMENT_ACCESS); + + $criteria->addSelectColumn(WebEntryPeer::WE_DATA); + + $criteria->addSelectColumn(WebEntryPeer::WE_CREATE_USR_UID); + + $criteria->addSelectColumn(WebEntryPeer::WE_UPDATE_USR_UID); + + $criteria->addSelectColumn(WebEntryPeer::WE_CREATE_DATE); + + $criteria->addSelectColumn(WebEntryPeer::WE_UPDATE_DATE); + + } + + const COUNT = 'COUNT(WEB_ENTRY.WE_UID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT WEB_ENTRY.WE_UID)'; + + /** + * Returns the number of rows matching criteria. + * + * @param Criteria $criteria + * @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria). + * @param Connection $con + * @return int Number of matching rows. + */ + public static function doCount(Criteria $criteria, $distinct = false, $con = null) + { + // we're going to modify criteria, so copy it first + $criteria = clone $criteria; + + // clear out anything that might confuse the ORDER BY clause + $criteria->clearSelectColumns()->clearOrderByColumns(); + if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { + $criteria->addSelectColumn(WebEntryPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(WebEntryPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach ($criteria->getGroupByColumns() as $column) { + $criteria->addSelectColumn($column); + } + + $rs = WebEntryPeer::doSelectRS($criteria, $con); + if ($rs->next()) { + return $rs->getInt(1); + } else { + // no rows returned; we infer that means 0 matches. + return 0; + } + } + /** + * Method to select one object from the DB. + * + * @param Criteria $criteria object used to create the SELECT statement. + * @param Connection $con + * @return WebEntry + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelectOne(Criteria $criteria, $con = null) + { + $critcopy = clone $criteria; + $critcopy->setLimit(1); + $objects = WebEntryPeer::doSelect($critcopy, $con); + if ($objects) { + return $objects[0]; + } + return null; + } + /** + * Method to do selects. + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con + * @return array Array of selected Objects + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doSelect(Criteria $criteria, $con = null) + { + return WebEntryPeer::populateObjects(WebEntryPeer::doSelectRS($criteria, $con)); + } + /** + * Prepares the Criteria object and uses the parent doSelect() + * method to get a ResultSet. + * + * Use this method directly if you want to just get the resultset + * (instead of an array of objects). + * + * @param Criteria $criteria The Criteria object used to build the SELECT statement. + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return ResultSet The resultset object with numerically-indexed fields. + * @see BasePeer::doSelect() + */ + public static function doSelectRS(Criteria $criteria, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if (!$criteria->getSelectColumns()) { + $criteria = clone $criteria; + WebEntryPeer::addSelectColumns($criteria); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + // BasePeer returns a Creole ResultSet, set to return + // rows indexed numerically. + return BasePeer::doSelect($criteria, $con); + } + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(ResultSet $rs) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = WebEntryPeer::getOMClass(); + $cls = Propel::import($cls); + // populate the object(s) + while ($rs->next()) { + + $obj = new $cls(); + $obj->hydrate($rs); + $results[] = $obj; + + } + return $results; + } + /** + * Returns the TableMap related to this peer. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); + } + + /** + * The class that the Peer will make instances of. + * + * This uses a dot-path notation which is tranalted into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @return string path.to.ClassName + */ + public static function getOMClass() + { + return WebEntryPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a WebEntry or Criteria object. + * + * @param mixed $values Criteria or WebEntry object containing data that is used to create the INSERT statement. + * @param Connection $con the connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } else { + $criteria = $values->buildCriteria(); // build Criteria from WebEntry object + } + + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->begin(); + $pk = BasePeer::doInsert($criteria, $con); + $con->commit(); + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + + return $pk; + } + + /** + * Method perform an UPDATE on the database, given a WebEntry or Criteria object. + * + * @param mixed $values Criteria or WebEntry object containing data create the UPDATE statement. + * @param Connection $con The connection to use (specify Connection exert more control over transactions). + * @return int The number of affected rows (if supported by underlying database driver). + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doUpdate($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $selectCriteria = new Criteria(self::DATABASE_NAME); + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + + $comparison = $criteria->getComparison(WebEntryPeer::WE_UID); + $selectCriteria->add(WebEntryPeer::WE_UID, $criteria->remove(WebEntryPeer::WE_UID), $comparison); + + } else { + $criteria = $values->buildCriteria(); // gets full criteria + $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) + } + + // set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + return BasePeer::doUpdate($selectCriteria, $criteria, $con); + } + + /** + * Method to DELETE all rows from the WEB_ENTRY table. + * + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll($con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + $affectedRows += BasePeer::doDeleteAll(WebEntryPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a WebEntry or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or WebEntry object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param Connection $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + * This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(WebEntryPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof WebEntry) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(WebEntryPeer::WE_UID, (array) $values, Criteria::IN); + } + + // Set the correct dbName + $criteria->setDbName(self::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->begin(); + + $affectedRows += BasePeer::doDelete($criteria, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Validates all modified columns of given WebEntry object. + * If parameter $columns is either a single column name or an array of column names + * than only those columns are validated. + * + * NOTICE: This does not apply to primary or foreign keys for now. + * + * @param WebEntry $obj The object to validate. + * @param mixed $cols Column name or array of column names. + * + * @return mixed TRUE if all columns are valid or the error message of the first invalid column. + */ + public static function doValidate(WebEntry $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(WebEntryPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(WebEntryPeer::TABLE_NAME); + + if (! is_array($cols)) { + $cols = array($cols); + } + + foreach ($cols as $colName) { + if ($tableMap->containsColumn($colName)) { + $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); + $columns[$colName] = $obj->$get(); + } + } + } else { + + } + + return BasePeer::doValidate(WebEntryPeer::DATABASE_NAME, WebEntryPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return WebEntry + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(WebEntryPeer::DATABASE_NAME); + + $criteria->add(WebEntryPeer::WE_UID, $pk); + + + $v = WebEntryPeer::doSelect($criteria, $con); + + return !empty($v) > 0 ? $v[0] : null; + } + + /** + * Retrieve multiple objects by pkey. + * + * @param array $pks List of primary keys + * @param Connection $con the connection to use + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function retrieveByPKs($pks, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $objs = null; + if (empty($pks)) { + $objs = array(); + } else { + $criteria = new Criteria(); + $criteria->add(WebEntryPeer::WE_UID, $pks, Criteria::IN); + $objs = WebEntryPeer::doSelect($criteria, $con); + } + return $objs; + } +} + + +// static code to register the map builder for this Peer with the main Propel class +if (Propel::isInit()) { + // the MapBuilder classes register themselves with Propel during initialization + // so we need to load them here. + try { + BaseWebEntryPeer::getMapBuilder(); + } catch (Exception $e) { + Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR); + } +} else { + // even if Propel is not yet initialized, the map builder class can be registered + // now and then it will be loaded when Propel initializes. + require_once 'classes/model/map/WebEntryMapBuilder.php'; + Propel::registerMapBuilder('classes.model.map.WebEntryMapBuilder'); +} + diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index 65be1a029..a6926d61a 100755 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -3058,6 +3058,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ @@ -3758,5 +3785,5 @@ - - \ No newline at end of file + + diff --git a/workflow/engine/data/mssql/schema.sql b/workflow/engine/data/mssql/schema.sql index 04264711d..7f1fb7f20 100755 --- a/workflow/engine/data/mssql/schema.sql +++ b/workflow/engine/data/mssql/schema.sql @@ -3184,3 +3184,51 @@ CREATE TABLE [APP_SOLR_QUEUE] [APP_UPDATED] TINYINT default 1 NOT NULL, CONSTRAINT APP_SOLR_QUEUE_PK PRIMARY KEY ([APP_UID]) ); + +/* ---------------------------------------------------------------------- */ +/* WEB_ENTRY */ +/* ---------------------------------------------------------------------- */ + +IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'WEB_ENTRY') +BEGIN + DECLARE @reftable_70 nvarchar(60), @constraintname_70 nvarchar(60) + DECLARE refcursor CURSOR FOR + select reftables.name tablename, cons.name constraintname + from sysobjects tables, + sysobjects reftables, + sysobjects cons, + sysreferences ref + where tables.id = ref.rkeyid + and cons.id = ref.constid + and reftables.id = ref.fkeyid + and tables.name = 'WEB_ENTRY' + OPEN refcursor + FETCH NEXT from refcursor into @reftable_70, @constraintname_70 + while @@FETCH_STATUS = 0 + BEGIN + exec ('alter table ' + @reftable_70 + ' drop constraint ' + @constraintname_70) + FETCH NEXT from refcursor into @reftable_70, @constraintname_70 + END + CLOSE refcursor + DEALLOCATE refcursor + DROP TABLE [WEB_ENTRY] +END + +CREATE TABLE WEB_ENTRY +( + WE_UID VARCHAR(32) NOT NULL, + PRO_UID VARCHAR(32) NOT NULL, + TAS_UID VARCHAR(32) NOT NULL, + DYN_UID VARCHAR(32) NOT NULL, + USR_UID VARCHAR(32) DEFAULT '', + WE_METHOD VARCHAR(4) DEFAULT 'HTML', + WE_INPUT_DOCUMENT_ACCESS INT DEFAULT 0, + WE_DATA NVARCHAR(MAX), + WE_CREATE_USR_UID VARCHAR(32) DEFAULT '' NOT NULL, + WE_UPDATE_USR_UID VARCHAR(32) DEFAULT '', + WE_CREATE_DATE CHAR(19) NOT NULL, + WE_UPDATE_DATE CHAR(19), + + CONSTRAINT WEB_ENTRY_PK PRIMARY KEY (WE_UID) +); + diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index 0d7fa87db..fab83281f 100755 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -1495,6 +1495,31 @@ CREATE TABLE `PROCESS_FILES` `PRF_UPDATE_DATE` DATETIME, PRIMARY KEY (`PRF_UID`) )ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='Application files metadata'; + +#----------------------------------------------------------------------------- +#-- WEB_ENTRY +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS WEB_ENTRY; + +CREATE TABLE WEB_ENTRY +( + WE_UID VARCHAR(32) NOT NULL, + PRO_UID VARCHAR(32) NOT NULL, + TAS_UID VARCHAR(32) NOT NULL, + DYN_UID VARCHAR(32) NOT NULL, + USR_UID VARCHAR(32) DEFAULT '', + WE_METHOD VARCHAR(4) DEFAULT 'HTML', + WE_INPUT_DOCUMENT_ACCESS INTEGER DEFAULT 0, + WE_DATA MEDIUMTEXT, + WE_CREATE_USR_UID VARCHAR(32) DEFAULT '' NOT NULL, + WE_UPDATE_USR_UID VARCHAR(32) DEFAULT '', + WE_CREATE_DATE DATETIME NOT NULL, + WE_UPDATE_DATE DATETIME, + + PRIMARY KEY (WE_UID) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + #----------------------------------------------------------------------------- #-- OAUTH_ACCESS_TOKENS #----------------------------------------------------------------------------- @@ -2034,3 +2059,4 @@ CREATE TABLE `BPMN_DOCUMENTATION` )ENGINE=InnoDB DEFAULT CHARSET='utf8'; # This restores the fkey checks, after having unset them earlier SET FOREIGN_KEY_CHECKS = 1; + diff --git a/workflow/engine/data/oracle/schema.sql b/workflow/engine/data/oracle/schema.sql index 6a5cba79e..a7d0f72d3 100755 --- a/workflow/engine/data/oracle/schema.sql +++ b/workflow/engine/data/oracle/schema.sql @@ -1798,3 +1798,30 @@ CREATE TABLE "APP_SOLR_QUEUE" ALTER TABLE "APP_SOLR_QUEUE" ADD CONSTRAINT "APP_SOLR_QUEUE_PK" PRIMARY KEY ("APP_UID"); + +/* ----------------------------------------------------------------------- + WEB_ENTRY + ----------------------------------------------------------------------- */ + +DROP TABLE WEB_ENTRY CASCADE CONSTRAINTS; + +CREATE TABLE WEB_ENTRY +( + WE_UID VARCHAR2(32) NOT NULL, + PRO_UID VARCHAR2(32) NOT NULL, + TAS_UID VARCHAR2(32) NOT NULL, + DYN_UID VARCHAR2(32) NOT NULL, + USR_UID VARCHAR2(32) DEFAULT '', + WE_METHOD VARCHAR2(4) DEFAULT 'HTML', + WE_INPUT_DOCUMENT_ACCESS NUMBER DEFAULT 0, + WE_DATA VARCHAR2(2000), + WE_CREATE_USR_UID VARCHAR2(32) DEFAULT '' NOT NULL, + WE_UPDATE_USR_UID VARCHAR2(32) DEFAULT '', + WE_CREATE_DATE DATE NOT NULL, + WE_UPDATE_DATE DATE +); + +ALTER TABLE WEB_ENTRY +ADD CONSTRAINT WEB_ENTRY_PK +PRIMARY KEY (WE_UID); + diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Calendar.php b/workflow/engine/src/ProcessMaker/BusinessModel/Calendar.php index 8c1e98403..d103d37e7 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Calendar.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Calendar.php @@ -283,11 +283,11 @@ class Calendar } /** - * Create Group + * Create Calendar * * @param array $arrayData Data * - * return array Return data of the new Group created + * return array Return data of the new Calendar created */ public function create($arrayData) { diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Process.php b/workflow/engine/src/ProcessMaker/BusinessModel/Process.php index 1f3c96e0f..bdc035709 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Process.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Process.php @@ -1456,39 +1456,6 @@ class Process } } - /** - * Get all Web Entries of a Process - * - * @param string $processUid Unique id of Process - * - * return array Return an array with all Web Entries of a Process - */ - public function getWebEntries($processUid) - { - try { - $arrayWebEntry = array(); - - //Verify data - //Get data - $webEntry = new \ProcessMaker\BusinessModel\WebEntry(); - $webEntry->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase); - $webEntry->setArrayFieldNameForException($this->arrayFieldNameForException); - - $arrayWebEntryData = $webEntry->getData($processUid); - - foreach ($arrayWebEntryData as $index => $value) { - $row = $value; - - $arrayWebEntry[] = $webEntry->getWebEntryDataFromRecord($row); - } - - //Return - return $arrayWebEntry; - } catch (\Exception $e) { - throw $e; - } - } - /** * Get field names which are primary key in a PM Table * diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php index f3e23f771..345782ef6 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/WebEntry.php @@ -4,21 +4,26 @@ namespace ProcessMaker\BusinessModel; class WebEntry { private $arrayFieldDefinition = array( - "TAS_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "taskUid"), - "DYN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"), - "METHOD" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("WS", "HTML"), "fieldNameAux" => "method"), - "INPUT_DOCUMENT_ACCESS" => array("type" => "int", "required" => true, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "inputDocumentAccess") + "WE_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "webEntryUid"), + + "TAS_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "taskUid"), + "DYN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"), + "USR_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid"), + "WE_TITLE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "webEntryTitle"), + "WE_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "webEntryDescription"), + "WE_METHOD" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("WS", "HTML"), "fieldNameAux" => "webEntryMethod"), + "WE_INPUT_DOCUMENT_ACCESS" => array("type" => "int", "required" => true, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "webEntryInputDocumentAccess") ); private $arrayUserFieldDefinition = array( - "USR_USERNAME" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUsername"), - "USR_PASSWORD" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userPassword") + "USR_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid") ); private $formatFieldNameInUppercase = true; private $arrayFieldNameForException = array( - "processUid" => "PRO_UID" + "processUid" => "PRO_UID", + "userUid" => "USR_UID" ); /** @@ -32,10 +37,6 @@ class WebEntry foreach ($this->arrayFieldDefinition as $key => $value) { $this->arrayFieldNameForException[$value["fieldNameAux"]] = $key; } - - foreach ($this->arrayUserFieldDefinition as $key => $value) { - $this->arrayFieldNameForException[$value["fieldNameAux"]] = $key; - } } catch (\Exception $e) { throw $e; } @@ -105,217 +106,172 @@ class WebEntry $name = trim($name); $arraySpecialCharSearch = array( - "ñ", "Ñ", - "á", "é", "í", "ó", "ú", "Á", "É", "Í", "Ó", "Ú", - "à", "è", "ì", "ò", "ù", "À", "È", "Ì", "Ò", "Ù", - "â", "ê", "î", "ô", "û", "Â", "Ê", "Î", "Ô", "Û", - "ä", "ë", "ï", "ö", "ü", "Ä", "Ë", "Ï", "Ö", "Ü", "/", "\\", " " ); $arraySpecialCharReplace = array( - "n", "N", - "a", "e", "i", "o", "u", "A", "E", "I", "O", "U", - "a", "e", "i", "o", "u", "A", "E", "I", "O", "U", - "a", "e", "i", "o", "u", "A", "E", "I", "O", "U", - "a", "e", "i", "o", "u", "A", "E", "I", "O", "U", "_", "_", "_" ); $newName = str_replace($arraySpecialCharSearch, $arraySpecialCharReplace, $name); - $arraySpecialCharSearch = array("/[^a-zA-Z0-9\_\-\.]/"); - $arraySpecialCharReplace = array(""); - - $newName = preg_replace($arraySpecialCharSearch, $arraySpecialCharReplace, $newName); - return $newName; } /** - * Get all Web Entries data of a Process + * Verify if exists the title of a Web Entry * - * @param string $processUid Unique id of Process - * @param string $option Option (ALL, UID, DYN_UID) - * @param string $taskUid Unique id of Task - * @param string $dynaFormUid Unique id of DynaForm + * @param string $processUid Unique id of Process + * @param string $webEntryTitle Title + * @param string $webEntryUidExclude Unique id of Web Entry to exclude * - * return array Return an array with all Web Entries data of a Process + * return bool Return true if exists the title of a Web Entry, false otherwise */ - public function getData($processUid, $option = "ALL", $taskUid = "", $dynaFormUid = "") + public function existsTitle($processUid, $webEntryTitle, $webEntryUidExclude = "") { try { - $arrayData = array(); + $delimiter = \DBAdapter::getStringDelimiter(); - //Verify data - $process = new \ProcessMaker\BusinessModel\Process(); + $criteria = new \Criteria("workflow"); - $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $criteria->addSelectColumn(\WebEntryPeer::WE_UID); - if ($taskUid != "") { - $process->throwExceptionIfNotExistsTask($processUid, $taskUid, $this->arrayFieldNameForException["taskUid"]); + $criteria->addAlias("CT", \ContentPeer::TABLE_NAME); + + $arrayCondition = array(); + $arrayCondition[] = array(\WebEntryPeer::WE_UID, "CT.CON_ID", \Criteria::EQUAL); + $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "WE_TITLE" . $delimiter, \Criteria::EQUAL); + $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); + $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); + + $criteria->add(\WebEntryPeer::PRO_UID, $processUid, \Criteria::EQUAL); + + if ($webEntryUidExclude != "") { + $criteria->add(\WebEntryPeer::WE_UID, $webEntryUidExclude, \Criteria::NOT_EQUAL); } - if ($dynaFormUid != "") { - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); + $criteria->add("CT.CON_VALUE", $webEntryTitle, \Criteria::EQUAL); - $dynaForm->throwExceptionIfNotExistsDynaForm($dynaFormUid, $processUid, $this->arrayFieldNameForException["dynaFormUid"]); + $rsCriteria = \WebEntryPeer::doSelectRS($criteria); + + if ($rsCriteria->next()) { + return true; + } else { + return false; } - - //Get data - $webEntryPath = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $processUid; - - if (is_dir($webEntryPath)) { - $task = new \Task(); - $dynaForm = new \Dynaform(); - - $step = new \ProcessMaker\BusinessModel\Step(); - - $arrayDirFile = scandir($webEntryPath); //Ascending Order - - $nrt = array("\n", "\r", "\t"); - $nrthtml = array("(n /)", "(r /)", "(t /)"); - - $http = (\G::is_https())? "https://" : "http://"; - $url = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $processUid; - - $flagNext = 1; - - for ($i = 0; $i <= count($arrayDirFile) - 1 && $flagNext == 1; $i++) { - $file = $arrayDirFile[$i]; - - if ($file != "" && $file != "." && $file != ".." && is_file($webEntryPath . PATH_SEP . $file)) { - $one = 0; - $two = 0; - - $one = count(explode("wsClient.php", $file)); - $two = count(explode("Post.php", $file)); - - if ($one == 1 && $two == 1) { - $arrayInfo = pathinfo($file); - - $weTaskUid = ""; - $weDynaFormUid = ""; - $weFileName = $arrayInfo["filename"]; - - $strContent = str_replace($nrt, $nrthtml, file_get_contents($webEntryPath . PATH_SEP . $weFileName . ".php")); - - if (preg_match("/^.*CURRENT_DYN_UID.*=.*[\"\'](\w{32})[\"\'].*$/", $strContent, $arrayMatch)) { - $weDynaFormUid = $arrayMatch[1]; - } - - if (file_exists($webEntryPath . PATH_SEP . $weFileName . "Post.php")) { - $strContent = str_replace($nrt, $nrthtml, file_get_contents($webEntryPath . PATH_SEP . $weFileName . "Post.php")); - - if (preg_match("/^.*ws_newCase\s*\(\s*[\"\']" . $processUid . "[\"\']\s*\,\s*[\"\'](\w{32})[\"\'].*\)\s*\;.*$/", $strContent, $arrayMatch)) { - $weTaskUid = $arrayMatch[1]; - } - } - - if ($weTaskUid != "" && $weDynaFormUid != "") { - $flagPush = 0; - - switch ($option) { - case "ALL": - if ($step->existsRecord($weTaskUid, "DYNAFORM", $weDynaFormUid)) { - $flagPush = 1; - } - break; - case "UID": - if ($taskUid != "" && $dynaFormUid != "" && $weTaskUid == $taskUid && $weDynaFormUid == $dynaFormUid && $step->existsRecord($weTaskUid, "DYNAFORM", $weDynaFormUid)) { - $flagPush = 1; - $flagNext = 0; - } - break; - case "DYN_UID": - if ($dynaFormUid != "" && $weDynaFormUid == $dynaFormUid && $step->existsRecord($weTaskUid, "DYNAFORM", $weDynaFormUid)) { - $flagPush = 1; - $flagNext = 0; - } - break; - } - - if ($flagPush == 1) { - $arrayTaskData = $task->load($weTaskUid); - $arrayDynaFormData = $dynaForm->Load($weDynaFormUid); - - $arrayData[$weTaskUid . "/" . $weDynaFormUid] = array( - "processUid" => $processUid, - "taskUid" => $weTaskUid, - "taskTitle" => $arrayTaskData["TAS_TITLE"], - "dynaFormUid" => $weDynaFormUid, - "dynaFormTitle" => $arrayDynaFormData["DYN_TITLE"], - "fileName" => $weFileName, - "url" => $url . "/" . $weFileName . ".php" - ); - } - } - } - } - } - } - - //Return - return $arrayData; } catch (\Exception $e) { throw $e; } } /** - * Create Web Entry for a Process + * Verify if does not exist the Web Entry in table WEB_ENTRY * - * @param string $processUid Unique id of Process - * @param array $arrayData Data + * @param string $webEntryUid Unique id of Web Entry + * @param string $fieldNameForException Field name for the exception * - * return array Return data of the new Web Entry created + * return void Throw exception if does not exist the Web Entry in table WEB_ENTRY */ - public function create($processUid, $arrayData) + public function throwExceptionIfNotExistsWebEntry($webEntryUid, $fieldNameForException) { try { - $arrayData = array_change_key_case($arrayData, CASE_UPPER); + $webEntry = \WebEntryPeer::retrieveByPK($webEntryUid); - //Verify data + if (is_null($webEntry)) { + $msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $webEntryUid), "The web entry with {0}: {1} does not exist."); + + throw (new \Exception($msg)); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the title of a Web Entry + * + * @param string $processUid Unique id of Process + * @param string $webEntryTitle Title + * @param string $fieldNameForException Field name for the exception + * @param string $webEntryUidExclude Unique id of Web Entry to exclude + * + * return void Throw exception if exists the title of a Web Entry + */ + public function throwExceptionIfExistsTitle($processUid, $webEntryTitle, $fieldNameForException, $webEntryUidExclude = "") + { + try { + if ($this->existsTitle($processUid, $webEntryTitle, $webEntryUidExclude)) { + $msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $webEntryTitle), "The web entry title with {0}: \"{1}\" already exists"); + + throw (new \Exception($msg)); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Validate the data if they are invalid (INSERT and UPDATE) + * + * @param string $webEntryUid Unique id of Web Entry + * @param string $processUid Unique id of Process + * @param array $arrayData Data + * + * return void Throw exception if data has an invalid value + */ + public function throwExceptionIfDataIsInvalid($webEntryUid, $processUid, $arrayData) + { + try { + //Set variables + $arrayWebEntryData = ($webEntryUid == "")? array() : $this->getWebEntry($webEntryUid, true); + $flagInsert = ($webEntryUid == "")? true : false; + + $arrayDataMain = array_merge($arrayWebEntryData, $arrayData); + + //Verify data - Field definition $process = new \ProcessMaker\BusinessModel\Process(); - $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert); - $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); - - $projectUser = new \ProcessMaker\BusinessModel\ProjectUser(); - - if ($arrayData["METHOD"] == "WS") { - $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayUserFieldDefinition, $this->arrayFieldNameForException, true); - - $loginData = $projectUser->userLogin($arrayData["USR_USERNAME"], $arrayData["USR_PASSWORD"]); - - if ($loginData->status_code != 0) { - throw (new \Exception($loginData->message)); - } + if ($arrayDataMain["WE_METHOD"] == "WS") { + $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayUserFieldDefinition, $this->arrayFieldNameForException, $flagInsert); } - $process->throwExceptionIfNotExistsTask($processUid, $arrayData["TAS_UID"], $this->arrayFieldNameForException["taskUid"]); + //Verify data + if (isset($arrayData["WE_TITLE"])) { + $this->throwExceptionIfExistsTitle($processUid, $arrayData["WE_TITLE"], $this->arrayFieldNameForException["webEntryTitle"], $webEntryUid); + } - $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); + if (isset($arrayData["TAS_UID"])) { + $process->throwExceptionIfNotExistsTask($processUid, $arrayData["TAS_UID"], $this->arrayFieldNameForException["taskUid"]); + } - $dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $processUid, $this->arrayFieldNameForException["dynaFormUid"]); + if (isset($arrayData["DYN_UID"])) { + $dynaForm = new \ProcessMaker\BusinessModel\DynaForm(); + + $dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $processUid, $this->arrayFieldNameForException["dynaFormUid"]); + } + + if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["USR_UID"])) { + $process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]); + } $task = new \Task(); - $arrayTaskData = $task->load($arrayData["TAS_UID"]); + $arrayTaskData = $task->load($arrayDataMain["TAS_UID"]); - $weEventUid = $task->getStartingEvent($arrayData["TAS_UID"]); + if (isset($arrayData["TAS_UID"])) { + if ($arrayTaskData["TAS_START"] == "FALSE") { + throw (new \Exception(str_replace(array("{0}"), array($arrayTaskData["TAS_TITLE"]), "The task \"{0}\" is not initial task"))); + } - if ($arrayTaskData["TAS_START"] == "FALSE") { - throw (new \Exception(str_replace(array("{0}"), array($arrayTaskData["TAS_TITLE"]), "The task \"{0}\" is not initial task"))); + if ($arrayTaskData["TAS_ASSIGN_TYPE"] != "BALANCED") { + throw (new \Exception(str_replace(array("{0}"), array($arrayTaskData["TAS_TITLE"]), "Web Entry only works with tasks which have \"Cyclical Assignment\", the task \"{0}\" does not have a valid assignment type. Please change the Assignment Rules"))); + } } - if ($arrayTaskData["TAS_ASSIGN_TYPE"] != "BALANCED") { - throw (new \Exception(str_replace(array("{0}"), array($arrayTaskData["TAS_TITLE"]), "Web Entry only works with tasks which have \"Cyclical Assignment\", the task \"{0}\" does not have a valid assignment type. Please change the Assignment Rules"))); - } - - if ($arrayData["METHOD"] == "WS") { + if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["TAS_UID"])) { $task = new \Tasks(); if ($task->assignUsertoTask($arrayData["TAS_UID"]) == 0) { @@ -323,87 +279,116 @@ class WebEntry } } - $dynaForm = new \Dynaform(); + if (isset($arrayData["DYN_UID"])) { + $dynaForm = new \Dynaform(); - $arrayDynaFormData = $dynaForm->Load($arrayData["DYN_UID"]); + $arrayDynaFormData = $dynaForm->Load($arrayData["DYN_UID"]); - $step = new \ProcessMaker\BusinessModel\Step(); + $step = new \ProcessMaker\BusinessModel\Step(); - if (!$step->existsRecord($arrayData["TAS_UID"], "DYNAFORM", $arrayData["DYN_UID"])) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($arrayDynaFormData["DYN_TITLE"], $arrayTaskData["TAS_TITLE"]), "The DynaForm \"{0}\" isn't assigned to the task \"{1}\""))); + if (!$step->existsRecord($arrayDataMain["TAS_UID"], "DYNAFORM", $arrayData["DYN_UID"])) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($arrayDynaFormData["DYN_TITLE"], $arrayTaskData["TAS_TITLE"]), "The DynaForm \"{0}\" isn't assigned to the task \"{1}\""))); + } } - if ($arrayData["METHOD"] == "WS") { - //Verify if the Web Entry exist - $arrayWebEntryData = $this->getData($processUid, "UID", $arrayData["TAS_UID"], $arrayData["DYN_UID"]); + if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["USR_UID"])) { + $user = new \Users(); - if (count($arrayWebEntryData) > 0) { - throw (new \Exception("The Web Entry exist")); - } + $arrayUserData = $user->load($arrayData["USR_UID"]); //Verify if User is assigned to Task - $criteria = new \Criteria("workflow"); + $projectUser = new \ProcessMaker\BusinessModel\ProjectUser(); - $criteria->addSelectColumn(\UsersPeer::USR_UID); - $criteria->add(\UsersPeer::USR_USERNAME, $arrayData["USR_USERNAME"], \Criteria::EQUAL); + if (!$projectUser->userIsAssignedToTask($arrayData["USR_UID"], $arrayDataMain["TAS_UID"])) { + throw (new \Exception(str_replace(array("{0}", "{1}"), array($arrayUserData["USR_USERNAME"], $arrayTaskData["TAS_TITLE"]), "The user \"{0}\" does not have the task \"{1}\" assigned"))); + } + } + } catch (\Exception $e) { + throw $e; + } + } - $rsCriteria = \UsersPeer::doSelectRS($criteria); - $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + /** + * Set value in WE_DATA + * + * @param string $webEntryUid Unique id of Web Entry + * + * return void + */ + public function setWeData($webEntryUid) + { + try { + //Verify data + $this->throwExceptionIfNotExistsWebEntry($webEntryUid, $this->arrayFieldNameForException["webEntryUid"]); - $rsCriteria->next(); + //Set variables + $arrayWebEntryData = $this->getWebEntry($webEntryUid, true); - $row = $rsCriteria->getRow(); + $processUid = $arrayWebEntryData["PRO_UID"]; + $taskUid = $arrayWebEntryData["TAS_UID"]; + $dynaFormUid = $arrayWebEntryData["DYN_UID"]; + $webEntryMethod = $arrayWebEntryData["WE_METHOD"]; + $webEntryInputDocumentAccess = $arrayWebEntryData["WE_INPUT_DOCUMENT_ACCESS"]; + $webEntryData = ""; - if (!$projectUser->userIsAssignedToTask($row["USR_UID"], $arrayData["TAS_UID"])) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($arrayData["USR_USERNAME"], $arrayTaskData["TAS_TITLE"]), "The user \"{0}\" does not have the task \"{1}\" assigned"))); + $wsRoundRobin = 0; //0, 1 //0 - Cyclical Assignment + + $pathDataPublicProcess = PATH_DATA_PUBLIC . $processUid; + + //Delete previous files + if (trim($arrayWebEntryData["WE_DATA"]) != "") { + $fileName = str_replace(".php", "", trim($arrayWebEntryData["WE_DATA"])); + $file = $pathDataPublicProcess . PATH_SEP . $fileName . ".php"; + + if (is_file($file) && file_exists($file)) { + unlink($file); + unlink($pathDataPublicProcess . PATH_SEP . $fileName . "Post.php"); } } - //Create - $taskUid = $arrayData["TAS_UID"]; - $dynaFormUid = $arrayData["DYN_UID"]; - $method = $arrayData["METHOD"]; - $inputDocumentAccess = $arrayData["INPUT_DOCUMENT_ACCESS"]; - $wsRoundRobin = 0; //0, 1 //0 - Cyclical Assignment - - $pathProcess = PATH_DATA_SITE . "public" . PATH_SEP . $processUid; - - \G::mk_dir($pathProcess, 0777); + //Create files + \G::mk_dir($pathDataPublicProcess, 0777); $http = (\G::is_https())? "https://" : "http://"; - $arrayDataAux = array(); - - switch ($method) { + switch ($webEntryMethod) { case "WS": - $usrUsername = $arrayData["USR_USERNAME"]; - $usrPassword = $arrayData["USR_PASSWORD"]; + $user = new \Users(); + + $arrayUserData = $user->load($arrayWebEntryData["USR_UID"]); + + $usrUsername = $arrayUserData["USR_USERNAME"]; + $usrPassword = $arrayUserData["USR_PASSWORD"]; + + $dynaForm = new \Dynaform(); + + $arrayDynaFormData = $dynaForm->Load($arrayWebEntryData["DYN_UID"]); //Creating sys.info; - $site_public_path = ""; + $sitePublicPath = ""; - if (file_exists($site_public_path . "")) { + if (file_exists($sitePublicPath . "")) { } //Creating the first file - $dynTitle = $this->sanitizeFilename($arrayDynaFormData["DYN_TITLE"]); - $fileName = $dynTitle; + $weTitle = $this->sanitizeFilename($arrayWebEntryData["WE_TITLE"]); + $fileName = $weTitle; $fileContent = "AddContent('dynaform', 'xmlform', '" . $processUid . '/' . $dynaFormUid . "', '', array(), '" . $fileName . 'Post.php' . "');\n"; - $fileContent .= "G::RenderPage('publish', 'blank');"; + $fileContent .= "\$_SESSION[\"PROCESS\"] = \"" . $processUid . "\";\n"; + $fileContent .= "\$_SESSION[\"CURRENT_DYN_UID\"] = \"" . $dynaFormUid . "\";\n"; + $fileContent .= "\$G_PUBLISH = new Publisher();\n"; + $fileContent .= "\$G_PUBLISH->AddContent(\"dynaform\", \"xmlform\", \"" . $processUid . "/" . $dynaFormUid . "\", \"\", array(), \"" . $fileName . "Post.php\");\n"; + $fileContent .= "G::RenderPage(\"publish\", \"blank\");"; - file_put_contents($pathProcess . PATH_SEP . $fileName . ".php", $fileContent); + file_put_contents($pathDataPublicProcess . PATH_SEP . $fileName . ".php", $fileContent); //Creating the second file, the post file who receive the post form. - $pluginTpl = PATH_CORE . "templates" . PATH_SEP . "processes" . PATH_SEP . "webentryPost.tpl"; + $pluginTpl = PATH_TPL . "processes" . PATH_SEP . "webentryPost.tpl"; $template = new \TemplatePower($pluginTpl); $template->prepare(); @@ -417,7 +402,7 @@ class WebEntry $template->assign("wsPass", "md5:" . md5($usrPassword)); $template->assign("wsRoundRobin", $wsRoundRobin); - if ($inputDocumentAccess == 0) { + if ($webEntryInputDocumentAccess == 0) { //Restricted to process permissions $template->assign("USR_VAR", "\$cInfo = ws_getCaseInfo(\$caseId);\n\t \$USR_UID = \$cInfo->currentUsers->userId;"); } else { @@ -425,23 +410,23 @@ class WebEntry $template->assign("USR_VAR", "\$USR_UID = -1;"); } - $template->assign("dynaform", $dynTitle); + $template->assign("dynaform", $arrayDynaFormData["DYN_TITLE"]); $template->assign("timestamp", date("l jS \of F Y h:i:s A")); $template->assign("ws", SYS_SYS); $template->assign("version", \System::getVersion()); - $fileName = $pathProcess . PATH_SEP . $dynTitle . "Post.php"; + $fileName = $pathDataPublicProcess . PATH_SEP . $weTitle . "Post.php"; file_put_contents($fileName, $template->getOutputContent()); //Creating the third file, only if this wsClient.php file doesn't exist. - $fileName = $pathProcess . PATH_SEP . "wsClient.php"; - $pluginTpl = PATH_CORE . "test" . PATH_SEP . "unit" . PATH_SEP . "ws" . PATH_SEP . "wsClient.php"; + $fileName = $pathDataPublicProcess . PATH_SEP . "wsClient.php"; + $pluginTpl = PATH_TEST . "unit" . PATH_SEP . "ws" . PATH_SEP . "wsClient.php"; if (file_exists($fileName)) { if (filesize($fileName) != filesize($pluginTpl)) { - @copy($fileName, $pathProcess . PATH_SEP . "wsClient.php.bck"); - @unlink($fileName); + copy($fileName, $pathDataPublicProcess . PATH_SEP . "wsClient.php.bak"); + unlink($fileName); $template = new \TemplatePower($pluginTpl); $template->prepare(); @@ -456,6 +441,12 @@ class WebEntry } //Event + $task = new \Task(); + + $arrayTaskData = $task->load($arrayWebEntryData["TAS_UID"]); + + $weEventUid = $task->getStartingEvent(); + if ($weEventUid != "") { $event = new \Event(); @@ -469,29 +460,27 @@ class WebEntry $result = $event->update($arrayEventData); } - //Data - $url = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $processUid . "/" . $dynTitle . ".php"; - - $arrayDataAux = array("URL" => $url); + //WE_DATA + $webEntryData = $weTitle . ".php"; break; case "HTML": global $G_FORM; if (! class_exists("Smarty")) { $loader = \Maveriks\Util\ClassLoader::getInstance(); - $loader->addClass("Smarty", PATH_THIRDPARTY . "smarty".PATH_SEP."libs".PATH_SEP."Smarty.class.php"); + $loader->addClass("Smarty", PATH_THIRDPARTY . "smarty" . PATH_SEP . "libs" . PATH_SEP . "Smarty.class.php"); } $G_FORM = new \Form($processUid . "/" . $dynaFormUid, PATH_DYNAFORM, SYS_LANG, false); $G_FORM->action = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/cases_StartExternal.php"; $scriptCode = ""; - $scriptCode = $G_FORM->render(PATH_CORE . "templates/" . "xmlform" . ".html", $scriptCode); + $scriptCode = $G_FORM->render(PATH_TPL . "xmlform" . ".html", $scriptCode); $scriptCode = str_replace("/controls/", $http . $_SERVER["HTTP_HOST"] . "/controls/", $scriptCode); $scriptCode = str_replace("/js/maborak/core/images/", $http . $_SERVER["HTTP_HOST"] . "/js/maborak/core/images/", $scriptCode); //Render the template - $pluginTpl = PATH_CORE . "templates" . PATH_SEP . "processes" . PATH_SEP . "webentry.tpl"; + $pluginTpl = PATH_TPL . "processes" . PATH_SEP . "webentry.tpl"; $template = new \TemplatePower($pluginTpl); $template->prepare(); @@ -520,21 +509,193 @@ class WebEntry } } - //Data + //WE_DATA $html = str_replace("", "", str_replace("", "", $template->getOutputContent())); - $arrayDataAux = array("HTML" => $html); + $webEntryData = $html; break; } - //Return - $arrayData = array_merge($arrayData, $arrayDataAux); + //Update + //Update where + $criteriaWhere = new \Criteria("workflow"); + $criteriaWhere->add(\WebEntryPeer::WE_UID, $webEntryUid); - if (!$this->formatFieldNameInUppercase) { - $arrayData = array_change_key_case($arrayData, CASE_LOWER); + //Update set + $criteriaSet = new \Criteria("workflow"); + $criteriaSet->add(\WebEntryPeer::WE_DATA, $webEntryData); + + \BasePeer::doUpdate($criteriaWhere, $criteriaSet, \Propel::getConnection("workflow")); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Create Web Entry for a Process + * + * @param string $processUid Unique id of Process + * @param string $userUidCreator Unique id of creator User + * @param array $arrayData Data + * + * return array Return data of the new Web Entry created + */ + public function create($processUid, $userUidCreator, $arrayData) + { + try { + //Verify data + $process = new \ProcessMaker\BusinessModel\Process(); + $validator = new \ProcessMaker\BusinessModel\Validator(); + + $validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData"); + $validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData"); + + //Set data + $arrayData = array_change_key_case($arrayData, CASE_UPPER); + + unset($arrayData["WE_UID"]); + unset($arrayData["WE_DATA"]); + + //Verify data + $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + + $this->throwExceptionIfDataIsInvalid("", $processUid, $arrayData); + + //Create + $cnn = \Propel::getConnection("workflow"); + + try { + $webEntry = new \WebEntry(); + + $webEntry->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME); + + $webEntryUid = \G::generateUniqueID(); + + $webEntry->setWeUid($webEntryUid); + $webEntry->setProUid($processUid); + $webEntry->setWeCreateUsrUid($userUidCreator); + $webEntry->setWeCreateDate("now"); + + if ($webEntry->validate()) { + $cnn->begin(); + + $result = $webEntry->save(); + + $cnn->commit(); + + //Set WE_TITLE + if (isset($arrayData["WE_TITLE"])) { + $result = \Content::addContent("WE_TITLE", "", $webEntryUid, SYS_LANG, $arrayData["WE_TITLE"]); + } + + if (isset($arrayData["WE_DESCRIPTION"])) { + $result = \Content::addContent("WE_DESCRIPTION", "", $webEntryUid, SYS_LANG, $arrayData["WE_DESCRIPTION"]); + } + + //Set WE_DATA + $this->setWeData($webEntryUid); + + //Return + return $this->getWebEntry($webEntryUid); + } else { + $msg = ""; + + foreach ($webEntry->getValidationFailures() as $validationFailure) { + $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage(); + } + + throw (new \Exception("The registry cannot be created!.\n" . $msg)); + } + } catch (\Exception $e) { + $cnn->rollback(); + + throw $e; } + } catch (\Exception $e) { + throw $e; + } + } - return $arrayData; + /** + * Update Web Entry + * + * @param string $webEntryUid Unique id of Web Entry + * @param string $userUidUpdater Unique id of updater User + * @param array $arrayData Data + * + * return array Return data of the Web Entry updated + */ + public function update($webEntryUid, $userUidUpdater, $arrayData) + { + try { + //Verify data + $process = new \ProcessMaker\BusinessModel\Process(); + $validator = new \ProcessMaker\BusinessModel\Validator(); + + $validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData"); + $validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData"); + + //Set data + $arrayData = array_change_key_case($arrayData, CASE_UPPER); + + //Set variables + $arrayWebEntryData = $this->getWebEntry($webEntryUid, true); + + //Verify data + $this->throwExceptionIfNotExistsWebEntry($webEntryUid, $this->arrayFieldNameForException["webEntryUid"]); + + $this->throwExceptionIfDataIsInvalid($webEntryUid, $arrayWebEntryData["PRO_UID"], $arrayData); + + //Update + $cnn = \Propel::getConnection("workflow"); + + try { + $webEntry = \WebEntryPeer::retrieveByPK($webEntryUid); + + $webEntry->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME); + + $webEntry->setWeUpdateUsrUid($userUidUpdater); + $webEntry->setWeUpdateDate("now"); + + if ($webEntry->validate()) { + $cnn->begin(); + + $result = $webEntry->save(); + + $cnn->commit(); + + //Set WE_TITLE + if (isset($arrayData["WE_TITLE"])) { + $result = \Content::addContent("WE_TITLE", "", $webEntryUid, SYS_LANG, $arrayData["WE_TITLE"]); + } + + if (isset($arrayData["WE_DESCRIPTION"])) { + $result = \Content::addContent("WE_DESCRIPTION", "", $webEntryUid, SYS_LANG, $arrayData["WE_DESCRIPTION"]); + } + + //Set WE_DATA + $this->setWeData($webEntryUid); + + //Return + if (!$this->formatFieldNameInUppercase) { + $arrayData = array_change_key_case($arrayData, CASE_LOWER); + } + + return $arrayData; + } else { + $msg = ""; + + foreach ($webEntry->getValidationFailures() as $validationFailure) { + $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage(); + } + + throw (new \Exception("The registry cannot be created!.\n" . $msg)); + } + } catch (\Exception $e) { + $cnn->rollback(); + + throw $e; + } } catch (\Exception $e) { throw $e; } @@ -543,28 +704,90 @@ class WebEntry /** * Delete Web Entry * - * @param string $processUid Unique id of Process - * @param string $taskUid Unique id of Task - * @param string $dynaFormUid Unique id of DynaForm + * @param string $webEntryUid Unique id of Web Entry * * return void */ - public function delete($processUid, $taskUid, $dynaFormUid) + public function delete($webEntryUid) { try { //Verify data - //Get data - $arrayWebEntryData = $this->getData($processUid, "UID", $taskUid, $dynaFormUid); + $this->throwExceptionIfNotExistsWebEntry($webEntryUid, $this->arrayFieldNameForException["webEntryUid"]); - if (count($arrayWebEntryData) == 0) { - throw (new \Exception("The Web Entry doesn't exist")); + //Set variables + $arrayWebEntryData = $this->getWebEntry($webEntryUid, true); + + //Delete content + \Content::removeContent("WE_TITLE", "", $webEntryUid); + \Content::removeContent("WE_DESCRIPTION", "", $webEntryUid); + + //Delete web entry + $criteria = new \Criteria("workflow"); + + $criteria->add(\WebEntryPeer::WE_UID, $webEntryUid); + + $result = \WebEntryPeer::doDelete($criteria); + + //Delete files + if ($arrayWebEntryData["WE_METHOD"] == "WS") { + $pathDataPublicProcess = PATH_DATA_PUBLIC . $arrayWebEntryData["PRO_UID"]; + + $fileName = str_replace(".php", "", trim($arrayWebEntryData["WE_DATA"])); + $file = $pathDataPublicProcess . PATH_SEP . $fileName . ".php"; + + if (is_file($file) && file_exists($file)) { + unlink($file); + unlink($pathDataPublicProcess . PATH_SEP . $fileName . "Post.php"); + } } + } catch (\Exception $e) { + throw $e; + } + } - //Delete - $webEntryPath = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $processUid; + /** + * Get criteria for Web Entry + * + * return object + */ + public function getWebEntryCriteria() + { + try { + $delimiter = \DBAdapter::getStringDelimiter(); - unlink($webEntryPath . PATH_SEP . $arrayWebEntryData[$taskUid . "/" . $dynaFormUid]["fileName"] . ".php"); - unlink($webEntryPath . PATH_SEP . $arrayWebEntryData[$taskUid . "/" . $dynaFormUid]["fileName"] . "Post.php"); + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\WebEntryPeer::WE_UID); + $criteria->addSelectColumn(\WebEntryPeer::PRO_UID); + $criteria->addSelectColumn(\WebEntryPeer::TAS_UID); + $criteria->addSelectColumn(\WebEntryPeer::DYN_UID); + $criteria->addSelectColumn(\WebEntryPeer::USR_UID); + $criteria->addAsColumn("WE_TITLE", "CT.CON_VALUE"); + $criteria->addAsColumn("WE_DESCRIPTION", "CD.CON_VALUE"); + $criteria->addSelectColumn(\WebEntryPeer::WE_METHOD); + $criteria->addSelectColumn(\WebEntryPeer::WE_INPUT_DOCUMENT_ACCESS); + $criteria->addSelectColumn(\WebEntryPeer::WE_DATA); + $criteria->addSelectColumn(\WebEntryPeer::WE_CREATE_USR_UID); + $criteria->addSelectColumn(\WebEntryPeer::WE_UPDATE_USR_UID); + $criteria->addSelectColumn(\WebEntryPeer::WE_CREATE_DATE); + $criteria->addSelectColumn(\WebEntryPeer::WE_UPDATE_DATE); + + $criteria->addAlias("CT", \ContentPeer::TABLE_NAME); + $criteria->addAlias("CD", \ContentPeer::TABLE_NAME); + + $arrayCondition = array(); + $arrayCondition[] = array(\WebEntryPeer::WE_UID, "CT.CON_ID", \Criteria::EQUAL); + $arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "WE_TITLE" . $delimiter, \Criteria::EQUAL); + $arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); + $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); + + $arrayCondition = array(); + $arrayCondition[] = array(\WebEntryPeer::WE_UID, "CD.CON_ID", \Criteria::EQUAL); + $arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "WE_DESCRIPTION" . $delimiter, \Criteria::EQUAL); + $arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL); + $criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN); + + return $criteria; } catch (\Exception $e) { throw $e; } @@ -575,45 +798,119 @@ class WebEntry * * @param array $record Record * - * return array Return an array with data of a Web Entry + * return array Return an array with data Web Entry */ public function getWebEntryDataFromRecord($record) { try { + if ($record["WE_METHOD"] == "WS") { + $http = (\G::is_https())? "https://" : "http://"; + $url = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/" . $record["PRO_UID"]; + + $record["WE_DATA"] = $url . "/" . $record["WE_DATA"]; + } + + $conf = new \Configurations(); + $confEnvSetting = $conf->getFormats(); + + $dateTime = new \DateTime($record["WE_CREATE_DATE"]); + $webEntryCreateDate = $dateTime->format($confEnvSetting["dateFormat"]); + + $webEntryUpdateDate = ""; + + if (!empty($record["WE_UPDATE_DATE"])) { + $dateTime = new \DateTime($record["WE_UPDATE_DATE"]); + $webEntryUpdateDate = $dateTime->format($confEnvSetting["dateFormat"]); + } + return array( - $this->getFieldNameByFormatFieldName("TAS_UID") => $record["taskUid"], - $this->getFieldNameByFormatFieldName("TAS_TITLE") => $record["taskTitle"], - $this->getFieldNameByFormatFieldName("DYN_UID") => $record["dynaFormUid"], - $this->getFieldNameByFormatFieldName("DYN_TITLE") => $record["dynaFormTitle"], - $this->getFieldNameByFormatFieldName("URL") => $record["url"] + $this->getFieldNameByFormatFieldName("WE_UID") => $record["WE_UID"], + $this->getFieldNameByFormatFieldName("TAS_UID") => $record["TAS_UID"], + $this->getFieldNameByFormatFieldName("DYN_UID") => $record["DYN_UID"], + $this->getFieldNameByFormatFieldName("USR_UID") => $record["USR_UID"] . "", + $this->getFieldNameByFormatFieldName("WE_TITLE") => $record["WE_TITLE"] . "", + $this->getFieldNameByFormatFieldName("WE_DESCRIPTION") => $record["WE_DESCRIPTION"] . "", + $this->getFieldNameByFormatFieldName("WE_METHOD") => $record["WE_METHOD"], + $this->getFieldNameByFormatFieldName("WE_INPUT_DOCUMENT_ACCESS") => (int)($record["WE_INPUT_DOCUMENT_ACCESS"]), + $this->getFieldNameByFormatFieldName("WE_DATA") => $record["WE_DATA"], + $this->getFieldNameByFormatFieldName("WE_CREATE_USR_UID") => $record["WE_CREATE_USR_UID"], + $this->getFieldNameByFormatFieldName("WE_UPDATE_USR_UID") => $record["WE_UPDATE_USR_UID"] . "", + $this->getFieldNameByFormatFieldName("WE_CREATE_DATE") => $webEntryCreateDate, + $this->getFieldNameByFormatFieldName("WE_UPDATE_DATE") => $webEntryUpdateDate . "" ); } catch (\Exception $e) { throw $e; } } + /** + * Get all Web Entries + * + * @param string $processUid Unique id of Process + * + * return array Return an array with all Web Entries + */ + public function getWebEntries($processUid) + { + try { + $arrayWebEntry = array(); + + //Verify data + $process = new \ProcessMaker\BusinessModel\Process(); + + $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); + + //Get data + $criteria = $this->getWebEntryCriteria(); + + $criteria->add(\WebEntryPeer::PRO_UID, $processUid, \Criteria::EQUAL); + $criteria->addAscendingOrderByColumn("WE_TITLE"); + + $rsCriteria = \WebEntryPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + while ($rsCriteria->next()) { + $row = $rsCriteria->getRow(); + + $arrayWebEntry[] = $this->getWebEntryDataFromRecord($row); + } + + //Return + return $arrayWebEntry; + } catch (\Exception $e) { + throw $e; + } + } + /** * Get data of a Web Entry * - * @param string $processUid Unique id of Process - * @param string $taskUid Unique id of Task - * @param string $dynaFormUid Unique id of DynaForm + * @param string $webEntryUid Unique id of Web Entry + * @param bool $flagGetRecord Value that set the getting * * return array Return an array with data of a Web Entry */ - public function getWebEntry($processUid, $taskUid, $dynaFormUid) + public function getWebEntry($webEntryUid, $flagGetRecord = false) { try { //Verify data - //Get data - $arrayWebEntryData = $this->getData($processUid, "UID", $taskUid, $dynaFormUid); + $this->throwExceptionIfNotExistsWebEntry($webEntryUid, $this->arrayFieldNameForException["webEntryUid"]); - if (count($arrayWebEntryData) == 0) { - throw (new \Exception("The Web Entry doesn't exist")); - } + //Get data + //SQL + $criteria = $this->getWebEntryCriteria(); + + $criteria->add(\WebEntryPeer::WE_UID, $webEntryUid, \Criteria::EQUAL); + + $rsCriteria = \WebEntryPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + $rsCriteria->next(); + + $row = $rsCriteria->getRow(); //Return - return $this->getWebEntryDataFromRecord($arrayWebEntryData[$taskUid . "/" . $dynaFormUid]); + return (!$flagGetRecord)? $this->getWebEntryDataFromRecord($row) : $row; } catch (\Exception $e) { throw $e; } diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project.php b/workflow/engine/src/ProcessMaker/Services/Api/Project.php index a97d0b25a..8e596a7f1 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Project.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project.php @@ -175,26 +175,6 @@ class Project extends Api } } - /** - * @url GET /:prj_uid/web-entries - * - * @param string $prj_uid {@min 32}{@max 32} - */ - public function doGetWebEntries($prj_uid) - { - try { - $process = new \ProcessMaker\BusinessModel\Process(); - $process->setFormatFieldNameInUppercase(false); - $process->setArrayFieldNameForException(array("processUid" => "prj_uid")); - - $response = $process->getWebEntries($prj_uid); - - return $response; - } catch (\Exception $e) { - throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); - } - } - /** * @url GET /:prj_uid/variables * diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project/WebEntry.php b/workflow/engine/src/ProcessMaker/Services/Api/Project/WebEntry.php index 70bbac8cd..20375e012 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Project/WebEntry.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project/WebEntry.php @@ -11,21 +11,51 @@ use \Luracast\Restler\RestException; */ class WebEntry extends Api { + private $webEntry; + /** - * @url GET /:prj_uid/web-entry/:tas_uid/:dyn_uid + * Constructor of the class * - * @param string $dyn_uid {@min 32}{@max 32} - * @param string $tas_uid {@min 32}{@max 32} - * @param string $prj_uid {@min 32}{@max 32} + * return void */ - public function doGetWebEntry($dyn_uid, $tas_uid, $prj_uid) + public function __construct() { try { - $webEntry = new \ProcessMaker\BusinessModel\WebEntry(); - $webEntry->setFormatFieldNameInUppercase(false); - $webEntry->setArrayFieldNameForException(array("processUid" => "prj_uid")); + $this->webEntry = new \ProcessMaker\BusinessModel\WebEntry(); - $response = $webEntry->getWebEntry($prj_uid, $tas_uid, $dyn_uid); + $this->webEntry->setFormatFieldNameInUppercase(false); + $this->webEntry->setArrayFieldNameForException(array("processUid" => "prj_uid")); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url GET /:prj_uid/web-entries + * + * @param string $prj_uid {@min 32}{@max 32} + */ + public function doGetWebEntries($prj_uid) + { + try { + $response = $this->webEntry->getWebEntries($prj_uid); + + return $response; + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } + + /** + * @url GET /:prj_uid/web-entry/:we_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $we_uid {@min 32}{@max 32} + */ + public function doGetWebEntry($prj_uid, $we_uid) + { + try { + $response = $this->webEntry->getWebEntry($we_uid); return $response; } catch (\Exception $e) { @@ -44,11 +74,7 @@ class WebEntry extends Api public function doPostWebEntry($prj_uid, $request_data) { try { - $webEntry = new \ProcessMaker\BusinessModel\WebEntry(); - $webEntry->setFormatFieldNameInUppercase(false); - $webEntry->setArrayFieldNameForException(array("processUid" => "prj_uid")); - - $arrayData = $webEntry->create($prj_uid, $request_data); + $arrayData = $this->webEntry->create($prj_uid, $this->getUserId(), $request_data); $response = $arrayData; @@ -59,20 +85,31 @@ class WebEntry extends Api } /** - * @url DELETE /:prj_uid/web-entry/:tas_uid/:dyn_uid + * @url PUT /:prj_uid/web-entry/:we_uid * - * @param string $dyn_uid {@min 32}{@max 32} - * @param string $tas_uid {@min 32}{@max 32} - * @param string $prj_uid {@min 32}{@max 32} + * @param string $prj_uid {@min 32}{@max 32} + * @param string $we_uid {@min 32}{@max 32} + * @param array $request_data */ - public function doDeleteWebEntry($dyn_uid, $tas_uid, $prj_uid) + public function doPutWebEntry($prj_uid, $we_uid, $request_data) { try { - $webEntry = new \ProcessMaker\BusinessModel\WebEntry(); - $webEntry->setFormatFieldNameInUppercase(false); - $webEntry->setArrayFieldNameForException(array("processUid" => "prj_uid")); + $arrayData = $this->webEntry->update($we_uid, $this->getUserId(), $request_data); + } catch (\Exception $e) { + throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); + } + } - $webEntry->delete($prj_uid, $tas_uid, $dyn_uid); + /** + * @url DELETE /:prj_uid/web-entry/:we_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $we_uid {@min 32}{@max 32} + */ + public function doDeleteWebEntry($prj_uid, $we_uid) + { + try { + $this->webEntry->delete($we_uid); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } From 999f8a66ec585ca8a3371bef2af1fa827c13bb7d Mon Sep 17 00:00:00 2001 From: Wendy Nestor Date: Tue, 22 Apr 2014 15:16:14 -0400 Subject: [PATCH 06/11] Modificaciones a los features cases actions y input document case --- .../case_actions/main_tests_cases_actions.feature | 3 +-- .../negative_tests_input_document_case.feature | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/features/backend/application_cases/case_actions/main_tests_cases_actions.feature b/features/backend/application_cases/case_actions/main_tests_cases_actions.feature index bff401527..c787d165a 100644 --- a/features/backend/application_cases/case_actions/main_tests_cases_actions.feature +++ b/features/backend/application_cases/case_actions/main_tests_cases_actions.feature @@ -234,12 +234,11 @@ Scenario Outline: Sends variables to a case - - Scenario Outline: Route a case to the next task in the process Given PUT this data: """ { + "case_uid": "", "del_index": "1" } """ diff --git a/features/backend/application_cases/input_documents_case/negative_tests_input_document_case.feature b/features/backend/application_cases/input_documents_case/negative_tests_input_document_case.feature index fb003d01d..514c33530 100644 --- a/features/backend/application_cases/input_documents_case/negative_tests_input_document_case.feature +++ b/features/backend/application_cases/input_documents_case/negative_tests_input_document_case.feature @@ -13,7 +13,7 @@ Scenario: Returns a list of the uploaded documents for a given case Then the response status code should be 400 Scenario Outline: Post metadata and then upload documents for a given case - Given POST upload an input document "" to "cases//input-document" + Given POST this data: """ { @@ -24,12 +24,14 @@ Scenario Outline: Post metadata and then upload documents for a given case } """ + And I request "cases//input-document" Then the response status code should be 400 + And the response status message should have the following text "" Examples: - | app_doc_uid_number | document_file | case_uid | inp_doc_uid | tas_uid | app_doc_comment | - | 1 | /inexistent_test1.html | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 | - | 1 | /home/wendy/uploadfiles/test1.html | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | | comment 1 | - | 1 | /home/wendy/uploadfiles/test1.html | 170220159534214f642abb8058832933 | | 19582733053319e304cfa76025663570 | comment 1 | + | test_description | case_uid | inp_doc_uid | tas_uid | app_doc_comment | error_message | + | Incorrect tas_uid | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | | comment 1 | tas_uid | + | Incorrect inp_doc_uid | 170220159534214f642abb8058832933 | | 19582733053319e304cfa76025663570 | comment 1 | inp_doc_uid | + | No file | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 | filename | \ No newline at end of file From 47db85fa27ceb875ea046c1e60554d6c733d57b9 Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Tue, 22 Apr 2014 15:49:11 -0400 Subject: [PATCH 07/11] Arreglo en input documents --- .../src/ProcessMaker/BusinessModel/Cases/InputDocument.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php index eeb849e07..aeebbfc36 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php @@ -183,7 +183,8 @@ class InputDocument //Triggers $arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); //Add Input Document - if (!$_FILES["form"]["error"]) { + $_FILES["form"]["error"] = ''; + if ($_FILES["form"]["error"] == '') { $_FILES["form"]["error"] = 0; } if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { From ebd5e7f63ad3b4d17b2f81d6f0716be84675c05e Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Tue, 22 Apr 2014 15:59:06 -0400 Subject: [PATCH 08/11] Fix checkstyle warnings --- .../src/ProcessMaker/BusinessModel/Cases/InputDocument.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php index aeebbfc36..f2c55a450 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php @@ -183,7 +183,9 @@ class InputDocument //Triggers $arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); //Add Input Document + $_FILES["form"]["name"] = ''; $_FILES["form"]["error"] = ''; + $_FILES["form"]["tmp_name"] = ''; if ($_FILES["form"]["error"] == '') { $_FILES["form"]["error"] = 0; } From 99327ac7da0b10910cb9bf2a11e8e7251318d998 Mon Sep 17 00:00:00 2001 From: Wendy Nestor Date: Tue, 22 Apr 2014 16:00:59 -0400 Subject: [PATCH 09/11] Modificacion al feature input document --- .../basic_sequence_input_document_case.feature | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature b/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature index 1d852279c..e11399d77 100644 --- a/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature +++ b/features/backend/application_cases/input_documents_case/basic_sequence_input_document_case.feature @@ -13,8 +13,7 @@ Scenario: Returns a list of the uploaded documents for a given case Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" - And the response has 10 records - + Scenario: Returns an uploaded documents for a given case Given I request "cases/170220159534214f642abb8058832933/input-document/925833635534215b9148a64026212674" From 5193a261b90fe502d91ac5084cef71194c42c935 Mon Sep 17 00:00:00 2001 From: jennylee Date: Tue, 22 Apr 2014 17:01:40 -0400 Subject: [PATCH 10/11] BUG-14530 The Title in the process list Designer Tab reads the HTML like a code. This was fixed just aplaying Ext.util.Format.htmlEncode(v). --- workflow/engine/templates/processes/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/engine/templates/processes/main.js b/workflow/engine/templates/processes/main.js index 50e9a7f1f..db9d00673 100755 --- a/workflow/engine/templates/processes/main.js +++ b/workflow/engine/templates/processes/main.js @@ -202,7 +202,7 @@ Ext.onReady(function(){ // TODO Labels for var 'type' are hardcoded, they must be replaced on the future var color = r.get('PROJECT_TYPE') == 'bpmn'? 'green': 'blue'; var type = r.get('PROJECT_TYPE') == 'bpmn'? ' (BPMN Project)': ''; - return v + ' ' + String.format("{1}", color, type); + return Ext.util.Format.htmlEncode(v) + ' ' + String.format("{1}", color, type); }}, {header: _('ID_TYPE'), dataIndex: 'PROJECT_TYPE', width: 60, hidden:false}, {header: _('ID_CATEGORY'), dataIndex: 'PRO_CATEGORY_LABEL', width: 100, hidden:false}, From ce50fa9308b89ebc5c41f52f03950b3ffb20cafa Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Wed, 23 Apr 2014 16:50:31 -0400 Subject: [PATCH 11/11] Arreglo en errores en BEHAT y adicion de validaciones para inputDocuments and outputDocuments --- ...asic_sequence_output_document_case.feature | 60 ++++++------ ...main_sequence_output_document_case.feature | 98 ++++++++----------- .../BusinessModel/Cases/InputDocument.php | 55 +++++------ .../BusinessModel/Cases/OutputDocument.php | 9 +- 4 files changed, 98 insertions(+), 124 deletions(-) diff --git a/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature b/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature index 8c1b095e6..1beddfcda 100644 --- a/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature +++ b/features/backend/application_cases/output_document_case/basic_sequence_output_document_case.feature @@ -1,48 +1,44 @@ @ProcessMakerMichelangelo @RestAPI Feature: Output Documents cases -Requirements: - a workspace with one case of the process "Test Output Document Case" - and there are six Output Documents in the process + Requirements: + a workspace with one case of the process "Test Output Document Case" + and there are six Output Documents in the process -Background: + Background: Given that I have a valid access_token -Scenario: Returns a list of the generated documents for a given cases + Scenario: Returns a list of the generated documents for a given cases Given I request "cases/33125846153383cecdf64f1079330191/output-documents" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" And the response has 1 records - -Scenario: Returns a generated document for a given case - Given I request "cases/33125846153383cecdf64f1079330191/output-document/75468909953383d0bc42f96046736849" + Scenario: Generate or regenerates an output documents for a given case + Given POST this data: + """ + { + "out_doc_uid": "2087233055331ef4127d238097105696" + } + """ + And I request "cases/33125846153383cecdf64f1079330191/output-document" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + And store "app_doc_uid" in session array as variable "app_doc_uid_0" + + Scenario: Returns a generated document for a given case + Given I request "cases/33125846153383cecdf64f1079330191/output-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_0" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "object" - -Scenario: Generate or regenerates an output documents for a given case - Given POST this data: - """ - { - "out_doc_uid": "2087233055331ef4127d238097105696" - } - """ - And I request "cases/33125846153383cecdf64f1079330191/output-document" - Then the response status code should be 200 - And the response charset is "UTF-8" - And the content type is "application/json" - And the type is "array" - And store "app_doc_uid" in session array as variable "app_doc_uid_0" - - - -Scenario: Delete an uploaded or generated document from a case. - And that I want to delete a resource with the key "app_doc_uid_0" stored in session array - Given I request "output-document" - Then the response status code should be 200 - And the content type is "application/json" - And the response charset is "UTF-8" - And the type is "object" + Scenario: Delete an uploaded or generated document from a case. + Given that I want to delete a resource with the key "app_doc_uid_0" stored in session array + And I request "cases/33125846153383cecdf64f1079330191/output-document" + Then the response status code should be 200 + And the content type is "application/json" + And the response charset is "UTF-8" + And the type is "object" diff --git a/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature b/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature index 026ab8570..2ebf6a565 100644 --- a/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature +++ b/features/backend/application_cases/output_document_case/main_sequence_output_document_case.feature @@ -1,96 +1,78 @@ @ProcessMakerMichelangelo @RestAPI Feature: Output Documents cases Main Tests -Requirements: - a workspace with one case of the process "Test Output Document Case" - and there are six Output Documents in the process + Requirements: + a workspace with one case of the process "Test Output Document Case" + and there are six Output Documents in the process -Background: + Background: Given that I have a valid access_token -Scenario Outline: Generate or regenerates an output documents for a given case - Given POST this data: - """ + Scenario Outline: Generate or regenerates an output documents for a given case + Given POST this data: + """ { - "out_doc_uid": "" + "out_doc_uid": "" } """ - And I request "cases/33125846153383cecdf64f1079330191/output-document" - Then the response status code should be 200 - And the response charset is "UTF-8" - And the content type is "application/json" - And the type is "array" - And store "app_doc_uid" in session array as variable "app_doc_uid_" - - - Examples: - - | test_description | app_doc_uid_number | out_doc_uid | - | Generate "output document only doc" | 1 | 2087233055331ef4127d238097105696 | - | Generate "output document with versioning" | 2 | 5961108155331efc976cee7011445347 | - | Generate "output document only pdf" | 3 | 7074907425331ef837aa8b2055964905 | - | Generate "output document old version" | 4 | 7385645355331ee70ea6a87029841722 | - | Generate "output document with pdf security" | 5 | 8594478445331eff2d30767061922215 | + And I request "cases/33125846153383cecdf64f1079330191/output-document" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + And store "app_doc_uid" in session array as variable "app_doc_uid_" -Scenario: Returns a list of the generated documents for a given cases + Examples: + + | test_description | app_doc_uid_number | out_doc_uid | + | Generate "output document only doc" | 1 | 2087233055331ef4127d238097105696 | + | Generate "output document with versioning" | 2 | 5961108155331efc976cee7011445347 | + | Generate "output document only pdf" | 3 | 7074907425331ef837aa8b2055964905 | + | Generate "output document old version" | 4 | 7385645355331ee70ea6a87029841722 | + | Generate "output document with pdf security" | 5 | 8594478445331eff2d30767061922215 | + + + Scenario: Returns a list of the generated documents for a given cases Given I request "cases/33125846153383cecdf64f1079330191/output-documents" Then the response status code should be 200 And the response charset is "UTF-8" And the type is "array" And the response has 6 records - And the "app_doc_filename" property in row 0 equals "output document new version.pdf" - And the "app_doc_filename" property in row 1 equals "output document with pdf security.pdf" - And the "app_doc_filename" property in row 2 equals "output document only pdf.pdf" - And the "app_doc_filename" property in row 3 equals "output document only doc.doc" - And the "app_doc_filename" property in row 4 equals "output document with versioning.pdf" - And the "app_doc_filename" property in row 5 equals "output document old version.pdf" - -Scenario Outline: Returns an generated document for a given case + Scenario Outline: Returns an generated document for a given case Given I request "cases/33125846153383cecdf64f1079330191/output-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_" Then the response status code should be 200 And the response charset is "UTF-8" - And the type is "Object" - And the "app_doc_uid" property equals "" + And the type is "array" And the "app_doc_filename" property equals "" And the "doc_uid" property equals "" - And the "app_doc_version" property equals "" - And the "app_doc_create_date" property equals "" And the "app_doc_create_user" property equals "" And the "app_doc_type" property equals "" - And the "app_doc_index" property equals "" - And the "app_doc_link" property equals "" + + Examples: + + | test_description | app_doc_uid_number | app_doc_filename | doc_uid | app_doc_create_user | app_doc_type | + | Get Output "output document only doc.doc" | 1 | output document only doc.doc | 2087233055331ef4127d238097105696 | , Administrator (admin) | OUTPUT DOC | + | Get Output "output document with versioning.pdf" | 2 | output document with versioning.pdf | 5961108155331efc976cee7011445347 | , Administrator (admin) | OUTPUT BOTH | + | Get Output "output document only pdf.pdf" | 3 | output document only pdf.pdf | 7074907425331ef837aa8b2055964905 | , Administrator (admin) | OUTPUT PDF | + | Get Output "output document old version.pdf" | 4 | output document old version.pdf | 7385645355331ee70ea6a87029841722 | , Administrator (admin) | OUTPUT BOTH | + | Get Output "output document with pdf security.pdf" | 5 | output document with pdf security.pdf| 8594478445331eff2d30767061922215 | , Administrator (admin) | OUTPUT BOTH | - Examples: - - | test_description | app_doc_uid_number | app_doc_filename | doc_uid | app_doc_version | app_doc_create_date | app_doc_create_user | app_doc_type | app_doc_index | app_doc_link | - | Get Output "output document new version.pdf" | 1 | output document new version.pdf | 3391282325331ee81c84715031595672 | 1 | 2014-03-26 12:29:30 | , Administrator (admin) | OUTPUT BOTH | 1 | cases/cases_ShowOutputDocument?a=3000248055333006ab56a01005891659&v=1&ext=pdf&random=1256696859 | - | Get Output "output document old version.pdf" | 2 | output document old version.pdf | 7385645355331ee70ea6a87029841722 | 1 | 2014-03-26 12:29:33 | , Administrator (admin) | OUTPUT BOTH | 2 | cases/cases_ShowOutputDocument?a=8865432395333006d75d824038425476&v=1&ext=pdf&random=1838956992 | - | Get Output "output document only doc.doc" | 3 | output document only doc.doc | 2087233055331ef4127d238097105696 | 1 | 2014-03-26 12:29:35 | , Administrator (admin) | OUTPUT DOC | 3 | cases/cases_ShowOutputDocument?a=4447256265333006fe6fb00061503934&v=1&ext=doc&random=949245639 | - | Get Output "output document only pdf.pdf" | 4 | output document only pdf.pdf | 7074907425331ef837aa8b2055964905 | 1 | 2014-03-26 12:29:38 | , Administrator (admin) | OUTPUT PDF | 4 | cases/cases_ShowOutputDocument?a=828039615533300724fdcb6091842678&v=1&ext=pdf&random=401448562 | - | Get Output "output document with pdf security.pdf" | 5 | output document with pdf security.pdf | 8594478445331eff2d30767061922215 | 1 | 2014-03-26 12:29:40 | , Administrator (admin) | OUTPUT BOTH | 5 | cases/cases_ShowOutputDocument?a=25293137553330074713ab9073501576&v=1&ext=pdf&random=324546362 | - | Get Output "output document with versioning.pdf" | 6 | output document with versioning.pdf | 5961108155331efc976cee7011445347 | 1 | 2014-03-26 12:29:42 | , Administrator (admin) | OUTPUT BOTH | 6 | cases/cases_ShowOutputDocument?a=354826487533300769e65e0027827984&v=1&ext=pdf&random=1682978530 | - - - -Scenario Outline: Delete an uploaded or generated document from a case. + Scenario Outline: Delete an uploaded or generated document from a case. Given that I want to delete a resource with the key "app_doc_uid" stored in session array as variable "app_doc_uid_" And I request "cases/33125846153383cecdf64f1079330191/output-document" And the response status code should be 200 And the content type is "application/json" And the response charset is "UTF-8" - And the type is "object" + And the type is "object" - Examples: + Examples: | app_doc_uid_number | | 1 | | 2 | | 3 | | 4 | - | 5 | - - - \ No newline at end of file + | 5 | diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php index f2c55a450..ecf9dddaa 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php @@ -14,10 +14,6 @@ class InputDocument public function getCasesInputDocuments($applicationUid, $userUid) { try { - $oApplication = \ApplicationPeer::retrieveByPk($applicationUid); - if (!is_object($oApplication)) { - throw (new \Exception("The Application with app_uid: '$applicationUid' doesn't exist!")); - } $sApplicationUID = $applicationUid; $sUserUID = $userUid; \G::LoadClass('case'); @@ -62,10 +58,6 @@ class InputDocument public function getCasesInputDocument($applicationUid, $userUid, $inputDocumentUid) { try { - $oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 ); - if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') { - throw (new \Exception('This input document with inp_doc_uid: '.$inputDocumentUid.' doesn\'t exist!')); - } $sApplicationUID = $applicationUid; $sUserUID = $userUid; \G::LoadClass('case'); @@ -90,6 +82,10 @@ class InputDocument $docrow['app_doc_index'] = $row['APP_DOC_INDEX']; $docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK']; if ($docrow['app_doc_uid'] == $inputDocumentUid) { + $oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, $row['DOC_VERSION'] ); + if (is_null( $oAppDocument )) { + throw (new \Exception('This input document with id: '.$inputDocumentUid.' doesn\'t exist!')); + } $result = $docrow; } } @@ -183,34 +179,34 @@ class InputDocument //Triggers $arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); //Add Input Document - $_FILES["form"]["name"] = ''; - $_FILES["form"]["error"] = ''; - $_FILES["form"]["tmp_name"] = ''; - if ($_FILES["form"]["error"] == '') { + if (empty($_FILES)) { + throw (new \Exception('This document filename doesn\'t exist!')); + } + if (!$_FILES["form"]["error"]) { $_FILES["form"]["error"] = 0; } if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { $appDocUid = $case->addInputDocument($inputDocumentUid, - $appDocUid, - $docVersion, - $appDocType, - $appDocComment, - '', - $applicationUid, - $delIndex, - $taskUid, - $userUid, - "xmlform", - $_FILES["form"]["name"], - $_FILES["form"]["error"], - $_FILES["form"]["tmp_name"]); + $appDocUid, + $docVersion, + $appDocType, + $appDocComment, + '', + $applicationUid, + $delIndex, + $taskUid, + $userUid, + "xmlform", + $_FILES["form"]["name"], + $_FILES["form"]["error"], + $_FILES["form"]["tmp_name"]); } //Trigger - Execute after - Start $arrayField["APP_DATA"] = $case->executeTriggers ($taskUid, - "INPUT_DOCUMENT", - $inputDocumentUid, - "AFTER", - $arrayField["APP_DATA"]); + "INPUT_DOCUMENT", + $inputDocumentUid, + "AFTER", + $arrayField["APP_DATA"]); //Trigger - Execute after - End //Save data $arrayData = array(); @@ -226,4 +222,3 @@ class InputDocument } } } - diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php index 8237f74dd..5225298dc 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php @@ -104,13 +104,14 @@ class OutputDocument public function removeOutputDocument($applicationDocumentUid) { try { - $oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, 1 ); + $oAppDocumentVersion = new \AppDocument(); + $lastDocVersion = $oAppDocumentVersion->getLastAppDocVersion($applicationDocumentUid); + $oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $lastDocVersion); if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') { throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!')); } - \G::LoadClass('wsBase'); - $ws = new \wsBase(); - $ws->removeDocument($applicationDocumentUid); + $aFields = array ('APP_DOC_UID' => $applicationDocumentUid,'DOC_VERSION' => $lastDocVersion,'APP_DOC_STATUS' => 'DELETED'); + $oAppDocument->update( $aFields ); } catch (\Exception $e) { throw $e; }