PMCORE-2396

This commit is contained in:
Andrea Adamczyk
2020-12-07 09:21:51 -04:00
parent b55e95fa33
commit 3cc4baff8e
6 changed files with 47 additions and 18 deletions

View File

@@ -34,7 +34,8 @@ $factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
'USR_ID' => $user->USR_ID, 'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID, 'PRO_ID' => $process->PRO_ID,
'TAS_ID' => $task->TAS_ID, 'TAS_ID' => $task->TAS_ID,
'DEL_DATA' => '' 'DEL_DATA' => '',
'DEL_TITLE' => $faker->word()
]; ];
}); });
@@ -73,7 +74,8 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'foreign_keys', function
'USR_ID' => $user->USR_ID, 'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID, 'PRO_ID' => $process->PRO_ID,
'TAS_ID' => $task->TAS_ID, 'TAS_ID' => $task->TAS_ID,
'DEL_DATA' => '' 'DEL_DATA' => '',
'DEL_TITLE' => $faker->word()
]; ];
}); });

View File

@@ -277,8 +277,7 @@ class DelegationTest extends TestCase
->states('foreign_keys') ->states('foreign_keys')
->create(); ->create();
$title = $delegations->last() $title = $delegations->last()
->application ->DEL_TITLE;
->APP_TITLE;
// We need to commit the records inserted because is needed for the "fulltext" index // We need to commit the records inserted because is needed for the "fulltext" index
DB::commit(); DB::commit();
@@ -2386,4 +2385,19 @@ class DelegationTest extends TestCase
$this->assertNotEmpty($result); $this->assertNotEmpty($result);
} }
/**
* This tests the getDeltitle() method
*
* @covers \ProcessMaker\Model\Delegation::getDeltitle()
* @test
*/
public function it_should_test_the_get_del_title_method()
{
$delegation = factory(Delegation::class)->create([
'DEL_TITLE' => "test"
]);
$result = Delegation::getDeltitle($delegation->APP_NUMBER, $delegation->DEL_INDEX);
$this->assertNotEmpty($result);
$this->assertEquals($result, $delegation->DEL_TITLE);
}
} }

View File

@@ -4147,14 +4147,16 @@ class Cases
$this->getExecuteTriggerProcess($sApplicationUID, 'PAUSED'); $this->getExecuteTriggerProcess($sApplicationUID, 'PAUSED');
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
$threadTitle = Delegation::getDeltitle($aData['APP_NUMBER'], $aData['APP_DEL_INDEX']);
$data = array( $data = array(
'APP_UID' => $sApplicationUID, 'APP_UID' => $sApplicationUID,
'DEL_INDEX' => $iDelegation, 'DEL_INDEX' => $iDelegation,
'USR_UID' => $sUserUID, 'USR_UID' => $sUserUID,
'APP_RESTART_DATE' => $sUnpauseDate, 'APP_RESTART_DATE' => $sUnpauseDate,
'APP_TITLE' => ($appTitle != null) ? $appTitle : $aFields['APP_TITLE'] 'APP_TITLE' => $threadTitle,
); );
$data = array_merge($aFields, $data); $data = array_merge($aFields, $data);
$oListPaused = new ListPaused(); $oListPaused = new ListPaused();
$oListPaused->create($data); $oListPaused->create($data);
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/

View File

@@ -387,7 +387,7 @@ class ListParticipatedLast extends BaseListParticipatedLast implements ListInter
$criteria->addSelectColumn(ListParticipatedLastPeer::TAS_UID); $criteria->addSelectColumn(ListParticipatedLastPeer::TAS_UID);
$criteria->addSelectColumn(ListParticipatedLastPeer::PRO_UID); $criteria->addSelectColumn(ListParticipatedLastPeer::PRO_UID);
$criteria->addSelectColumn(ListParticipatedLastPeer::APP_NUMBER); $criteria->addSelectColumn(ListParticipatedLastPeer::APP_NUMBER);
$criteria->addSelectColumn(ApplicationPeer::APP_TITLE); $criteria->addSelectColumn(ListParticipatedLastPeer::APP_TITLE);
$criteria->addSelectColumn(ListParticipatedLastPeer::APP_PRO_TITLE); $criteria->addSelectColumn(ListParticipatedLastPeer::APP_PRO_TITLE);
$criteria->addSelectColumn(ListParticipatedLastPeer::APP_TAS_TITLE); $criteria->addSelectColumn(ListParticipatedLastPeer::APP_TAS_TITLE);
$criteria->addSelectColumn(ListParticipatedLastPeer::APP_STATUS); $criteria->addSelectColumn(ListParticipatedLastPeer::APP_STATUS);
@@ -405,7 +405,6 @@ class ListParticipatedLast extends BaseListParticipatedLast implements ListInter
$criteria->addSelectColumn(ListParticipatedLastPeer::DEL_PRIORITY); $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_PRIORITY);
$criteria->addSelectColumn(ListParticipatedLastPeer::DEL_THREAD_STATUS); $criteria->addSelectColumn(ListParticipatedLastPeer::DEL_THREAD_STATUS);
$criteria->add(ListParticipatedLastPeer::USR_UID, $usr_uid, Criteria::EQUAL); $criteria->add(ListParticipatedLastPeer::USR_UID, $usr_uid, Criteria::EQUAL);
//Check if the user was participated in a specific case //Check if the user was participated in a specific case
if ($appUid != '') { if ($appUid != '') {
$criteria->add(ListParticipatedLastPeer::APP_UID, $appUid, Criteria::EQUAL); $criteria->add(ListParticipatedLastPeer::APP_UID, $appUid, Criteria::EQUAL);

View File

@@ -262,10 +262,10 @@ class ListUnassigned extends BaseListUnassigned implements ListInterface
'APP_DELEGATION.DEL_TASK_DUE_DATE', 'APP_DELEGATION.DEL_TASK_DUE_DATE',
'APP_DELEGATION.DEL_PRIORITY', 'APP_DELEGATION.DEL_PRIORITY',
'APP_DELEGATION.DEL_PREVIOUS', 'APP_DELEGATION.DEL_PREVIOUS',
'APP_DELEGATION.DEL_TITLE AS APP_TITLE',
// TASK table // TASK table
'TASK.TAS_TITLE', 'TASK.TAS_TITLE',
// APPLICATION table // APPLICATION table
'APPLICATION.APP_TITLE',
'APPLICATION.APP_UPDATE_DATE', 'APPLICATION.APP_UPDATE_DATE',
// PROCESS table // PROCESS table
'PROCESS.PRO_TITLE' 'PROCESS.PRO_TITLE'
@@ -274,7 +274,7 @@ class ListUnassigned extends BaseListUnassigned implements ListInterface
'APP_NUMBER' => 'APP_NUMBER', 'APP_NUMBER' => 'APP_NUMBER',
'DEL_DUE_DATE' => 'DEL_TASK_DUE_DATE', 'DEL_DUE_DATE' => 'DEL_TASK_DUE_DATE',
'DEL_DELEGATE_DATE' => 'DEL_DELEGATE_DATE', 'DEL_DELEGATE_DATE' => 'DEL_DELEGATE_DATE',
'APP_TITLE' => 'APP_TITLE', 'APP_DELEGATION.DEL_TITLE AS APP_TITLE',
'APP_PRO_TITLE' => 'PRO_TITLE', 'APP_PRO_TITLE' => 'PRO_TITLE',
'APP_TAS_TITLE' => 'TAS_TITLE', 'APP_TAS_TITLE' => 'TAS_TITLE',
'DEL_PREVIOUS_USR_UID' => 'USR_ID' 'DEL_PREVIOUS_USR_UID' => 'USR_ID'

View File

@@ -187,7 +187,7 @@ class Delegation extends Model
'APPLICATION.APP_CREATE_DATE', 'APPLICATION.APP_CREATE_DATE',
'APPLICATION.APP_FINISH_DATE', 'APPLICATION.APP_FINISH_DATE',
'APPLICATION.APP_UPDATE_DATE', 'APPLICATION.APP_UPDATE_DATE',
'APPLICATION.APP_TITLE', 'APP_DELEGATION.DEL_TITLE AS APP_TITLE',
'APP_DELEGATION.USR_UID', 'APP_DELEGATION.USR_UID',
'APP_DELEGATION.TAS_UID', 'APP_DELEGATION.TAS_UID',
'APP_DELEGATION.USR_ID', 'APP_DELEGATION.USR_ID',
@@ -240,12 +240,11 @@ class Delegation extends Model
// Build the "fulltext" expression // Build the "fulltext" expression
$search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"'; $search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"';
// Searching using "fulltext" index // Searching using "fulltext" index
$join->whereRaw("MATCH(APPLICATION.APP_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)"); $join->whereRaw("MATCH(APP_DELEGATION.DEL_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)");
} else { } else {
// Searching using "like" operator // Searching using "like" operator
$join->where('APPLICATION.APP_TITLE', 'LIKE', "%${search}%"); $join->where('APP_DELEGATION.DEL_TITLE', 'LIKE', "%${search}%");
} }
} }
// Based on the below, we can further limit the join so that we have a smaller data set based on join criteria // Based on the below, we can further limit the join so that we have a smaller data set based on join criteria
@@ -269,7 +268,6 @@ class Delegation extends Model
// Don't do anything here, we'll need to do the more advanced where below // Don't do anything here, we'll need to do the more advanced where below
} }
}); });
// Add join for process, but only for certain scenarios such as category or process // Add join for process, but only for certain scenarios such as category or process
if ($category || $process || $sort == 'APP_PRO_TITLE') { if ($category || $process || $sort == 'APP_PRO_TITLE') {
$query->join('PROCESS', function ($join) use ($category) { $query->join('PROCESS', function ($join) use ($category) {
@@ -562,7 +560,7 @@ class Delegation extends Model
}); });
// Add join clause with APPLICATION table if required // Add join clause with APPLICATION table if required
if (array_search('APPLICATION.APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') { if (array_search('APP_DELEGATION.DEL_TITLE AS APP_TITLE', $selectedColumns) !== false || array_search('APPLICATION.APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') {
$query1->join('APPLICATION', function ($join) { $query1->join('APPLICATION', function ($join) {
$join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER'); $join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER');
}); });
@@ -583,7 +581,7 @@ class Delegation extends Model
// Build where clause for the text to search // Build where clause for the text to search
if (!empty($textToSearch)) { if (!empty($textToSearch)) {
$query1->where('APPLICATION.APP_TITLE', 'LIKE', "%$textToSearch%") $query1->where('APP_DELEGATION.DEL_TITLE', 'LIKE', "%$textToSearch%")
->orWhere('TASK.TAS_TITLE', 'LIKE', "%$textToSearch%") ->orWhere('TASK.TAS_TITLE', 'LIKE', "%$textToSearch%")
->orWhere('PROCESS.PRO_TITLE', 'LIKE', "%$textToSearch%"); ->orWhere('PROCESS.PRO_TITLE', 'LIKE', "%$textToSearch%");
} }
@@ -618,7 +616,7 @@ class Delegation extends Model
} }
// Add join clause with APPLICATION table if required // Add join clause with APPLICATION table if required
if (array_search('APPLICATION.APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') { if (array_search('APP_DELEGATION.DEL_TITLE AS APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') {
$query2->join('APPLICATION', function ($join) { $query2->join('APPLICATION', function ($join) {
$join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER'); $join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER');
}); });
@@ -639,7 +637,7 @@ class Delegation extends Model
// Build where clause for the text to search // Build where clause for the text to search
if (!empty($textToSearch)) { if (!empty($textToSearch)) {
$query2->where('APPLICATION.APP_TITLE', 'LIKE', "%$textToSearch%") $query2->where('APP_DELEGATION.DEL_TITLE', 'LIKE', "%$textToSearch%")
->orWhere('TASK.TAS_TITLE', 'LIKE', "%$textToSearch%") ->orWhere('TASK.TAS_TITLE', 'LIKE', "%$textToSearch%")
->orWhere('PROCESS.PRO_TITLE', 'LIKE', "%$textToSearch%"); ->orWhere('PROCESS.PRO_TITLE', 'LIKE', "%$textToSearch%");
} }
@@ -902,4 +900,18 @@ class Delegation extends Model
return $threadTitle; return $threadTitle;
} }
/**
* Get the DEL_TITLE related to DELEGATION table
*
* @param int $appNumber
* @param int $delIndex
* @return string
*/
public static function getDeltitle($appNumber, $delIndex)
{
$query = Delegation::select(['DEL_TITLE'])->where('APP_NUMBER', $appNumber)->where('DEL_INDEX', $delIndex);
$res = $query->first();
return $res->DEL_TITLE;
}
} }