First commit on ProcessMaker CORE Engine and Jeaqueline's changes

This commit is contained in:
girish
2010-12-07 11:49:51 +00:00
parent 720db63b61
commit 2e97a8e9ec
31 changed files with 2118 additions and 889 deletions

View File

@@ -5160,4 +5160,46 @@ class Cases {
}
}
function discriminateCases($aData){
$siblingThreadData = $this->GetAllOpenDelegation($aData);
foreach($siblingThreadData as $thread => $threadData)
{
$this->closeAppThread ( $aData['APP_UID'], $threadData['DEL_INDEX']); //Close Sibling AppThreads
$this->CloseCurrentDelegation ($aData['APP_UID'], $threadData['DEL_INDEX']); //Close Sibling AppDelegations
}
}
/*
* We're getting all threads in a task
*
* @name GetAllThreads of Particular Parent Thread
* @param string $sAppUid
* @param string $sAppParent
* @return $aThreads
*/
function GetAllOpenDelegation($aData)
{
//('SELECT * FROM APP_THREAD WHERE APP_UID='".$aData['APP_UID']."' AND APP_THREAD_PARENT = '".$aData['APP_THREAD_PARENT']."'");
try {
$aThreads = array();
$c = new Criteria();
$c->add(AppDelegationPeer::APP_UID, $aData['APP_UID']);
$c->add(AppDelegationPeer::DEL_PREVIOUS, $aData['APP_THREAD_PARENT']);
$c->add(AppDelegationPeer::DEL_THREAD_STATUS,'OPEN');
$rs = AppDelegationPeer::doSelectRs($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rs->next();
$row = $rs->getRow();
while (is_array($row)) {
$aThreads[] = $row;
$rs->next();
$row = $rs->getRow();
}
return $aThreads;
}
catch (exception $e) {
throw ($e);
}
}
}

View File

@@ -52,7 +52,7 @@ class Derivation
*
* @param array $aData
* @return $taskInfo
*/
*/
function prepareInformation($aData)
{
$oTask = new Task();
@@ -134,7 +134,7 @@ class Derivation
else {
//3. load the task information of normal NEXT_TASK
$aDerivation['NEXT_TASK'] = $oTask->load( $aDerivation['ROU_NEXT_TASK'] );//print $aDerivation['ROU_NEXT_TASK']." **** ".$aDerivation['NEXT_TASK']['TAS_TYPE']."<hr>";
if ($aDerivation['NEXT_TASK']['TAS_TYPE'] === 'SUBPROCESS') {
$oCriteria = new Criteria('workflow');
$oCriteria->add(SubProcessPeer::PRO_PARENT, $aDerivation['PRO_UID']);
@@ -340,8 +340,8 @@ class Derivation
/* get next assigned user
*
* @param Array $tasInfo
* @return Array $userFields
* @param Array $tasInfo
* @return Array $userFields
*/
function getNextAssignedUser( $tasInfo ){
$oUser = new Users();
@@ -401,9 +401,9 @@ class Derivation
}
}
else
throw ( new Exception("Task doesn't have a valid user in variable $variable or this variable doesn't exist.") ) ;
throw ( new Exception("Task doesn't have a valid user in variable $variable or this variable doesn't exists.") ) ;
break;
case 'REPORT_TO' :
//default error user when the reportsTo is not assigned to that user
//look for USR_REPORTS_TO to this user
@@ -413,7 +413,7 @@ class Derivation
$userFields['USR_FIRSTNAME'] = '';
$userFields['USR_LASTNAME'] = '';
$userFields['USR_EMAIL'] = '';
//look for USR_REPORTS_TO to this user
$useruid = $this->getDenpendentUser($tasInfo['USER_UID']);
if ( isset ( $useruid ) ) {
@@ -432,7 +432,7 @@ class Derivation
$userFields = "ERROR";
//throw ( new Exception("The current user does not have a valid Reports To user. Please contact administrator.") ) ;
break;
case 'SELF_SERVICE' :
//look for USR_REPORTS_TO to this user
$userFields['USR_UID'] = '';
@@ -452,30 +452,30 @@ class Derivation
/* getDenpendentUser
*
* @param string $USR_UID
* @return string $aRow['USR_REPORTS_TO']
* @return string $aRow['USR_REPORTS_TO']
*/
function getDenpendentUser($USR_UID)
{
//require_once 'classes/model/Users.php';
//here the uid to next Users
$oC=new Criteria();
$oC->addSelectColumn(UsersPeer::USR_REPORTS_TO);
$oC->addSelectColumn(UsersPeer::USR_REPORTS_TO);
$oC->add(UsersPeer::USR_UID,$USR_UID);
$oDataset=UsersPeer::doSelectRS($oC);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aRow = $oDataset->getRow();
return $aRow['USR_REPORTS_TO'];
}
/* setTasLastAssigned
/* setTasLastAssigned
*
* @param string $tasUid
* @param string $usrUid
* @throws Exception $e
* @return void
*/
function setTasLastAssigned ( $tasUid, $usrUid )
function setTasLastAssigned ( $tasUid, $usrUid )
{
try {
$oTask = TaskPeer::retrieveByPk( $tasUid );
@@ -486,7 +486,7 @@ class Derivation
throw ( $e );
}
}
/* derivate
*
* @param array $currentDelegation
@@ -495,6 +495,7 @@ class Derivation
*/
function derivate($currentDelegation=array(), $nextDelegations =array())
{
//define this...
if ( !defined('TASK_FINISH_PROCESS')) define('TASK_FINISH_PROCESS',-1);
if ( !defined('TASK_FINISH_TASK')) define('TASK_FINISH_TASK', -2);
@@ -507,7 +508,7 @@ class Derivation
//Count how many tasks should be derivated.
//$countNextTask = count($nextDelegations);
foreach($nextDelegations as $nextDel) {
//subprocesses??
//subprocesses??
if ($nextDel['TAS_PARENT'] != '') {
$oCriteria = new Criteria('workflow');
$oCriteria->add(SubProcessPeer::PRO_PARENT, $appFields['PRO_UID']);
@@ -531,14 +532,13 @@ class Derivation
continue;
}
}
//get TAS_ASSIGN_TYPE for current Delegation
$oTask = TaskPeer::retrieveByPk( $currentDelegation['TAS_UID'] );
$aTask = $oTask->toArray(BasePeer::TYPE_FIELDNAME);
$oTask = new Task();
$aTask = $oTask->load($currentDelegation['TAS_UID']);
$currentDelegation['TAS_ASSIGN_TYPE'] = $aTask['TAS_ASSIGN_TYPE'];
$currentDelegation['TAS_MI_COMPLETE_VARIABLE'] = isset($aTask['TAS_MI_COMPLETE_VARIABLE']) ? $aTask['TAS_MI_COMPLETE_VARIABLE'] : '';
$currentDelegation['TAS_MI_INSTANCE_VARIABLE'] = isset($aTask['TAS_MI_INSTANCE_VARIABLE']) ? $aTask['TAS_MI_INSTANCE_VARIABLE'] : '';
$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'] );
//if we are derivating to finish process but there are no more open thread then we are finishing only the task, we are not finishing the whole process
@@ -559,92 +559,91 @@ class Derivation
default:
// get all siblingThreads
//if($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI')
switch ($currentDelegation['TAS_ASSIGN_TYPE']) {
switch ($currentDelegation['TAS_ASSIGN_TYPE']) {
case 'CANCEL_MI':
case 'STATIC_MI':
$siblingThreads = $this->case->GetAllOpenDelegation($currentDelegation);
$aData = $this->case->loadCase($currentDelegation['APP_UID']);
if (isset($aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'])]))
$sMIinstanceVar = $aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'])];
else
$sMIinstanceVar = $aData['APP_DATA']['TAS_MI_INSTANCE_VARIABLE'];
if (isset($aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'])]))
$sMIcompleteVar = $aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'])];
else
$sMIcompleteVar = $aData['APP_DATA']['TAS_MI_COMPLETE_VARIABLE'];
$discriminateThread = $sMIinstanceVar - $sMIcompleteVar;
// -1 because One App Delegation is closed by above Code
if($discriminateThread == count($siblingThreads))
$canDerivate =true;
else
$canDerivate =false;
break;
default:
if ( $currentDelegation['ROU_TYPE'] == 'SEC-JOIN') {
$siblingThreads = $this->case->getOpenSiblingThreads($nextDel['TAS_UID'], $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'], $currentDelegation['TAS_UID'],$currentDelegation['ROU_TYPE']);
$canDerivate = count($siblingThreads) == 0;
}
else if($currentDelegation['ROU_TYPE'] == 'DISCRIMINATOR')
{
//First get the total threads of Next Task where route type='Discriminator'
$siblingThreads = $this->case->getOpenSiblingThreads($nextDel['TAS_UID'], $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'], $currentDelegation['TAS_UID'],$currentDelegation['ROU_TYPE']);
$siblingThreadsCount = count($siblingThreads);
$discriminateThread = $currentDelegation['ROU_CONDITION'];
//$checkThread = count($totalThreads) - $cond;
if($discriminateThread == $siblingThreadsCount)
$canDerivate = true;
else
$canDerivate = false;
}
else {
$canDerivate = true;
}
$siblingThreads = $this->case->GetAllOpenDelegation($currentDelegation);
$aData = $this->case->loadCase($currentDelegation['APP_UID']);
if (isset($aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'])]))
$sMIinstanceVar = $aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_INSTANCE_VARIABLE'])];
else
$sMIinstanceVar = $aData['APP_DATA']['TAS_MI_INSTANCE_VARIABLE'];
if (isset($aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'])]))
$sMIcompleteVar = $aData['APP_DATA'][str_replace('@@', '', $currentDelegation['TAS_MI_COMPLETE_VARIABLE'])];
else
$sMIcompleteVar = $aData['APP_DATA']['TAS_MI_COMPLETE_VARIABLE'];
$discriminateThread = $sMIinstanceVar - $sMIcompleteVar;
// -1 because One App Delegation is closed by above Code
if($discriminateThread == count($siblingThreads))
$canDerivate =true;
else
$canDerivate =false;
break;
default:
if ( $currentDelegation['ROU_TYPE'] == 'SEC-JOIN') {
$siblingThreads = $this->case->getOpenSiblingThreads($nextDel['TAS_UID'], $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'], $currentDelegation['TAS_UID'],$currentDelegation['ROU_TYPE']);
$canDerivate = count($siblingThreads) == 0;
}
else if($currentDelegation['ROU_TYPE'] == 'DISCRIMINATOR')
{
//First get the total threads of Next Task where route type='Discriminator'
$siblingThreads = $this->case->getOpenSiblingThreads($nextDel['TAS_UID'], $currentDelegation['APP_UID'], $currentDelegation['DEL_INDEX'], $currentDelegation['TAS_UID'],$currentDelegation['ROU_TYPE']);
$siblingThreadsCount = count($siblingThreads);
$discriminateThread = $currentDelegation['ROU_CONDITION'];
//$checkThread = count($totalThreads) - $cond;
if($discriminateThread == $siblingThreadsCount)
$canDerivate = true;
else
$canDerivate = false;
}
else {
$canDerivate = true;
}
}
if ( $canDerivate ) {
$iAppThreadIndex = $appFields['DEL_THREAD'];
$delType = 'NORMAL';
$iAppThreadIndex = $appFields['DEL_THREAD'];
$delType = 'NORMAL';
switch ( $nextDel['TAS_ASSIGN_TYPE'] ) {
case 'CANCEL_MI':
case 'STATIC_MI':
// Create new delegation depending on the no of users in the group
$iNewAppThreadIndex = $appFields['DEL_THREAD'];
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
foreach($nextDel['NEXT_TASK']['USER_ASSIGNED'] as $key=>$aValue){
//Incrementing the Del_thread First so that new delegation has new del_thread
$iNewAppThreadIndex += 1;
//Creating new delegation according to users in group
$iMIDelIndex = $this->case->newAppDelegation( $appFields['PRO_UID'],$currentDelegation['APP_UID'],$nextDel['TAS_UID'],
(isset($aValue['USR_UID']) ? $aValue['USR_UID'] : ''),
$currentDelegation['DEL_INDEX'],
$nextDel['DEL_PRIORITY'],
$delType,
$iNewAppThreadIndex);
case 'CANCEL_MI':
case 'STATIC_MI':
// Create new delegation depending on the no of users in the group
$iNewAppThreadIndex = $appFields['DEL_THREAD'];
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
foreach($nextDel['NEXT_TASK']['USER_ASSIGNED'] as $key=>$aValue){
//Incrementing the Del_thread First so that new delegation has new del_thread
$iNewAppThreadIndex += 1;
//Creating new delegation according to users in group
$iMIDelIndex = $this->case->newAppDelegation( $appFields['PRO_UID'],$currentDelegation['APP_UID'],$nextDel['TAS_UID'],
(isset($aValue['USR_UID']) ? $aValue['USR_UID'] : ''),
$currentDelegation['DEL_INDEX'],
$nextDel,
$delType,
$iNewAppThreadIndex);
$iNewThreadIndex = $this->case->newAppThread ( $currentDelegation['APP_UID'], $iMIDelIndex, $iAppThreadIndex );
//Setting the del Index for Updating the AppThread delIndex
if($key == 0)
$iNewDelIndex = $iMIDelIndex -1;
}
break;
case 'BALANCED' :
$this->setTasLastAssigned ($nextDel['TAS_UID'], $nextDel['USR_UID']);
//No Break, need no execute the default ones....
default:
// Create new delegation
$iNewDelIndex = $this->case->newAppDelegation(
$appFields['PRO_UID'], $currentDelegation['APP_UID'], $nextDel['TAS_UID'],
(isset($nextDel['USR_UID']) ? $nextDel['USR_UID'] : ''),
$currentDelegation['DEL_INDEX'],
$nextDel['DEL_PRIORITY'],
$delType,
$iAppThreadIndex);
break;
}
$iNewThreadIndex = $this->case->newAppThread ( $currentDelegation['APP_UID'], $iMIDelIndex, $iAppThreadIndex );
//Setting the del Index for Updating the AppThread delIndex
if($key == 0)
$iNewDelIndex = $iMIDelIndex -1;
}
break;
case 'BALANCED' :
$this->setTasLastAssigned ($nextDel['TAS_UID'], $nextDel['USR_UID']);
//No Break, need no execute the default ones....
default:
// Create new delegation
$iNewDelIndex = $this->case->newAppDelegation( $appFields['PRO_UID'],$currentDelegation['APP_UID'],$nextDel['TAS_UID'],
(isset($nextDel['USR_UID']) ? $nextDel['USR_UID'] : ''),
$currentDelegation['DEL_INDEX'],
$nextDel,
$delType,
$iAppThreadIndex);
break;
}
$iAppThreadIndex = $appFields['DEL_THREAD'];
switch ( $currentDelegation['ROU_TYPE'] ) {
case 'PARALLEL' :
@@ -652,20 +651,21 @@ class Derivation
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
$iNewThreadIndex = $this->case->newAppThread ( $currentDelegation['APP_UID'], $iNewDelIndex, $iAppThreadIndex );
$this->case->updateAppDelegation ( $currentDelegation['APP_UID'], $iNewDelIndex, $iNewThreadIndex );
//print " this->case->updateAppDelegation ( " . $currentDelegation['APP_UID'] .", " . $iNewDelIndex ." , " . $iNewThreadIndex . " )<br>";
break;
case 'DISCRIMINATOR':
case 'DISCRIMINATOR':
if($currentDelegation['ROU_OPTIONAL'] == 'TRUE')
{
$this->case->discriminateCases($currentDelegation);
} //No Break, executing Default Condition
default :
switch ($currentDelegation['TAS_ASSIGN_TYPE']) {
case 'CANCEL_MI':
case 'CANCEL_MI':
$this->case->discriminateCases($currentDelegation);
} //No Break, executing updateAppThread
} //No Break, executing updateAppThread
$this->case->updateAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex, $iNewDelIndex );
}//switch
//if there are subprocess to create
if (isset($aSP)) {
//Create the new case in the sub-process
@@ -732,7 +732,7 @@ class Derivation
}
}
}
}
else { //when the task doesnt generate a new AppDelegation
$iAppThreadIndex = $appFields['DEL_THREAD'];
@@ -777,7 +777,7 @@ class Derivation
* @param string $sApplicationUID
* @return void
*/
function verifyIsCaseChild($sApplicationUID)
function verifyIsCaseChild($sApplicationUID)
{
//Obtain the related row in the table SUB_APPLICATION
$oCriteria = new Criteria('workflow');
@@ -836,7 +836,7 @@ class Derivation
$aDeriveTask['NEXT_TASK']['USER_ASSIGNED'] = $selectedUser;
$myLabels = array ( $aDeriveTask['NEXT_TASK']['TAS_TITLE'], $aParentCase['APP_NUMBER'], $selectedUser['USR_USERNAME'], $selectedUser['USR_FIRSTNAME'], $selectedUser['USR_LASTNAME'] );
G::SendTemporalMessage( 'ID_TASK_WAS_ASSIGNED_TO_USER', 'warning', 'labels', 10, null, $myLabels);
}
$nextDelegations2[] = array(
'TAS_UID' => $aDeriveTask['NEXT_TASK']['TAS_UID'],
@@ -861,16 +861,16 @@ class Derivation
}
}
/* getDerivatedCases
/* getDerivatedCases
* get all derivated cases and subcases from any task,
* this function is useful to know who users have been assigned and what task they do.
*
* @param string $sParentUid
* @param string $sDelIndexParent
* @return array $derivation
*
*
*/
function getDerivatedCases ( $sParentUid, $sDelIndexParent )
function getDerivatedCases ( $sParentUid, $sDelIndexParent )
{
$oCriteria = new Criteria('workflow');
$cases = array();

View File

@@ -170,6 +170,9 @@ class processMap {
case 'SEC-JOIN' :
$aRow2 ['ROU_TYPE'] = 5;
break;
case 'DISCRIMINATOR' :
$aRow2 ['ROU_TYPE'] = 8;
break;
}
$oTo = null;
$oTo->task = $aRow2 ['ROU_NEXT_TASK'];
@@ -2247,6 +2250,18 @@ class processMap {
}
$sXmlform = 'patterns_ParallelByEvaluation';
break;
case 'DISCRIMINATOR' :
G::LoadClass ( 'xmlfield_InputPM' );
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_OPTIONAL'] [$aRow ['ROU_CASE']] = $aRow ['ROU_OPTIONAL'];
G::LoadClass('tasks');
$oTasks = new Tasks();
$routeData = $oTasks->getRouteByType($sProcessUID, $aRow['ROU_NEXT_TASK'], $aRow['ROU_TYPE']);
$aFields['ROUTE_COUNT'] = count($routeData);
$sXmlform = 'patterns_Discriminator';
break;
}
}
$aFields ['action'] = 'savePattern';
@@ -2337,6 +2352,19 @@ class processMap {
$oDataset->next();
}
break;
case 'DISCRIMINATOR' :
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_OPTIONAL'] [$aRow ['ROU_CASE']] = $aRow ['ROU_OPTIONAL'];
while ( $aRow = $oDataset->getRow () ) {
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] [$aRow ['ROU_CASE']] = $aRow ['ROU_UID'];
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_NEXT_TASK'] [$aRow ['ROU_CASE']] = $aRow ['ROU_NEXT_TASK'];
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_CONDITION'] [$aRow ['ROU_CASE']] = $aRow ['ROU_CONDITION'];
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_OPTIONAL'] [$aRow ['ROU_CASE']] = $aRow ['ROU_OPTIONAL'];
$oDataset->next ();
}
break;
}
} else {
@@ -2375,6 +2403,13 @@ class processMap {
$aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
$aFields ['GRID_PARALLEL_EVALUATION_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
break;
case 'DISCRIMINATOR' :
$iRow = (isset ( $aFields ['GRID_DISCRIMINATOR_TYPE'] ) ? count ( $aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] ) + 1 : 0);
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_UID'] [$iRow] = '';
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_NEXT_TASK'] [$iRow] = $sNextTask;
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_CONDITION'] [$iRow] = '';
$aFields ['GRID_DISCRIMINATOR_TYPE'] ['ROU_TO_LAST_USER'] [$iRow] = '';
break;
}
$aFields ['action'] = 'savePattern';
$aFields ['LANG'] = SYS_LANG;

View File

@@ -36,7 +36,7 @@ require_once 'classes/model/Users.php';
/**
* Tasks - Tasks class
* @package ProcessMaker
* @author Julio Cesar Laura Avenda<64>o
* @author Julio Cesar Laura Avenda<64>o
* @copyright 2007 COLOSA
*/
@@ -648,5 +648,35 @@ class Tasks
throw($oError);
}
}
/**
* Get Routes for any Process,route type,route next task
* @param string $sProUid, $sTaskUid
* @return array
* by Girish
*/
public function getRouteByType($sProUid, $sRouteNextTaskUid,$sRouteType)
{
try {
$aRoutes = array();
$oCriteria = new Criteria('workflow');
$oCriteria->add(RoutePeer::PRO_UID, $sProUid);
$oCriteria->add(RoutePeer::ROU_NEXT_TASK, $sRouteNextTaskUid);
$oCriteria->add(RoutePeer::ROU_TYPE, $sRouteType);
$oDataset = RoutePeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$aRoutes[] = $aRow;
$oDataset->next();
}
return $aRoutes;
}
catch (Exception $oError) {
throw($oError);
}
}
}
?>

View File

@@ -26,6 +26,7 @@
require_once 'classes/model/om/BaseAppDelegation.php';
require_once ( "classes/model/HolidayPeer.php" );
require_once ( "classes/model/TaskPeer.php" );
require_once ( "classes/model/Task.php" );
G::LoadClass("dates");
/**
@@ -51,7 +52,7 @@ class AppDelegation extends BaseAppDelegation {
* @param $isSubprocess is a subprocess inside a process?
* @return delegation index of the application delegation.
*/
function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess=false, $sPrevious=-1 ) {
function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $sNextTasParam,$iPriority = 3, $isSubprocess=false ) {
if (!isset($sProUid) || strlen($sProUid) == 0 ) {
throw ( new Exception ( 'Column "PRO_UID" cannot be null.' ) );
@@ -75,17 +76,19 @@ class AppDelegation extends BaseAppDelegation {
$c = new Criteria ();
$c->clearSelectColumns();
$c->addSelectColumn ( 'MAX(' . AppDelegationPeer::DEL_INDEX . ') ' );
$c->addSelectColumn ( AppDelegationPeer::DEL_STARTED );
$c->add ( AppDelegationPeer::APP_UID, $sAppUid );
$rs = AppDelegationPeer::doSelectRS ( $c );
$rs->next();
$row = $rs->getRow();
$delIndex = $row[0] + 1;
//$delStarted = $row[1]; ???? blame -> gustavo,..$row[1] doesn't exist
$this->setAppUid ( $sAppUid );
$this->setProUid ( $sProUid );
$this->setTasUid ( $sTasUid );
$this->setDelIndex ( $delIndex );
$this->setDelPrevious ( $sPrevious == -1 ? 0 : $sPrevious );
$this->setDelPrevious ( 0 );
$this->setUsrUid ( $sUsrUid );
$this->setDelType ( 'NORMAL' );
$this->setDelPriority ( ($iPriority != '' ? $iPriority : '3') );
@@ -93,14 +96,15 @@ class AppDelegation extends BaseAppDelegation {
$this->setDelThreadStatus ( 'OPEN' );
$this->setDelDelegateDate ( 'now' );
//The function return an array now. By JHL
$delTaskDueDate=$this->calculateDueDate();
$delTaskDueDate=$this->calculateDueDate($sNextTasParam);
$this->setDelTaskDueDate ( $delTaskDueDate['DUE_DATE'] ); // Due date formatted
$this->setDelData ( '' ); //$delTaskDueDate['DUE_DATE_LOG'] ); // Log of actions made by Calendar Engine
$this->setDelData ( $delTaskDueDate['DUE_DATE_LOG'] ); // Log of actions made by Calendar Engine
// this condition assures that an internal delegation like a subprocess dont have an initial date setted
if ( $delIndex == 1 && !$isSubprocess ) //the first delegation, init date this should be now for draft applications, in other cases, should be null.
$this->setDelInitDate ('now' );
if ($this->validate() ) {
try {
$res = $this->save();
@@ -116,7 +120,7 @@ class AppDelegation extends BaseAppDelegation {
foreach($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "<br/>";
}
throw ( new Exception ( 'Failed Data validation saving APP_DELEGATION row: ' . $msg ) );
throw ( new Exception ( 'Failed Data validation. ' . $msg ) );
}
return $this->getDelIndex();
@@ -139,7 +143,7 @@ class AppDelegation extends BaseAppDelegation {
return $aFields;
}
else {
throw( new Exception( "The row '$AppUid, $sDelIndex' in table AppDelegation doesn't exist!" ));
throw( new Exception( "The row '$AppUid, $sDelIndex' in table AppDelegation doesn't exists!" ));
}
}
catch (Exception $oError) {
@@ -176,7 +180,7 @@ class AppDelegation extends BaseAppDelegation {
}
else {
$con->rollback();
throw(new Exception( "This AppDelegation row doesn't exist!" ));
throw(new Exception( "This AppDelegation row doesn't exists!" ));
}
}
catch (Exception $oError) {
@@ -203,20 +207,44 @@ class AppDelegation extends BaseAppDelegation {
// TasTypeDay = 1 => working days
// TasTypeDay = 2 => calendar days
function calculateDueDate()
function calculateDueDate($sNextTasParam)
{
//Get Task properties
$task = TaskPeer::retrieveByPK( $this->getTasUid() );
$aData['TAS_UID'] = $this->getTasUid();
//Added to allow User defined Timing Control at Run time from Derivation screen
if(isset($sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY']) && $sNextTasParam['NEXT_TASK']['TAS_TRANSFER_HIDDEN_FLY'] == 'true')
{
$aData['TAS_DURATION'] = $sNextTasParam['NEXT_TASK']['TAS_DURATION'];
$aData['TAS_TIMEUNIT'] = $sNextTasParam['NEXT_TASK']['TAS_TIMEUNIT'];
$aData['TAS_TYPE_DAY'] = $sNextTasParam['NEXT_TASK']['TAS_TYPE_DAY'];
if(isset($sNextTasParam['NEXT_TASK']['TAS_CALENDAR']) && $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'] != '')
$aCalendarUID = $sNextTasParam['NEXT_TASK']['TAS_CALENDAR'];
else
$aCalendarUID = '';
//Updating the task Table , so that user will see updated values in the assign screen in consequent cases
$oTask = new Task();
$oTask->update($aData);
}
else
{
$aData['TAS_DURATION'] = $task->getTasDuration();
$aData['TAS_TIMEUNIT'] = $task->getTasTimeUnit();
$aData['TAS_TYPE_DAY'] = $task->getTasTypeDay();
$aCalendarUID = '';
}
//use the dates class to calculate dates
$dates = new dates();
$iDueDate = $dates->calculateDate( $this->getDelDelegateDate(),
$task->getTasDuration(),
$task->getTasTimeUnit(), //hours or days, ( we only accept this two types or maybe weeks
$task->getTasTypeDay(), //working or calendar days
$aData['TAS_DURATION'],
$aData['TAS_TIMEUNIT'], //hours or days, ( we only accept this two types or maybe weeks
$aData['TAS_TYPE_DAY'], //working or calendar days
$this->getUsrUid(),
$task->getProUid(),
$this->getTasUid() );
$aData['TAS_UID'],
$aCalendarUID);
return $iDueDate;
}
@@ -226,7 +254,7 @@ function getDiffDate ( $date1, $date2 ) {
}
function calculateDuration() {
try {
//patch rows with initdate = null and finish_date
//patch rows with initdate = null and finish_date
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn(AppDelegationPeer::APP_UID );
@@ -272,7 +300,7 @@ function getDiffDate ( $date1, $date2 ) {
$c->addSelectColumn(TaskPeer::TAS_DURATION);
$c->addSelectColumn(TaskPeer::TAS_TIMEUNIT);
$c->addSelectColumn(TaskPeer::TAS_TYPE_DAY);
$c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN );
//$c->add(AppDelegationPeer::DEL_INIT_DATE, NULL, Criteria::ISNULL);
//$c->add(AppDelegationPeer::APP_UID, '7694483844a37bfeb0931b1063501289');
@@ -289,7 +317,7 @@ function getDiffDate ( $date1, $date2 ) {
$row = $rs->getRow();
$i =0;
//print "<table colspacing='2' border='1'>";
//print "<tr><td>iDelegateDate </td><td>iInitDate </td><td>iDueDate </td><td>iFinishDate </td><td>isStarted </td><td>isFinished </td><td>isDelayed </td><td>queueDuration </td><td>delDuration </td><td>delayDuration</td></tr>";
//print "<tr><td>iDelegateDate </td><td>iInitDate </td><td>iDueDate </td><td>iFinishDate </td><td>isStarted </td><td>isFinished </td><td>isDelayed </td><td>queueDuration </td><td>delDuration </td><td>delayDuration</td></tr>";
$now = strtotime ( 'now' );
while ( is_array($row) ) {
$fTaskDuration = $row['TAS_DURATION'];
@@ -304,9 +332,9 @@ $i =0;
$delDuration = 0;
$delayDuration = 0;
$overduePercentage = 0.0;
//get the object,
//get the object,
$oAppDel = AppDelegationPeer::retrieveByPk($row['APP_UID'], $row['DEL_INDEX'] );
//if the task is not started
//if the task is not started
if ( $isStarted == 0 ) {
if ( $row['DEL_INIT_DATE'] != NULL && $row['DEL_INIT_DATE'] != '' ) {
$oAppDel->setDelStarted(1);
@@ -322,7 +350,7 @@ $i =0;
$oAppDel->setDelDelayDuration( $delayDuration);
if ( $fTaskDuration != 0) {
$overduePercentage = $delayDuration / $fTaskDuration;
$oAppDel->setAppOverduePercentage( $overduePercentage);
$oAppDel->setAppOverduePercentage( $overduePercentage);
if ( $iDueDate < $now ) {
$oAppDel->setDelDelayed(1);
}
@@ -352,7 +380,7 @@ $i =0;
if ( $row['DEL_INIT_DATE'] != NULL && $row['DEL_INIT_DATE'] != '' ) {
$delDuration = $this->getDiffDate ($now, $iInitDate );
}
else
else
$delDuration = $this->getDiffDate ($now, $iDelegateDate);
$oAppDel->setDelDuration( $delDuration);
@@ -361,7 +389,7 @@ $i =0;
$oAppDel->setDelDelayDuration( $delayDuration);
if ( $fTaskDuration != 0) {
$overduePercentage = $delayDuration / $fTaskDuration;
$oAppDel->setAppOverduePercentage($overduePercentage );
$oAppDel->setAppOverduePercentage($overduePercentage );
if ( $iDueDate < $now ) {
$oAppDel->setDelDelayed(1);
}
@@ -369,26 +397,26 @@ $i =0;
}
}
//and finally save the record
$RES = $oAppDel->save();
//print "<tr><td>$iDelegateDate </td><td>$iInitDate </td><td>$iDueDate </td><td>$iFinishDate </td><td>$isStarted </td><td>$isFinished </td><td>$isDelayed</td><td>$queueDuration </td><td>$delDuration </td>" .
// "<td>$delayDuration</td><td>$overduePercentage</td><td>" . $row['DEL_INDEX'] . " $RES </td></tr>";
// "<td>$delayDuration</td><td>$overduePercentage</td><td>" . $row['DEL_INDEX'] . " $RES </td></tr>";
//UPDATE APP_DELEGATION SET DEL_DELAYED = 0
//where
//where
// APP_OVERDUE_PERCENTAGE < 0
$rs->next();
$row = $rs->getRow();
}
}
catch ( Exception $oError) {
//krumo ( $oError->getMessage() );
}
}
function getLastDeleration($APP_UID){
$c = new Criteria('workflow');
$c->addSelectColumn(AppDelegationPeer::APP_UID );
@@ -404,7 +432,7 @@ $i =0;
$c->addSelectColumn(AppDelegationPeer::DEL_FINISHED);
$c->addSelectColumn(AppDelegationPeer::DEL_DELAYED);
$c->addSelectColumn(AppDelegationPeer::USR_UID);
$c->add(AppDelegationPeer::APP_UID, $APP_UID);
$c->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
$rs = AppDelegationPeer::doSelectRS($c);

View File

@@ -144,7 +144,7 @@ class TaskMapBuilder {
$tMap->addColumn('TAS_BOUNDARY', 'TasBoundary', 'string', CreoleTypes::VARCHAR, true, 32);
$tMap->addValidator('TAS_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'NORMAL|ADHOC|SUBPROCESS', 'Please select a valid value for TAS_TYPE.');
$tMap->addValidator('TAS_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'NORMAL|ADHOC|SUBPROCESS|HIDDEN', 'Please select 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.');