From edd52832393d76f23faab1fe2d83ece2647ae0a1 Mon Sep 17 00:00:00 2001 From: "Paula V. Quispe" Date: Fri, 15 Apr 2016 16:46:47 -0400 Subject: [PATCH] HOR-771 --- workflow/engine/classes/class.case.php | 5 +-- workflow/engine/classes/class.derivation.php | 20 +++++++++-- .../engine/classes/model/AppDelegation.php | 33 ++++++++++++++++++- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/workflow/engine/classes/class.case.php b/workflow/engine/classes/class.case.php index 205da0d28..84948b5b1 100755 --- a/workflow/engine/classes/class.case.php +++ b/workflow/engine/classes/class.case.php @@ -1750,12 +1750,13 @@ class Cases * @return void */ - public function newAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sPrevious, $iPriority, $sDelType, $iAppThreadIndex = 1, $nextDel = null, $flagControl = false) + public function newAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sPrevious, $iPriority, $sDelType, $iAppThreadIndex = 1, $nextDel = null, $flagControl = false, $flagControlMulInstance = false, $delPrevious = 0) { try { $appDel = new AppDelegation(); $result = $appDel->createAppDelegation( - $sProUid, $sAppUid, $sTasUid, $sUsrUid, $iAppThreadIndex, $iPriority, false, $sPrevious, $nextDel, $flagControl + $sProUid, $sAppUid, $sTasUid, $sUsrUid, $iAppThreadIndex, $iPriority, false, $sPrevious, $nextDel, $flagControl, + $flagControlMulInstance, $delPrevious ); //update searchindex if ($this->appSolr != null) { diff --git a/workflow/engine/classes/class.derivation.php b/workflow/engine/classes/class.derivation.php index a125964cc..43c57f698 100755 --- a/workflow/engine/classes/class.derivation.php +++ b/workflow/engine/classes/class.derivation.php @@ -49,6 +49,7 @@ class Derivation { var $case; protected $flagControl; + protected $flagControlMulInstance; /** * prepareInformationTask @@ -1136,7 +1137,11 @@ class Derivation } $canDerivate = empty($arrayOpenThread); if($canDerivate){ - $this->flagControl = true; + if($flagTaskIsMultipleInstance && $flagTaskAssignTypeIsMultipleInstance){ + $this->flagControlMulInstance = true; + }else{ + $this->flagControl = true; + } } break; @@ -1385,8 +1390,19 @@ class Derivation $this->setTasLastAssigned( $nextDel['TAS_UID'], $nextDel['USR_UID'] ); //No Break, need no execute the default ones.... default: + $delPrevious = 0; + if($this->flagControlMulInstance){ + $criteriaMulti = new Criteria("workflow"); + $criteriaMulti->addSelectColumn(AppDelegationPeer::DEL_PREVIOUS); + $criteriaMulti->add(AppDelegationPeer::TAS_UID, $currentDelegation['TAS_UID'], Criteria::EQUAL); + $criteriaMultiR = AppDelegationPeer::doSelectRS($criteriaMulti); + $criteriaMultiR->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $criteriaMultiR->next(); + $row = $criteriaMultiR->getRow(); + $delPrevious = $row['DEL_PREVIOUS']; + } // 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, $this->flagControl ); + $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, $this->flagControlMulInstance, $delPrevious); break; } diff --git a/workflow/engine/classes/model/AppDelegation.php b/workflow/engine/classes/model/AppDelegation.php index cc30a59b4..b5371945b 100755 --- a/workflow/engine/classes/model/AppDelegation.php +++ b/workflow/engine/classes/model/AppDelegation.php @@ -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, $flagControl = false) + public function createAppDelegation ($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sAppThread, $iPriority = 3, $isSubprocess = false, $sPrevious = -1, $sNextTasParam = null, $flagControl = false, $flagControlMulInstance = false, $delPrevious = 0) { if (! isset( $sProUid ) || strlen( $sProUid ) == 0) { throw (new Exception( 'Column "PRO_UID" cannot be null.' )); @@ -121,6 +121,14 @@ class AppDelegation extends BaseAppDelegation return 0; } } + if($flagControlMulInstance){ + $nextTaskUid = $sTasUid; + $index = $this->getAllTheardMultipleInstance($delPrevious, $sAppUid); + if($this->createThread($index, $sAppUid)){ + return 0; + } + } + //Update set $criteriaUpdate = new Criteria('workflow'); @@ -794,5 +802,28 @@ class AppDelegation extends BaseAppDelegation return $res; } + /** + * Get all Threads for Multiple Instance + * + * @param string $sPrevious + * @param string $sAppUid + * @return array $index + */ + public static function getAllTheardMultipleInstance($sPrevious, $sAppUid){ + $criteriaR = new Criteria('workflow'); + $criteriaR->addSelectColumn(AppDelegationPeer::DEL_INDEX); + $criteriaR->add(AppDelegationPeer::APP_UID, $sAppUid, Criteria::EQUAL); + $criteriaR->add(AppDelegationPeer::DEL_PREVIOUS, $sPrevious, Criteria::EQUAL); + $rsCriteriaR = AppDelegationPeer::doSelectRS($criteriaR); + $rsCriteriaR->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $index = array(); + $c = 0; + while($rsCriteriaR->next()){ + $row = $rsCriteriaR->getRow(); + $index[$c++] = $row['DEL_INDEX']; + } + return $index; + } + }