PMCORE-2433
This commit is contained in:
13
database/factories/ElementTaskRelationFactory.php
Normal file
13
database/factories/ElementTaskRelationFactory.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
|
$factory->define(\ProcessMaker\Model\ElementTaskRelation::class, function(Faker $faker) {
|
||||||
|
return [
|
||||||
|
'ETR_UID' => G::generateUniqueID(),
|
||||||
|
'PRJ_UID' => G::generateUniqueID(),
|
||||||
|
'ELEMENT_UID' => G::generateUniqueID(),
|
||||||
|
'ELEMENT_TYPE' => 'bpmnEvent',
|
||||||
|
'TAS_UID' => G::generateUniqueID(),
|
||||||
|
];
|
||||||
|
});
|
||||||
@@ -5,6 +5,8 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
|||||||
use G;
|
use G;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use ProcessMaker\Model\Delegation;
|
use ProcessMaker\Model\Delegation;
|
||||||
|
use ProcessMaker\Model\ElementTaskRelation;
|
||||||
|
use ProcessMaker\Model\Process;
|
||||||
use ProcessMaker\Model\Task;
|
use ProcessMaker\Model\Task;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@@ -124,4 +126,50 @@ class TaskTest extends TestCase
|
|||||||
$result .= ' 01 '. G::LoadTranslation('ID_SECOND_ABBREVIATE');
|
$result .= ' 01 '. G::LoadTranslation('ID_SECOND_ABBREVIATE');
|
||||||
$this->assertEquals($taskInfo['DURATION'], $result);
|
$this->assertEquals($taskInfo['DURATION'], $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It tests the setTaskDefTitle() method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Task::setTaskDefTitle()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_set_task_title_method()
|
||||||
|
{
|
||||||
|
$project = factory(Process::class)->create();
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_DEF_TITLE' => 'something'
|
||||||
|
]);
|
||||||
|
$elementTask = factory(ElementTaskRelation::class)->create([
|
||||||
|
'PRJ_UID' => $project->PRO_UID,
|
||||||
|
'TAS_UID' => $task->TAS_UID,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Task::setTaskDefTitle($elementTask->ELEMENT_UID, "Task title new");
|
||||||
|
$query = Task::query();
|
||||||
|
$query->select()->where('TASK.TAS_UID', $task->TAS_UID);
|
||||||
|
$res = $query->get()->values()->toArray();
|
||||||
|
$this->assertEquals($res[0]['TAS_DEF_TITLE'], 'Task title new');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It tests the getTaskDefTitle() method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\Model\Task::getTaskDefTitle()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_task_def_title_method()
|
||||||
|
{
|
||||||
|
$project = factory(Process::class)->create();
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_DEF_TITLE' => 'something'
|
||||||
|
]);
|
||||||
|
$elementTask = factory(ElementTaskRelation::class)->create([
|
||||||
|
'PRJ_UID' => $project->PRO_UID,
|
||||||
|
'TAS_UID' => $task->TAS_UID,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$res = Task::getTaskDefTitle($elementTask->ELEMENT_UID);
|
||||||
|
|
||||||
|
$this->assertEquals($res, $task->TAS_DEF_TITLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProcessMaker\BusinessModel;
|
namespace ProcessMaker\BusinessModel;
|
||||||
|
|
||||||
|
use ProcessMaker\Model\Task;
|
||||||
|
|
||||||
class MessageEventDefinition
|
class MessageEventDefinition
|
||||||
{
|
{
|
||||||
private $arrayFieldDefinition = array(
|
private $arrayFieldDefinition = array(
|
||||||
@@ -353,6 +355,10 @@ class MessageEventDefinition
|
|||||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||||
$arrayDataBackup = $arrayData;
|
$arrayDataBackup = $arrayData;
|
||||||
|
|
||||||
|
$evnUid = $arrayData['EVN_UID'];
|
||||||
|
$caseTitle = $arrayData['CASE_TITLE'];
|
||||||
|
Task::setTaskDefTitle($evnUid, $caseTitle);
|
||||||
|
|
||||||
unset($arrayData["MSGED_UID"]);
|
unset($arrayData["MSGED_UID"]);
|
||||||
unset($arrayData["PRJ_UID"]);
|
unset($arrayData["PRJ_UID"]);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace ProcessMaker\BusinessModel;
|
|||||||
|
|
||||||
use Bootstrap;
|
use Bootstrap;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use ProcessMaker\Model\Task;
|
||||||
|
|
||||||
class TimerEvent
|
class TimerEvent
|
||||||
{
|
{
|
||||||
@@ -748,6 +749,10 @@ class TimerEvent
|
|||||||
//Update
|
//Update
|
||||||
$cnn = \Propel::getConnection("workflow");
|
$cnn = \Propel::getConnection("workflow");
|
||||||
|
|
||||||
|
$evnUid = $arrayData['EVN_UID'];
|
||||||
|
$caseTitle = $arrayData['CASETITLE'];
|
||||||
|
Task::setTaskDefTitle($evnUid, $caseTitle);
|
||||||
|
|
||||||
$arrayData = $this->unsetFields($arrayData);
|
$arrayData = $this->unsetFields($arrayData);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -851,6 +856,7 @@ class TimerEvent
|
|||||||
|
|
||||||
throw new \Exception(\G::LoadTranslation("ID_REGISTRY_CANNOT_BE_UPDATED") . (($msg != "")? "\n" . $msg : ""));
|
throw new \Exception(\G::LoadTranslation("ID_REGISTRY_CANNOT_BE_UPDATED") . (($msg != "")? "\n" . $msg : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$cnn->rollback();
|
$cnn->rollback();
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -120,4 +120,43 @@ class Task extends Model
|
|||||||
|
|
||||||
return $taskInfo;
|
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'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProcessMaker\Services\Api\Project;
|
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
|
* Project\MessageEventDefinition Api Controller
|
||||||
@@ -38,7 +39,9 @@ class MessageEventDefinition extends Api
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$response = $this->messageEventDefinition->getMessageEventDefinitions($prj_uid);
|
$response = $this->messageEventDefinition->getMessageEventDefinitions($prj_uid);
|
||||||
|
foreach ($response as $index => $val){
|
||||||
|
$response[$index]['tas_def_title'] = Task::getTaskDefTitle($response[$index]['evn_uid']);
|
||||||
|
}
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProcessMaker\Services\Api\Project;
|
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
|
* Project\TimerEvent Api Controller
|
||||||
@@ -78,7 +79,7 @@ class TimerEvent extends Api
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$response = $this->timerEvent->getTimerEventByEvent($prj_uid, $evn_uid);
|
$response = $this->timerEvent->getTimerEventByEvent($prj_uid, $evn_uid);
|
||||||
|
$response["tas_def_title"] =Task::getTaskDefTitle($evn_uid);
|
||||||
return \ProcessMaker\Util\DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
|
return \ProcessMaker\Util\DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user