BUG 7864 7635 "Parallel Join Routing Rule by evaluation problem" SOLVED

- problem when a condition is evaluated false, so the join never completes solved
This commit is contained in:
Erik Amaru Ortiz
2011-10-24 08:48:59 -04:00
parent ccf5d21531
commit 93d9f365f5
3 changed files with 234 additions and 197 deletions

View File

@@ -1198,14 +1198,19 @@ class Cases {
$oDataset3->next();
$aRow3 = $oDataset3->getRow();
if (is_array($aRow3)) {
//there are closed delegations, so we need to get back without returning delegation rows
} else { //if not we start the recursion searching previous open tasks from this task.
if (!in_array($aRow['TAS_UID'],$aPreviousTasks)){
//TODO there are closed delegations, so we need to get back without returning delegation rows
}
else { //if not we start the recursion searching previous open tasks from this task.
if (!in_array($aRow['TAS_UID'],$aPreviousTasks)) {
// storing the current task uid of the task currently checked
$aPreviousTasks[] = $aRow['TAS_UID'];
// passing the array of previous tasks in oprder to avoid an infinite loop that prevents
$aTaskReviewed[] = $this->searchOpenPreviousTasks($aRow['TAS_UID'], $sAppUid, $aPreviousTasks);
$openPreviousTask = $this->searchOpenPreviousTasks($aRow['TAS_UID'], $sAppUid, $aPreviousTasks);
if (count($previousTasks) > 0) {
array_push($aTaskReviewed, $openPreviousTask);
}
}
}
}

View File

@@ -550,10 +550,12 @@ class Derivation
$this->case->closeAllThreads ( $currentDelegation['APP_UID']);
//I think we need to change the APP_STATUS to completed,
break;
case TASK_FINISH_TASK:
$iAppThreadIndex = $appFields['DEL_THREAD'];
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
break;
default:
// get all siblingThreads
//if($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI')
@@ -572,20 +574,28 @@ class Derivation
$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']);
$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')
{
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);
@@ -599,18 +609,64 @@ class Derivation
else {
$canDerivate = true;
}
}
} //end switch
if ( $canDerivate ) {
$aSP = isset($aSP) ? $aSP : null;
$this->doDerivation($currentDelegation, $nextDel, $appFields, $aSP);
}
else { //when the task doesnt generate a new AppDelegation
$iAppThreadIndex = $appFields['DEL_THREAD'];
switch ( $currentDelegation['ROU_TYPE'] ) {
case 'DISCRIMINATOR':
case 'SEC-JOIN' :
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
break;
default :
if($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI' || $currentDelegation['TAS_ASSIGN_TYPE'] == 'CANCEL_MI')
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
}//switch
}
}
//SETS THE APP_PROC_CODE
//if (isset($nextDel['TAS_DEF_PROC_CODE']))
//$appFields['APP_PROC_CODE'] = $nextDel['TAS_DEF_PROC_CODE'];
unset($aSP);
} //end foreach
/* Start Block : UPDATES APPLICATION */
//Set THE APP_STATUS
$appFields['APP_STATUS'] = $currentDelegation['APP_STATUS'];
/* Start Block : Count the open threads of $currentDelegation['APP_UID'] */
$openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] );
if ($openThreads == 0) {//Close case
$appFields['APP_STATUS'] = 'COMPLETED';
$appFields['APP_FINISH_DATE'] = 'now';
$this->verifyIsCaseChild($currentDelegation['APP_UID']);
}
$appFields['DEL_INDEX'] = (isset($iNewDelIndex) ? $iNewDelIndex : 0);
$appFields['TAS_UID'] = $nextDel['TAS_UID'];
/* Start Block : UPDATES APPLICATION */
$this->case->updateCase ( $currentDelegation['APP_UID'], $appFields );
/* End Block : UPDATES APPLICATION */
}
function doDerivation($currentDelegation, $nextDel, $appFields, $aSP = null)
{
$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;
@@ -632,8 +688,10 @@ class Derivation
//Setting the del Index for Updating the AppThread delIndex
if($key == 0)
$iNewDelIndex = $iMIDelIndex -1;
}
} //end foreach
break;
case 'BALANCED' :
$this->setTasLastAssigned ($nextDel['TAS_UID'], $nextDel['USR_UID']);
//No Break, need no execute the default ones....
@@ -652,7 +710,9 @@ class Derivation
);
break;
}
$iAppThreadIndex = $appFields['DEL_THREAD'];
switch ( $currentDelegation['ROU_TYPE'] ) {
case 'PARALLEL' :
case 'PARALLEL-BY-EVALUATION' :
@@ -661,18 +721,20 @@ class Derivation
$this->case->updateAppDelegation ( $currentDelegation['APP_UID'], $iNewDelIndex, $iNewThreadIndex );
//print " this->case->updateAppDelegation ( " . $currentDelegation['APP_UID'] .", " . $iNewDelIndex ." , " . $iNewThreadIndex . " )<br>";
break;
case 'DISCRIMINATOR':
if($currentDelegation['ROU_OPTIONAL'] == 'TRUE')
{
if($currentDelegation['ROU_OPTIONAL'] == 'TRUE') {
$this->case->discriminateCases($currentDelegation);
} //No Break, executing Default Condition
default :
switch ($currentDelegation['TAS_ASSIGN_TYPE']) {
case 'CANCEL_MI':
$this->case->discriminateCases($currentDelegation);
} //No Break, executing updateAppThread
$this->case->updateAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex, $iNewDelIndex );
}//switch
}//en switch
//if there are subprocess to create
if (isset($aSP)) {
@@ -683,6 +745,7 @@ class Derivation
$aFields = unserialize($aSP['SP_VARIABLES_OUT']);
$aNewFields = array();
$aOldFields = $this->case->loadCase($aNewCase['APPLICATION']);
foreach ($aFields as $sOriginField => $sTargetField) {
$sOriginField = str_replace('@', '', $sOriginField);
$sOriginField = str_replace('#', '', $sOriginField);
@@ -690,8 +753,10 @@ class Derivation
$sTargetField = str_replace('#', '', $sTargetField);
$aNewFields[$sTargetField] = isset($appFields['APP_DATA'][$sOriginField]) ? $appFields['APP_DATA'][$sOriginField] : '';
}
$aOldFields['APP_DATA'] = array_merge($aOldFields['APP_DATA'], $aNewFields);
$aOldFields['APP_STATUS'] = 'TO_DO';
$this->case->updateCase($aNewCase['APPLICATION'], $aOldFields);
//Create a registry in SUB_APPLICATION table
$aSubApplication = array('APP_UID' => $aNewCase['APPLICATION'],
@@ -701,10 +766,12 @@ class Derivation
'SA_STATUS' => 'ACTIVE',
'SA_VALUES_OUT' => serialize($aNewFields),
'SA_INIT_DATE' => date('Y-m-d H:i:s'));
if ($aSP['SP_SYNCHRONOUS'] == 0) {
$aSubApplication['SA_STATUS'] = 'FINISHED';
$aSubApplication['SA_FINISH_DATE'] = $aSubApplication['SA_INIT_DATE'];
}
$oSubApplication = new SubApplication();
$oSubApplication->create($aSubApplication);
//Update the AppDelegation to execute the update trigger
@@ -716,6 +783,7 @@ class Derivation
$AppDelegation->save();
//If not is SYNCHRONOUS derivate one more time
if ($aSP['SP_SYNCHRONOUS'] == 0) {
$this->case->setDelInitDate($currentDelegation['APP_UID'], $iNewDelIndex);
$aDeriveTasks = $this->prepareInformation(
@@ -723,6 +791,7 @@ class Derivation
'APP_UID' => $currentDelegation['APP_UID'],
'DEL_INDEX' => $iNewDelIndex)
);
if (isset($aDeriveTasks[1])) {
if ($aDeriveTasks[1]['ROU_TYPE'] != 'SELECT') {
$nextDelegations2 = array();
@@ -747,45 +816,7 @@ class Derivation
}
}
}
}
}
else { //when the task doesnt generate a new AppDelegation
$iAppThreadIndex = $appFields['DEL_THREAD'];
switch ( $currentDelegation['ROU_TYPE'] ) {
case 'DISCRIMINATOR':
case 'SEC-JOIN' :
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
break;
default :
if($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI' || $currentDelegation['TAS_ASSIGN_TYPE'] == 'CANCEL_MI')
$this->case->closeAppThread ( $currentDelegation['APP_UID'], $iAppThreadIndex);
}//switch
}
}
//SETS THE APP_PROC_CODE
//if (isset($nextDel['TAS_DEF_PROC_CODE']))
//$appFields['APP_PROC_CODE'] = $nextDel['TAS_DEF_PROC_CODE'];
unset($aSP);
}
/* Start Block : UPDATES APPLICATION */
//Set THE APP_STATUS
$appFields['APP_STATUS'] = $currentDelegation['APP_STATUS'];
/* Start Block : Count the open threads of $currentDelegation['APP_UID'] */
$openThreads = $this->case->GetOpenThreads( $currentDelegation['APP_UID'] );
if ($openThreads == 0) {//Close case
$appFields['APP_STATUS'] = 'COMPLETED';
$appFields['APP_FINISH_DATE'] = 'now';
$this->verifyIsCaseChild($currentDelegation['APP_UID']);
}
$appFields['DEL_INDEX'] = (isset($iNewDelIndex) ? $iNewDelIndex : 0);
$appFields['TAS_UID'] = $nextDel['TAS_UID'];
/* Start Block : UPDATES APPLICATION */
$this->case->updateCase ( $currentDelegation['APP_UID'], $appFields );
/* End Block : UPDATES APPLICATION */
} //end switch
}
/* verifyIsCaseChild

View File

@@ -23,6 +23,7 @@ var main = function(){
enableDD:true,
containerScroll: true,
border: false,
width: 250,
height: 120,
dropConfig: {appendOnly:true},