Merged in victorsl/processmaker/3.0.1-GA (pull request #2533)

PM-2923 "0017509: El caso que se derivo a un grupo no..." SOLVED
This commit is contained in:
Julio Cesar Laura Avendaño
2015-07-28 10:38:22 -04:00
2 changed files with 18 additions and 51 deletions

View File

@@ -6649,19 +6649,6 @@ class Cases
} }
} }
public 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
//update searchindex
if ($this->appSolr != null) {
$this->appSolr->updateApplicationSearchIndex($aData['APP_UID']);
}
}
}
/* /*
* We're getting all threads in a task * We're getting all threads in a task
* *

View File

@@ -778,7 +778,6 @@ class Derivation
//when the task doesnt generate a new AppDelegation //when the task doesnt generate a new AppDelegation
$iAppThreadIndex = $appFields['DEL_THREAD']; $iAppThreadIndex = $appFields['DEL_THREAD'];
switch ($currentDelegation['ROU_TYPE']) { switch ($currentDelegation['ROU_TYPE']) {
case 'DISCRIMINATOR':
case 'SEC-JOIN': case 'SEC-JOIN':
$this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex ); $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );
break; break;
@@ -786,6 +785,7 @@ class Derivation
if ($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI' || $currentDelegation['TAS_ASSIGN_TYPE'] == 'CANCEL_MI') { if ($currentDelegation['TAS_ASSIGN_TYPE'] == 'STATIC_MI' || $currentDelegation['TAS_ASSIGN_TYPE'] == 'CANCEL_MI') {
$this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex ); $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );
} }
break;
} //switch } //switch
} }
} }
@@ -936,22 +936,12 @@ class Derivation
$this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex ); $this->case->closeAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex );
$iNewThreadIndex = $this->case->newAppThread( $currentDelegation['APP_UID'], $iNewDelIndex, $iAppThreadIndex ); $iNewThreadIndex = $this->case->newAppThread( $currentDelegation['APP_UID'], $iNewDelIndex, $iAppThreadIndex );
$this->case->updateAppDelegation( $currentDelegation['APP_UID'], $iNewDelIndex, $iNewThreadIndex ); $this->case->updateAppDelegation( $currentDelegation['APP_UID'], $iNewDelIndex, $iNewThreadIndex );
//print " this->case->updateAppDelegation ( " . $currentDelegation['APP_UID'] .", " . $iNewDelIndex ." , " . $iNewThreadIndex . " )<br>";
break; break;
case 'DISCRIMINATOR':
if ($currentDelegation['ROU_OPTIONAL'] == 'TRUE') {
$this->case->discriminateCases( $currentDelegation );
} //No Break, executing Default Condition
default: 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 ); $this->case->updateAppThread( $currentDelegation['APP_UID'], $iAppThreadIndex, $iNewDelIndex );
break;
} //en switch } //en switch
//if there are subprocess to create //if there are subprocess to create
if (isset( $aSP )) { if (isset( $aSP )) {
//Create the new case in the sub-process //Create the new case in the sub-process
@@ -960,35 +950,15 @@ class Derivation
$taskNextDel = TaskPeer::retrieveByPK($aSP["TAS_UID"]); //Sub-Process $taskNextDel = TaskPeer::retrieveByPK($aSP["TAS_UID"]); //Sub-Process
//Create record in table APP_ASSIGN_SELF_SERVICE_VALUE
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])));
}
}
//Copy case variables to sub-process case //Copy case variables to sub-process case
$aFields = unserialize( $aSP['SP_VARIABLES_OUT'] ); $aFields = unserialize( $aSP['SP_VARIABLES_OUT'] );
$aNewFields = array (); $aNewFields = array ();
$aOldFields = $this->case->loadCase( $aNewCase['APPLICATION'] ); $aOldFields = $this->case->loadCase( $aNewCase['APPLICATION'] );
foreach ($aFields as $sOriginField => $sTargetField) { foreach ($aFields as $sOriginField => $sTargetField) {
$sOriginField = str_replace( '@', '', $sOriginField ); $sOriginField = trim($sOriginField, " @#%?$=");
$sOriginField = str_replace( '#', '', $sOriginField ); $sTargetField = trim($sTargetField, " @#%?$=");
$sOriginField = str_replace( '%', '', $sOriginField );
$sOriginField = str_replace( '?', '', $sOriginField );
$sOriginField = str_replace( '$', '', $sOriginField );
$sOriginField = str_replace( '=', '', $sOriginField );
$sTargetField = str_replace( '@', '', $sTargetField );
$sTargetField = str_replace( '#', '', $sTargetField );
$sTargetField = str_replace( '%', '', $sTargetField );
$sTargetField = str_replace( '?', '', $sTargetField );
$sTargetField = str_replace( '$', '', $sTargetField );
$sTargetField = str_replace( '=', '', $sTargetField );
$aNewFields[$sTargetField] = isset( $appFields['APP_DATA'][$sOriginField] ) ? $appFields['APP_DATA'][$sOriginField] : ''; $aNewFields[$sTargetField] = isset( $appFields['APP_DATA'][$sOriginField] ) ? $appFields['APP_DATA'][$sOriginField] : '';
} }
@@ -996,6 +966,7 @@ class Derivation
$aOldFields['APP_STATUS'] = 'TO_DO'; $aOldFields['APP_STATUS'] = 'TO_DO';
$this->case->updateCase( $aNewCase['APPLICATION'], $aOldFields ); $this->case->updateCase( $aNewCase['APPLICATION'], $aOldFields );
//Create a registry in SUB_APPLICATION table //Create a registry in SUB_APPLICATION table
$aSubApplication = array ('APP_UID' => $aNewCase['APPLICATION'],'APP_PARENT' => $currentDelegation['APP_UID'],'DEL_INDEX_PARENT' => $iNewDelIndex,'DEL_THREAD_PARENT' => $iAppThreadIndex,'SA_STATUS' => 'ACTIVE','SA_VALUES_OUT' => serialize( $aNewFields ),'SA_INIT_DATE' => date( 'Y-m-d H:i:s' ) $aSubApplication = array ('APP_UID' => $aNewCase['APPLICATION'],'APP_PARENT' => $currentDelegation['APP_UID'],'DEL_INDEX_PARENT' => $iNewDelIndex,'DEL_THREAD_PARENT' => $iAppThreadIndex,'SA_STATUS' => 'ACTIVE','SA_VALUES_OUT' => serialize( $aNewFields ),'SA_INIT_DATE' => date( 'Y-m-d H:i:s' )
); );
@@ -1014,11 +985,20 @@ class Derivation
// the following line of code was commented because it is related to the 6878 bug // the following line of code was commented because it is related to the 6878 bug
//$AppDelegation->setDelInitDate("+1 second"); //$AppDelegation->setDelInitDate("+1 second");
$AppDelegation->save(); $AppDelegation->save();
//Create record in table APP_ASSIGN_SELF_SERVICE_VALUE
if ($taskNextDel->getTasAssignType() == "SELF_SERVICE" && trim($taskNextDel->getTasGroupVariable()) != "") {
$nextTaskGroupVariable = trim($taskNextDel->getTasGroupVariable(), " @#");
if (isset($aOldFields["APP_DATA"][$nextTaskGroupVariable]) && trim($aOldFields["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($aOldFields["APP_DATA"][$nextTaskGroupVariable])));
}
}
//If not is SYNCHRONOUS derivate one more time //If not is SYNCHRONOUS derivate one more time
if ($aSP['SP_SYNCHRONOUS'] == 0) { if ($aSP['SP_SYNCHRONOUS'] == 0) {
$this->case->setDelInitDate( $currentDelegation['APP_UID'], $iNewDelIndex ); $this->case->setDelInitDate( $currentDelegation['APP_UID'], $iNewDelIndex );
$aDeriveTasks = $this->prepareInformation( array ('USER_UID' => -1,'APP_UID' => $currentDelegation['APP_UID'],'DEL_INDEX' => $iNewDelIndex $aDeriveTasks = $this->prepareInformation( array ('USER_UID' => -1,'APP_UID' => $currentDelegation['APP_UID'],'DEL_INDEX' => $iNewDelIndex