diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index 8ce06b095..5d9983008 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -249,7 +249,7 @@ class Cases $rows[] = array('uid' => 'char', 'value' => 'char'); $tasks = array(); - $arrayTaskTypeToExclude = array("WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT", "SCRIPT-TASK"); + $arrayTaskTypeToExclude = array("WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT", "SCRIPT-TASK", "START-TIMER-EVENT", "INTERMEDIATE-CATCH-TIMER-EVENT"); $c = new Criteria(); $c->clearSelectColumns(); @@ -7014,3 +7014,4 @@ class Cases return $unserializedData; } } + diff --git a/workflow/engine/classes/class.derivation.php b/workflow/engine/classes/class.derivation.php index 2f99c9e44..ee530a872 100755 --- a/workflow/engine/classes/class.derivation.php +++ b/workflow/engine/classes/class.derivation.php @@ -112,7 +112,7 @@ class Derivation $arrayTaskData["NEXT_TASK"]["TAS_PARENT"] = ""; } - $arrayTaskData["NEXT_TASK"]["USER_ASSIGNED"] = (!in_array($arrayTaskData["NEXT_TASK"]["TAS_TYPE"], array("GATEWAYTOGATEWAY", "END-MESSAGE-EVENT", "SCRIPT-TASK", "END-EMAIL-EVENT")))? $this->getNextAssignedUser($arrayTaskData) : array("USR_UID" => "", "USR_FULLNAME" => ""); + $arrayTaskData["NEXT_TASK"]["USER_ASSIGNED"] = (!in_array($arrayTaskData["NEXT_TASK"]["TAS_TYPE"], array("GATEWAYTOGATEWAY", "END-MESSAGE-EVENT", "SCRIPT-TASK", "INTERMEDIATE-CATCH-TIMER-EVENT", "END-EMAIL-EVENT")))? $this->getNextAssignedUser($arrayTaskData) : array("USR_UID" => "", "USR_FULLNAME" => ""); } //Return @@ -237,7 +237,7 @@ class Derivation } } else { if (in_array($arrayNextTaskData["TAS_TYPE"], array("END-MESSAGE-EVENT", "END-EMAIL-EVENT")) && - $arrayNextTaskData["NEXT_TASK"]["TAS_UID"] == "-1" + $arrayNextTaskData["NEXT_TASK"]["TAS_UID"] == "-1" ) { $arrayNextTaskData["NEXT_TASK"]["TAS_UID"] = $arrayNextTaskData["TAS_UID"] . "/" . $arrayNextTaskData["NEXT_TASK"]["TAS_UID"]; } @@ -593,13 +593,20 @@ class Derivation //We close the current derivation, then we'll try to derivate to each defined route $this->case->CloseCurrentDelegation( $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'] ); + //Get data for current delegation (current Task) + $task = TaskPeer::retrieveByPK($currentDelegation["TAS_UID"]); + + $currentDelegation["TAS_ASSIGN_TYPE"] = $task->getTasAssignType(); + $currentDelegation["TAS_MI_COMPLETE_VARIABLE"] = $task->getTasMiCompleteVariable(); + $currentDelegation["TAS_MI_INSTANCE_VARIABLE"] = $task->getTasMiInstanceVariable(); + //Count how many tasks should be derivated. //$countNextTask = count($nextDelegations); //$removeList = true; foreach ($nextDelegations as $nextDel) { - //BpmnEvent - END-MESSAGE-EVENT - Check and get unique id - //BpmnEvent - END-EMAIL-EVENT - Check and get unique id + //BpmnEvent - END-MESSAGE-EVENT, END-EMAIL-EVENT + //Check and get unique id if (preg_match("/^(.{32})\/(\-1)$/", $nextDel["TAS_UID"], $arrayMatch)) { $nextDel["TAS_UID"] = $arrayMatch[2]; $nextDel["TAS_UID_DUMMY"] = $arrayMatch[1]; @@ -624,12 +631,6 @@ class Derivation continue; } } - //get TAS_ASSIGN_TYPE for current Delegation - $oTask = new Task(); - $aTask = $oTask->load( $currentDelegation['TAS_UID'] ); - $currentDelegation['TAS_ASSIGN_TYPE'] = $aTask['TAS_ASSIGN_TYPE']; - $currentDelegation['TAS_MI_COMPLETE_VARIABLE'] = $aTask['TAS_MI_COMPLETE_VARIABLE']; - $currentDelegation['TAS_MI_INSTANCE_VARIABLE'] = $aTask['TAS_MI_INSTANCE_VARIABLE']; //get open threads $openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] ); @@ -637,6 +638,9 @@ class Derivation if (($nextDel['TAS_UID'] == TASK_FINISH_PROCESS) && (($openThreads + 1) > 1)) { $nextDel['TAS_UID'] = TASK_FINISH_TASK; } + + $taskNextDel = TaskPeer::retrieveByPK($nextDel["TAS_UID"]); //Get data for next delegation (next Task) + switch ($nextDel['TAS_UID']) { case TASK_FINISH_PROCESS: /*Close all delegations of $currentDelegation['APP_UID'] */ @@ -644,29 +648,22 @@ class Derivation $this->case->closeAllThreads( $currentDelegation['APP_UID'] ); //I think we need to change the APP_STATUS to completed, - //BpmnEvent - END-MESSAGE-EVENT and END-EMAIL-EVENT + //BpmnEvent - END-MESSAGE-EVENT, END-EMAIL-EVENT if (isset($nextDel["TAS_UID_DUMMY"])) { $taskDummy = TaskPeer::retrieveByPK($nextDel["TAS_UID_DUMMY"]); + switch ($taskDummy->getTasType()) { case "END-MESSAGE-EVENT": //Throw Message-Events - BpmnEvent - END-MESSAGE-EVENT $case = new \ProcessMaker\BusinessModel\Cases(); - - $case->throwMessageEventBetweenElementOriginAndElementDest( - $currentDelegation["TAS_UID"], - $nextDel["TAS_UID_DUMMY"], - $appFields - ); + + $case->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields); break; case "END-EMAIL-EVENT": //Email Event $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); - - $emailEvent->emailEventBetweenElementOriginAndElementDest( - $currentDelegation["TAS_UID"], - $nextDel["TAS_UID_DUMMY"], - $appFields - ); + + $emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID_DUMMY"], $appFields); break; } } @@ -730,21 +727,15 @@ class Derivation $case = new \ProcessMaker\BusinessModel\Cases(); $case->throwMessageEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields); - - //Email Event + + //Throw Email-Events $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); - $emailEvent->emailEventBetweenElementOriginAndElementDest( - $currentDelegation["TAS_UID"], - $nextDel["TAS_UID"], - $appFields - ); - + $emailEvent->emailEventBetweenElementOriginAndElementDest($currentDelegation["TAS_UID"], $nextDel["TAS_UID"], $appFields); + //Derivate $aSP = isset( $aSP ) ? $aSP : null; - $taskNextDel = \TaskPeer::retrieveByPK($nextDel["TAS_UID"]); - $iNewDelIndex = $this->doDerivation( $currentDelegation, $nextDel, $appFields, $aSP ); //Execute Script-Task @@ -753,12 +744,11 @@ class Derivation $appFields["APP_DATA"] = $scriptTask->execScriptByActivityUid($nextDel["TAS_UID"], $appFields); //Create record in table APP_ASSIGN_SELF_SERVICE_VALUE - $task = new Task(); - $arrayNextTaskData = $task->load($nextDel["TAS_UID"]); + $arrayTaskTypeToExclude = array("SCRIPT-TASK"); - if (!in_array($arrayNextTaskData["TAS_TYPE"], array("SCRIPT-TASK"))) { - if ($arrayNextTaskData["TAS_ASSIGN_TYPE"] == "SELF_SERVICE" && trim($arrayNextTaskData["TAS_GROUP_VARIABLE"]) != "") { - $nextTaskGroupVariable = trim($arrayNextTaskData["TAS_GROUP_VARIABLE"], " @#"); + if (!in_array($taskNextDel->getTasType(), $arrayTaskTypeToExclude)) { + if ($taskNextDel->getTasAssignType() == "SELF_SERVICE" && trim($taskNextDel->getTasGroupVariable()) != "") { + $nextTaskGroupVariable = trim($taskNextDel->getTasGroupVariable(), " @#"); if (isset($appFields["APP_DATA"][$nextTaskGroupVariable]) && trim($appFields["APP_DATA"][$nextTaskGroupVariable]) != "") { $appAssignSelfServiceValue = new AppAssignSelfServiceValue(); @@ -768,8 +758,8 @@ class Derivation } } - //Check if $nextDel["TAS_UID"] is Script-Task - if (!is_null($taskNextDel) && $taskNextDel->getTasType() == "SCRIPT-TASK") { + //Check if $taskNextDel is Script-Task + if ($taskNextDel->getTasType() == "SCRIPT-TASK") { $this->case->CloseCurrentDelegation($currentDelegation["APP_UID"], $iNewDelIndex); //Get for $nextDel["TAS_UID"] your next Task @@ -823,12 +813,9 @@ class Derivation $users->refreshTotal($appFields['CURRENT_USER_UID'], 'remove', 'inbox'); } } elseif ($nextDel['TAS_UID'] != '-1') { - $taskNex = TaskPeer::retrieveByPK($nextDel['TAS_UID']); - $aTask = $taskNex->toArray( BasePeer::TYPE_FIELDNAME ); + $arrayTaskTypeToExclude = array("WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT", "SCRIPT-TASK", "INTERMEDIATE-CATCH-TIMER-EVENT"); - $arrayTaskTypeToExclude = array("WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT", "SCRIPT-TASK"); - - if (!in_array($aTask['TAS_TYPE'], $arrayTaskTypeToExclude)) { + if (!in_array($taskNextDel->getTasType(), $arrayTaskTypeToExclude)) { if (!empty($iNewDelIndex) && empty($aSP)) { $oAppDel = AppDelegationPeer::retrieveByPK( $appFields['APP_UID'], $iNewDelIndex ); $aFields = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME ); @@ -854,7 +841,9 @@ class Derivation } } } else { - if (!in_array($aTask['TAS_TYPE'], array("SCRIPT-TASK"))) { + $arrayTaskTypeToExclude = array("SCRIPT-TASK"); + + if ($removeList && !in_array($taskNextDel->getTasType(), $arrayTaskTypeToExclude)) { $oRow = ApplicationPeer::retrieveByPK($appFields["APP_UID"]); $aFields = $oRow->toArray( BasePeer::TYPE_FIELDNAME ); @@ -869,6 +858,7 @@ class Derivation } } /*----------------------------------********---------------------------------*/ + unset( $aSP ); $removeList = false; @@ -977,19 +967,19 @@ class Derivation // set the initial date to null the time its created $aNewCase = $this->case->startCase( $aSP['TAS_UID'], $aSP['USR_UID'], true, $appFields); + $taskNextDel = TaskPeer::retrieveByPK($aSP["TAS_UID"]); //Sub-Process + //Create record in table APP_ASSIGN_SELF_SERVICE_VALUE - $taskSub = new Task(); - $arrayNextTaskData = $taskSub->load($aSP["TAS_UID"]); - if ($arrayNextTaskData["TAS_ASSIGN_TYPE"] == "SELF_SERVICE" && trim($arrayNextTaskData["TAS_GROUP_VARIABLE"]) != "") { - $nextTaskGroupVariable = trim($arrayNextTaskData["TAS_GROUP_VARIABLE"], " @#"); + if ($taskNextDel->getTasAssignType() == "SELF_SERVICE" && trim($taskNextDel->getTasGroupVariable()) != "") { + $nextTaskGroupVariable = trim($taskNextDel->getTasGroupVariable(), " @#"); if (isset($appFields["APP_DATA"][$nextTaskGroupVariable]) && trim($appFields["APP_DATA"][$nextTaskGroupVariable]) != "") { - $appAssignSelfServiceValue = new AppAssignSelfServiceValue(); - $appAssignSelfServiceValue->create($aNewCase['APPLICATION'], $aNewCase['INDEX'], array("PRO_UID" => $aNewCase['PROCESS'], "TAS_UID" => $aSP["TAS_UID"], "GRP_UID" => trim($appFields["APP_DATA"][$nextTaskGroupVariable]))); + $appAssignSelfServiceValue->create($aNewCase["APPLICATION"], $aNewCase["INDEX"], array("PRO_UID" => $aNewCase["PROCESS"], "TAS_UID" => $aSP["TAS_UID"], "GRP_UID" => trim($appFields["APP_DATA"][$nextTaskGroupVariable]))); } } + //Copy case variables to sub-process case $aFields = unserialize( $aSP['SP_VARIABLES_OUT'] ); $aNewFields = array (); @@ -1284,3 +1274,4 @@ class Derivation } } } + diff --git a/workflow/engine/classes/class.processes.php b/workflow/engine/classes/class.processes.php index 6a064c9e9..7d938872c 100755 --- a/workflow/engine/classes/class.processes.php +++ b/workflow/engine/classes/class.processes.php @@ -847,13 +847,13 @@ class Processes $oData->messageType[$key]["PRJ_UID"] = $sNewProUid; } } - + if (isset($oData->emailEvent)) { foreach ($oData->emailEvent as $key => $value) { $oData->emailEvent[$key]["PRJ_UID"] = $sNewProUid; } } - + if (isset($oData->filesManager)) { foreach ($oData->filesManager as $key => $value) { $oData->filesManager[$key]["PRO_UID"] = $sNewProUid; @@ -2401,7 +2401,7 @@ class Processes throw $e; } } - + /** * Renew the GUID's for all the Uids for all the elements * @@ -3180,60 +3180,6 @@ class Processes throw $e; } } - - public function getEmailEvent($processUid) - { - try { - $arrayEmailEvent = array(); - - $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); - $criteria = $emailEvent->getEmailEventCriteria(); - - //Get data - $criteria->add(EmailEventPeer::PRJ_UID, $processUid, Criteria::EQUAL); - $rsCriteria = EmailEventPeer::doSelectRS($criteria); - $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $rsCriteria->next(); - while ($aRow = $rsCriteria->getRow()) { - $arrayEmailEvent[] = $aRow; - $rsCriteria->next(); - } - //Return - return $arrayEmailEvent; - } catch (Exception $e) { - throw $e; - } - } - - public function getFilesManager($processUid) - { - try { - $arrayFilesManager = array(); - //Get data - $criteria = new \Criteria("workflow"); - $criteria->addSelectColumn(\ProcessFilesPeer::PRF_UID); - $criteria->addSelectColumn(\ProcessFilesPeer::PRO_UID); - $criteria->addSelectColumn(\ProcessFilesPeer::USR_UID); - $criteria->addSelectColumn(\ProcessFilesPeer::PRF_UPDATE_USR_UID); - $criteria->addSelectColumn(\ProcessFilesPeer::PRF_PATH); - $criteria->addSelectColumn(\ProcessFilesPeer::PRF_TYPE); - $criteria->addSelectColumn(\ProcessFilesPeer::PRF_EDITABLE); - $criteria->addSelectColumn(\ProcessFilesPeer::PRF_CREATE_DATE); - $criteria->addSelectColumn(\ProcessFilesPeer::PRF_UPDATE_DATE); - $criteria->add(ProcessFilesPeer::PRO_UID, $processUid, Criteria::EQUAL); - $rsCriteria = ProcessFilesPeer::doSelectRS($criteria); - $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $rsCriteria->next(); - while ($aRow = $rsCriteria->getRow()) { - $arrayFilesManager[] = $aRow; - $rsCriteria->next(); - } - //Return - return $arrayFilesManager; - } catch (Exception $e) { - throw $e; - } - } public function getScriptTasks($processUid) { @@ -3263,6 +3209,88 @@ class Processes } } + public function getTimerEvents($processUid) + { + try { + $arrayTimerEvent = array(); + + $timerEvent = new \ProcessMaker\BusinessModel\TimerEvent(); + + //Get data + $criteria = $timerEvent->getTimerEventCriteria(); + + $criteria->add(\TimerEventPeer::PRJ_UID, $processUid, \Criteria::EQUAL); + + $rsCriteria = \TimerEventPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + while ($rsCriteria->next()) { + $row = $rsCriteria->getRow(); + + $arrayTimerEvent[] = $row; + } + + //Return + return $arrayTimerEvent; + } catch (Exception $e) { + throw $e; + } + } + + public function getEmailEvent($processUid) + { + try { + $arrayEmailEvent = array(); + + $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); + $criteria = $emailEvent->getEmailEventCriteria(); + + //Get data + $criteria->add(EmailEventPeer::PRJ_UID, $processUid, Criteria::EQUAL); + $rsCriteria = EmailEventPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $rsCriteria->next(); + while ($aRow = $rsCriteria->getRow()) { + $arrayEmailEvent[] = $aRow; + $rsCriteria->next(); + } + //Return + return $arrayEmailEvent; + } catch (Exception $e) { + throw $e; + } + } + + public function getFilesManager($processUid) + { + try { + $arrayFilesManager = array(); + //Get data + $criteria = new \Criteria("workflow"); + $criteria->addSelectColumn(\ProcessFilesPeer::PRF_UID); + $criteria->addSelectColumn(\ProcessFilesPeer::PRO_UID); + $criteria->addSelectColumn(\ProcessFilesPeer::USR_UID); + $criteria->addSelectColumn(\ProcessFilesPeer::PRF_UPDATE_USR_UID); + $criteria->addSelectColumn(\ProcessFilesPeer::PRF_PATH); + $criteria->addSelectColumn(\ProcessFilesPeer::PRF_TYPE); + $criteria->addSelectColumn(\ProcessFilesPeer::PRF_EDITABLE); + $criteria->addSelectColumn(\ProcessFilesPeer::PRF_CREATE_DATE); + $criteria->addSelectColumn(\ProcessFilesPeer::PRF_UPDATE_DATE); + $criteria->add(ProcessFilesPeer::PRO_UID, $processUid, Criteria::EQUAL); + $rsCriteria = ProcessFilesPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $rsCriteria->next(); + while ($aRow = $rsCriteria->getRow()) { + $arrayFilesManager[] = $aRow; + $rsCriteria->next(); + } + //Return + return $arrayFilesManager; + } catch (Exception $e) { + throw $e; + } + } + /** * Get Task User Rows from an array of data * @@ -3423,7 +3451,7 @@ class Processes $arrayWebEntryData = $webEntry->create($processUid, $userUidCreator, $record); } } catch (Exception $e) { - //throw $e; + throw $e; } } @@ -3447,7 +3475,7 @@ class Processes $arrayWebEntryEventData = $webEntryEvent->create($processUid, $userUidCreator, $record); } } catch (Exception $e) { - //throw $e; + throw $e; } } @@ -3528,48 +3556,6 @@ class Processes throw $e; } } - - /** - * Create Email-event records - * - * @param string $processUid Unique id of Process - * @param array $arrayData Data - * - * return void - */ - public function createEmailEvent($processUid, array $arrayData) - { - try { - $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); - - foreach ($arrayData as $value) { - $emailEventData = $emailEvent->save($processUid, $value); - } - } catch (Exception $e) { - throw $e; - } - } - - /** - * Create Files Manager records - * - * @param string $processUid Unique id of Process - * @param array $arrayData Data - * - * return void - */ - public function createFilesManager($processUid, array $arrayData) - { - try { - $filesManager = new \ProcessMaker\BusinessModel\FilesManager(); - - foreach ($arrayData as $value) { - $filesManager->addProcessFilesManagerInDb($value); - } - } catch (Exception $e) { - throw $e; - } - } /** * Create Script-Task records @@ -3590,7 +3576,72 @@ class Processes $result = $scriptTask->create($processUid, $record); } } catch (Exception $e) { - //throw $e; + throw $e; + } + } + + /** + * Create Timer-Event records + * + * @param string $processUid Unique id of Process + * @param array $arrayData Data + * + * return void + */ + public function createTimerEvent($processUid, array $arrayData) + { + try { + $timerEvent = new \ProcessMaker\BusinessModel\TimerEvent(); + + foreach ($arrayData as $value) { + $record = $value; + + $result = $timerEvent->singleCreate($processUid, $record); + } + } catch (Exception $e) { + throw $e; + } + } + + /** + * Create Email-Event records + * + * @param string $processUid Unique id of Process + * @param array $arrayData Data + * + * return void + */ + public function createEmailEvent($processUid, array $arrayData) + { + try { + $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); + + foreach ($arrayData as $value) { + $emailEventData = $emailEvent->save($processUid, $value); + } + } catch (Exception $e) { + throw $e; + } + } + + /** + * Create Files Manager records + * + * @param string $processUid Unique id of Process + * @param array $arrayData Data + * + * return void + */ + public function createFilesManager($processUid, array $arrayData) + { + try { + $filesManager = new \ProcessMaker\BusinessModel\FilesManager(); + + foreach ($arrayData as $value) { + $filesManager->addProcessFilesManagerInDb($value); + } + } catch (Exception $e) { + throw $e; } } @@ -3784,8 +3835,9 @@ class Processes $oData->messageTypeVariable = $this->getMessageTypeVariables($sProUid); $oData->messageEventDefinition = $this->getMessageEventDefinitions($sProUid); $oData->scriptTask = $this->getScriptTasks($sProUid); + $oData->timerEvent = $this->getTimerEvents($sProUid); $oData->emailEvent = $this->getEmailEvent($sProUid); - $oData->filesManager = $this->getFilesManager($sProUid); + $oData->filesManager = $this->getFilesManager($sProUid); $oData->groupwfs = $this->groupwfsMerge($oData->groupwfs, $oData->processUser, "USR_UID"); $oData->process["PRO_TYPE_PROCESS"] = "PUBLIC"; @@ -4886,6 +4938,7 @@ class Processes $this->createMessageTypeVariable((isset($oData->messageTypeVariable))? $oData->messageTypeVariable : array()); $this->createMessageEventDefinition($arrayProcessData["PRO_UID"], (isset($oData->messageEventDefinition))? $oData->messageEventDefinition : array()); $this->createScriptTask($arrayProcessData["PRO_UID"], (isset($oData->scriptTask))? $oData->scriptTask : array()); + $this->createTimerEvent($arrayProcessData["PRO_UID"], (isset($oData->timerEvent))? $oData->timerEvent : array()); $this->createEmailEvent($arrayProcessData["PRO_UID"], (isset($oData->emailEvent))? $oData->emailEvent : array()); $this->createFilesManager($arrayProcessData["PRO_UID"], (isset($oData->filesManager))? $oData->filesManager : array()); } @@ -5456,3 +5509,4 @@ class ObjectCellection } } } + diff --git a/workflow/engine/classes/model/TimerEvent.php b/workflow/engine/classes/model/TimerEvent.php new file mode 100644 index 000000000..82bb1f675 --- /dev/null +++ b/workflow/engine/classes/model/TimerEvent.php @@ -0,0 +1,5 @@ +addColumn('SCRTAS_OBJ_UID', 'ScrtasObjUid', 'string', CreoleTypes::VARCHAR, true, 32); - $tMap->addValidator('SCRTAS_OBJ_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'TRIGGER', 'Please set a valid value for TMREVN_DEF_STATUS'); + $tMap->addValidator('SCRTAS_OBJ_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'TRIGGER', 'Please set a valid value for SCRTAS_OBJ_TYPE'); } // doBuild() diff --git a/workflow/engine/classes/model/map/TaskMapBuilder.php b/workflow/engine/classes/model/map/TaskMapBuilder.php index 6a4a92a13..ed4b783d5 100755 --- a/workflow/engine/classes/model/map/TaskMapBuilder.php +++ b/workflow/engine/classes/model/map/TaskMapBuilder.php @@ -159,13 +159,13 @@ class TaskMapBuilder $tMap->addColumn('TAS_SELFSERVICE_EXECUTION', 'TasSelfserviceExecution', 'string', CreoleTypes::VARCHAR, false, 15); - $tMap->addValidator('TAS_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'NORMAL|ADHOC|SUBPROCESS|HIDDEN|GATEWAYTOGATEWAY|WEBENTRYEVENT|END-MESSAGE-EVENT|START-MESSAGE-EVENT|INTERMEDIATE-THROW-MESSAGE-EVENT|INTERMEDIATE-CATCH-MESSAGE-EVENT|SCRIPT-TASK|END-EMAIL-EVENT', 'Please enter a valid value for TAS_TYPE'); + $tMap->addValidator('TAS_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'NORMAL|ADHOC|SUBPROCESS|HIDDEN|GATEWAYTOGATEWAY|WEBENTRYEVENT|END-MESSAGE-EVENT|START-MESSAGE-EVENT|INTERMEDIATE-THROW-MESSAGE-EVENT|INTERMEDIATE-CATCH-MESSAGE-EVENT|SCRIPT-TASK|START-TIMER-EVENT|INTERMEDIATE-CATCH-TIMER-EVENT|END-EMAIL-EVENT', 'Please set a valid value for TAS_TYPE'); $tMap->addValidator('TAS_TIMEUNIT', 'validValues', 'propel.validator.ValidValuesValidator', 'MINUTES|HOURS|DAYS|WEEKS|MONTHS', 'Please select a valid value for TAS_TIMEUNIT.'); $tMap->addValidator('TAS_ALERT', 'validValues', 'propel.validator.ValidValuesValidator', 'TRUE|FALSE', 'Please select a valid value for TAS_ALERT.'); - $tMap->addValidator('TAS_ASSIGN_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'BALANCED|MANUAL|EVALUATE|REPORT_TO|SELF_SERVICE|STATIC_MI|CANCEL_MI', 'Please select a valid value for TAS_ASSIGN_TYPE.'); + $tMap->addValidator('TAS_ASSIGN_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'BALANCED|MANUAL|EVALUATE|REPORT_TO|SELF_SERVICE|STATIC_MI|CANCEL_MI', 'Please select a valid value for TAS_ASSIGN_TYPE.'); $tMap->addValidator('TAS_ASSIGN_LOCATION', 'validValues', 'propel.validator.ValidValuesValidator', 'TRUE|FALSE', 'Please select a valid value for TAS_ASSIGN_LOCATION.'); @@ -199,4 +199,4 @@ class TaskMapBuilder } // doBuild() -} // TaskMapBuilder \ No newline at end of file +} // TaskMapBuilder diff --git a/workflow/engine/classes/model/map/TimerEventMapBuilder.php b/workflow/engine/classes/model/map/TimerEventMapBuilder.php new file mode 100644 index 000000000..439bae621 --- /dev/null +++ b/workflow/engine/classes/model/map/TimerEventMapBuilder.php @@ -0,0 +1,102 @@ +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('TIMER_EVENT'); + $tMap->setPhpName('TimerEvent'); + + $tMap->setUseIdGenerator(false); + + $tMap->addPrimaryKey('TMREVN_UID', 'TmrevnUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('PRJ_UID', 'PrjUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('EVN_UID', 'EvnUid', 'string', CreoleTypes::VARCHAR, true, 32); + + $tMap->addColumn('TMREVN_OPTION', 'TmrevnOption', 'string', CreoleTypes::VARCHAR, true, 50); + + $tMap->addColumn('TMREVN_START_DATE', 'TmrevnStartDate', 'int', CreoleTypes::DATE, false, null); + + $tMap->addColumn('TMREVN_END_DATE', 'TmrevnEndDate', 'int', CreoleTypes::DATE, false, null); + + $tMap->addColumn('TMREVN_DAY', 'TmrevnDay', 'string', CreoleTypes::VARCHAR, true, 2); + + $tMap->addColumn('TMREVN_HOUR', 'TmrevnHour', 'string', CreoleTypes::VARCHAR, true, 2); + + $tMap->addColumn('TMREVN_MINUTE', 'TmrevnMinute', 'string', CreoleTypes::VARCHAR, true, 2); + + $tMap->addColumn('TMREVN_CONFIGURATION_DATA', 'TmrevnConfigurationData', 'string', CreoleTypes::LONGVARCHAR, true, null); + + $tMap->addColumn('TMREVN_NEXT_RUN_DATE', 'TmrevnNextRunDate', 'int', CreoleTypes::TIMESTAMP, false, null); + + $tMap->addColumn('TMREVN_LAST_RUN_DATE', 'TmrevnLastRunDate', 'int', CreoleTypes::TIMESTAMP, false, null); + + $tMap->addColumn('TMREVN_LAST_EXECUTION_DATE', 'TmrevnLastExecutionDate', 'int', CreoleTypes::TIMESTAMP, false, null); + + $tMap->addColumn('TMREVN_STATUS', 'TmrevnStatus', 'string', CreoleTypes::VARCHAR, true, 25); + + $tMap->addValidator('TMREVN_OPTION', 'validValues', 'propel.validator.ValidValuesValidator', 'HOURLY|DAILY|MONTHLY|EVERY|ONE-DATE-TIME|WAIT-FOR|WAIT-UNTIL-SPECIFIED-DATE-TIME', 'Please set a valid value for TMREVN_OPTION'); + + $tMap->addValidator('TMREVN_STATUS', 'validValues', 'propel.validator.ValidValuesValidator', 'ACTIVE|INACTIVE|PROCESSED', 'Please set a valid value for TMREVN_STATUS'); + + } // doBuild() + +} // TimerEventMapBuilder diff --git a/workflow/engine/classes/model/om/BaseTimerEvent.php b/workflow/engine/classes/model/om/BaseTimerEvent.php new file mode 100644 index 000000000..1ab7a9076 --- /dev/null +++ b/workflow/engine/classes/model/om/BaseTimerEvent.php @@ -0,0 +1,1404 @@ +tmrevn_uid; + } + + /** + * Get the [prj_uid] column value. + * + * @return string + */ + public function getPrjUid() + { + + return $this->prj_uid; + } + + /** + * Get the [evn_uid] column value. + * + * @return string + */ + public function getEvnUid() + { + + return $this->evn_uid; + } + + /** + * Get the [tmrevn_option] column value. + * + * @return string + */ + public function getTmrevnOption() + { + + return $this->tmrevn_option; + } + + /** + * Get the [optionally formatted] [tmrevn_start_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 getTmrevnStartDate($format = 'Y-m-d') + { + + if ($this->tmrevn_start_date === null || $this->tmrevn_start_date === '') { + return null; + } elseif (!is_int($this->tmrevn_start_date)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->tmrevn_start_date); + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse value of [tmrevn_start_date] as date/time value: " . + var_export($this->tmrevn_start_date, true)); + } + } else { + $ts = $this->tmrevn_start_date; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Get the [optionally formatted] [tmrevn_end_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 getTmrevnEndDate($format = 'Y-m-d') + { + + if ($this->tmrevn_end_date === null || $this->tmrevn_end_date === '') { + return null; + } elseif (!is_int($this->tmrevn_end_date)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->tmrevn_end_date); + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse value of [tmrevn_end_date] as date/time value: " . + var_export($this->tmrevn_end_date, true)); + } + } else { + $ts = $this->tmrevn_end_date; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Get the [tmrevn_day] column value. + * + * @return string + */ + public function getTmrevnDay() + { + + return $this->tmrevn_day; + } + + /** + * Get the [tmrevn_hour] column value. + * + * @return string + */ + public function getTmrevnHour() + { + + return $this->tmrevn_hour; + } + + /** + * Get the [tmrevn_minute] column value. + * + * @return string + */ + public function getTmrevnMinute() + { + + return $this->tmrevn_minute; + } + + /** + * Get the [tmrevn_configuration_data] column value. + * + * @return string + */ + public function getTmrevnConfigurationData() + { + + return $this->tmrevn_configuration_data; + } + + /** + * Get the [optionally formatted] [tmrevn_next_run_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 getTmrevnNextRunDate($format = 'Y-m-d H:i:s') + { + + if ($this->tmrevn_next_run_date === null || $this->tmrevn_next_run_date === '') { + return null; + } elseif (!is_int($this->tmrevn_next_run_date)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->tmrevn_next_run_date); + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse value of [tmrevn_next_run_date] as date/time value: " . + var_export($this->tmrevn_next_run_date, true)); + } + } else { + $ts = $this->tmrevn_next_run_date; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Get the [optionally formatted] [tmrevn_last_run_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 getTmrevnLastRunDate($format = 'Y-m-d H:i:s') + { + + if ($this->tmrevn_last_run_date === null || $this->tmrevn_last_run_date === '') { + return null; + } elseif (!is_int($this->tmrevn_last_run_date)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->tmrevn_last_run_date); + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse value of [tmrevn_last_run_date] as date/time value: " . + var_export($this->tmrevn_last_run_date, true)); + } + } else { + $ts = $this->tmrevn_last_run_date; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Get the [optionally formatted] [tmrevn_last_execution_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 getTmrevnLastExecutionDate($format = 'Y-m-d H:i:s') + { + + if ($this->tmrevn_last_execution_date === null || $this->tmrevn_last_execution_date === '') { + return null; + } elseif (!is_int($this->tmrevn_last_execution_date)) { + // a non-timestamp value was set externally, so we convert it + $ts = strtotime($this->tmrevn_last_execution_date); + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse value of [tmrevn_last_execution_date] as date/time value: " . + var_export($this->tmrevn_last_execution_date, true)); + } + } else { + $ts = $this->tmrevn_last_execution_date; + } + if ($format === null) { + return $ts; + } elseif (strpos($format, '%') !== false) { + return strftime($format, $ts); + } else { + return date($format, $ts); + } + } + + /** + * Get the [tmrevn_status] column value. + * + * @return string + */ + public function getTmrevnStatus() + { + + return $this->tmrevn_status; + } + + /** + * Set the value of [tmrevn_uid] column. + * + * @param string $v new value + * @return void + */ + public function setTmrevnUid($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->tmrevn_uid !== $v) { + $this->tmrevn_uid = $v; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_UID; + } + + } // setTmrevnUid() + + /** + * Set the value of [prj_uid] column. + * + * @param string $v new value + * @return void + */ + public function setPrjUid($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->prj_uid !== $v) { + $this->prj_uid = $v; + $this->modifiedColumns[] = TimerEventPeer::PRJ_UID; + } + + } // setPrjUid() + + /** + * Set the value of [evn_uid] column. + * + * @param string $v new value + * @return void + */ + public function setEvnUid($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->evn_uid !== $v) { + $this->evn_uid = $v; + $this->modifiedColumns[] = TimerEventPeer::EVN_UID; + } + + } // setEvnUid() + + /** + * Set the value of [tmrevn_option] column. + * + * @param string $v new value + * @return void + */ + public function setTmrevnOption($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->tmrevn_option !== $v || $v === 'DAILY') { + $this->tmrevn_option = $v; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_OPTION; + } + + } // setTmrevnOption() + + /** + * Set the value of [tmrevn_start_date] column. + * + * @param int $v new value + * @return void + */ + public function setTmrevnStartDate($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + //Date/time accepts null values + if ($v == '') { + $ts = null; + } + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse date/time value for [tmrevn_start_date] from input: " . + var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->tmrevn_start_date !== $ts) { + $this->tmrevn_start_date = $ts; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_START_DATE; + } + + } // setTmrevnStartDate() + + /** + * Set the value of [tmrevn_end_date] column. + * + * @param int $v new value + * @return void + */ + public function setTmrevnEndDate($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + //Date/time accepts null values + if ($v == '') { + $ts = null; + } + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse date/time value for [tmrevn_end_date] from input: " . + var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->tmrevn_end_date !== $ts) { + $this->tmrevn_end_date = $ts; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_END_DATE; + } + + } // setTmrevnEndDate() + + /** + * Set the value of [tmrevn_day] column. + * + * @param string $v new value + * @return void + */ + public function setTmrevnDay($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->tmrevn_day !== $v || $v === '') { + $this->tmrevn_day = $v; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_DAY; + } + + } // setTmrevnDay() + + /** + * Set the value of [tmrevn_hour] column. + * + * @param string $v new value + * @return void + */ + public function setTmrevnHour($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->tmrevn_hour !== $v || $v === '') { + $this->tmrevn_hour = $v; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_HOUR; + } + + } // setTmrevnHour() + + /** + * Set the value of [tmrevn_minute] column. + * + * @param string $v new value + * @return void + */ + public function setTmrevnMinute($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->tmrevn_minute !== $v || $v === '') { + $this->tmrevn_minute = $v; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_MINUTE; + } + + } // setTmrevnMinute() + + /** + * Set the value of [tmrevn_configuration_data] column. + * + * @param string $v new value + * @return void + */ + public function setTmrevnConfigurationData($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->tmrevn_configuration_data !== $v || $v === '') { + $this->tmrevn_configuration_data = $v; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_CONFIGURATION_DATA; + } + + } // setTmrevnConfigurationData() + + /** + * Set the value of [tmrevn_next_run_date] column. + * + * @param int $v new value + * @return void + */ + public function setTmrevnNextRunDate($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + //Date/time accepts null values + if ($v == '') { + $ts = null; + } + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse date/time value for [tmrevn_next_run_date] from input: " . + var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->tmrevn_next_run_date !== $ts) { + $this->tmrevn_next_run_date = $ts; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_NEXT_RUN_DATE; + } + + } // setTmrevnNextRunDate() + + /** + * Set the value of [tmrevn_last_run_date] column. + * + * @param int $v new value + * @return void + */ + public function setTmrevnLastRunDate($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + //Date/time accepts null values + if ($v == '') { + $ts = null; + } + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse date/time value for [tmrevn_last_run_date] from input: " . + var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->tmrevn_last_run_date !== $ts) { + $this->tmrevn_last_run_date = $ts; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_LAST_RUN_DATE; + } + + } // setTmrevnLastRunDate() + + /** + * Set the value of [tmrevn_last_execution_date] column. + * + * @param int $v new value + * @return void + */ + public function setTmrevnLastExecutionDate($v) + { + + if ($v !== null && !is_int($v)) { + $ts = strtotime($v); + //Date/time accepts null values + if ($v == '') { + $ts = null; + } + if ($ts === -1 || $ts === false) { + throw new PropelException("Unable to parse date/time value for [tmrevn_last_execution_date] from input: " . + var_export($v, true)); + } + } else { + $ts = $v; + } + if ($this->tmrevn_last_execution_date !== $ts) { + $this->tmrevn_last_execution_date = $ts; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_LAST_EXECUTION_DATE; + } + + } // setTmrevnLastExecutionDate() + + /** + * Set the value of [tmrevn_status] column. + * + * @param string $v new value + * @return void + */ + public function setTmrevnStatus($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->tmrevn_status !== $v || $v === 'ACTIVE') { + $this->tmrevn_status = $v; + $this->modifiedColumns[] = TimerEventPeer::TMREVN_STATUS; + } + + } // setTmrevnStatus() + + /** + * 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->tmrevn_uid = $rs->getString($startcol + 0); + + $this->prj_uid = $rs->getString($startcol + 1); + + $this->evn_uid = $rs->getString($startcol + 2); + + $this->tmrevn_option = $rs->getString($startcol + 3); + + $this->tmrevn_start_date = $rs->getDate($startcol + 4, null); + + $this->tmrevn_end_date = $rs->getDate($startcol + 5, null); + + $this->tmrevn_day = $rs->getString($startcol + 6); + + $this->tmrevn_hour = $rs->getString($startcol + 7); + + $this->tmrevn_minute = $rs->getString($startcol + 8); + + $this->tmrevn_configuration_data = $rs->getString($startcol + 9); + + $this->tmrevn_next_run_date = $rs->getTimestamp($startcol + 10, null); + + $this->tmrevn_last_run_date = $rs->getTimestamp($startcol + 11, null); + + $this->tmrevn_last_execution_date = $rs->getTimestamp($startcol + 12, null); + + $this->tmrevn_status = $rs->getString($startcol + 13); + + $this->resetModified(); + + $this->setNew(false); + + // FIXME - using NUM_COLUMNS may be clearer. + return $startcol + 14; // 14 = TimerEventPeer::NUM_COLUMNS - TimerEventPeer::NUM_LAZY_LOAD_COLUMNS). + + } catch (Exception $e) { + throw new PropelException("Error populating TimerEvent 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(TimerEventPeer::DATABASE_NAME); + } + + try { + $con->begin(); + TimerEventPeer::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(TimerEventPeer::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 = TimerEventPeer::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 += TimerEventPeer::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 = TimerEventPeer::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 = TimerEventPeer::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->getTmrevnUid(); + break; + case 1: + return $this->getPrjUid(); + break; + case 2: + return $this->getEvnUid(); + break; + case 3: + return $this->getTmrevnOption(); + break; + case 4: + return $this->getTmrevnStartDate(); + break; + case 5: + return $this->getTmrevnEndDate(); + break; + case 6: + return $this->getTmrevnDay(); + break; + case 7: + return $this->getTmrevnHour(); + break; + case 8: + return $this->getTmrevnMinute(); + break; + case 9: + return $this->getTmrevnConfigurationData(); + break; + case 10: + return $this->getTmrevnNextRunDate(); + break; + case 11: + return $this->getTmrevnLastRunDate(); + break; + case 12: + return $this->getTmrevnLastExecutionDate(); + break; + case 13: + return $this->getTmrevnStatus(); + 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 = TimerEventPeer::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getTmrevnUid(), + $keys[1] => $this->getPrjUid(), + $keys[2] => $this->getEvnUid(), + $keys[3] => $this->getTmrevnOption(), + $keys[4] => $this->getTmrevnStartDate(), + $keys[5] => $this->getTmrevnEndDate(), + $keys[6] => $this->getTmrevnDay(), + $keys[7] => $this->getTmrevnHour(), + $keys[8] => $this->getTmrevnMinute(), + $keys[9] => $this->getTmrevnConfigurationData(), + $keys[10] => $this->getTmrevnNextRunDate(), + $keys[11] => $this->getTmrevnLastRunDate(), + $keys[12] => $this->getTmrevnLastExecutionDate(), + $keys[13] => $this->getTmrevnStatus(), + ); + 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 = TimerEventPeer::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->setTmrevnUid($value); + break; + case 1: + $this->setPrjUid($value); + break; + case 2: + $this->setEvnUid($value); + break; + case 3: + $this->setTmrevnOption($value); + break; + case 4: + $this->setTmrevnStartDate($value); + break; + case 5: + $this->setTmrevnEndDate($value); + break; + case 6: + $this->setTmrevnDay($value); + break; + case 7: + $this->setTmrevnHour($value); + break; + case 8: + $this->setTmrevnMinute($value); + break; + case 9: + $this->setTmrevnConfigurationData($value); + break; + case 10: + $this->setTmrevnNextRunDate($value); + break; + case 11: + $this->setTmrevnLastRunDate($value); + break; + case 12: + $this->setTmrevnLastExecutionDate($value); + break; + case 13: + $this->setTmrevnStatus($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 = TimerEventPeer::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) { + $this->setTmrevnUid($arr[$keys[0]]); + } + + if (array_key_exists($keys[1], $arr)) { + $this->setPrjUid($arr[$keys[1]]); + } + + if (array_key_exists($keys[2], $arr)) { + $this->setEvnUid($arr[$keys[2]]); + } + + if (array_key_exists($keys[3], $arr)) { + $this->setTmrevnOption($arr[$keys[3]]); + } + + if (array_key_exists($keys[4], $arr)) { + $this->setTmrevnStartDate($arr[$keys[4]]); + } + + if (array_key_exists($keys[5], $arr)) { + $this->setTmrevnEndDate($arr[$keys[5]]); + } + + if (array_key_exists($keys[6], $arr)) { + $this->setTmrevnDay($arr[$keys[6]]); + } + + if (array_key_exists($keys[7], $arr)) { + $this->setTmrevnHour($arr[$keys[7]]); + } + + if (array_key_exists($keys[8], $arr)) { + $this->setTmrevnMinute($arr[$keys[8]]); + } + + if (array_key_exists($keys[9], $arr)) { + $this->setTmrevnConfigurationData($arr[$keys[9]]); + } + + if (array_key_exists($keys[10], $arr)) { + $this->setTmrevnNextRunDate($arr[$keys[10]]); + } + + if (array_key_exists($keys[11], $arr)) { + $this->setTmrevnLastRunDate($arr[$keys[11]]); + } + + if (array_key_exists($keys[12], $arr)) { + $this->setTmrevnLastExecutionDate($arr[$keys[12]]); + } + + if (array_key_exists($keys[13], $arr)) { + $this->setTmrevnStatus($arr[$keys[13]]); + } + + } + + /** + * 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(TimerEventPeer::DATABASE_NAME); + + if ($this->isColumnModified(TimerEventPeer::TMREVN_UID)) { + $criteria->add(TimerEventPeer::TMREVN_UID, $this->tmrevn_uid); + } + + if ($this->isColumnModified(TimerEventPeer::PRJ_UID)) { + $criteria->add(TimerEventPeer::PRJ_UID, $this->prj_uid); + } + + if ($this->isColumnModified(TimerEventPeer::EVN_UID)) { + $criteria->add(TimerEventPeer::EVN_UID, $this->evn_uid); + } + + if ($this->isColumnModified(TimerEventPeer::TMREVN_OPTION)) { + $criteria->add(TimerEventPeer::TMREVN_OPTION, $this->tmrevn_option); + } + + if ($this->isColumnModified(TimerEventPeer::TMREVN_START_DATE)) { + $criteria->add(TimerEventPeer::TMREVN_START_DATE, $this->tmrevn_start_date); + } + + if ($this->isColumnModified(TimerEventPeer::TMREVN_END_DATE)) { + $criteria->add(TimerEventPeer::TMREVN_END_DATE, $this->tmrevn_end_date); + } + + if ($this->isColumnModified(TimerEventPeer::TMREVN_DAY)) { + $criteria->add(TimerEventPeer::TMREVN_DAY, $this->tmrevn_day); + } + + if ($this->isColumnModified(TimerEventPeer::TMREVN_HOUR)) { + $criteria->add(TimerEventPeer::TMREVN_HOUR, $this->tmrevn_hour); + } + + if ($this->isColumnModified(TimerEventPeer::TMREVN_MINUTE)) { + $criteria->add(TimerEventPeer::TMREVN_MINUTE, $this->tmrevn_minute); + } + + if ($this->isColumnModified(TimerEventPeer::TMREVN_CONFIGURATION_DATA)) { + $criteria->add(TimerEventPeer::TMREVN_CONFIGURATION_DATA, $this->tmrevn_configuration_data); + } + + if ($this->isColumnModified(TimerEventPeer::TMREVN_NEXT_RUN_DATE)) { + $criteria->add(TimerEventPeer::TMREVN_NEXT_RUN_DATE, $this->tmrevn_next_run_date); + } + + if ($this->isColumnModified(TimerEventPeer::TMREVN_LAST_RUN_DATE)) { + $criteria->add(TimerEventPeer::TMREVN_LAST_RUN_DATE, $this->tmrevn_last_run_date); + } + + if ($this->isColumnModified(TimerEventPeer::TMREVN_LAST_EXECUTION_DATE)) { + $criteria->add(TimerEventPeer::TMREVN_LAST_EXECUTION_DATE, $this->tmrevn_last_execution_date); + } + + if ($this->isColumnModified(TimerEventPeer::TMREVN_STATUS)) { + $criteria->add(TimerEventPeer::TMREVN_STATUS, $this->tmrevn_status); + } + + + 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(TimerEventPeer::DATABASE_NAME); + + $criteria->add(TimerEventPeer::TMREVN_UID, $this->tmrevn_uid); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return string + */ + public function getPrimaryKey() + { + return $this->getTmrevnUid(); + } + + /** + * Generic method to set the primary key (tmrevn_uid column). + * + * @param string $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setTmrevnUid($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 TimerEvent (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->setPrjUid($this->prj_uid); + + $copyObj->setEvnUid($this->evn_uid); + + $copyObj->setTmrevnOption($this->tmrevn_option); + + $copyObj->setTmrevnStartDate($this->tmrevn_start_date); + + $copyObj->setTmrevnEndDate($this->tmrevn_end_date); + + $copyObj->setTmrevnDay($this->tmrevn_day); + + $copyObj->setTmrevnHour($this->tmrevn_hour); + + $copyObj->setTmrevnMinute($this->tmrevn_minute); + + $copyObj->setTmrevnConfigurationData($this->tmrevn_configuration_data); + + $copyObj->setTmrevnNextRunDate($this->tmrevn_next_run_date); + + $copyObj->setTmrevnLastRunDate($this->tmrevn_last_run_date); + + $copyObj->setTmrevnLastExecutionDate($this->tmrevn_last_execution_date); + + $copyObj->setTmrevnStatus($this->tmrevn_status); + + + $copyObj->setNew(true); + + $copyObj->setTmrevnUid(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 TimerEvent 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 TimerEventPeer + */ + public function getPeer() + { + if (self::$peer === null) { + self::$peer = new TimerEventPeer(); + } + return self::$peer; + } +} + diff --git a/workflow/engine/classes/model/om/BaseTimerEventPeer.php b/workflow/engine/classes/model/om/BaseTimerEventPeer.php new file mode 100644 index 000000000..70999068c --- /dev/null +++ b/workflow/engine/classes/model/om/BaseTimerEventPeer.php @@ -0,0 +1,638 @@ + array ('TmrevnUid', 'PrjUid', 'EvnUid', 'TmrevnOption', 'TmrevnStartDate', 'TmrevnEndDate', 'TmrevnDay', 'TmrevnHour', 'TmrevnMinute', 'TmrevnConfigurationData', 'TmrevnNextRunDate', 'TmrevnLastRunDate', 'TmrevnLastExecutionDate', 'TmrevnStatus', ), + BasePeer::TYPE_COLNAME => array (TimerEventPeer::TMREVN_UID, TimerEventPeer::PRJ_UID, TimerEventPeer::EVN_UID, TimerEventPeer::TMREVN_OPTION, TimerEventPeer::TMREVN_START_DATE, TimerEventPeer::TMREVN_END_DATE, TimerEventPeer::TMREVN_DAY, TimerEventPeer::TMREVN_HOUR, TimerEventPeer::TMREVN_MINUTE, TimerEventPeer::TMREVN_CONFIGURATION_DATA, TimerEventPeer::TMREVN_NEXT_RUN_DATE, TimerEventPeer::TMREVN_LAST_RUN_DATE, TimerEventPeer::TMREVN_LAST_EXECUTION_DATE, TimerEventPeer::TMREVN_STATUS, ), + BasePeer::TYPE_FIELDNAME => array ('TMREVN_UID', 'PRJ_UID', 'EVN_UID', 'TMREVN_OPTION', 'TMREVN_START_DATE', 'TMREVN_END_DATE', 'TMREVN_DAY', 'TMREVN_HOUR', 'TMREVN_MINUTE', 'TMREVN_CONFIGURATION_DATA', 'TMREVN_NEXT_RUN_DATE', 'TMREVN_LAST_RUN_DATE', 'TMREVN_LAST_EXECUTION_DATE', 'TMREVN_STATUS', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + ); + + /** + * 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 ('TmrevnUid' => 0, 'PrjUid' => 1, 'EvnUid' => 2, 'TmrevnOption' => 3, 'TmrevnStartDate' => 4, 'TmrevnEndDate' => 5, 'TmrevnDay' => 6, 'TmrevnHour' => 7, 'TmrevnMinute' => 8, 'TmrevnConfigurationData' => 9, 'TmrevnNextRunDate' => 10, 'TmrevnLastRunDate' => 11, 'TmrevnLastExecutionDate' => 12, 'TmrevnStatus' => 13, ), + BasePeer::TYPE_COLNAME => array (TimerEventPeer::TMREVN_UID => 0, TimerEventPeer::PRJ_UID => 1, TimerEventPeer::EVN_UID => 2, TimerEventPeer::TMREVN_OPTION => 3, TimerEventPeer::TMREVN_START_DATE => 4, TimerEventPeer::TMREVN_END_DATE => 5, TimerEventPeer::TMREVN_DAY => 6, TimerEventPeer::TMREVN_HOUR => 7, TimerEventPeer::TMREVN_MINUTE => 8, TimerEventPeer::TMREVN_CONFIGURATION_DATA => 9, TimerEventPeer::TMREVN_NEXT_RUN_DATE => 10, TimerEventPeer::TMREVN_LAST_RUN_DATE => 11, TimerEventPeer::TMREVN_LAST_EXECUTION_DATE => 12, TimerEventPeer::TMREVN_STATUS => 13, ), + BasePeer::TYPE_FIELDNAME => array ('TMREVN_UID' => 0, 'PRJ_UID' => 1, 'EVN_UID' => 2, 'TMREVN_OPTION' => 3, 'TMREVN_START_DATE' => 4, 'TMREVN_END_DATE' => 5, 'TMREVN_DAY' => 6, 'TMREVN_HOUR' => 7, 'TMREVN_MINUTE' => 8, 'TMREVN_CONFIGURATION_DATA' => 9, 'TMREVN_NEXT_RUN_DATE' => 10, 'TMREVN_LAST_RUN_DATE' => 11, 'TMREVN_LAST_EXECUTION_DATE' => 12, 'TMREVN_STATUS' => 13, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) + ); + + /** + * @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/TimerEventMapBuilder.php'; + return BasePeer::getMapBuilder('classes.model.map.TimerEventMapBuilder'); + } + /** + * 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 = TimerEventPeer::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. TimerEventPeer::COLUMN_NAME). + * @return string + */ + public static function alias($alias, $column) + { + return str_replace(TimerEventPeer::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(TimerEventPeer::TMREVN_UID); + + $criteria->addSelectColumn(TimerEventPeer::PRJ_UID); + + $criteria->addSelectColumn(TimerEventPeer::EVN_UID); + + $criteria->addSelectColumn(TimerEventPeer::TMREVN_OPTION); + + $criteria->addSelectColumn(TimerEventPeer::TMREVN_START_DATE); + + $criteria->addSelectColumn(TimerEventPeer::TMREVN_END_DATE); + + $criteria->addSelectColumn(TimerEventPeer::TMREVN_DAY); + + $criteria->addSelectColumn(TimerEventPeer::TMREVN_HOUR); + + $criteria->addSelectColumn(TimerEventPeer::TMREVN_MINUTE); + + $criteria->addSelectColumn(TimerEventPeer::TMREVN_CONFIGURATION_DATA); + + $criteria->addSelectColumn(TimerEventPeer::TMREVN_NEXT_RUN_DATE); + + $criteria->addSelectColumn(TimerEventPeer::TMREVN_LAST_RUN_DATE); + + $criteria->addSelectColumn(TimerEventPeer::TMREVN_LAST_EXECUTION_DATE); + + $criteria->addSelectColumn(TimerEventPeer::TMREVN_STATUS); + + } + + const COUNT = 'COUNT(TIMER_EVENT.TMREVN_UID)'; + const COUNT_DISTINCT = 'COUNT(DISTINCT TIMER_EVENT.TMREVN_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(TimerEventPeer::COUNT_DISTINCT); + } else { + $criteria->addSelectColumn(TimerEventPeer::COUNT); + } + + // just in case we're grouping: add those columns to the select statement + foreach ($criteria->getGroupByColumns() as $column) { + $criteria->addSelectColumn($column); + } + + $rs = TimerEventPeer::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 TimerEvent + * @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 = TimerEventPeer::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 TimerEventPeer::populateObjects(TimerEventPeer::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; + TimerEventPeer::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 = TimerEventPeer::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 TimerEventPeer::CLASS_DEFAULT; + } + + /** + * Method perform an INSERT on the database, given a TimerEvent or Criteria object. + * + * @param mixed $values Criteria or TimerEvent 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 TimerEvent 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 TimerEvent or Criteria object. + * + * @param mixed $values Criteria or TimerEvent 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(TimerEventPeer::TMREVN_UID); + $selectCriteria->add(TimerEventPeer::TMREVN_UID, $criteria->remove(TimerEventPeer::TMREVN_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 TIMER_EVENT 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(TimerEventPeer::TABLE_NAME, $con); + $con->commit(); + return $affectedRows; + } catch (PropelException $e) { + $con->rollback(); + throw $e; + } + } + + /** + * Method perform a DELETE on the database, given a TimerEvent or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or TimerEvent 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(TimerEventPeer::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + $criteria = clone $values; // rename for clarity + } elseif ($values instanceof TimerEvent) { + + $criteria = $values->buildPkeyCriteria(); + } else { + // it must be the primary key + $criteria = new Criteria(self::DATABASE_NAME); + $criteria->add(TimerEventPeer::TMREVN_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 TimerEvent 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 TimerEvent $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(TimerEvent $obj, $cols = null) + { + $columns = array(); + + if ($cols) { + $dbMap = Propel::getDatabaseMap(TimerEventPeer::DATABASE_NAME); + $tableMap = $dbMap->getTable(TimerEventPeer::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 { + + if ($obj->isNew() || $obj->isColumnModified(TimerEventPeer::TMREVN_OPTION)) + $columns[TimerEventPeer::TMREVN_OPTION] = $obj->getTmrevnOption(); + + if ($obj->isNew() || $obj->isColumnModified(TimerEventPeer::TMREVN_STATUS)) + $columns[TimerEventPeer::TMREVN_STATUS] = $obj->getTmrevnStatus(); + + } + + return BasePeer::doValidate(TimerEventPeer::DATABASE_NAME, TimerEventPeer::TABLE_NAME, $columns); + } + + /** + * Retrieve a single object by pkey. + * + * @param mixed $pk the primary key. + * @param Connection $con the connection to use + * @return TimerEvent + */ + public static function retrieveByPK($pk, $con = null) + { + if ($con === null) { + $con = Propel::getConnection(self::DATABASE_NAME); + } + + $criteria = new Criteria(TimerEventPeer::DATABASE_NAME); + + $criteria->add(TimerEventPeer::TMREVN_UID, $pk); + + + $v = TimerEventPeer::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(TimerEventPeer::TMREVN_UID, $pks, Criteria::IN); + $objs = TimerEventPeer::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 { + BaseTimerEventPeer::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/TimerEventMapBuilder.php'; + Propel::registerMapBuilder('classes.model.map.TimerEventMapBuilder'); +} + diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index 01157d37f..a6cd512d7 100755 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -1,5084 +1,5119 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - -
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
- + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ @@ -5099,5 +5134,6 @@ -
-
\ No newline at end of file + + + diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index 64148c412..631abf018 100755 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -2833,7 +2833,9 @@ CREATE TABLE `CATALOG` #----------------------------------------------------------------------------- #-- TABLE: SCRIPT_TASK #----------------------------------------------------------------------------- + DROP TABLE IF EXISTS SCRIPT_TASK; + CREATE TABLE SCRIPT_TASK ( SCRTAS_UID VARCHAR(32) NOT NULL, @@ -2845,6 +2847,32 @@ CREATE TABLE SCRIPT_TASK PRIMARY KEY (SCRTAS_UID) )ENGINE=InnoDB DEFAULT CHARSET='utf8'; +#----------------------------------------------------------------------------- +#-- TIMER_EVENT +#----------------------------------------------------------------------------- + +DROP TABLE IF EXISTS TIMER_EVENT; + +CREATE TABLE TIMER_EVENT +( + TMREVN_UID VARCHAR(32) NOT NULL, + PRJ_UID VARCHAR(32) NOT NULL, + EVN_UID VARCHAR(32) NOT NULL, + TMREVN_OPTION VARCHAR(50) default 'DAILY' NOT NULL, + TMREVN_START_DATE DATE, + TMREVN_END_DATE DATE, + TMREVN_DAY VARCHAR(2) default '' NOT NULL, + TMREVN_HOUR VARCHAR(2) default '' NOT NULL, + TMREVN_MINUTE VARCHAR(2) default '' NOT NULL, + TMREVN_CONFIGURATION_DATA MEDIUMTEXT default '' NOT NULL, + TMREVN_NEXT_RUN_DATE DATETIME, + TMREVN_LAST_RUN_DATE DATETIME, + TMREVN_LAST_EXECUTION_DATE DATETIME, + TMREVN_STATUS VARCHAR(25) default 'ACTIVE' NOT NULL, + + PRIMARY KEY (TMREVN_UID) +)ENGINE=InnoDB DEFAULT CHARSET='utf8'; + #----------------------------------------------------------------------------- #-- EMAIL_EVENT #----------------------------------------------------------------------------- @@ -2860,7 +2888,8 @@ CREATE TABLE `EMAIL_EVENT` `EMAIL_EVENT_SUBJECT` VARCHAR(150) default '' NOT NULL, `PRF_UID` VARCHAR(32) default '' NOT NULL, PRIMARY KEY (`EMAIL_EVENT_UID`) -)ENGINE=InnoDB DEFAULT CHARSET='utf8'; +)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/methods/cases/cases_Step.php b/workflow/engine/methods/cases/cases_Step.php index 1e42bf69e..9b273a682 100755 --- a/workflow/engine/methods/cases/cases_Step.php +++ b/workflow/engine/methods/cases/cases_Step.php @@ -760,7 +760,7 @@ try { } //set priority value - $sTask = $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_UID']; + //$sTask = $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_UID']; //TAS_UID has a hidden field to store the TAS_UID $hiddenName = "form[TASKS][" . $sKey . "][TAS_UID]"; $hiddenField = ''; @@ -893,7 +893,10 @@ try { switch ($optionTaskType) { case "SCRIPT-TASK": - $aFields["TASK"][$sKey]["NEXT_TASK"]["USR_UID"] = G::LoadTranslation("ID_ROUTE_TO_TASK_SCRIPT_TASK");; + $aFields["TASK"][$sKey]["NEXT_TASK"]["USR_UID"] = G::LoadTranslation("ID_ROUTE_TO_TASK_SCRIPT_TASK"); + break; + case "INTERMEDIATE-CATCH-TIMER-EVENT": + $aFields["TASK"][$sKey]["NEXT_TASK"]["USR_UID"] = G::LoadTranslation("ID_ROUTE_TO_TASK_INTERMEDIATE_CATCH_TIMER_EVENT"); break; } @@ -967,6 +970,7 @@ try { $aFields['TASK'][$sKey]['NEXT_TASK']['TAS_PARENT'] = ''; } } + $aFields['PROCESSING_MESSAGE'] = G::loadTranslation( 'ID_PROCESSING' ); /** @@ -1107,3 +1111,4 @@ if ($_SESSION['TRIGGER_DEBUG']['ISSET']) { showdebug(); }' ); } + diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/TimerEvent.php b/workflow/engine/src/ProcessMaker/BusinessModel/TimerEvent.php new file mode 100644 index 000000000..a7d17932b --- /dev/null +++ b/workflow/engine/src/ProcessMaker/BusinessModel/TimerEvent.php @@ -0,0 +1,1073 @@ + array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventUid"), + + "EVN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "eventUid"), + "TMREVN_OPTION" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("HOURLY", "DAILY", "MONTHLY", "EVERY", "ONE-DATE-TIME", "WAIT-FOR", "WAIT-UNTIL-SPECIFIED-DATE-TIME"), "fieldNameAux" => "timerEventOption"), + "TMREVN_START_DATE" => array("type" => "date", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "timerEventStartDate"), + "TMREVN_END_DATE" => array("type" => "date", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "timerEventEndDate"), + "TMREVN_DAY" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "timerEventDay"), + "TMREVN_HOUR" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "timerEventHour"), + "TMREVN_MINUTE" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "timerEventMinute"), + "TMREVN_CONFIGURATION_DATA" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "timerEventConfigurationData"), + "TMREVN_NEXT_RUN_DATE" => array("type" => "datetime", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "timerEventNextRunDate"), + "TMREVN_STATUS" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("ACTIVE", "INACTIVE", "PROCESSED"), "fieldNameAux" => "timerEventStatus") + ); + + private $formatFieldNameInUppercase = true; + + private $arrayFieldNameForException = array( + "projectUid" => "PRJ_UID" + ); + + /** + * Constructor of the class + * + * return void + */ + public function __construct() + { + try { + foreach ($this->arrayFieldDefinition as $key => $value) { + $this->arrayFieldNameForException[$value["fieldNameAux"]] = $key; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set the format of the fields name (uppercase, lowercase) + * + * @param bool $flag Value that set the format + * + * return void + */ + public function setFormatFieldNameInUppercase($flag) + { + try { + $this->formatFieldNameInUppercase = $flag; + + $this->setArrayFieldNameForException($this->arrayFieldNameForException); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set exception messages for fields + * + * @param array $arrayData Data with the fields + * + * return void + */ + public function setArrayFieldNameForException(array $arrayData) + { + try { + foreach ($arrayData as $key => $value) { + $this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get the name of the field according to the format + * + * @param string $fieldName Field name + * + * return string Return the field name according the format + */ + public function getFieldNameByFormatFieldName($fieldName) + { + try { + return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get year, month, day, hour, minute and second by datetime + * + * @param string $datetime Datetime (yyyy-mm-dd hh:ii:ss) + * + * return array Return data + */ + public function getYearMonthDayHourMinuteSecondByDatetime($datetime) + { + try { + $arrayData = array(); + + if (preg_match("/^(\d{4})\-(\d{2})\-(\d{2})(?:\s(\d{2})\:(\d{2})\:(\d{2}))?$/", $datetime, $arrayMatch)) { + $arrayData[] = $arrayMatch[1]; //Year + $arrayData[] = $arrayMatch[2]; //Month + $arrayData[] = $arrayMatch[3]; //Day + $arrayData[] = (isset($arrayMatch[4]))? $arrayMatch[4] : "00"; //Hour + $arrayData[] = (isset($arrayMatch[4]))? $arrayMatch[5] : "00"; //Minute + $arrayData[] = (isset($arrayMatch[4]))? $arrayMatch[6] : "00"; //Second + } + + //Return + return $arrayData; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get valid Next Run Date + * + * @param array $arrayTimerEventData Timer-Event data + * @param string $datetime Datetime + * @param bool $flagIncludeDatetime Flag + * + * return string Return the valid Next Run Date + */ + public function getValidNextRunDateByDataAndDatetime(array $arrayTimerEventData, $datetime, $flagIncludeDatetime = true) + { + try { + $nextRunDate = $datetime; + + //Get Next Run Date + list($year, $month, $day, $hour, $minute, $second) = $this->getYearMonthDayHourMinuteSecondByDatetime($datetime); + + $arrayMonthsShort = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); + $arrayWeekdays = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); + + switch ($arrayTimerEventData["TMREVN_OPTION"]) { + case "HOURLY": + $hhmmss = "$hour:" . $arrayTimerEventData["TMREVN_MINUTE"] . ":00"; + + $nextRunDate = "$year-$month-$day $hhmmss"; + + if (!$flagIncludeDatetime) { + $nextRunDate = date("Y-m-d H:i:s", strtotime("$nextRunDate +1 hour")); + } + break; + case "DAILY": + $hhmmss = $arrayTimerEventData["TMREVN_HOUR"] . ":" . $arrayTimerEventData["TMREVN_MINUTE"] . ":00"; + + $arrayWeekdaysData = $arrayTimerEventData["TMREVN_CONFIGURATION_DATA"]; + + if (!empty($arrayWeekdaysData)) { + sort($arrayWeekdaysData); + + $weekday = (int)(date("w", strtotime($datetime))); + $weekday = ($weekday == 0)? 7 : $weekday; + + $firstWeekday = (int)($arrayWeekdaysData[0]); + + $nextWeekday = $firstWeekday; + $typeStatement = "this"; + $flag = false; + + foreach ($arrayWeekdaysData as $value) { + $d = (int)($value); + + if (($flagIncludeDatetime && $d >= $weekday) || (!$flagIncludeDatetime && $d > $weekday)) { + $nextWeekday = $d; + $flag = true; + break; + } + } + + if (!$flag) { + $typeStatement = "next"; + } + + $nextRunDate = date("Y-m-d", strtotime("$year-$month-$day $typeStatement " . $arrayWeekdays[$nextWeekday - 1])) . " $hhmmss"; + } else { + $nextRunDate = "$year-$month-$day $hhmmss"; + + if (!$flagIncludeDatetime) { + $nextRunDate = date("Y-m-d", strtotime("$nextRunDate +1 day")) . " $hhmmss"; + } + } + break; + case "MONTHLY": + $hhmmss = $arrayTimerEventData["TMREVN_HOUR"] . ":" . $arrayTimerEventData["TMREVN_MINUTE"] . ":00"; + + $arrayMonthsData = $arrayTimerEventData["TMREVN_CONFIGURATION_DATA"]; + + if (!empty($arrayMonthsData)) { + sort($arrayMonthsData); + + $firstMonth = (int)($arrayMonthsData[0]); + + $nextMonth = $firstMonth; + $flag = false; + + foreach ($arrayMonthsData as $value) { + $m = (int)($value); + + if (($flagIncludeDatetime && $m >= $month) || (!$flagIncludeDatetime && $m > $month)) { + $nextMonth = $m; + $flag = true; + break; + } + } + + if (!$flag) { + $year++; + } + + if (checkdate((int)($nextMonth), (int)($arrayTimerEventData["TMREVN_DAY"]), (int)($year))) { + $nextRunDate = "$year-$nextMonth-" . $arrayTimerEventData["TMREVN_DAY"] . " $hhmmss"; + } else { + $nextRunDate = date("Y-m-d", strtotime("last day of " . $arrayMonthsShort[((int)($nextMonth)) - 1] . " $year")) . " $hhmmss"; + } + } else { + if (checkdate((int)($month), (int)($arrayTimerEventData["TMREVN_DAY"]), (int)($year))) { + $nextRunDate = "$year-$month-" . $arrayTimerEventData["TMREVN_DAY"] . " $hhmmss"; + } else { + $nextRunDate = date("Y-m-d", strtotime("last day of " . $arrayMonthsShort[((int)($month)) - 1] . " $year")) . " $hhmmss"; + } + + if (!$flagIncludeDatetime) { + list($yearAux, $monthAux) = $this->getYearMonthDayHourMinuteSecondByDatetime(date("Y-m-d", strtotime("$year-$month-01 next month"))); + + if (checkdate((int)($monthAux), (int)($arrayTimerEventData["TMREVN_DAY"]), (int)($yearAux))) { + $nextRunDate = "$yearAux-$monthAux-" . $arrayTimerEventData["TMREVN_DAY"] . " $hhmmss"; + } else { + $nextRunDate = date("Y-m-d", strtotime("last day of " . $arrayMonthsShort[((int)($monthAux)) - 1] . " $yearAux")) . " $hhmmss"; + } + } + } + break; + case "EVERY": + if ($arrayTimerEventData["TMREVN_HOUR"] . "" != "") { + $nextRunDate = date("Y-m-d H:i:s", strtotime("$nextRunDate +" . ((int)($arrayTimerEventData["TMREVN_HOUR"])) . " hours")); + } + + if ($arrayTimerEventData["TMREVN_MINUTE"] . "" != "") { + $nextRunDate = date("Y-m-d H:i:s", strtotime("$nextRunDate +" . ((int)($arrayTimerEventData["TMREVN_MINUTE"])) . " minutes")); + } + break; + } + + //Return + return $nextRunDate; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get Next Run Date + * + * @param array $arrayTimerEventData Timer-Event data + * @param string $datetime Datetime + * @param bool $flagIncludeDatetime Flag + * + * return string Return the Next Run Date + */ + public function getNextRunDateByDataAndDatetime(array $arrayTimerEventData, $datetime, $flagIncludeDatetime = true) + { + try { + $nextRunDate = $datetime; + + //Get Next Run Date + if (!is_array($arrayTimerEventData["TMREVN_CONFIGURATION_DATA"])) { + $arrayTimerEventData["TMREVN_CONFIGURATION_DATA"] = unserialize($arrayTimerEventData["TMREVN_CONFIGURATION_DATA"]); + } + + $timeDatetime = strtotime($datetime); + + $flagNextRunDate = true; + + switch ($arrayTimerEventData["TMREVN_OPTION"]) { + case "HOURLY": + case "DAILY": + case "MONTHLY": + //case "EVERY": + $nextRunDate = $this->getValidNextRunDateByDataAndDatetime($arrayTimerEventData, $arrayTimerEventData["TMREVN_START_DATE"] . " 00:00:00", $flagIncludeDatetime); + $timeNextRunDate = strtotime($nextRunDate); + + if ($timeNextRunDate > $timeDatetime) { + $flagNextRunDate = false; + } + break; + } + + if ($flagNextRunDate) { + switch ($arrayTimerEventData["TMREVN_OPTION"]) { + case "HOURLY": + case "DAILY": + case "MONTHLY": + case "EVERY": + $nextRunDate = $this->getValidNextRunDateByDataAndDatetime($arrayTimerEventData, $datetime, $flagIncludeDatetime); + $timeNextRunDate = strtotime($nextRunDate); + + if ($timeNextRunDate < $timeDatetime) { + $nextRunDate = $this->getValidNextRunDateByDataAndDatetime($arrayTimerEventData, $datetime, false); + } + break; + } + } + + //Return + return $nextRunDate; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the Timer-Event + * + * @param string $timerEventUid Unique id of Timer-Event + * + * return bool Return true if exists the Timer-Event, false otherwise + */ + public function exists($timerEventUid) + { + try { + $obj = \TimerEventPeer::retrieveByPK($timerEventUid); + + return (!is_null($obj))? true : false; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the Event of a Timer-Event + * + * @param string $projectUid Unique id of Project + * @param string $eventUid Unique id of Event + * @param string $timerEventUidToExclude Unique id of Timer-Event to exclude + * + * return bool Return true if exists the Event of a Timer-Event, false otherwise + */ + public function existsEvent($projectUid, $eventUid, $timerEventUidToExclude = "") + { + try { + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_UID); + $criteria->add(\TimerEventPeer::PRJ_UID, $projectUid, \Criteria::EQUAL); + + if ($timerEventUidToExclude != "") { + $criteria->add(\TimerEventPeer::TMREVN_UID, $timerEventUidToExclude, \Criteria::NOT_EQUAL); + } + + $criteria->add(\TimerEventPeer::EVN_UID, $eventUid, \Criteria::EQUAL); + + $rsCriteria = \TimerEventPeer::doSelectRS($criteria); + + return ($rsCriteria->next())? true : false; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if does not exists the Timer-Event + * + * @param string $timerEventUid Unique id of Timer-Event + * @param string $fieldNameForException Field name for the exception + * + * return void Throw exception if does not exists the Timer-Event + */ + public function throwExceptionIfNotExistsTimerEvent($timerEventUid, $fieldNameForException) + { + try { + if (!$this->exists($timerEventUid)) { + throw new \Exception(\G::LoadTranslation("ID_TIMER_EVENT_DOES_NOT_EXIST", array($fieldNameForException, $timerEventUid))); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if is registered the Event + * + * @param string $projectUid Unique id of Project + * @param string $eventUid Unique id of Event + * @param string $fieldNameForException Field name for the exception + * @param string $timerEventUidToExclude Unique id of Timer-Event to exclude + * + * return void Throw exception if is registered the Event + */ + public function throwExceptionIfEventIsRegistered($projectUid, $eventUid, $fieldNameForException, $timerEventUidToExclude = "") + { + try { + if ($this->existsEvent($projectUid, $eventUid, $timerEventUidToExclude)) { + throw new \Exception(\G::LoadTranslation("ID_TIMER_EVENT_ALREADY_REGISTERED", array($fieldNameForException, $eventUid))); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Validate the data if they are invalid (INSERT and UPDATE) + * + * @param string $timerEventUid Unique id of Timer-Event + * @param string $projectUid Unique id of Project + * @param array $arrayData Data + * + * return void Throw exception if data has an invalid value + */ + public function throwExceptionIfDataIsInvalid($timerEventUid, $projectUid, array $arrayData) + { + try { + //Set variables + $arrayTimerEventData = ($timerEventUid == "")? array() : $this->getTimerEvent($timerEventUid, true); + $flagInsert = ($timerEventUid == "")? true : false; + + $arrayFinalData = array_merge($arrayTimerEventData, $arrayData); + + //Verify data - Field definition + $process = new \ProcessMaker\BusinessModel\Process(); + + $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert); + + //Verify data + if (isset($arrayData["EVN_UID"])) { + $arrayEventType = array("START", "INTERMEDIATE"); + $arrayEventMarker = array("TIMER"); + + $bpmnEvent = \BpmnEventPeer::retrieveByPK($arrayData["EVN_UID"]); + + if (is_null($bpmnEvent)) { + throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_EXIST", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"]))); + } + + if (!in_array($bpmnEvent->getEvnType(), $arrayEventType) || !in_array($bpmnEvent->getEvnMarker(), $arrayEventMarker)) { + throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_IS_TIMER_EVENT", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"]))); + } + + if ($bpmnEvent->getPrjUid() != $projectUid) { + throw new \Exception(\G::LoadTranslation("ID_EVENT_EVENT_NOT_BELONG_TO_PROJECT", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"], $this->arrayFieldNameForException["projectUid"], $projectUid))); + } + + $this->throwExceptionIfEventIsRegistered($projectUid, $arrayData["EVN_UID"], $this->arrayFieldNameForException["eventUid"], $timerEventUid); + } + + //Verify data - Field definition + $arrayFieldDefinition = array(); + + $bpmnEvent = \BpmnEventPeer::retrieveByPK($arrayFinalData["EVN_UID"]); + + switch ($bpmnEvent->getEvnType()) { + case "START": + $arrayFieldDefinition = array( + "TMREVN_OPTION" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("HOURLY", "DAILY", "MONTHLY", "EVERY", "ONE-DATE-TIME"), "fieldNameAux" => "timerEventOption") + ); + break; + case "INTERMEDIATE": + $arrayFieldDefinition = array( + "TMREVN_OPTION" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("WAIT-FOR", "WAIT-UNTIL-SPECIFIED-DATE-TIME"), "fieldNameAux" => "timerEventOption") + ); + break; + } + + if (!empty($arrayFieldDefinition)) { + $process->throwExceptionIfDataNotMetFieldDefinition($arrayFinalData, $arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert); + } + + $arrayFieldDefinition = array(); + + switch ($arrayFinalData["TMREVN_OPTION"]) { + case "HOURLY": + $arrayFieldDefinition = array( + "TMREVN_START_DATE" => array("type" => "date", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventStartDate"), + "TMREVN_END_DATE" => array("type" => "date", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "timerEventEndDate"), + "TMREVN_MINUTE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventMinute") + ); + break; + case "DAILY": + $arrayFieldDefinition = array( + "TMREVN_START_DATE" => array("type" => "date", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventStartDate"), + "TMREVN_END_DATE" => array("type" => "date", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "timerEventEndDate"), + "TMREVN_HOUR" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventHour"), + "TMREVN_MINUTE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventMinute"), + "TMREVN_CONFIGURATION_DATA" => array("type" => "array", "required" => false, "empty" => true, "defaultValues" => array(1, 2, 3, 4, 5, 6, 7), "fieldNameAux" => "timerEventConfigurationData") + ); + break; + case "MONTHLY": + $arrayFieldDefinition = array( + "TMREVN_START_DATE" => array("type" => "date", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventStartDate"), + "TMREVN_END_DATE" => array("type" => "date", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "timerEventEndDate"), + "TMREVN_DAY" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventDay"), + "TMREVN_HOUR" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventHour"), + "TMREVN_MINUTE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventMinute"), + "TMREVN_CONFIGURATION_DATA" => array("type" => "array", "required" => false, "empty" => true, "defaultValues" => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), "fieldNameAux" => "timerEventConfigurationData") + ); + break; + case "EVERY": + $arrayFieldDefinition = array( + "TMREVN_HOUR" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventHour"), + "TMREVN_MINUTE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventMinute") + ); + break; + case "ONE-DATE-TIME": + $arrayFieldDefinition = array( + "TMREVN_NEXT_RUN_DATE" => array("type" => "datetime", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventNextRunDate") + ); + break; + case "WAIT-FOR": + //TMREVN_DAY + //TMREVN_HOUR + //TMREVN_MINUTE + break; + case "WAIT-UNTIL-SPECIFIED-DATE-TIME": + $arrayFieldDefinition = array( + "TMREVN_CONFIGURATION_DATA" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "timerEventConfigurationData") + ); + break; + } + + if (!empty($arrayFieldDefinition)) { + $process->throwExceptionIfDataNotMetFieldDefinition($arrayFinalData, $arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert); + } + + $arrayValidateData = array( + "TMREVN_DAY" => array("/^(?:[0-2]\d|3[01])$/", $this->arrayFieldNameForException["timerEventDay"]), + "TMREVN_HOUR" => array("/^(?:[0-1]\d|2[0-3])$/", $this->arrayFieldNameForException["timerEventHour"]), + "TMREVN_MINUTE" => array("/^(?:[0-5]\d)$/", $this->arrayFieldNameForException["timerEventMinute"]) + ); + + foreach ($arrayValidateData as $key => $value) { + if (isset($arrayData[$key]) && !preg_match($value[0], $arrayData[$key])) { + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE", array($value[1]))); + } + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Create Timer-Event for a Project + * + * @param string $projectUid Unique id of Project + * @param array $arrayData Data + * + * return array Return data of the new Timer-Event created + */ + public function create($projectUid, array $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["TMREVN_UID"]); + unset($arrayData["PRJ_UID"]); + unset($arrayData["TMREVN_LAST_RUN_DATE"]); + unset($arrayData["TMREVN_LAST_EXECUTION_DATE"]); + + //Verify data + $process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]); + + $this->throwExceptionIfDataIsInvalid("", $projectUid, $arrayData); + + //Create + $cnn = \Propel::getConnection("workflow"); + + try { + $timerEvent = new \TimerEvent(); + $bpmnEvent = \BpmnEventPeer::retrieveByPK($arrayData["EVN_UID"]); + + $timerEventUid = \ProcessMaker\Util\Common::generateUID(); + + $arrayData["TMREVN_START_DATE"] = (isset($arrayData["TMREVN_START_DATE"]) && $arrayData["TMREVN_START_DATE"] . "" != "")? $arrayData["TMREVN_START_DATE"] : null; + $arrayData["TMREVN_END_DATE"] = (isset($arrayData["TMREVN_END_DATE"]) && $arrayData["TMREVN_END_DATE"] . "" != "")? $arrayData["TMREVN_END_DATE"] : null; + $arrayData["TMREVN_NEXT_RUN_DATE"] = (isset($arrayData["TMREVN_NEXT_RUN_DATE"]) && $arrayData["TMREVN_NEXT_RUN_DATE"] . "" != "")? $arrayData["TMREVN_NEXT_RUN_DATE"] : null; + $arrayData["TMREVN_CONFIGURATION_DATA"] = serialize((isset($arrayData["TMREVN_CONFIGURATION_DATA"]))? $arrayData["TMREVN_CONFIGURATION_DATA"] : ""); + + $timerEvent->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME); + + $timerEvent->setTmrevnUid($timerEventUid); + $timerEvent->setPrjUid($projectUid); + + if ($bpmnEvent->getEvnType() == "START") { + switch ($arrayData["TMREVN_OPTION"]) { + case "HOURLY": + case "DAILY": + case "MONTHLY": + case "EVERY": + $timerEvent->setTmrevnNextRunDate($this->getNextRunDateByDataAndDatetime($arrayData, date("Y-m-d H:i:s"))); + break; + } + } + + if ($timerEvent->validate()) { + $cnn->begin(); + + $result = $timerEvent->save(); + + $cnn->commit(); + + //Return + return $this->getTimerEvent($timerEventUid); + } else { + $msg = ""; + + foreach ($timerEvent->getValidationFailures() as $validationFailure) { + $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage(); + } + + throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : "")); + } + } catch (\Exception $e) { + $cnn->rollback(); + + throw $e; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Single create Timer-Event + * + * @param string $projectUid Unique id of Project + * @param array $arrayData Data + * + * return string Return unique id of Timer-Event + */ + public function singleCreate($projectUid, array $arrayData) + { + try { + $cnn = \Propel::getConnection("workflow"); + + try { + $timerEvent = new \TimerEvent(); + + $timerEventUid = \ProcessMaker\Util\Common::generateUID(); + + $timerEvent->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME); + + $timerEvent->setTmrevnUid($timerEventUid); + $timerEvent->setPrjUid($projectUid); + + if ($timerEvent->validate()) { + $cnn->begin(); + + $result = $timerEvent->save(); + + $cnn->commit(); + + //Return + return $timerEventUid; + } else { + $msg = ""; + + foreach ($timerEvent->getValidationFailures() as $validationFailure) { + $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage(); + } + + throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : "")); + } + } catch (\Exception $e) { + $cnn->rollback(); + + throw $e; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Update Timer-Event + * + * @param string $timerEventUid Unique id of Timer-Event + * @param array $arrayData Data + * + * return array Return data of the Timer-Event updated + */ + public function update($timerEventUid, array $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); + $arrayDataBackup = $arrayData; + + unset($arrayData["TMREVN_UID"]); + unset($arrayData["PRJ_UID"]); + unset($arrayData["TMREVN_LAST_RUN_DATE"]); + unset($arrayData["TMREVN_LAST_EXECUTION_DATE"]); + + //Set variables + $arrayTimerEventData = $this->getTimerEvent($timerEventUid, true); + + $arrayFinalData = array_merge($arrayTimerEventData, $arrayData); + + //Verify data + $this->throwExceptionIfNotExistsTimerEvent($timerEventUid, $this->arrayFieldNameForException["timerEventUid"]); + + $this->throwExceptionIfDataIsInvalid($timerEventUid, $arrayTimerEventData["PRJ_UID"], $arrayData); + + //Update + $cnn = \Propel::getConnection("workflow"); + + try { + $timerEvent = \TimerEventPeer::retrieveByPK($timerEventUid); + $bpmnEvent = \BpmnEventPeer::retrieveByPK($arrayFinalData["EVN_UID"]); + + if (isset($arrayData["TMREVN_START_DATE"])) { + $arrayData["TMREVN_START_DATE"] = ($arrayData["TMREVN_START_DATE"] . "" != "")? $arrayData["TMREVN_START_DATE"] : null; + } + + if (isset($arrayData["TMREVN_END_DATE"])) { + $arrayData["TMREVN_END_DATE"] = ($arrayData["TMREVN_END_DATE"] . "" != "")? $arrayData["TMREVN_END_DATE"] : null; + } + + if (isset($arrayData["TMREVN_NEXT_RUN_DATE"])) { + $arrayData["TMREVN_NEXT_RUN_DATE"] = ($arrayData["TMREVN_NEXT_RUN_DATE"] . "" != "")? $arrayData["TMREVN_NEXT_RUN_DATE"] : null; + } + + if (isset($arrayData["TMREVN_CONFIGURATION_DATA"])) { + $arrayData["TMREVN_CONFIGURATION_DATA"] = serialize($arrayData["TMREVN_CONFIGURATION_DATA"]); + } + + $timerEvent->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME); + + if ($bpmnEvent->getEvnType() == "START") { + switch ($arrayFinalData["TMREVN_OPTION"]) { + case "HOURLY": + case "DAILY": + case "MONTHLY": + case "EVERY": + $flagUpdateNextRunDate = false; + + $arrayFieldsToCheck = array(); + + switch ($arrayFinalData["TMREVN_OPTION"]) { + case "HOURLY": + $arrayFieldsToCheck = array("TMREVN_START_DATE", "TMREVN_END_DATE", "TMREVN_MINUTE"); + break; + case "DAILY": + $arrayFieldsToCheck = array("TMREVN_START_DATE", "TMREVN_END_DATE", "TMREVN_HOUR", "TMREVN_MINUTE", "TMREVN_CONFIGURATION_DATA"); + break; + case "MONTHLY": + $arrayFieldsToCheck = array("TMREVN_START_DATE", "TMREVN_END_DATE", "TMREVN_DAY", "TMREVN_HOUR", "TMREVN_MINUTE", "TMREVN_CONFIGURATION_DATA"); + break; + case "EVERY": + $arrayFieldsToCheck = array("TMREVN_HOUR", "TMREVN_MINUTE"); + break; + } + + foreach ($arrayFieldsToCheck as $value) { + if (isset($arrayData[$value])) { + if ($value == "TMREVN_CONFIGURATION_DATA") { + $arrayAux = unserialize($arrayData[$value]); + + $array1 = array_diff($arrayAux, $arrayTimerEventData[$value]); + $array2 = array_diff($arrayTimerEventData[$value], $arrayAux); + + $flagUpdateNextRunDate = !empty($array1) || !empty($array2); + } else { + $flagUpdateNextRunDate = $arrayData[$value] != $arrayTimerEventData[$value]; + } + + if ($flagUpdateNextRunDate) { + break; + } + } + } + + if ($flagUpdateNextRunDate) { + $timerEvent->setTmrevnNextRunDate($this->getNextRunDateByDataAndDatetime($arrayFinalData, date("Y-m-d H:i:s"))); + } + break; + } + } + + if ($timerEvent->validate()) { + $cnn->begin(); + + $result = $timerEvent->save(); + + $cnn->commit(); + + //Return + $arrayData = $arrayDataBackup; + + if (!$this->formatFieldNameInUppercase) { + $arrayData = array_change_key_case($arrayData, CASE_LOWER); + } + + return $arrayData; + } else { + $msg = ""; + + foreach ($timerEvent->getValidationFailures() as $validationFailure) { + $msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage(); + } + + throw new \Exception(\G::LoadTranslation("ID_REGISTRY_CANNOT_BE_UPDATED") . (($msg != "")? "\n" . $msg : "")); + } + } catch (\Exception $e) { + $cnn->rollback(); + + throw $e; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Delete Timer-Event + * + * @param string $timerEventUid Unique id of Timer-Event + * + * return void + */ + public function delete($timerEventUid) + { + try { + //Verify data + $this->throwExceptionIfNotExistsTimerEvent($timerEventUid, $this->arrayFieldNameForException["timerEventUid"]); + + //Delete + $criteria = new \Criteria("workflow"); + + $criteria->add(\TimerEventPeer::TMREVN_UID, $timerEventUid, \Criteria::EQUAL); + + $result = \TimerEventPeer::doDelete($criteria); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Delete Timer-Event + * + * @param array $arrayCondition Conditions + * + * return void + */ + public function deleteWhere(array $arrayCondition) + { + try { + //Delete + $criteria = new \Criteria("workflow"); + + foreach ($arrayCondition as $key => $value) { + if (is_array($value)) { + $criteria->add($key, $value[0], $value[1]); + } else { + $criteria->add($key, $value, \Criteria::EQUAL); + } + } + + $result = \TimerEventPeer::doDelete($criteria); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get criteria for Timer-Event + * + * return object + */ + public function getTimerEventCriteria() + { + try { + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_UID); + $criteria->addSelectColumn(\TimerEventPeer::PRJ_UID); + $criteria->addSelectColumn(\TimerEventPeer::EVN_UID); + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_OPTION); + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_START_DATE); + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_END_DATE); + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_DAY); + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_HOUR); + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_MINUTE); + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_CONFIGURATION_DATA); + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_NEXT_RUN_DATE); + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_LAST_RUN_DATE); + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_LAST_EXECUTION_DATE); + $criteria->addSelectColumn(\TimerEventPeer::TMREVN_STATUS); + + return $criteria; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Timer-Event from a record + * + * @param array $record Record + * + * return array Return an array with data Timer-Event + */ + public function getTimerEventDataFromRecord(array $record) + { + try { + return array( + $this->getFieldNameByFormatFieldName("TMREVN_UID") => $record["TMREVN_UID"], + $this->getFieldNameByFormatFieldName("EVN_UID") => $record["EVN_UID"], + $this->getFieldNameByFormatFieldName("TMREVN_OPTION") => $record["TMREVN_OPTION"], + $this->getFieldNameByFormatFieldName("TMREVN_START_DATE") => $record["TMREVN_START_DATE"] . "", + $this->getFieldNameByFormatFieldName("TMREVN_END_DATE") => $record["TMREVN_END_DATE"] . "", + $this->getFieldNameByFormatFieldName("TMREVN_DAY") => $record["TMREVN_DAY"] . "", + $this->getFieldNameByFormatFieldName("TMREVN_HOUR") => $record["TMREVN_HOUR"] . "", + $this->getFieldNameByFormatFieldName("TMREVN_MINUTE") => $record["TMREVN_MINUTE"] . "", + $this->getFieldNameByFormatFieldName("TMREVN_CONFIGURATION_DATA") => $record["TMREVN_CONFIGURATION_DATA"], + $this->getFieldNameByFormatFieldName("TMREVN_NEXT_RUN_DATE") => $record["TMREVN_NEXT_RUN_DATE"] . "", + $this->getFieldNameByFormatFieldName("TMREVN_LAST_RUN_DATE") => $record["TMREVN_LAST_RUN_DATE"] . "", + $this->getFieldNameByFormatFieldName("TMREVN_LAST_EXECUTION_DATE") => $record["TMREVN_LAST_EXECUTION_DATE"] . "", + $this->getFieldNameByFormatFieldName("TMREVN_STATUS") => $record["TMREVN_STATUS"] + ); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get all Timer-Events + * + * @param string $projectUid Unique id of Project + * + * return array Return an array with all Timer-Events + */ + public function getTimerEvents($projectUid) + { + try { + $arrayTimerEvent = array(); + + //Verify data + $process = new \ProcessMaker\BusinessModel\Process(); + + $process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]); + + //Get data + $criteria = $this->getTimerEventCriteria(); + + $criteria->add(\TimerEventPeer::PRJ_UID, $projectUid, \Criteria::EQUAL); + + $rsCriteria = \TimerEventPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + while ($rsCriteria->next()) { + $row = $rsCriteria->getRow(); + $row["TMREVN_CONFIGURATION_DATA"] = unserialize($row["TMREVN_CONFIGURATION_DATA"]); + + $arrayTimerEvent[] = $this->getTimerEventDataFromRecord($row); + } + + //Return + return $arrayTimerEvent; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Timer-Event + * + * @param string $timerEventUid Unique id of Timer-Event + * @param bool $flagGetRecord Value that set the getting + * + * return array Return an array with data of a Timer-Event + */ + public function getTimerEvent($timerEventUid, $flagGetRecord = false) + { + try { + //Verify data + $this->throwExceptionIfNotExistsTimerEvent($timerEventUid, $this->arrayFieldNameForException["timerEventUid"]); + + //Get data + $criteria = $this->getTimerEventCriteria(); + + $criteria->add(\TimerEventPeer::TMREVN_UID, $timerEventUid, \Criteria::EQUAL); + + $rsCriteria = \TimerEventPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + $result = $rsCriteria->next(); + + $row = $rsCriteria->getRow(); + $row["TMREVN_CONFIGURATION_DATA"] = unserialize($row["TMREVN_CONFIGURATION_DATA"]); + + //Return + return (!$flagGetRecord)? $this->getTimerEventDataFromRecord($row) : $row; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get data of a Timer-Event by unique id of Event + * + * @param string $projectUid Unique id of Project + * @param string $eventUid Unique id of Event + * @param bool $flagGetRecord Value that set the getting + * + * return array Return an array with data of a Timer-Event by unique id of Event + */ + public function getTimerEventByEvent($projectUid, $eventUid, $flagGetRecord = false) + { + try { + //Verify data + $process = new \ProcessMaker\BusinessModel\Process(); + $bpmnEvent = \BpmnEventPeer::retrieveByPK($eventUid); + + $process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]); + + if (is_null($bpmnEvent)) { + throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_EXIST", array($this->arrayFieldNameForException["eventUid"], $eventUid))); + } + + if ($bpmnEvent->getPrjUid() != $projectUid) { + throw new \Exception(\G::LoadTranslation("ID_EVENT_EVENT_NOT_BELONG_TO_PROJECT", array($this->arrayFieldNameForException["eventUid"], $eventUid, $this->arrayFieldNameForException["projectUid"], $projectUid))); + } + + //Get data + if (!$this->existsEvent($projectUid, $eventUid)) { + //Return + return array(); + } + + $criteria = $this->getTimerEventCriteria(); + + $criteria->add(\TimerEventPeer::PRJ_UID, $projectUid, \Criteria::EQUAL); + $criteria->add(\TimerEventPeer::EVN_UID, $eventUid, \Criteria::EQUAL); + + $rsCriteria = \TimerEventPeer::doSelectRS($criteria); + $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); + + $result = $rsCriteria->next(); + + $row = $rsCriteria->getRow(); + $row["TMREVN_CONFIGURATION_DATA"] = unserialize($row["TMREVN_CONFIGURATION_DATA"]); + + //Return + return (!$flagGetRecord)? $this->getTimerEventDataFromRecord($row) : $row; + } catch (\Exception $e) { + throw $e; + } + } +} + diff --git a/workflow/engine/src/ProcessMaker/Importer/Importer.php b/workflow/engine/src/ProcessMaker/Importer/Importer.php index 0b53ce68c..c2fbe2377 100755 --- a/workflow/engine/src/ProcessMaker/Importer/Importer.php +++ b/workflow/engine/src/ProcessMaker/Importer/Importer.php @@ -391,7 +391,7 @@ abstract class Importer foreach ($arrayWorkflowTables["tasks"] as $key => $value) { $arrayTaskData = $value; - if (!in_array($arrayTaskData["TAS_TYPE"], array("GATEWAYTOGATEWAY", "WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT", "END-EMAIL-EVENT", "INTERMEDIATE-EMAIL-EVENT"))) { + if (!in_array($arrayTaskData["TAS_TYPE"], array("GATEWAYTOGATEWAY", "WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT", "START-TIMER-EVENT", "INTERMEDIATE-CATCH-TIMER-EVENT", "END-EMAIL-EVENT", "INTERMEDIATE-EMAIL-EVENT"))) { $result = $workflow->updateTask($arrayTaskData["TAS_UID"], $arrayTaskData); } } diff --git a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php index 0073eae68..d316f68a2 100755 --- a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php @@ -29,6 +29,8 @@ class BpmnWorkflow extends Project\Bpmn "start-message-event" => array("type" => "START-MESSAGE-EVENT", "prefix" => "sme-"), "intermediate-throw-message-event" => array("type" => "INTERMEDIATE-THROW-MESSAGE-EVENT", "prefix" => "itme-"), "intermediate-catch-message-event" => array("type" => "INTERMEDIATE-CATCH-MESSAGE-EVENT", "prefix" => "icme-"), + "start-timer-event" => array("type" => "START-TIMER-EVENT", "prefix" => "ste-"), + "intermediate-catch-timer-event" => array("type" => "INTERMEDIATE-CATCH-TIMER-EVENT", "prefix" => "icte-"), "end-email-event" => array("type" => "END-EMAIL-EVENT", "prefix" => "eee-") ); @@ -323,7 +325,7 @@ class BpmnWorkflow extends Project\Bpmn $this->wp->setStartTask($data["FLO_ELEMENT_DEST"]); } - $this->updateEventStartObjects($data["FLO_ELEMENT_ORIGIN"], $data["FLO_ELEMENT_DEST"]); + //$this->updateEventStartObjects($data["FLO_ELEMENT_ORIGIN"], $data["FLO_ELEMENT_DEST"]); //WebEntry-Event - Update $this->updateWebEntryEventByEvent($data["FLO_ELEMENT_ORIGIN"], array("ACT_UID" => $data["FLO_ELEMENT_DEST"])); @@ -373,7 +375,7 @@ class BpmnWorkflow extends Project\Bpmn //Setting as start Task $this->wp->setStartTask($flowCurrent->getFloElementDest()); - $this->updateEventStartObjects($flowCurrent->getFloElementOrigin(), $flowCurrent->getFloElementDest()); + //$this->updateEventStartObjects($flowCurrent->getFloElementOrigin(), $flowCurrent->getFloElementDest()); //WebEntry-Event - Update $this->updateWebEntryEventByEvent($flowCurrent->getFloElementOrigin(), array("ACT_UID" => $flowCurrent->getFloElementDest())); @@ -471,7 +473,7 @@ class BpmnWorkflow extends Project\Bpmn } } - $this->updateEventStartObjects($flow->getFloElementOrigin(), ""); + //$this->updateEventStartObjects($flow->getFloElementOrigin(), ""); //WebEntry-Event - Update if (is_null($bpmnFlow)) { @@ -559,15 +561,6 @@ class BpmnWorkflow extends Project\Bpmn public function removeEventDefinition(\BpmnEvent $bpmnEvent) { try { - //Case-Scheduler - Delete - if ($bpmnEvent->getEvnType() == "START" && $bpmnEvent->getEvnMarker() == "TIMER") { - $caseScheduler = new \CaseScheduler(); - - if ($caseScheduler->Exists($bpmnEvent->getEvnUid())) { - $this->wp->removeCaseScheduler($bpmnEvent->getEvnUid()); - } - } - //WebEntry-Event - Delete if ($bpmnEvent->getEvnType() == "START" && $bpmnEvent->getEvnMarker() == "EMPTY") { $webEntryEvent = new \ProcessMaker\BusinessModel\WebEntryEvent(); @@ -593,6 +586,19 @@ class BpmnWorkflow extends Project\Bpmn } } + //Timer-Event - Delete + $arrayEventType = array("START", "INTERMEDIATE"); + $arrayEventMarker = array("TIMER"); + + if (in_array($bpmnEvent->getEvnType(), $arrayEventType) && in_array($bpmnEvent->getEvnMarker(), $arrayEventMarker)) { + $timerEvent = new \ProcessMaker\BusinessModel\TimerEvent(); + + $timerEvent->deleteWhere(array( + \TimerEventPeer::PRJ_UID => array($bpmnEvent->getPrjUid(), \Criteria::EQUAL), + \TimerEventPeer::EVN_UID => array($bpmnEvent->getEvnUid(), \Criteria::EQUAL) + )); + } + //Email-Event - Delete $arrayEventType = array("END", "INTERMEDIATE"); $arrayEventMarker = array("EMAIL"); @@ -623,15 +629,15 @@ class BpmnWorkflow extends Project\Bpmn $eventUid = parent::addEvent($data); $event = \BpmnEventPeer::retrieveByPK($eventUid); - // create case scheduler - if ($event && $event->getEvnMarker() == "TIMER" && $event->getEvnType() == "START") { - $this->wp->addCaseScheduler($eventUid); - } - - // create web entry - if ($event && $event->getEvnMarker() == "MESSAGE" && $event->getEvnType() == "START") { - $this->wp->addWebEntry($eventUid); - } + //// create case scheduler + //if ($event && $event->getEvnMarker() == "TIMER" && $event->getEvnType() == "START") { + // $this->wp->addCaseScheduler($eventUid); + //} + // + //// create web entry + //if ($event && $event->getEvnMarker() == "MESSAGE" && $event->getEvnType() == "START") { + // $this->wp->addWebEntry($eventUid); + //} return $eventUid; } @@ -668,6 +674,7 @@ class BpmnWorkflow extends Project\Bpmn } } + /* public function updateEventStartObjects($eventUid, $taskUid) { $event = \BpmnEventPeer::retrieveByPK($eventUid); @@ -686,6 +693,7 @@ class BpmnWorkflow extends Project\Bpmn // $this->wp->updateWebEntry($eventUid, array("TAS_UID" => $taskUid)); //} } + */ public function createTaskByElement($elementUid, $elementType, $key) { @@ -917,12 +925,19 @@ class BpmnWorkflow extends Project\Bpmn $arrayEventData = \BpmnEvent::findOneBy(\BpmnEventPeer::EVN_UID, $eventUid)->toArray(); if (!is_null($arrayEventData)) { - //Event - INTERMEDIATE-CATCH-MESSAGE-EVENT - if ($arrayEventData["EVN_TYPE"] == "INTERMEDIATE" && $arrayEventData["EVN_MARKER"] == "MESSAGECATCH") { + $arrayEventType = array("INTERMEDIATE"); + $arrayEventMarker = array("MESSAGECATCH", "TIMER"); + + if (in_array($arrayEventData["EVN_TYPE"], $arrayEventType) && in_array($arrayEventData["EVN_MARKER"], $arrayEventMarker)) { + $arrayKey = array( + "MESSAGECATCH" => "intermediate-catch-message-event", + "TIMER" => "intermediate-catch-timer-event" + ); + $taskUid = $this->createTaskByElement( $eventUid, "bpmnEvent", - "intermediate-catch-message-event" + $arrayKey[$arrayEventData["EVN_MARKER"]] ); $result = $this->wp->addRoute($activityUid, $taskUid, $routeType, $routeCondition, $routeDefault); @@ -1113,6 +1128,17 @@ class BpmnWorkflow extends Project\Bpmn $this->wp->setStartTask($taskUid); + $this->mapBpmnEventToWorkflowRoutes($taskUid, $event["EVN_UID"]); + break; + case "TIMER": + $taskUid = $this->createTaskByElement( + $event["EVN_UID"], + "bpmnEvent", + "start-timer-event" + ); + + $this->wp->setStartTask($taskUid); + $this->mapBpmnEventToWorkflowRoutes($taskUid, $event["EVN_UID"]); break; case "EMPTY": @@ -1120,10 +1146,10 @@ class BpmnWorkflow extends Project\Bpmn break; } break; - case "END": - break; - case "INTERMEDIATE": - break; + //case "END": + // break; + //case "INTERMEDIATE": + // break; } } } @@ -1329,7 +1355,6 @@ class BpmnWorkflow extends Project\Bpmn * @param $projectData * @return array */ - public static function updateFromStruct($prjUid, $projectData, $generateUid = true, $forceInsert = false) { $diagram = isset($projectData["diagrams"]) && isset($projectData["diagrams"][0]) ? $projectData["diagrams"][0] : array(); @@ -1954,3 +1979,4 @@ class BpmnWorkflow extends Project\Bpmn } } } + diff --git a/workflow/engine/src/ProcessMaker/Project/Workflow.php b/workflow/engine/src/ProcessMaker/Project/Workflow.php index fb05ff2f7..cefd7613b 100755 --- a/workflow/engine/src/ProcessMaker/Project/Workflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Workflow.php @@ -855,7 +855,17 @@ class Workflow extends Handler $messageEventDefinition->delete($row["MSGED_UID"]); } - + + //Delete Script-Task + $scriptTask = new \ProcessMaker\BusinessModel\ScriptTask(); + + $scriptTask->deleteWhere(array(\ScriptTaskPeer::PRJ_UID => array($sProcessUID, \Criteria::EQUAL))); + + //Delete Timer-Event + $timerEvent = new \ProcessMaker\BusinessModel\TimerEvent(); + + $timerEvent->deleteWhere(array(\TimerEventPeer::PRJ_UID => array($sProcessUID, \Criteria::EQUAL))); + //Delete Email-Event $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent(); $criteria = new \Criteria("workflow"); @@ -868,7 +878,7 @@ class Workflow extends Handler $row = $rsCriteria->getRow(); $emailEvent->delete($sProcessUID,$row["EMAIL_EVENT_UID"],false); } - + //Delete files Manager $filesManager = new \ProcessMaker\BusinessModel\FilesManager(); $criteria = new \Criteria("workflow"); @@ -882,23 +892,6 @@ class Workflow extends Handler $filesManager->deleteProcessFilesManager($sProcessUID, $row["PRF_UID"]); } - //Delete Script-Task - $scriptTask = new \ProcessMaker\BusinessModel\ScriptTask(); - - $criteria = new \Criteria("workflow"); - - $criteria->addSelectColumn(\ScriptTaskPeer::SCRTAS_UID); - $criteria->add(\ScriptTaskPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL); - - $rsCriteria = \ScriptTaskPeer::doSelectRS($criteria); - $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); - - while ($rsCriteria->next()) { - $row = $rsCriteria->getRow(); - - $scriptTask->delete($row["SCRTAS_UID"]); - } - //Delete the process try { $oProcess->remove($sProcessUID); @@ -1238,80 +1231,33 @@ class Workflow extends Handler $processUidOld = $arrayUid[0]["old_uid"]; $processUid = $arrayUid[0]["new_uid"]; - //Update TASK.TAS_UID - foreach ($arrayWorkflowData["tasks"] as $key => $value) { - $taskUid = $arrayWorkflowData["tasks"][$key]["TAS_UID"]; + //Update Table.Field + $arrayUpdateTableField = array( + "tasks" => array("fieldname" => "TAS_UID", "oldFieldname" => "TAS_UID_OLD"), //Update TASK.TAS_UID + "webEntryEvent" => array("fieldname" => "EVN_UID", "oldFieldname" => "EVN_UID_OLD"), //Update WEB_ENTRY_EVENT.EVN_UID + "messageEventDefinition" => array("fieldname" => "EVN_UID", "oldFieldname" => "EVN_UID_OLD"), //Update MESSAGE_EVENT_DEFINITION.EVN_UID + "scriptTask" => array("fieldname" => "ACT_UID", "oldFieldname" => "ACT_UID_OLD"), //Update SCRIPT_TASK.ACT_UID + "timerEvent" => array("fieldname" => "EVN_UID", "oldFieldname" => "EVN_UID_OLD"), //Update TIMER_EVENT.EVN_UID + "emailEvent" => array("fieldname" => "EVN_UID", "oldFieldname" => "EVN_UID_OLD") //Update EMAIL_EVENT.EVN_UID + ); - foreach ($arrayUid as $value2) { - $arrayItem = $value2; + foreach ($arrayUpdateTableField as $key => $value) { + $table = $key; + $fieldname = $value["fieldname"]; + $oldFieldname = $value["oldFieldname"]; - if ($arrayItem["old_uid"] == $taskUid) { - $arrayWorkflowData["tasks"][$key]["TAS_UID_OLD"] = $taskUid; - $arrayWorkflowData["tasks"][$key]["TAS_UID"] = $arrayItem["new_uid"]; - break; - } - } - } + if (isset($arrayWorkflowData[$table])) { + foreach ($arrayWorkflowData[$table] as $key2 => $value2) { + $uid = $arrayWorkflowData[$table][$key2][$fieldname]; - //Update WEB_ENTRY_EVENT.EVN_UID - if (isset($arrayWorkflowData["webEntryEvent"])) { - foreach ($arrayWorkflowData["webEntryEvent"] as $key => $value) { - $webEntryEventEventUid = $arrayWorkflowData["webEntryEvent"][$key]["EVN_UID"]; + foreach ($arrayUid as $value3) { + $arrayItem = $value3; - foreach ($arrayUid as $value2) { - $arrayItem = $value2; - - if ($arrayItem["old_uid"] == $webEntryEventEventUid) { - $arrayWorkflowData["webEntryEvent"][$key]["EVN_UID"] = $arrayItem["new_uid"]; - break; - } - } - } - } - - //Update MESSAGE_EVENT_DEFINITION.EVN_UID - if (isset($arrayWorkflowData["messageEventDefinition"])) { - foreach ($arrayWorkflowData["messageEventDefinition"] as $key => $value) { - $messageEventDefinitionEventUid = $arrayWorkflowData["messageEventDefinition"][$key]["EVN_UID"]; - - foreach ($arrayUid as $value2) { - $arrayItem = $value2; - - if ($arrayItem["old_uid"] == $messageEventDefinitionEventUid) { - $arrayWorkflowData["messageEventDefinition"][$key]["EVN_UID"] = $arrayItem["new_uid"]; - break; - } - } - } - } - - //Update EMAIL_EVENT.EVN_UID - if (isset($arrayWorkflowData["emailEvent"])) { - foreach ($arrayWorkflowData["emailEvent"] as $key => $value) { - $emailEventEventUid = $arrayWorkflowData["emailEvent"][$key]["EVN_UID"]; - - foreach ($arrayUid as $value2) { - $arrayItem = $value2; - - if ($arrayItem["old_uid"] == $emailEventEventUid) { - $arrayWorkflowData["emailEvent"][$key]["EVN_UID"] = $arrayItem["new_uid"]; - break; - } - } - } - } - - //Update SCRIPT_TASK.ACT_UID - if (isset($arrayWorkflowData["scriptTask"])) { - foreach ($arrayWorkflowData["scriptTask"] as $key => $value) { - $scriptTaskActivityUid = $arrayWorkflowData["scriptTask"][$key]["ACT_UID"]; - - foreach ($arrayUid as $value2) { - $arrayItem = $value2; - - if ($arrayItem["old_uid"] == $scriptTaskActivityUid) { - $arrayWorkflowData["scriptTask"][$key]["ACT_UID"] = $arrayItem["new_uid"]; - break; + if ($arrayItem["old_uid"] == $uid) { + $arrayWorkflowData[$table][$key2][$fieldname] = $arrayItem["new_uid"]; + $arrayWorkflowData[$table][$key2][$oldFieldname] = $uid; + break; + } } } } @@ -1369,3 +1315,4 @@ class Workflow extends Handler } } } + diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Project/TimerEvent.php b/workflow/engine/src/ProcessMaker/Services/Api/Project/TimerEvent.php new file mode 100644 index 000000000..ec9ab3518 --- /dev/null +++ b/workflow/engine/src/ProcessMaker/Services/Api/Project/TimerEvent.php @@ -0,0 +1,134 @@ +timerEvent = new \ProcessMaker\BusinessModel\TimerEvent(); + + $this->timerEvent->setFormatFieldNameInUppercase(false); + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url GET /:prj_uid/timer-events + * + * @param string $prj_uid {@min 32}{@max 32} + */ + public function doGetTimerEvents($prj_uid) + { + try { + $response = $this->timerEvent->getTimerEvents($prj_uid); + + return $response; + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url GET /:prj_uid/timer-event/:tmrevn_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $tmrevn_uid {@min 32}{@max 32} + */ + public function doGetTimerEvent($prj_uid, $tmrevn_uid) + { + try { + $response = $this->timerEvent->getTimerEvent($tmrevn_uid); + + return $response; + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url GET /:prj_uid/timer-event/event/:evn_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $evn_uid {@min 32}{@max 32} + */ + public function doGetTimerEventEvent($prj_uid, $evn_uid) + { + try { + $response = $this->timerEvent->getTimerEventByEvent($prj_uid, $evn_uid); + + return $response; + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url POST /:prj_uid/timer-event + * + * @param string $prj_uid {@min 32}{@max 32} + * @param array $request_data + * + * @status 201 + */ + public function doPostTimerEvent($prj_uid, array $request_data) + { + try { + $arrayData = $this->timerEvent->create($prj_uid, $request_data); + + $response = $arrayData; + + return $response; + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url PUT /:prj_uid/timer-event/:tmrevn_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $tmrevn_uid {@min 32}{@max 32} + * @param array $request_data + */ + public function doPutTimerEvent($prj_uid, $tmrevn_uid, array $request_data) + { + try { + $arrayData = $this->timerEvent->update($tmrevn_uid, $request_data); + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } + + /** + * @url DELETE /:prj_uid/timer-event/:tmrevn_uid + * + * @param string $prj_uid {@min 32}{@max 32} + * @param string $tmrevn_uid {@min 32}{@max 32} + */ + public function doDeleteTimerEvent($prj_uid, $tmrevn_uid) + { + try { + $this->timerEvent->delete($tmrevn_uid); + } catch (\Exception $e) { + throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); + } + } +} + diff --git a/workflow/engine/src/ProcessMaker/Services/api.ini b/workflow/engine/src/ProcessMaker/Services/api.ini index 2d985e10d..d24e93b78 100644 --- a/workflow/engine/src/ProcessMaker/Services/api.ini +++ b/workflow/engine/src/ProcessMaker/Services/api.ini @@ -41,8 +41,9 @@ debug = 1 message-type-variable = "ProcessMaker\Services\Api\Project\MessageType\Variable" web-entry-event = "ProcessMaker\Services\Api\Project\WebEntryEvent" message-event-definition = "ProcessMaker\Services\Api\Project\MessageEventDefinition" - script-task = "ProcessMaker\Services\Api\Project\ScriptTask" - email-event = "ProcessMaker\Services\Api\Project\EmailEvent" + script-task = "ProcessMaker\Services\Api\Project\ScriptTask" + timer-event = "ProcessMaker\Services\Api\Project\TimerEvent" + email-event = "ProcessMaker\Services\Api\Project\EmailEvent" [alias: projects] project = "ProcessMaker\Services\Api\Project" @@ -112,3 +113,4 @@ debug = 1 [alias: catalog] dashboard = "ProcessMaker\Services\Api\Catalog" + diff --git a/workflow/engine/src/ProcessMaker/Util/Common.php b/workflow/engine/src/ProcessMaker/Util/Common.php index 8991e303b..ec03eb6fe 100644 --- a/workflow/engine/src/ProcessMaker/Util/Common.php +++ b/workflow/engine/src/ProcessMaker/Util/Common.php @@ -3,6 +3,78 @@ namespace ProcessMaker\Util; class Common extends \Maveriks\Util\Common { + private $frontEnd = false; + + /** + * Set front-end flag (Terminal's front-end) + * + * @param bool $flag Flag + * + * return void + */ + public function setFrontEnd($flag) + { + try { + $this->frontEnd = $flag; + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Show front-end (Terminal's front-end) + * + * @param string $option Option + * @param string $data Data string + * + * return void + */ + public function frontEndShow($option, $data = "") + { + try { + if (!$this->frontEnd) { + return; + } + + $numc = 100; + + switch ($option) { + case "BAR": + echo "\r" . "| " . $data . str_repeat(" ", $numc - 2 - strlen($data)); + break; + case "TEXT": + echo "\r" . "| " . $data . str_repeat(" ", $numc - 2 - strlen($data)) . "\n"; + break; + default: + //START, END + echo "\r" . "+" . str_repeat("-", $numc - 2) . "+" . "\n"; + break; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Progress bar (Progress bar for terminal) + * + * @param int $total Total + * @param int $count Count + * + * return string Return a string that represent progress bar + */ + public function progressBar($total, $count) + { + try { + $p = (int)(($count * 100) / $total); + $n = (int)($p / 2); + + return "[" . str_repeat("|", $n) . str_repeat(" ", 50 - $n) . "] $p%"; + } catch (\Exception $e) { + throw $e; + } + } + /** * Generate random number * @@ -64,4 +136,5 @@ class Common extends \Maveriks\Util\Common return $sCode; } -} \ No newline at end of file +} + diff --git a/workflow/engine/templates/cases/cases_ScreenDerivation.html b/workflow/engine/templates/cases/cases_ScreenDerivation.html index 8724ae9bc..413e4b2a8 100755 --- a/workflow/engine/templates/cases/cases_ScreenDerivation.html +++ b/workflow/engine/templates/cases/cases_ScreenDerivation.html @@ -1,7 +1,7 @@
-
+
@@ -16,7 +16,7 @@ - {if $PREVIOUS_PAGE} + {if $PREVIOUS_PAGE}
@@ -61,14 +61,18 @@ {/if} {if $PROCESS.ERROR eq '' } - {if $data.NEXT_TASK.TAS_TYPE != "INTERMEDIATE-CATCH-MESSAGE-EVENT"} + {if ($data.NEXT_TASK.TAS_TYPE == "INTERMEDIATE-CATCH-MESSAGE-EVENT")} - - + + + {elseif ($data.NEXT_TASK.TAS_TYPE == "INTERMEDIATE-CATCH-TIMER-EVENT")} + + {else} - + + {/if} {/if} @@ -94,6 +98,11 @@ + {elseif ($data.NEXT_TASK.TAS_TYPE == "INTERMEDIATE-CATCH-TIMER-EVENT")} + + + + {else}
{$NEXT_TASK_LABEL}:{$data.NEXT_TASK.TAS_TITLE}{$data.NEXT_TASK.TAS_HIDDEN_FIELD}{$data.NEXT_TASK.TAS_TITLE}{$data.NEXT_TASK.TAS_HIDDEN_FIELD}
{$data.NEXT_TASK.TAS_HIDDEN_FIELD}
{$data.NEXT_TASK.TAS_TITLE}{$data.NEXT_TASK.TAS_HIDDEN_FIELD}{$NEXT_TASK_LABEL}:{$data.NEXT_TASK.TAS_TITLE}{$data.NEXT_TASK.TAS_HIDDEN_FIELD}
{$data.NEXT_TASK.USR_UID}{$data.NEXT_TASK.USR_HIDDEN_FIELD}
{$NEXT_TASK_LABEL}:{$data.NEXT_TASK.USR_UID}{$data.NEXT_TASK.USR_HIDDEN_FIELD}
{$EMPLOYEE}: