HOR-756
This commit is contained in:
@@ -1750,12 +1750,12 @@ class Cases
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function newAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sPrevious, $iPriority, $sDelType, $iAppThreadIndex = 1, $nextDel = null)
|
||||
public function newAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sPrevious, $iPriority, $sDelType, $iAppThreadIndex = 1, $nextDel = null, $flagControl = false)
|
||||
{
|
||||
try {
|
||||
$appDel = new AppDelegation();
|
||||
$result = $appDel->createAppDelegation(
|
||||
$sProUid, $sAppUid, $sTasUid, $sUsrUid, $iAppThreadIndex, $iPriority, false, $sPrevious, $nextDel
|
||||
$sProUid, $sAppUid, $sTasUid, $sUsrUid, $iAppThreadIndex, $iPriority, false, $sPrevious, $nextDel, $flagControl
|
||||
);
|
||||
//update searchindex
|
||||
if ($this->appSolr != null) {
|
||||
|
||||
@@ -48,6 +48,7 @@ G::LoadClass( "plugin" );
|
||||
class Derivation
|
||||
{
|
||||
var $case;
|
||||
protected $flagControl;
|
||||
|
||||
/**
|
||||
* prepareInformationTask
|
||||
@@ -1134,6 +1135,9 @@ class Derivation
|
||||
$arrayOpenThread = array_merge($arrayOpenThread, $arraySiblings);
|
||||
}
|
||||
$canDerivate = empty($arrayOpenThread);
|
||||
if($canDerivate){
|
||||
$this->flagControl = true;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
@@ -1184,8 +1188,9 @@ class Derivation
|
||||
break;
|
||||
default:
|
||||
$iNewDelIndex = $this->doDerivation($currentDelegation, $nextDel, $appFields, $aSP);
|
||||
|
||||
$arrayDerivationResult[] = ['DEL_INDEX' => $iNewDelIndex, 'TAS_UID' => $nextDel['TAS_UID'], 'USR_UID' => (isset($nextDel['USR_UID']))? $nextDel['USR_UID'] : ''];
|
||||
if($iNewDelIndex !== 0){
|
||||
$arrayDerivationResult[] = ['DEL_INDEX' => $iNewDelIndex, 'TAS_UID' => $nextDel['TAS_UID'], 'USR_UID' => (isset($nextDel['USR_UID']))? $nextDel['USR_UID'] : ''];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1381,7 +1386,7 @@ class Derivation
|
||||
//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, $nextDel );
|
||||
$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, $nextDel, $this->flagControl );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class AppDelegation extends BaseAppDelegation
|
||||
* @param $isSubprocess is a subprocess inside a process?
|
||||
* @return delegation index of the application delegation.
|
||||
*/
|
||||
public function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null)
|
||||
public function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null, $flagControl = false)
|
||||
{
|
||||
if (! isset( $sProUid ) || strlen( $sProUid ) == 0) {
|
||||
throw (new Exception( 'Column "PRO_UID" cannot be null.' ));
|
||||
@@ -82,6 +82,7 @@ class AppDelegation extends BaseAppDelegation
|
||||
$criteria = new Criteria("workflow");
|
||||
$criteria->add(AppDelegationPeer::APP_UID, $sAppUid);
|
||||
$criteria->add(AppDelegationPeer::DEL_LAST_INDEX, 1);
|
||||
$criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX);
|
||||
|
||||
$criteriaIndex = clone $criteria;
|
||||
|
||||
@@ -112,6 +113,14 @@ class AppDelegation extends BaseAppDelegation
|
||||
$delIndex = (isset($row["DEL_INDEX"]))? $row["DEL_INDEX"] + 1 : 1;
|
||||
}
|
||||
}
|
||||
//Verify successors: parrallel submit in the same time
|
||||
if($flagControl){
|
||||
$nextTaskUid = $sTasUid;
|
||||
$index = $this->getAllTasksBeforeSecJoin($nextTaskUid, $sAppUid);
|
||||
if($this->createThread($index, $sAppUid)){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Update set
|
||||
$criteriaUpdate = new Criteria('workflow');
|
||||
@@ -156,7 +165,8 @@ class AppDelegation extends BaseAppDelegation
|
||||
try {
|
||||
$res = $this->save();
|
||||
} catch (PropelException $e) {
|
||||
throw ($e);
|
||||
error_log($e->getMessage());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Something went wrong. We can now get the validationFailures and handle them.
|
||||
@@ -739,5 +749,50 @@ class AppDelegation extends BaseAppDelegation
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all task before Join Threads
|
||||
*
|
||||
* @param string $nextTaskUid
|
||||
* @param string $sAppUid
|
||||
* @return array $index
|
||||
*/
|
||||
public static function getAllTasksBeforeSecJoin($nextTaskUid, $sAppUid){
|
||||
$criteriaR = new Criteria('workflow');
|
||||
$criteriaR->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
$criteriaR->addJoin(RoutePeer::TAS_UID, AppDelegationPeer::TAS_UID, Criteria::LEFT_JOIN);
|
||||
$criteriaR->add(RoutePeer::ROU_NEXT_TASK, $nextTaskUid, Criteria::EQUAL);
|
||||
$criteriaR->add(RoutePeer::ROU_TYPE, 'SEC-JOIN', Criteria::EQUAL);
|
||||
$criteriaR->add(AppDelegationPeer::APP_UID, $sAppUid, Criteria::EQUAL);
|
||||
$rsCriteriaR = RoutePeer::doSelectRS($criteriaR);
|
||||
$rsCriteriaR->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$index = array();
|
||||
$c = 0;
|
||||
while($rsCriteriaR->next()){
|
||||
$row = $rsCriteriaR->getRow();
|
||||
$index[$c++] = $row['DEL_INDEX'];
|
||||
}
|
||||
return $index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if we need to create a new Thread
|
||||
*
|
||||
* @param array $index
|
||||
* @param string $sAppUid
|
||||
* @return boolean $res
|
||||
*/
|
||||
public static function createThread($index, $sAppUid){
|
||||
$criteriaDel = new Criteria("workflow");
|
||||
$criteriaDel->addSelectColumn(AppDelegationPeer::DEL_INDEX);
|
||||
$criteriaDel->addSelectColumn(AppDelegationPeer::DEL_PREVIOUS);
|
||||
$criteriaDel->add(AppDelegationPeer::APP_UID, $sAppUid);
|
||||
$criteriaDel->add(AppDelegationPeer::DEL_PREVIOUS, $index, Criteria::IN);
|
||||
$criteriaDel = AppDelegationPeer::doSelectRS($criteriaDel);
|
||||
$criteriaDel->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$res = $criteriaDel->next();
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user