PMCORE-2524: Conflicts with develop

This commit is contained in:
Paula Quispe
2020-12-09 12:26:20 -04:00
26 changed files with 969 additions and 547 deletions

View File

@@ -1,6 +1,8 @@
<?php
namespace ProcessMaker\BusinessModel;
use ProcessMaker\Model\Task;
class MessageEventDefinition
{
private $arrayFieldDefinition = array(
@@ -353,6 +355,10 @@ class MessageEventDefinition
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
$arrayDataBackup = $arrayData;
$evnUid = $arrayData['EVN_UID'];
$caseTitle = $arrayData['CASE_TITLE'];
Task::setTaskDefTitle($evnUid, $caseTitle);
unset($arrayData["MSGED_UID"]);
unset($arrayData["PRJ_UID"]);

View File

@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel;
use Bootstrap;
use Illuminate\Support\Facades\Log;
use ProcessMaker\Model\Task;
class TimerEvent
{
@@ -748,6 +749,10 @@ class TimerEvent
//Update
$cnn = \Propel::getConnection("workflow");
$evnUid = $arrayData['EVN_UID'];
$caseTitle = $arrayData['CASETITLE'];
Task::setTaskDefTitle($evnUid, $caseTitle);
$arrayData = $this->unsetFields($arrayData);
try {
@@ -851,6 +856,7 @@ class TimerEvent
throw new \Exception(\G::LoadTranslation("ID_REGISTRY_CANNOT_BE_UPDATED") . (($msg != "")? "\n" . $msg : ""));
}
} catch (\Exception $e) {
$cnn->rollback();

View File

@@ -7,6 +7,7 @@ use G;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Core\System;
use ProcessMaker\Model\Task;
class Delegation extends Model
{
@@ -1026,7 +1027,7 @@ class Delegation extends Model
'APPLICATION.APP_CREATE_DATE',
'APPLICATION.APP_FINISH_DATE',
'APPLICATION.APP_UPDATE_DATE',
'APPLICATION.APP_TITLE',
'APP_DELEGATION.DEL_TITLE AS APP_TITLE',
'APP_DELEGATION.USR_UID',
'APP_DELEGATION.TAS_UID',
'APP_DELEGATION.USR_ID',
@@ -1082,12 +1083,11 @@ class Delegation extends Model
// Build the "fulltext" expression
$search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"';
// 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 {
// 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
@@ -1111,7 +1111,6 @@ class Delegation extends Model
// 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
if ($category || $process || $sort == 'APP_PRO_TITLE') {
$query->join('PROCESS', function ($join) use ($category) {
@@ -1412,7 +1411,7 @@ class Delegation extends Model
});
// 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) {
$join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER');
});
@@ -1433,7 +1432,7 @@ class Delegation extends Model
// Build where clause for the text to search
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('PROCESS.PRO_TITLE', 'LIKE', "%$textToSearch%");
}
@@ -1467,7 +1466,7 @@ class Delegation extends Model
});
}
// 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) {
$join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER');
});
@@ -1488,7 +1487,7 @@ class Delegation extends Model
// Build where clause for the text to search
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('PROCESS.PRO_TITLE', 'LIKE', "%$textToSearch%");
}
@@ -1671,6 +1670,25 @@ class Delegation extends Model
return ($query->count() > 0);
}
/**
* Return the task related to the thread
*
* @param int $appNumber
* @param int $index
*
* @return array
*/
public static function getThreadInfo(int $appNumber, int $index)
{
$query = Delegation::query()->select(['APP_NUMBER', 'TAS_UID', 'TAS_ID', 'DEL_PREVIOUS', 'DEL_TITLE']);
$query->where('APP_NUMBER', $appNumber);
$query->where('DEL_INDEX', $index);
$query->limit(1);
$result = $query->get()->toArray();
return head($result);
}
/**
* Return the thread related to the specific task-index
*
@@ -1720,7 +1738,6 @@ class Delegation extends Model
return $thread;
}
/**
* Return the open thread related to the task
*
@@ -1746,4 +1763,49 @@ class Delegation extends Model
return $results;
}
/**
* Get the thread title related to the delegation
*
* @param string $tasUid
* @param int $appNumber
* @param int $delIndexPrevious
* @param array $caseData
*
* @return string
*/
public static function getThreadTitle(string $tasUid, int $appNumber, int $delIndexPrevious, $caseData = [])
{
// Get task title defined
$task = new Task();
$taskTitle = $task->taskCaseTitle($tasUid);
// If exist we will to replace the variables data
if (!empty($taskTitle)) {
$threadTitle = G::replaceDataField($taskTitle, $caseData, 'mysql', false);
} else {
// If is empty get the previous title
if ($delIndexPrevious > 0) {
$thread = self::getThreadInfo($appNumber, $delIndexPrevious);
$threadTitle = $thread['DEL_TITLE'];
} else {
$threadTitle = '# '. $appNumber;
}
}
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;
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace ProcessMaker\Model;
use G;
use Illuminate\Database\Eloquent\Model;
class ElementTaskRelation extends Model
{
protected $table = 'ELEMENT_TASK_RELATION';
protected $primaryKey = 'ETR_UID';
// We do not have create/update timestamps for this table
public $timestamps = false;
}

View File

@@ -91,6 +91,27 @@ class Task extends Model
return $title;
}
/**
* Get the title of the task
*
* @param string $tasUid
*
* @return string
*/
public function taskCaseTitle(string $tasUid)
{
$query = Task::query()->select(['TAS_DEF_TITLE']);
$query->where('TAS_UID', $tasUid);
$query->limit(1);
$results = $query->get();
$title = '';
$results->each(function ($item) use (&$title) {
$title = $item->TAS_DEF_TITLE;
});
return $title;
}
/**
* Get task data
*
@@ -131,4 +152,43 @@ class Task extends Model
return $taskInfo;
}
/**
* Set the TAS_DEF_TITLE value
*
* @param string $evnUid
* @param string $caseTitle
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public static function setTaskDefTitle($evnUid, $caseTitle)
{
$query = Task::select(['TASK.TAS_UID']);
$query->join('ELEMENT_TASK_RELATION', function ($join) use ($evnUid) {
$join->on('ELEMENT_TASK_RELATION.TAS_UID', '=', 'TASK.TAS_UID')
->where('ELEMENT_TASK_RELATION.ELEMENT_UID', '=', $evnUid);
});
$query->update(['TASK.TAS_DEF_TITLE' => $caseTitle]);
return $query;
}
/**
* Get the TAS_DEF_TITLE value
*
* @param string $evnUid
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public static function getTaskDefTitle($evnUid)
{
$query = Task::select(['TASK.TAS_DEF_TITLE']);
$query->join('ELEMENT_TASK_RELATION', function ($join) use ($evnUid) {
$join->on('ELEMENT_TASK_RELATION.TAS_UID', '=', 'TASK.TAS_UID')
->where('ELEMENT_TASK_RELATION.ELEMENT_UID', '=', $evnUid);
});
return $query->get()->values()->toArray()['0']['TAS_DEF_TITLE'];
}
}

View File

@@ -1,8 +1,9 @@
<?php
namespace ProcessMaker\Services\Api\Project;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
use Luracast\Restler\RestException;
use ProcessMaker\Model\Task;
use ProcessMaker\Services\Api;
/**
* Project\MessageEventDefinition Api Controller
@@ -38,7 +39,9 @@ class MessageEventDefinition extends Api
{
try {
$response = $this->messageEventDefinition->getMessageEventDefinitions($prj_uid);
foreach ($response as $index => $val){
$response[$index]['tas_def_title'] = Task::getTaskDefTitle($response[$index]['evn_uid']);
}
return $response;
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());

View File

@@ -1,8 +1,9 @@
<?php
namespace ProcessMaker\Services\Api\Project;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
use Luracast\Restler\RestException;
use ProcessMaker\Model\Task;
use ProcessMaker\Services\Api;
/**
* Project\TimerEvent Api Controller
@@ -78,7 +79,7 @@ class TimerEvent extends Api
{
try {
$response = $this->timerEvent->getTimerEventByEvent($prj_uid, $evn_uid);
$response["tas_def_title"] =Task::getTaskDefTitle($evn_uid);
return \ProcessMaker\Util\DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
} catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());