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

@@ -18,6 +18,7 @@ $factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
return [ return [
'APP_UID' => $application->APP_UID, 'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 1, 'DEL_INDEX' => 1,
'DELEGATION_ID' => $faker->unique()->randomNumber,
'APP_NUMBER' => $application->APP_NUMBER, 'APP_NUMBER' => $application->APP_NUMBER,
'DEL_PREVIOUS' => 0, 'DEL_PREVIOUS' => 0,
'PRO_UID' => $process->PRO_UID, 'PRO_UID' => $process->PRO_UID,
@@ -31,10 +32,12 @@ $factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
'DEL_INIT_DATE' => $faker->dateTime(), 'DEL_INIT_DATE' => $faker->dateTime(),
'DEL_TASK_DUE_DATE' => $faker->dateTime(), 'DEL_TASK_DUE_DATE' => $faker->dateTime(),
'DEL_RISK_DATE' => $faker->dateTime(), 'DEL_RISK_DATE' => $faker->dateTime(),
'DEL_LAST_INDEX' => 0,
'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()
]; ];
}); });
@@ -77,7 +80,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

@@ -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(),
];
});

View File

@@ -16,6 +16,7 @@ $factory->define(\ProcessMaker\Model\Task::class, function(Faker $faker) {
'TAS_TYPE_DAY' => 1, 'TAS_TYPE_DAY' => 1,
'TAS_DURATION' => 1, 'TAS_DURATION' => 1,
'TAS_ASSIGN_TYPE' => 'BALANCED', 'TAS_ASSIGN_TYPE' => 'BALANCED',
'TAS_DEF_TITLE' => $faker->sentence(2),
'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED', 'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED',
'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE', 'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE',
'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE', 'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE',
@@ -45,6 +46,7 @@ $factory->state(\ProcessMaker\Model\Task::class, 'foreign_keys', function (Faker
'TAS_TYPE_DAY' => 1, 'TAS_TYPE_DAY' => 1,
'TAS_DURATION' => 1, 'TAS_DURATION' => 1,
'TAS_ASSIGN_TYPE' => 'BALANCED', 'TAS_ASSIGN_TYPE' => 'BALANCED',
'TAS_DEF_TITLE' => $faker->sentence(2),
'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED', 'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED',
'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE', 'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE',
'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE', 'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE',

View File

@@ -144,6 +144,7 @@ class DerivationTest extends TestCase
]; ];
$appFields = [ $appFields = [
'APP_NUMBER' => $application->APP_NUMBER, 'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appDelegation->DEL_INDEX,
'DEL_THREAD' => $appDelegation->DEL_THREAD, 'DEL_THREAD' => $appDelegation->DEL_THREAD,
'PRO_UID' => $process->PRO_UID, 'PRO_UID' => $process->PRO_UID,
'PRO_ID' => $process->PRO_ID, 'PRO_ID' => $process->PRO_ID,

View File

@@ -0,0 +1,84 @@
<?php
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
class WorkspaceToolsTest extends TestCase
{
/**
* Tests the migrateCaseTitleToThreads method
*
* @covers \WorkspaceTools::migrateCaseTitleToThreads
* @test
*/
public function it_should_test_migrate_case_title_to_threads_method()
{
$application1 = factory(Application::class)->create([
'APP_STATUS' => 'TO_DO',
'APP_STATUS_ID' => 2,
]);
$application2 = factory(Application::class)->create([
'APP_STATUS' => 'COMPLETED',
'APP_STATUS_ID' => 3,
]);
$application3 = factory(Application::class)->create([
'APP_STATUS' => 'CANCELED',
'APP_STATUS_ID' => 4,
]);
factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'DEL_INDEX' => 1
]);
factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'DEL_INDEX' => 2
]);
$delegation1 = factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'DEL_INDEX' => 3,
]);
factory(Delegation::class)->create([
'APP_UID' => $application2->APP_UID,
'APP_NUMBER' => $application2->APP_NUMBER,
'DEL_INDEX' => 1
]);
$delegation2 = factory(Delegation::class)->create([
'APP_UID' => $application2->APP_UID,
'APP_NUMBER' => $application2->APP_NUMBER,
'DEL_INDEX' => 2,
'DEL_LAST_INDEX' => 1
]);
factory(Delegation::class)->create([
'APP_UID' => $application3->APP_UID,
'APP_NUMBER' => $application3->APP_NUMBER,
'DEL_INDEX' => 1
]);
$delegation3 = factory(Delegation::class)->create([
'APP_UID' => $application3->APP_UID,
'APP_NUMBER' => $application3->APP_NUMBER,
'DEL_INDEX' => 2,
'DEL_LAST_INDEX' => 1
]);
$workspaceTools = new WorkspaceTools('');
$workspaceTools->migrateCaseTitleToThreads(['testexternal']);
$result = ob_get_contents();
$this->assertRegExp("/The Case Title has been updated successfully in APP_DELEGATION table./", $result);
$r = Delegation::select('DEL_TITLE')->where('DELEGATION_ID', $delegation1->DELEGATION_ID)->get()->values()->toArray();
$this->assertEquals($r[0]['DEL_TITLE'], $application1->APP_TITLE);
$r = Delegation::select('DEL_TITLE')->where('DELEGATION_ID', $delegation2->DELEGATION_ID)->get()->values()->toArray();
$this->assertEquals($r[0]['DEL_TITLE'], $application2->APP_TITLE);
$r = Delegation::select('DEL_TITLE')->where('DELEGATION_ID', $delegation3->DELEGATION_ID)->get()->values()->toArray();
$this->assertEquals($r[0]['DEL_TITLE'], $application3->APP_TITLE);
}
}

View File

@@ -196,7 +196,7 @@ class CasesTraitTest extends TestCase
$task2 = $result->task2; $task2 = $result->task2;
$processUid = $application->PRO_UID; $processUid = $application->PRO_UID;
$application = $application->APP_UID; $appUid = $application->APP_UID;
$postForm = [ $postForm = [
'ROU_TYPE' => 'SEQUENTIAL', 'ROU_TYPE' => 'SEQUENTIAL',
'TASKS' => [ 'TASKS' => [
@@ -229,9 +229,9 @@ class CasesTraitTest extends TestCase
$userLogged = $user->USR_UID; $userLogged = $user->USR_UID;
$cases = new Cases(); $cases = new Cases();
$cases->routeCase($processUid, $application, $postForm, $status, $flagGmail, $tasUid, $index, $userLogged); $cases->routeCase($processUid, $appUid, $postForm, $status, $flagGmail, $tasUid, $index, $userLogged);
$result = Delegation::where('APP_UID', '=', $application)->where('DEL_INDEX', '=', $index)->get()->first(); $result = Delegation::where('APP_UID', '=', $appUid)->where('DEL_INDEX', '=', $index)->get()->first();
$this->assertEquals('CLOSED', $result->DEL_THREAD_STATUS); $this->assertEquals('CLOSED', $result->DEL_THREAD_STATUS);
} }

View File

@@ -415,8 +415,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();
@@ -2510,4 +2509,33 @@ class DelegationTest extends TestCase
$result = Delegation::participation($application->APP_UID, $user->USR_UID); $result = Delegation::participation($application->APP_UID, $user->USR_UID);
$this->assertFalse($result); $this->assertFalse($result);
} }
/**
* This check the return of thread title
*
* @covers \ProcessMaker\Model\Delegation::getThreadTitle()
* @test
*/
public function it_get_thread_title()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::getThreadTitle($delegation->TAS_UID, $delegation->APP_NUMBER, $delegation->DEL_INDEX, []);
$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

@@ -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,64 @@ 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);
}
/**
* It tests the get case title defined in the task
*
* @covers \ProcessMaker\Model\Task::taskCaseTitle()
* @test
*/
public function it_get_case_title()
{
$task = factory(Task::class)->create();
$tas = new Task();
$result = $tas->taskCaseTitle($task->TAS_UID);
$this->assertNotEmpty($result);
}
} }

View File

@@ -2,6 +2,7 @@
use ProcessMaker\BusinessModel\WebEntry; use ProcessMaker\BusinessModel\WebEntry;
use ProcessMaker\Core\JobsManager; use ProcessMaker\Core\JobsManager;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process; use ProcessMaker\Model\Process;
use ProcessMaker\Validation\MySQL57; use ProcessMaker\Validation\MySQL57;
@@ -450,6 +451,19 @@ EOT
); );
CLI::taskRun('convert_old_web_entries'); CLI::taskRun('convert_old_web_entries');
/**
* Populate the column APP_DELEGATION.DEL_TITLE with the case title APPLICATION.APP_TITLE
*/
CLI::taskName('migrate-case-title-to-threads');
CLI::taskDescription(<<<EOT
Populate the new column APPLICATION.APP_TITLE into the APP_DELEGATION table
EOT
);
CLI::taskArg('WORKSPACE', false);
CLI::taskArg('caseNumberFrom', true);
CLI::taskArg('caseNumberTo', true);
CLI::taskRun('migrate_case_title_to_threads');
/** /**
* Function run_info * Function run_info
* *
@@ -1335,7 +1349,8 @@ function run_clear_dyn_content_history_data($args, $opts)
* @return void * @return void
* @see workflow/engine/bin/tasks/cliWorkspaces.php CLI::taskRun() * @see workflow/engine/bin/tasks/cliWorkspaces.php CLI::taskRun()
*/ */
function run_sync_forms_with_info_from_input_documents($args, $opts) { function run_sync_forms_with_info_from_input_documents($args, $opts)
{
if (count($args) === 1) { if (count($args) === 1) {
//This variable is not defined and does not involve its value in this //This variable is not defined and does not involve its value in this
//task, it is removed at the end of the method. //task, it is removed at the end of the method.
@@ -1689,3 +1704,15 @@ function convert_old_web_entries($args)
CLI::logging($e->getMessage() . PHP_EOL . PHP_EOL); CLI::logging($e->getMessage() . PHP_EOL . PHP_EOL);
} }
} }
/**
* Populate the new column APPLICATION.APP_TITLE into the APP_DELEGATION table
*
* @param array $args
*/
function migrate_case_title_to_threads($args)
{
//The constructor requires an argument, so we send an empty value in order to use the class.
$workspaceTools = new WorkspaceTools('');
$workspaceTools->migrateCaseTitleToThreads($args);
}

View File

@@ -10,6 +10,7 @@ use ProcessMaker\Cases\CasesTrait;
use ProcessMaker\ChangeLog\ChangeLog; use ProcessMaker\ChangeLog\ChangeLog;
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
use ProcessMaker\Core\System; use ProcessMaker\Core\System;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Plugins\PluginRegistry; use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Util\DateTime; use ProcessMaker\Util\DateTime;
@@ -25,6 +26,7 @@ class Cases
public $dir = 'ASC'; public $dir = 'ASC';
public $sort = 'APP_MSG_DATE'; public $sort = 'APP_MSG_DATE';
public $arrayTriggerExecutionTime = []; public $arrayTriggerExecutionTime = [];
public $caseTitle = '';
private $triggerMessageExecution = ''; private $triggerMessageExecution = '';
public function __construct() public function __construct()
@@ -34,6 +36,27 @@ class Cases
$this->appSolr = new AppSolr($solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance']); $this->appSolr = new AppSolr($solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance']);
} }
} }
/**
* Get the caseTitle
*
* @return string
*/
public function getCaseTitle()
{
return $this->caseTitle;
}
/**
* Set the caseTitle
*
* @param string $v
*
* @return void
*/
public function setCaseTitle(string $v)
{
$this->caseTitle = $v;
}
/** /**
* Get the triggerMessageExecution * Get the triggerMessageExecution
@@ -609,168 +632,36 @@ class Cases
} }
/** /**
* This function loads the label case * Update the thread title
* PROCESO:
* If there is a label then it is loaded
* To get APP_DELEGATIONS that they are opened in the case
* To look for APP_DELEGATIONS wich TASK in it, It has a label defined(CASE_TITLE)
* We need to read the last APP_DELEGATION->TASK
* @param string $sAppUid
* @param string $aAppData
* @param string $sLabel
* @return $appLabel
*/
public function refreshCaseLabel($sAppUid, $aAppData, $sLabel)
{
$getAppLabel = "getApp$sLabel";
$getTasDef = "getTasDef$sLabel";
$oApplication = new Application;
if (!$oApplication->exists($sAppUid)) {
return null;
} else {
$oApplication->load($sAppUid);
$appLabel = $oApplication->$getAppLabel();
}
$cri = new Criteria;
$cri->add(AppDelegationPeer::APP_UID, $sAppUid);
$cri->add(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN");
$currentDelegations = AppDelegationPeer::doSelect($cri);
for ($r = count($currentDelegations) - 1; $r >= 0; $r--) {
$task = TaskPeer::retrieveByPk($currentDelegations[$r]->getTasUid());
$caseLabel = $task->$getTasDef();
if ($caseLabel != '') {
$appLabel = G::replaceDataField($caseLabel, $aAppData, 'mysql', false);
break;
}
}
return $appLabel;
}
/**
* Optimized for speed. This function loads the title and description label in a case
* If there is a label then it is loaded
* Get Open APP_DELEGATIONS in the case
* To look for APP_DELEGATIONS which TASK in it, It has a label defined(CASE_TITLE)
* We need to read the last APP_DELEGATION->TASK
* *
* @param string $appUid * @param string $appUid
* @param array $fields * @param int $appNumber
* @param array $lastFieldsCase * @param int $delIndex
* @param array $caseData
* *
* @return array * @return void
* *
* @see classes/Cases->startCase() * @see Cases::updateCase()
* @see classes/Cases->updateCase()
*/ */
public function newRefreshCaseTitleAndDescription($appUid, $fields, $lastFieldsCase = []) public function updateThreadTitle(string $appUid, int $appNumber, int $delIndex, $caseData = [])
{ {
$res = []; $threadTitle = $this->getCaseTitle();
if (empty($threadTitle) && !empty($appNumber) && !empty($delIndex)) {
$flagTitle = false; $thread = Delegation::getThreadInfo($appNumber, $delIndex);
$flagDescription = false; $previous = $thread['DEL_PREVIOUS'];
$appNumber = $thread['APP_NUMBER'];
$cri = new Criteria; $tasUid = $thread['TAS_UID'];
$cri->clearSelectColumns(); if (!empty($tasUid)) {
$cri->addSelectColumn(AppDelegationPeer::TAS_UID); $threadTitle = Delegation::getThreadTitle($tasUid, $appNumber, $previous, $caseData);
$cri->add(AppDelegationPeer::APP_UID, $appUid);
$cri->add(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN");
if (isset($fields['DEL_INDEX'])) {
$cri->add(AppDelegationPeer::DEL_INDEX, $fields['DEL_INDEX']);
}
$rsCri = AppDelegationPeer::doSelectRS($cri);
$rsCri->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$rsCri->next();
$rowCri = $rsCri->getRow();
//load only the tas_def fields, because these three or two values are needed
while (is_array($rowCri)) {
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn(TaskPeer::TAS_DEF_TITLE);
$c->addSelectColumn(TaskPeer::TAS_DEF_DESCRIPTION);
$c->add(TaskPeer::TAS_UID, $rowCri['TAS_UID']);
$rs = TaskPeer::doSelectRS($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($rs->next()) {
$row = $rs->getRow();
$newValues = [];
//Get the case title
$tasDefTitle = trim($row['TAS_DEF_TITLE']);
if (!empty($tasDefTitle) && !$flagTitle) {
$newAppProperty = G::replaceDataField($tasDefTitle, $lastFieldsCase, 'mysql', false);
$res['APP_TITLE'] = $newAppProperty;
if (!(isset($currentValue) && ($currentValue == $tasDefTitle))) {
$newValues['APP_TITLE'] = $newAppProperty;
$flagTitle = true;
} }
} }
//Get the case description // Update thread title
$tasDefDescription = trim($row['TAS_DEF_DESCRIPTION']); $rows = [];
if (!empty($tasDefDescription) && !$flagDescription) { $rows['APP_UID'] = $appUid;
$newAppProperty = G::replaceDataField($tasDefDescription, $lastFieldsCase, 'mysql', false); $rows['DEL_INDEX'] = $delIndex;
$res['APP_DESCRIPTION'] = $newAppProperty; $rows['DEL_TITLE'] = $threadTitle;
if (!(isset($currentValue) && ($currentValue == $tasDefDescription))) { $delegation = new AppDelegation();
$newValues['APP_DESCRIPTION'] = $newAppProperty; $delegation->update($rows);
$flagDescription = true;
}
}
if (!empty($newValues)) {
$application = new Application();
$newValues['APP_UID'] = $appUid;
$application->update($newValues);
}
}
$rsCri->next();
$rowCri = $rsCri->getRow();
}
return $res;
}
/**
* Small function, it uses to return the title from a case
*
*
* @name refreshCaseTitle
* @param string $sAppUid
* @param array $aAppData
* @access public
* @return $appLabel
*/
public function refreshCaseTitle($sAppUid, $aAppData)
{
return $this->refreshCaseLabel($sAppUid, $aAppData, "Title");
}
/**
* Small function, it uses to return the description from a case
*
*
* @name refreshCaseDescription
* @param string $sAppUid
* @param array $aAppData
* @access public
* @return $appLabel
*/
public function refreshCaseDescription($sAppUid, $aAppData)
{
return $this->refreshCaseLabel($sAppUid, $aAppData, "Description");
}
/**
* Small function, it uses to return the code process from a case
*
*
* @name refreshCaseDescription
* @param string $sAppUid
* @param array $aAppData
* @access public
* @return $appLabel
*/
public function refreshCaseStatusCode($sAppUid, $aAppData)
{
return $this->refreshCaseLabel($sAppUid, $aAppData, "ProcCode");
} }
/** /**
@@ -906,12 +797,10 @@ class Cases
$appFields['DEL_INDEX'] = $Fields['DEL_INDEX']; $appFields['DEL_INDEX'] = $Fields['DEL_INDEX'];
} }
//Get the appTitle and appDescription // Update case title
$newTitleOrDescription = $this->newRefreshCaseTitleAndDescription( if (!empty($appUid) && !empty($appFields['APP_NUMBER']) && !empty($appFields['DEL_INDEX'])) {
$appUid, $this->updateThreadTitle($appUid, $appFields['APP_NUMBER'], $appFields['DEL_INDEX'], $appFields['APP_DATA']);
$appFields, }
$appData
);
//Start: Save History --By JHL //Start: Save History --By JHL
if (isset($Fields['CURRENT_DYNAFORM'])) { if (isset($Fields['CURRENT_DYNAFORM'])) {
@@ -1027,7 +916,7 @@ class Cases
$inbox = new ListInbox(); $inbox = new ListInbox();
unset($Fields['DEL_INIT_DATE']); unset($Fields['DEL_INIT_DATE']);
unset($Fields['DEL_DELEGATE_DATE']); unset($Fields['DEL_DELEGATE_DATE']);
$inbox->update(array_merge($Fields, $newTitleOrDescription)); $inbox->update($Fields);
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
//Return //Return
@@ -1708,14 +1597,13 @@ class Cases
* This function creates a new row into APP_DELEGATION * This function creates a new row into APP_DELEGATION
* *
* @name newAppDelegation * @name newAppDelegation
* @param string $sProUid, * @param string $proUid
* @param string $sAppUid, * @param string $appUid
* @param string $sTasUid, * @param string $tasUid
* @param string $sUsrUid * @param string $usrUid
* @param string $sPrevious * @param string $previous
* @param string $iPriority * @param string $priority
* @param string $sDelType * @param int $threadIndex
* @param string $iAppThreadIndex
* @param string $nextDel * @param string $nextDel
* @param boolean $flagControl * @param boolean $flagControl
* @param boolean $flagControlMulInstance * @param boolean $flagControlMulInstance
@@ -1723,22 +1611,55 @@ class Cases
* @param int $appNumber * @param int $appNumber
* @param int $proId * @param int $proId
* @param int $tasId * @param int $tasId
* @return void * @param array $caseData
*
* @see Cases::reassignCase()
* @see Cases::startCase()
* @see Cases::unpauseCase()
* @see Cases::unCancelCase()
* @see Derivation::doDerivation()
* @see Derivation::doDerivationStaticMi()
*
* @return int
* @throw Exception
*/ */
public function newAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sPrevious, $iPriority, $sDelType, $iAppThreadIndex = 1, $nextDel = null, $flagControl = false, $flagControlMulInstance = false, $delPrevious = 0, $appNumber = 0, $proId = 0, $tasId = 0) public function newAppDelegation(
{ $proUid,
$appUid,
$tasUid,
$usrUid,
$previous,
$priority,
$threadIndex = 1,
$nextDel = null,
$flagControl = false,
$flagControlMulInstance = false,
$delPrevious = 0,
$appNumber = 0,
$proId = 0,
$tasId = 0,
$caseData = []
){
try { try {
$user = UsersPeer::retrieveByPK($sUsrUid); // Get case title
$appDel = new AppDelegation(); $threadTitle = $this->getCaseTitle();
$result = $appDel->createAppDelegation( if (empty($threadTitle)) {
$sProUid, $threadTitle = Delegation::getThreadTitle($tasUid, $appNumber, $previous, $caseData);
$sAppUid, }
$sTasUid,
$sUsrUid, $user = UsersPeer::retrieveByPK($usrUid);
$iAppThreadIndex, // Create new delegation
$iPriority, $delegation = new AppDelegation();
$delegation->setDelTitle($threadTitle);
$result = $delegation->createAppDelegation(
$proUid,
$appUid,
$tasUid,
$usrUid,
$threadIndex,
$priority,
false, false,
$sPrevious, $previous,
$nextDel, $nextDel,
$flagControl, $flagControl,
$flagControlMulInstance, $flagControlMulInstance,
@@ -1748,12 +1669,12 @@ class Cases
(empty($user)) ? 0 : $user->getUsrId(), (empty($user)) ? 0 : $user->getUsrId(),
$proId $proId
); );
//update searchindex // Update search index
if ($this->appSolr != null) { if ($this->appSolr != null) {
$this->appSolr->updateApplicationSearchIndex($sAppUid); $this->appSolr->updateApplicationSearchIndex($appUid);
} }
return $result; return $result;
} catch (exception $e) { } catch (Exception $e) {
throw ($e); throw ($e);
} }
} }
@@ -2105,185 +2026,175 @@ class Cases
} }
/** /**
* This function start a case using the task for the user $sUsrUid * This function start a case using the task for the user $usrUid
* With this function we can Start a case * With this function we can Start a case
* *
* @param string $taskUid * @name startCase
* @param string $userUid * @param string $tasUid
* @param bool $isSubProcess * @param string $usrUid
* @param array $dataPreviousApplication * @param bool $isSubprocess
* @param array $previousInfo
* @param bool $isSelfService * @param bool $isSelfService
* @param string $sequenceType * @param string $sequenceType
* @return array *
* @throws Exception * @return Fields
* @throw Exception
*/ */
public function startCase($taskUid, $userUid, $isSubProcess = false, $dataPreviousApplication = [], $isSelfService = false, $sequenceType = AppSequence::APP_TYPE_NORMAL) public function startCase(string $tasUid, string $usrUid, $isSubprocess = false, $previousInfo = [], $isSelfService = false, $sequenceType = AppSequence::APP_TYPE_NORMAL)
{ {
if ($taskUid != '') { if (!empty($tasUid)) {
try { try {
$task = TaskPeer::retrieveByPK($taskUid); $task = TaskPeer::retrieveByPK($tasUid);
$user = UsersPeer::retrieveByPK($userUid); $user = UsersPeer::retrieveByPK($usrUid);
if (is_null($task)) { if (is_null($task)) {
throw new Exception(G::LoadTranslation("ID_TASK_NOT_EXIST", ["TAS_UID", $taskUid])); throw new Exception(G::LoadTranslation("ID_TASK_NOT_EXIST", ["TAS_UID", $tasUid]));
} }
// To allow Self Service as the first task // To allow Self Service as the first task
$arrayTaskTypeToExclude = ["START-TIMER-EVENT"]; $tasksTypeToExclude = ["START-TIMER-EVENT"];
if (!is_null($task) && !in_array($task->getTasType(), $tasksTypeToExclude) && $task->getTasAssignType() != "SELF_SERVICE" && $usrUid == "") {
if (!is_null($task) && !in_array($task->getTasType(), $arrayTaskTypeToExclude) && $task->getTasAssignType() != "SELF_SERVICE" && $userUid == "") {
throw (new Exception('You tried to start a new case without send the USER UID!')); throw (new Exception('You tried to start a new case without send the USER UID!'));
} }
// Process // Load Process
$processUid = $task->getProUid(); $proUid = $task->getProUid();
$this->Process = new Process; $this->Process = new Process;
$proFields = $this->Process->Load($processUid); $proFields = $this->Process->Load($proUid);
// Application // Create application
$application = new Application; $application = new Application;
$appUid = $application->create($processUid, $userUid, $sequenceType); $appUid = $application->create($proUid, $usrUid, $sequenceType);
$fields = $application->toArray(BasePeer::TYPE_FIELDNAME);
// AppDelegation // Create appDelegation
$appDelegation = new AppDelegation; $delIndex = $this->newAppDelegation(
$appThreadIndex = 1; // Start Thread $proUid,
$appDelPriority = 3; // Priority
$delIndex = $appDelegation->createAppDelegation(
$processUid,
$appUid, $appUid,
$taskUid, $tasUid,
$userUid, $usrUid,
$appThreadIndex, -1, // previous
$appDelPriority, 3, // Priority
$isSubProcess, 1, // Start Thread
-1, null, // Next delegation
null, false, // Flag control
false, false, // Flag control multi-instance
false, 0, // Thread previous
0,
$application->getAppNumber(), $application->getAppNumber(),
$this->Process->getProId(),
$task->getTasId(), $task->getTasId(),
(empty($user)) ? 0 : $user->getUsrId(), $fields['APP_DATA']
$this->Process->getProId()
); );
// AppThread // Instance appThread
$appThread = new AppThread; $thread = new AppThread;
$appThreadIndex = $appThread->createAppThread($appUid, $delIndex, 0); $threadIndex = $thread->createAppThread($appUid, $delIndex, 0);
// Instance Derivation
$derivation = new Derivation(); $routing = new Derivation();
// Multiple Instance // Multiple Instance
$usersFields = []; $userFields = [];
$taskAssignType = $task->getTasAssignType(); $taskAssignType = $task->getTasAssignType();
$nextTaskAssignVariable = $task->getTasAssignVariable();
if ($taskAssignType == "MULTIPLE_INSTANCE" || $taskAssignType == "MULTIPLE_INSTANCE_VALUE_BASED") { if ($taskAssignType == "MULTIPLE_INSTANCE" || $taskAssignType == "MULTIPLE_INSTANCE_VALUE_BASED") {
switch ($taskAssignType) { switch ($taskAssignType) {
case 'MULTIPLE_INSTANCE': case 'MULTIPLE_INSTANCE':
$userFields = $derivation->getUsersFullNameFromArray($derivation->getAllUsersFromAnyTask($taskUid)); $userFields = $routing->getUsersFullNameFromArray($routing->getAllUsersFromAnyTask($tasUid));
break; break;
default: default:
throw (new Exception('Invalid Task Assignment method')); throw (new Exception('Invalid Task Assignment method'));
break; break;
} }
$userFields = $derivation->getUsersFullNameFromArray($derivation->getAllUsersFromAnyTask($taskUid)); $userFields = $routing->getUsersFullNameFromArray($routing->getAllUsersFromAnyTask($tasUid));
$count = 0; $count = 0;
foreach ($userFields as $rowUser) { foreach ($userFields as $rowUser) {
if ($rowUser["USR_UID"] != $userUid) { if ($rowUser["USR_UID"] != $usrUid) {
// AppDelegation // Create appDelegation
$appDelegation = new AppDelegation; $delegation = new AppDelegation;
$appThreadIndex ++; // Start Thread $threadIndex ++; // Start Thread
$appDelPriority = 3; // Priority $priority = 3; // Priority
$user = UsersPeer::retrieveByPK($rowUser["USR_UID"]); $user = UsersPeer::retrieveByPK($rowUser["USR_UID"]);
$delIndex1 = $appDelegation->createAppDelegation( // Create a new delegation
$processUid, $delIndex1 = $this->newAppDelegation(
$proUid,
$appUid, $appUid,
$taskUid, $tasUid,
$rowUser["USR_UID"], $rowUser["USR_UID"],
$appThreadIndex, -1, // previous
$appDelPriority, $priority, // Priority
$isSubProcess, $threadIndex, // Start Thread
-1, null, // Next delegation
null, false, // Flag control
false, false, // Flag control multi-instance
false, 0, // Thread previous
0,
$application->getAppNumber(), $application->getAppNumber(),
$this->Process->getProId(),
$task->getTasId(), $task->getTasId(),
(empty($user)) ? 0 : $user->getUsrId(), $fields['APP_DATA']
$this->Process->getProId()
); );
// AppThread // Create appThread
$appThread = new AppThread; $thread = new AppThread;
$appThreadIndex = $appThread->createAppThread($appUid, $delIndex1, 0); $threadIndex = $thread->createAppThread($appUid, $delIndex1, 0);
// Save Information // Save Information
$usersFields[$count] = $rowUser; $userFields[$count] = $rowUser;
$usersFields[$count]["DEL_INDEX"] = $delIndex1; $userFields[$count]["DEL_INDEX"] = $delIndex1;
$count++; $count++;
} }
} }
} }
// Update the application
$fields = $application->toArray(BasePeer::TYPE_FIELDNAME); $fields = $application->toArray(BasePeer::TYPE_FIELDNAME);
$applicationFields = $fields['APP_DATA'];
$fields['DEL_INDEX'] = $delIndex; $fields['DEL_INDEX'] = $delIndex;
$newValues = $this->newRefreshCaseTitleAndDescription($appUid, $fields, $applicationFields);
if (!isset($newValues['APP_TITLE'])) {
$newValues['APP_TITLE'] = '';
}
$caseNumber = $fields['APP_NUMBER'];
$application->update($fields); $application->update($fields);
// Get current case number
$caseNumber = $fields['APP_NUMBER'];
// Update the task last assigned (for web entry and web services) // Update the task last assigned (for web entry and web services)
$derivation->setTasLastAssigned($taskUid, $userUid); $routing->setTasLastAssigned($tasUid, $usrUid);
// Execute Events // Execute Events
$event = new Event(); $event = new Event();
$event->createAppEvents($processUid, $appUid, $delIndex, $taskUid); $event->createAppEvents($proUid, $appUid, $delIndex, $tasUid);
// Update search index // Update solr
if ($this->appSolr != null) { if ($this->appSolr != null) {
$this->appSolr->updateApplicationSearchIndex($appUid); $this->appSolr->updateApplicationSearchIndex($appUid);
} }
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
$fields['TAS_UID'] = $taskUid; $fields['TAS_UID'] = $tasUid;
$fields['USR_UID'] = $userUid; $fields['USR_UID'] = $usrUid;
$fields['DEL_INDEX'] = $delIndex; $fields['DEL_INDEX'] = $delIndex;
$fields['APP_STATUS'] = 'TO_DO'; $fields['APP_STATUS'] = 'TO_DO';
$fields['DEL_DELEGATE_DATE'] = $fields['APP_INIT_DATE']; $fields['DEL_DELEGATE_DATE'] = $fields['APP_INIT_DATE'];
if (!$isSubProcess) { if (!$isSubprocess) {
$fields['APP_STATUS'] = 'DRAFT'; $fields['APP_STATUS'] = 'DRAFT';
} else { } else {
$fields['APP_INIT_DATE'] = null; $fields['APP_INIT_DATE'] = null;
} }
$inbox = new ListInbox(); $inbox = new ListInbox();
$inbox->newRow($fields, $userUid, $isSelfService); $inbox->newRow($fields, $usrUid, $isSelfService);
// Multiple Instance // Multiple Instance
foreach ($usersFields as $rowUser) { foreach ($userFields as $rowUser) {
$fields["USR_UID"] = $rowUser["USR_UID"]; $fields["USR_UID"] = $rowUser["USR_UID"];
$fields["DEL_INDEX"] = $rowUser["DEL_INDEX"]; $fields["DEL_INDEX"] = $rowUser["DEL_INDEX"];
$inbox = new ListInbox(); $inbox = new ListInbox();
$inbox->newRow($fields, $userUid, $isSelfService); $inbox->newRow($fields, $usrUid, $isSelfService);
} }
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
} catch (Exception $e) { } catch (Exception $e) {
throw ($e); throw ($e);
} }
} else { } else {
throw (new Exception('You tried to start a new case without send the USER UID or TASK UID!')); throw new Exception('You tried to start a new case without send the USER UID or TASK UID!');
} }
// Log // Log
$message = 'Create case'; $message = 'Create case';
$context = $data = [ $context = $data = [
"appUid" => $appUid, "appUid" => $appUid,
"usrUid" => $userUid, "usrUid" => $usrUid,
"tasUid" => $taskUid, "tasUid" => $tasUid,
"isSubProcess" => $isSubProcess, "isSubprocess" => $isSubprocess,
"appNumber" => $caseNumber, "appNumber" => $caseNumber,
"delIndex" => $delIndex, "delIndex" => $delIndex,
"appInitDate" => $fields['APP_INIT_DATE'] "appInitDate" => $fields['APP_INIT_DATE']
@@ -2291,16 +2202,16 @@ class Cases
Log::channel(':CreateCase')->info($message, Bootstrap::context($context)); Log::channel(':CreateCase')->info($message, Bootstrap::context($context));
// Call plugin // Call plugin
if (class_exists('folderData')) { if (class_exists('folderData')) {
$folderData = new folderData($processUid, $proFields['PRO_TITLE'], $appUid, $newValues['APP_TITLE'], $userUid); $folderData = new folderData($proUid, $proFields['PRO_TITLE'], $appUid, '', $usrUid);
$pluginRegistry = PluginRegistry::loadSingleton(); $oPluginRegistry = PluginRegistry::loadSingleton();
$pluginRegistry->executeTriggers(PM_CREATE_CASE, $folderData); $oPluginRegistry->executeTriggers(PM_CREATE_CASE, $folderData);
} }
$this->getExecuteTriggerProcess($appUid, 'CREATE'); $this->getExecuteTriggerProcess($appUid, 'CREATE');
// End plugin //end plugin
return [ return [
'APPLICATION' => $appUid, 'APPLICATION' => $appUid,
'INDEX' => $delIndex, 'INDEX' => $delIndex,
'PROCESS' => $processUid, 'PROCESS' => $proUid,
'CASE_NUMBER' => $caseNumber 'CASE_NUMBER' => $caseNumber
]; ];
} }
@@ -3595,17 +3506,6 @@ class Cases
} }
} }
/**
* Get the caseTitle from the nextTask and update the caseTitle
*/
if ($varInAfterRouting) {
$this->newRefreshCaseTitleAndDescription(
$appUid,
['DEL_INDEX' => 0],
$fieldsCase
);
}
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
if (!empty($foundDisabledCode)) { if (!empty($foundDisabledCode)) {
G::SendTemporalMessage( G::SendTemporalMessage(
@@ -4246,14 +4146,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);
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
@@ -4263,112 +4165,113 @@ class Cases
* unpause a case * unpause a case
* *
* @name unpauseCase * @name unpauseCase
* @param string $sApplicationUID * @param string $appUid
* @param string $iDelegation * @param int $index
* @param string $sUserUID * @param string $usrUid
* @return object * @return object
*/ */
public function unpauseCase($sApplicationUID, $iDelegation, $sUserUID) public function unpauseCase($appUid, $index, $usrUid)
{ {
// Verify status of the case // Verify status of the case
$oDelay = new AppDelay(); $delay = new AppDelay();
if (method_exists($oDelay, 'isPaused')) { if (method_exists($delay, 'isPaused')) {
if ($oDelay->isPaused($sApplicationUID, $iDelegation) === false) { if ($delay->isPaused($appUid, $index) === false) {
return false; return false;
} }
} }
//get information about current $iDelegation row // Get information about current $index row
$oAppDelegation = new AppDelegation(); $delegation = new AppDelegation();
$user = UsersPeer::retrieveByPK($sUserUID); $delRow = $delegation->Load($appUid, $index);
$aFieldsDel = $oAppDelegation->Load($sApplicationUID, $iDelegation);
//and creates a new AppDelegation row with the same user, task, process, etc. //and creates a new AppDelegation row with the same user, task, process, etc.
$proUid = $aFieldsDel['PRO_UID']; $proUid = $delRow['PRO_UID'];
$appUid = $aFieldsDel['APP_UID']; $appUid = $delRow['APP_UID'];
$tasUid = $aFieldsDel['TAS_UID']; $tasUid = $delRow['TAS_UID'];
$usrUid = $aFieldsDel['USR_UID']; $usrUid = $delRow['USR_UID'];
$delThread = $aFieldsDel['DEL_THREAD']; // Load Application
$iIndex = $oAppDelegation->createAppDelegation( $application = new Application();
$caseFields = $application->Load($appUid);
$caseData = unserialize($caseFields['APP_DATA']);
// Create a new delegation
$newIndex = $this->newAppDelegation(
$proUid, $proUid,
$appUid, $appUid,
$tasUid, $tasUid,
$usrUid, $usrUid,
$delThread, -1, // previous
3, 3, // Priority
false, 1, // Start Thread
-1, null, // Next delegation
null, false, // Flag control
false, false, // Flag control multi-instance
false, 0, // Thread previous
0, $delRow['APP_NUMBER'],
$aFieldsDel['APP_NUMBER'], $delRow['PRO_ID'],
$aFieldsDel['TAS_ID'], $delRow['TAS_ID'],
(empty($user)) ? 0 : $user->getUsrId(), $caseData
$aFieldsDel['PRO_ID']
); );
//update other fields in the recent new appDelegation // Update other fields in the recent new appDelegation
$aData = array(); $row = [];
$aData['APP_UID'] = $aFieldsDel['APP_UID']; $row['APP_UID'] = $delRow['APP_UID'];
$aData['DEL_INDEX'] = $iIndex; $row['DEL_INDEX'] = $newIndex;
$aData['DEL_PREVIOUS'] = $aFieldsDel['DEL_PREVIOUS']; $row['DEL_PREVIOUS'] = $delRow['DEL_PREVIOUS'];
$aData['DEL_TYPE'] = $aFieldsDel['DEL_TYPE']; $row['DEL_TYPE'] = $delRow['DEL_TYPE'];
$aData['DEL_PRIORITY'] = $aFieldsDel['DEL_PRIORITY']; $row['DEL_PRIORITY'] = $delRow['DEL_PRIORITY'];
$aData['DEL_DELEGATE_DATE'] = $aFieldsDel['DEL_DELEGATE_DATE']; $row['DEL_DELEGATE_DATE'] = $delRow['DEL_DELEGATE_DATE'];
$aData['DEL_INIT_DATE'] = date('Y-m-d H:i:s'); $row['DEL_INIT_DATE'] = date('Y-m-d H:i:s');
$aData['DEL_FINISH_DATE'] = null; $row['DEL_FINISH_DATE'] = null;
$oAppDelegation->update($aData); $delegation->update($row);
//get the APP_DELAY row ( with app_uid, del_index and app_type=pause // Get the APP_DELAY row with app_uid, del_index and app_type=pause
$oCriteria = new Criteria('workflow'); $criteria = new Criteria('workflow');
$oCriteria->clearSelectColumns(); $criteria->clearSelectColumns();
$oCriteria->addSelectColumn(AppDelayPeer::APP_DELAY_UID); $criteria->addSelectColumn(AppDelayPeer::APP_DELAY_UID);
$oCriteria->addSelectColumn(AppDelayPeer::APP_THREAD_INDEX); $criteria->addSelectColumn(AppDelayPeer::APP_THREAD_INDEX);
$oCriteria->addSelectColumn(AppDelayPeer::APP_STATUS); $criteria->addSelectColumn(AppDelayPeer::APP_STATUS);
$oCriteria->add(AppDelayPeer::APP_UID, $sApplicationUID); $criteria->add(AppDelayPeer::APP_UID, $appUid);
$oCriteria->add(AppDelayPeer::APP_DEL_INDEX, $iDelegation); $criteria->add(AppDelayPeer::APP_DEL_INDEX, $index);
$oCriteria->add(AppDelayPeer::APP_TYPE, 'PAUSE'); $criteria->add(AppDelayPeer::APP_TYPE, 'PAUSE');
$oCriteria->add( $criteria->add(
$oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL)->addOr( $criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL)->addOr(
$oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)) $criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL))
); );
$dataset = AppDelayPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();
$rowPaused = $dataset->getRow();
$oDataset = AppDelayPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aRow = $oDataset->getRow();
$oApplication = new Application(); $caseFields['APP_STATUS'] = $rowPaused['APP_STATUS'];
$aFields = $oApplication->Load($sApplicationUID); $application->update($caseFields);
$aFields['APP_STATUS'] = $aRow['APP_STATUS'];
$oApplication->update($aFields);
//update the DEL_INDEX ? in APP_THREAD table? // Update the DEL_INDEX ? in APP_THREAD table?
$aUpdate = array( $rowUpdate = [
'APP_UID' => $sApplicationUID, 'APP_UID' => $appUid,
'APP_THREAD_INDEX' => $aRow['APP_THREAD_INDEX'], 'APP_THREAD_INDEX' => $rowPaused['APP_THREAD_INDEX'],
'DEL_INDEX' => $iIndex 'DEL_INDEX' => $newIndex
); ];
$oAppThread = new AppThread(); $thread = new AppThread();
$oAppThread->update($aUpdate); $thread->update($rowUpdate);
$aData['APP_DELAY_UID'] = $aRow['APP_DELAY_UID']; $row['APP_DELAY_UID'] = $rowPaused['APP_DELAY_UID'];
$aData['APP_DISABLE_ACTION_USER'] = $sUserUID; $row['APP_DISABLE_ACTION_USER'] = $usrUid;
$aData['APP_DISABLE_ACTION_DATE'] = date('Y-m-d H:i:s'); $row['APP_DISABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
$oAppDelay = new AppDelay(); $delay = new AppDelay();
$aFieldsDelay = $oAppDelay->update($aData); $rowDelay = $delay->update($row);
//update searchindex // Update searchindex
if ($this->appSolr != null) { if ($this->appSolr != null) {
$this->appSolr->updateApplicationSearchIndex($sApplicationUID); $this->appSolr->updateApplicationSearchIndex($appUid);
} }
$this->getExecuteTriggerProcess($sApplicationUID, "UNPAUSE"); $this->getExecuteTriggerProcess($appUid, "UNPAUSE");
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
$aData = array_merge($aFieldsDel, $aData); $row = array_merge($delRow, $row);
$oListPaused = new ListPaused(); $listPaused = new ListPaused();
$oListPaused->remove($sApplicationUID, $iDelegation, $aData); $listPaused->remove($appUid, $index, $row);
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
} }
@@ -4514,24 +4417,22 @@ class Cases
$appDelegation = new AppDelegation(); $appDelegation = new AppDelegation();
$delegationClosed = $appDelegation->Load($appUid, $row['APP_DEL_INDEX']); $delegationClosed = $appDelegation->Load($appUid, $row['APP_DEL_INDEX']);
// Create an appDelegation for each thread // Create an appDelegation for each thread
$appDelegation = new AppDelegation(); $delIndex = $this->newAppDelegation(
$delIndex = $appDelegation->createAppDelegation(
$delegationClosed['PRO_UID'], $delegationClosed['PRO_UID'],
$delegationClosed['APP_UID'], $delegationClosed['APP_UID'],
$delegationClosed['TAS_UID'], $delegationClosed['TAS_UID'],
$usrUid, $usrUid,
$delegationClosed['DEL_THREAD'], $delegationClosed['DEL_PREVIOUS'], // previous
3, 3, // Priority
false, $delegationClosed['DEL_THREAD'], // Start Thread
$delegationClosed['DEL_PREVIOUS'], null, // Next delegation
null, false, // Flag control
false, false, // Flag control multi-instance
false, 0, // Thread previous
0,
$delegationClosed['APP_NUMBER'], $delegationClosed['APP_NUMBER'],
$delegationClosed['PRO_ID'],
$delegationClosed['TAS_ID'], $delegationClosed['TAS_ID'],
$userId, $caseFields['APP_DATA']
$delegationClosed['PRO_ID']
); );
//Update the appThread //Update the appThread
@@ -4663,23 +4564,29 @@ class Cases
$user = UsersPeer::retrieveByPK($newUserUid); $user = UsersPeer::retrieveByPK($newUserUid);
$appDelegation = new AppDelegation(); $appDelegation = new AppDelegation();
$fieldsDel = $appDelegation->Load($appUid, $delIndex); $fieldsDel = $appDelegation->Load($appUid, $delIndex);
$newDelIndex = $appDelegation->createAppDelegation(
// Load application
$application = new Application();
$dataFields = $application->Load($appUid);
$caseData = unserialize($dataFields['APP_DATA']);
// Create a new delegation
$newDelIndex = $this->newAppDelegation(
$fieldsDel['PRO_UID'], $fieldsDel['PRO_UID'],
$fieldsDel['APP_UID'], $fieldsDel['APP_UID'],
$fieldsDel['TAS_UID'], $fieldsDel['TAS_UID'],
$newUserUid, $newUserUid,
$fieldsDel['DEL_THREAD'], -1, // previous
3, 3, // Priority
false, $fieldsDel['DEL_THREAD'], // Start Thread
-1, null, // Next delegation
null, false, // Flag control
false, false, // Flag control multi-instance
false, 0, // Thread previous
0,
$fieldsDel['APP_NUMBER'], $fieldsDel['APP_NUMBER'],
$fieldsDel['PRO_ID'],
$fieldsDel['TAS_ID'], $fieldsDel['TAS_ID'],
(empty($user)) ? 0 : $user->getUsrId(), $caseData
$fieldsDel['PRO_ID']
); );
$newData = []; $newData = [];
@@ -4703,9 +4610,7 @@ class Cases
] ]
); );
//Save in APP_DELAY
$application = new Application();
$dataFields = $application->Load($appUid);
$newData['PRO_UID'] = $fieldsDel['PRO_UID']; $newData['PRO_UID'] = $fieldsDel['PRO_UID'];
$newData['APP_UID'] = $appUid; $newData['APP_UID'] = $appUid;
$newData['APP_THREAD_INDEX'] = $fieldsDel['DEL_THREAD']; $newData['APP_THREAD_INDEX'] = $fieldsDel['DEL_THREAD'];

View File

@@ -1286,7 +1286,6 @@ class Derivation
$newDelegationUser, $newDelegationUser,
$currentDelegation['DEL_INDEX'], $currentDelegation['DEL_INDEX'],
$nextDel['DEL_PRIORITY'], $nextDel['DEL_PRIORITY'],
$delType,
$iAppThreadIndex, $iAppThreadIndex,
$nextDel, $nextDel,
$this->flagControl, $this->flagControl,
@@ -2365,7 +2364,6 @@ class Derivation
(isset( $aValue['USR_UID'] ) ? $aValue['USR_UID'] : ''), (isset( $aValue['USR_UID'] ) ? $aValue['USR_UID'] : ''),
$currentDelegation['DEL_INDEX'], $currentDelegation['DEL_INDEX'],
$nextDel['DEL_PRIORITY'], $nextDel['DEL_PRIORITY'],
$delType,
$iNewAppThreadIndex, $iNewAppThreadIndex,
$nextDel, $nextDel,
$appFields['APP_NUMBER'], $appFields['APP_NUMBER'],

View File

@@ -12,6 +12,7 @@ use ProcessMaker\Core\Installer;
use ProcessMaker\Core\ProcessesManager; use ProcessMaker\Core\ProcessesManager;
use ProcessMaker\Core\System; use ProcessMaker\Core\System;
use ProcessMaker\Model\Application; use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Fields; use ProcessMaker\Model\Fields;
use ProcessMaker\Plugins\Adapters\PluginAdapter; use ProcessMaker\Plugins\Adapters\PluginAdapter;
use ProcessMaker\Project\Adapter\BpmnWorkflow; use ProcessMaker\Project\Adapter\BpmnWorkflow;
@@ -377,6 +378,11 @@ class WorkspaceTools
Propel::init(PATH_CONFIG . 'databases.php'); Propel::init(PATH_CONFIG . 'databases.php');
WebEntry::convertFromV1ToV2(); WebEntry::convertFromV1ToV2();
CLI::logging("* End converting Web Entries v1.0 to v2.0 for BPMN processes...(" . (microtime(true) - $start) . " seconds)\n"); CLI::logging("* End converting Web Entries v1.0 to v2.0 for BPMN processes...(" . (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start migrating case title...\n");
$start = microtime(true);
$this->migrateCaseTitleToThreads([$workspace]);
CLI::logging("* End migrating case title...(Completed on " . (microtime(true) - $start) . " seconds)\n");
} }
/** /**
@@ -593,9 +599,19 @@ class WorkspaceTools
$rbDetails = $this->getDBCredentials("rb"); $rbDetails = $this->getDBCredentials("rb");
$rpDetails = $this->getDBCredentials("rp"); $rpDetails = $this->getDBCredentials("rp");
$config = array('datasources' => array('workflow' => array('connection' => $wfDetails["dsn"], 'adapter' => $wfDetails["adapter"] $config = array(
), 'rbac' => array('connection' => $rbDetails["dsn"], 'adapter' => $rbDetails["adapter"] 'datasources' => array(
), 'rp' => array('connection' => $rpDetails["dsn"], 'adapter' => $rpDetails["adapter"] 'workflow' => array(
'connection' => $wfDetails["dsn"],
'adapter' => $wfDetails["adapter"]
),
'rbac' => array(
'connection' => $rbDetails["dsn"],
'adapter' => $rbDetails["adapter"]
),
'rp' => array(
'connection' => $rpDetails["dsn"],
'adapter' => $rpDetails["adapter"]
) )
) )
); );
@@ -1039,12 +1055,14 @@ class WorkspaceTools
$this->initPropel(true); $this->initPropel(true);
$conf = new Configurations(); $conf = new Configurations();
if (!$conf->exists("ENVIRONMENT_SETTINGS")) { if (!$conf->exists("ENVIRONMENT_SETTINGS")) {
$conf->aConfig = array("format" => '@userName (@firstName @lastName)', $conf->aConfig = array(
"format" => '@userName (@firstName @lastName)',
"dateFormat" => 'd/m/Y', "dateFormat" => 'd/m/Y',
"startCaseHideProcessInf" => false, "startCaseHideProcessInf" => false,
"casesListDateFormat" => 'Y-m-d H:i:s', "casesListDateFormat" => 'Y-m-d H:i:s',
"casesListRowNumber" => 25, "casesListRowNumber" => 25,
"casesListRefreshTime" => 120); "casesListRefreshTime" => 120
);
$conf->saveConfig('ENVIRONMENT_SETTINGS', ''); $conf->saveConfig('ENVIRONMENT_SETTINGS', '');
} }
$conf->setDirectoryStructureVer(2); $conf->setDirectoryStructureVer(2);
@@ -1299,8 +1317,12 @@ class WorkspaceTools
} }
// Instantiate the class to execute the query in background // Instantiate the class to execute the query in background
$upgradeQueries[] = new RunProcessUpgradeQuery($this->name, $database->generateAddColumnsSql($tableName, $upgradeQueries[] = new RunProcessUpgradeQuery($this->name, $database->generateAddColumnsSql(
$tableColumn, $indexes, $fulltextIndexes), $rbac); $tableName,
$tableColumn,
$indexes,
$fulltextIndexes
), $rbac);
} }
// Run queries in multiple threads // Run queries in multiple threads
@@ -1510,7 +1532,8 @@ class WorkspaceTools
if ($fields['DB_NAME'] == $fields['DB_RBAC_NAME']) { if ($fields['DB_NAME'] == $fields['DB_RBAC_NAME']) {
$info = array('Workspace Name' => $fields['WORKSPACE_NAME'], 'Workflow Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_USER'], $fields['DB_PASS'], $fields['DB_HOST'], $fields['DB_NAME']), 'MySql Version' => $fields['DATABASE']); $info = array('Workspace Name' => $fields['WORKSPACE_NAME'], 'Workflow Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_USER'], $fields['DB_PASS'], $fields['DB_HOST'], $fields['DB_NAME']), 'MySql Version' => $fields['DATABASE']);
} else { } else {
$info = array('Workspace Name' => $fields['WORKSPACE_NAME'], $info = array(
'Workspace Name' => $fields['WORKSPACE_NAME'],
//'Available Databases' => $fields['AVAILABLE_DB'], //'Available Databases' => $fields['AVAILABLE_DB'],
'Workflow Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_USER'], $fields['DB_PASS'], $fields['DB_HOST'], $fields['DB_NAME']), 'RBAC Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_RBAC_USER'], $fields['DB_RBAC_PASS'], $fields['DB_RBAC_HOST'], $fields['DB_RBAC_NAME']), 'Report Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_REPORT_USER'], $fields['DB_REPORT_PASS'], $fields['DB_REPORT_HOST'], $fields['DB_REPORT_NAME']), 'MySql Version' => $fields['DATABASE'] 'Workflow Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_USER'], $fields['DB_PASS'], $fields['DB_HOST'], $fields['DB_NAME']), 'RBAC Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_RBAC_USER'], $fields['DB_RBAC_PASS'], $fields['DB_RBAC_HOST'], $fields['DB_RBAC_NAME']), 'Report Database' => sprintf("%s://%s:%s@%s/%s", $fields['DB_ADAPTER'], $fields['DB_REPORT_USER'], $fields['DB_REPORT_PASS'], $fields['DB_REPORT_HOST'], $fields['DB_REPORT_NAME']), 'MySql Version' => $fields['DATABASE']
); );
@@ -1648,9 +1671,7 @@ class WorkspaceTools
/* Write metadata to file, but make it prettier before. The metadata is just /* Write metadata to file, but make it prettier before. The metadata is just
* a JSON codified array. * a JSON codified array.
*/ */
if (!file_put_contents($metaFilename, str_replace(array(",", "{", "}" if (!file_put_contents($metaFilename, str_replace(array(",", "{", "}"), array(",\n ", "{\n ", "\n}\n"), G::json_encode($metadata)))) {
), array(",\n ", "{\n ", "\n}\n"
), G::json_encode($metadata)))) {
throw new Exception("Could not create backup metadata"); throw new Exception("Could not create backup metadata");
} }
CLI::logging("Copying database to backup...\n"); CLI::logging("Copying database to backup...\n");
@@ -2123,8 +2144,7 @@ class WorkspaceTools
$pmVersionWorkspaceToRestore . "", $pmVersionWorkspaceToRestore . "",
$pmVersion . "", $pmVersion . "",
"<" "<"
) || empty($pmVersion)) || $pmVersion == "dev-version-backup" ) || empty($pmVersion)) || $pmVersion == "dev-version-backup") {
) {
// Upgrade the database schema and data // Upgrade the database schema and data
CLI::logging("* Start updating database schema...\n"); CLI::logging("* Start updating database schema...\n");
$start = microtime(true); $start = microtime(true);
@@ -2234,6 +2254,11 @@ class WorkspaceTools
Propel::init(PATH_CONFIG . 'databases.php'); Propel::init(PATH_CONFIG . 'databases.php');
WebEntry::convertFromV1ToV2(); WebEntry::convertFromV1ToV2();
CLI::logging("* End converting Web Entries v1.0 to v2.0 for BPMN processes...(" . (microtime(true) - $start) . " seconds)\n"); CLI::logging("* End converting Web Entries v1.0 to v2.0 for BPMN processes...(" . (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start migrating case title...\n");
$start = microtime(true);
$workspace->migrateCaseTitleToThreads([$workspaceName]);
CLI::logging("* End migrating case title...(Completed on " . (microtime(true) - $start) . " seconds)\n");
} }
CLI::logging("> Start To Verify License Enterprise...\n"); CLI::logging("> Start To Verify License Enterprise...\n");
@@ -3017,7 +3042,8 @@ class WorkspaceTools
* *
* @throws Exception * @throws Exception
*/ */
public function runUpdateListField(array $listTables, $methodName) { public function runUpdateListField(array $listTables, $methodName)
{
// Clean the queries array // Clean the queries array
$listQueries = []; $listQueries = [];
@@ -3049,7 +3075,8 @@ class WorkspaceTools
* *
* @see \WorkspaceTools->migrateList() * @see \WorkspaceTools->migrateList()
*/ */
public function updateListProId($list) { public function updateListProId($list)
{
$query = 'UPDATE ' . $list . ' AS LT $query = 'UPDATE ' . $list . ' AS LT
INNER JOIN ( INNER JOIN (
SELECT PROCESS.PRO_UID, PROCESS.PRO_ID SELECT PROCESS.PRO_UID, PROCESS.PRO_ID
@@ -3070,7 +3097,8 @@ class WorkspaceTools
* *
* @see \WorkspaceTools->migrateList() * @see \WorkspaceTools->migrateList()
*/ */
public function updateListUsrId($list) { public function updateListUsrId($list)
{
$query = 'UPDATE ' . $list . ' AS LT $query = 'UPDATE ' . $list . ' AS LT
INNER JOIN ( INNER JOIN (
SELECT USERS.USR_UID, USERS.USR_ID SELECT USERS.USR_UID, USERS.USR_ID
@@ -3091,7 +3119,8 @@ class WorkspaceTools
* *
* @see \WorkspaceTools->migrateList() * @see \WorkspaceTools->migrateList()
*/ */
public function updateListTasId($list) { public function updateListTasId($list)
{
$query = 'UPDATE ' . $list . ' AS LT $query = 'UPDATE ' . $list . ' AS LT
INNER JOIN ( INNER JOIN (
SELECT TASK.TAS_UID, TASK.TAS_ID SELECT TASK.TAS_UID, TASK.TAS_ID
@@ -3112,7 +3141,8 @@ class WorkspaceTools
* *
* @see \WorkspaceTools->migrateList() * @see \WorkspaceTools->migrateList()
*/ */
public function updateListAppStatusId($list) { public function updateListAppStatusId($list)
{
$query = "UPDATE " . $list . " $query = "UPDATE " . $list . "
SET APP_STATUS_ID = (case SET APP_STATUS_ID = (case
when APP_STATUS = 'DRAFT' then 1 when APP_STATUS = 'DRAFT' then 1
@@ -4414,8 +4444,7 @@ class WorkspaceTools
if (is_dir($path)) { if (is_dir($path)) {
$dir = opendir($path); $dir = opendir($path);
while ($fileName = readdir($dir)) { while ($fileName = readdir($dir)) {
if ($fileName !== "." && $fileName !== ".." && strpos($fileName, "wsClient.php") === false && strpos($fileName, "Post.php") === false if ($fileName !== "." && $fileName !== ".." && strpos($fileName, "wsClient.php") === false && strpos($fileName, "Post.php") === false) {
) {
CLI::logging("Verifying if file: " . $fileName . " is a web entry\n"); CLI::logging("Verifying if file: " . $fileName . " is a web entry\n");
$step = new Criteria("workflow"); $step = new Criteria("workflow");
$step->addSelectColumn(StepPeer::PRO_UID); $step->addSelectColumn(StepPeer::PRO_UID);
@@ -4821,6 +4850,7 @@ class WorkspaceTools
. "ASSIGNEE_TYPE=-1 " . "ASSIGNEE_TYPE=-1 "
. "WHERE ASSIGNEE_ID = 0"); . "WHERE ASSIGNEE_ID = 0");
$con->commit(); $con->commit();
} }
/** /**
@@ -4850,7 +4880,8 @@ class WorkspaceTools
/** /**
* Sync JSON definition of the Forms with Input Documents information * Sync JSON definition of the Forms with Input Documents information
*/ */
public function syncFormsWithInputDocumentInfo() { public function syncFormsWithInputDocumentInfo()
{
// Initialize Propel and instance the required classes // Initialize Propel and instance the required classes
$this->initPropel(true); $this->initPropel(true);
$processInstance = new Process(); $processInstance = new Process();
@@ -4950,8 +4981,8 @@ class WorkspaceTools
$className = '', $className = '',
$pathWorkspace, $pathWorkspace,
int $start = 0, int $start = 0,
int $limit = 10) int $limit = 10
{ ) {
$this->initPropel(); $this->initPropel();
$dbHost = explode(':', $this->dbHost); $dbHost = explode(':', $this->dbHost);
config(['database.connections.workflow.host' => $dbHost[0]]); config(['database.connections.workflow.host' => $dbHost[0]]);
@@ -5127,4 +5158,43 @@ class WorkspaceTools
$conf->aConfig = ['updated' => true]; $conf->aConfig = ['updated' => true];
$conf->saveConfig('ADDED_ASYNC_OPTION_TO_SCHEDULER', 'scheduler'); $conf->saveConfig('ADDED_ASYNC_OPTION_TO_SCHEDULER', 'scheduler');
} }
/**
* Populate the column APP_DELEGATION.DEL_TITLE with the case title APPLICATION.APP_TITLE
* @param array $args
*/
public function migrateCaseTitleToThreads($args)
{
try {
if (!empty($args)) {
// Set workspace constants and initialize DB connection
Bootstrap::setConstantsRelatedWs($args[0]);
Propel::init(PATH_CONFIG . 'databases.php');
$query = Delegation::leftJoin('APPLICATION', function ($leftJoin) {
$leftJoin->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER');
});
$query->where(function ($query) {
$query->whereIn('APPLICATION.APP_STATUS_ID', [2]);
$query->orWhere(function ($query) {
$query->whereIn('APPLICATION.APP_STATUS_ID', [3, 4]);
$query->where('APP_DELEGATION.DEL_LAST_INDEX', '=', 1);
});
});
if (!empty($args[1]) && is_numeric($args[1])) {
$query->where('APP_DELEGATION.APP_NUMBER', '>=', $args[1]);
}
if (!empty($args[2]) && is_numeric($args[2])) {
$query->where('APP_DELEGATION.APP_NUMBER', '<=', $args[2]);
}
$query->update(['APP_DELEGATION.DEL_TITLE' => DB::raw('APPLICATION.APP_TITLE')]);
CLI::logging("The Case Title has been updated successfully in APP_DELEGATION table." . PHP_EOL);
} else {
CLI::logging("The workspace is required." . PHP_EOL . PHP_EOL);
}
} catch (Exception $e) {
// Display the error message
CLI::logging($e->getMessage() . PHP_EOL . PHP_EOL);
}
}
} }

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

@@ -123,6 +123,8 @@ class AppDelegationMapBuilder
$tMap->addColumn('TAS_ID', 'TasId', 'int', CreoleTypes::INTEGER, false, null); $tMap->addColumn('TAS_ID', 'TasId', 'int', CreoleTypes::INTEGER, false, null);
$tMap->addColumn('DEL_TITLE', 'DelTitle', 'string', CreoleTypes::VARCHAR, true, 999);
$tMap->addValidator('DEL_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'NORMAL|PARALLEL', 'Please select a valid status.'); $tMap->addValidator('DEL_TYPE', 'validValues', 'propel.validator.ValidValuesValidator', 'NORMAL|PARALLEL', 'Please select a valid status.');
$tMap->addValidator('DEL_PRIORITY', 'validValues', 'propel.validator.ValidValuesValidator', '1|2|3|4|5', 'Please select a valid Priority.'); $tMap->addValidator('DEL_PRIORITY', 'validValues', 'propel.validator.ValidValuesValidator', '1|2|3|4|5', 'Please select a valid Priority.');

View File

@@ -201,6 +201,12 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
*/ */
protected $tas_id = 0; protected $tas_id = 0;
/**
* The value for the del_title field.
* @var string
*/
protected $del_title;
/** /**
* Flag to prevent endless save loop, if this object is referenced * Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction. * by another object which falls in this transaction.
@@ -639,6 +645,17 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
return $this->tas_id; return $this->tas_id;
} }
/**
* Get the [del_title] column value.
*
* @return string
*/
public function getDelTitle()
{
return $this->del_title;
}
/** /**
* Set the value of [app_uid] column. * Set the value of [app_uid] column.
* *
@@ -1288,6 +1305,28 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
} // setTasId() } // setTasId()
/**
* Set the value of [del_title] column.
*
* @param string $v new value
* @return void
*/
public function setDelTitle($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->del_title !== $v) {
$this->del_title = $v;
$this->modifiedColumns[] = AppDelegationPeer::DEL_TITLE;
}
} // setDelTitle()
/** /**
* Hydrates (populates) the object variables with values from the database resultset. * Hydrates (populates) the object variables with values from the database resultset.
* *
@@ -1363,12 +1402,14 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
$this->tas_id = $rs->getInt($startcol + 28); $this->tas_id = $rs->getInt($startcol + 28);
$this->del_title = $rs->getString($startcol + 29);
$this->resetModified(); $this->resetModified();
$this->setNew(false); $this->setNew(false);
// FIXME - using NUM_COLUMNS may be clearer. // FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 29; // 29 = AppDelegationPeer::NUM_COLUMNS - AppDelegationPeer::NUM_LAZY_LOAD_COLUMNS). return $startcol + 30; // 30 = AppDelegationPeer::NUM_COLUMNS - AppDelegationPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) { } catch (Exception $e) {
throw new PropelException("Error populating AppDelegation object", $e); throw new PropelException("Error populating AppDelegation object", $e);
@@ -1659,6 +1700,9 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
case 28: case 28:
return $this->getTasId(); return $this->getTasId();
break; break;
case 29:
return $this->getDelTitle();
break;
default: default:
return null; return null;
break; break;
@@ -1708,6 +1752,7 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
$keys[26] => $this->getUsrId(), $keys[26] => $this->getUsrId(),
$keys[27] => $this->getProId(), $keys[27] => $this->getProId(),
$keys[28] => $this->getTasId(), $keys[28] => $this->getTasId(),
$keys[29] => $this->getDelTitle(),
); );
return $result; return $result;
} }
@@ -1826,6 +1871,9 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
case 28: case 28:
$this->setTasId($value); $this->setTasId($value);
break; break;
case 29:
$this->setDelTitle($value);
break;
} // switch() } // switch()
} }
@@ -1965,6 +2013,10 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
$this->setTasId($arr[$keys[28]]); $this->setTasId($arr[$keys[28]]);
} }
if (array_key_exists($keys[29], $arr)) {
$this->setDelTitle($arr[$keys[29]]);
}
} }
/** /**
@@ -2092,6 +2144,10 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
$criteria->add(AppDelegationPeer::TAS_ID, $this->tas_id); $criteria->add(AppDelegationPeer::TAS_ID, $this->tas_id);
} }
if ($this->isColumnModified(AppDelegationPeer::DEL_TITLE)) {
$criteria->add(AppDelegationPeer::DEL_TITLE, $this->del_title);
}
return $criteria; return $criteria;
} }
@@ -2212,6 +2268,8 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
$copyObj->setTasId($this->tas_id); $copyObj->setTasId($this->tas_id);
$copyObj->setDelTitle($this->del_title);
$copyObj->setNew(true); $copyObj->setNew(true);

View File

@@ -25,7 +25,7 @@ abstract class BaseAppDelegationPeer
const CLASS_DEFAULT = 'classes.model.AppDelegation'; const CLASS_DEFAULT = 'classes.model.AppDelegation';
/** The total number of columns. */ /** The total number of columns. */
const NUM_COLUMNS = 29; const NUM_COLUMNS = 30;
/** The number of lazy-loaded columns. */ /** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0; const NUM_LAZY_LOAD_COLUMNS = 0;
@@ -118,6 +118,9 @@ abstract class BaseAppDelegationPeer
/** the column name for the TAS_ID field */ /** the column name for the TAS_ID field */
const TAS_ID = 'APP_DELEGATION.TAS_ID'; const TAS_ID = 'APP_DELEGATION.TAS_ID';
/** the column name for the DEL_TITLE field */
const DEL_TITLE = 'APP_DELEGATION.DEL_TITLE';
/** The PHP to DB Name Mapping */ /** The PHP to DB Name Mapping */
private static $phpNameMap = null; private static $phpNameMap = null;
@@ -129,10 +132,10 @@ abstract class BaseAppDelegationPeer
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/ */
private static $fieldNames = array ( private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('AppUid', 'DelIndex', 'DelegationId', 'AppNumber', 'DelPrevious', 'DelLastIndex', 'ProUid', 'TasUid', 'UsrUid', 'DelType', 'DelThread', 'DelThreadStatus', 'DelPriority', 'DelDelegateDate', 'DelInitDate', 'DelFinishDate', 'DelTaskDueDate', 'DelRiskDate', 'DelDuration', 'DelQueueDuration', 'DelDelayDuration', 'DelStarted', 'DelFinished', 'DelDelayed', 'DelData', 'AppOverduePercentage', 'UsrId', 'ProId', 'TasId', ), BasePeer::TYPE_PHPNAME => array ('AppUid', 'DelIndex', 'DelegationId', 'AppNumber', 'DelPrevious', 'DelLastIndex', 'ProUid', 'TasUid', 'UsrUid', 'DelType', 'DelThread', 'DelThreadStatus', 'DelPriority', 'DelDelegateDate', 'DelInitDate', 'DelFinishDate', 'DelTaskDueDate', 'DelRiskDate', 'DelDuration', 'DelQueueDuration', 'DelDelayDuration', 'DelStarted', 'DelFinished', 'DelDelayed', 'DelData', 'AppOverduePercentage', 'UsrId', 'ProId', 'TasId', 'DelTitle', ),
BasePeer::TYPE_COLNAME => array (AppDelegationPeer::APP_UID, AppDelegationPeer::DEL_INDEX, AppDelegationPeer::DELEGATION_ID, AppDelegationPeer::APP_NUMBER, AppDelegationPeer::DEL_PREVIOUS, AppDelegationPeer::DEL_LAST_INDEX, AppDelegationPeer::PRO_UID, AppDelegationPeer::TAS_UID, AppDelegationPeer::USR_UID, AppDelegationPeer::DEL_TYPE, AppDelegationPeer::DEL_THREAD, AppDelegationPeer::DEL_THREAD_STATUS, AppDelegationPeer::DEL_PRIORITY, AppDelegationPeer::DEL_DELEGATE_DATE, AppDelegationPeer::DEL_INIT_DATE, AppDelegationPeer::DEL_FINISH_DATE, AppDelegationPeer::DEL_TASK_DUE_DATE, AppDelegationPeer::DEL_RISK_DATE, AppDelegationPeer::DEL_DURATION, AppDelegationPeer::DEL_QUEUE_DURATION, AppDelegationPeer::DEL_DELAY_DURATION, AppDelegationPeer::DEL_STARTED, AppDelegationPeer::DEL_FINISHED, AppDelegationPeer::DEL_DELAYED, AppDelegationPeer::DEL_DATA, AppDelegationPeer::APP_OVERDUE_PERCENTAGE, AppDelegationPeer::USR_ID, AppDelegationPeer::PRO_ID, AppDelegationPeer::TAS_ID, ), BasePeer::TYPE_COLNAME => array (AppDelegationPeer::APP_UID, AppDelegationPeer::DEL_INDEX, AppDelegationPeer::DELEGATION_ID, AppDelegationPeer::APP_NUMBER, AppDelegationPeer::DEL_PREVIOUS, AppDelegationPeer::DEL_LAST_INDEX, AppDelegationPeer::PRO_UID, AppDelegationPeer::TAS_UID, AppDelegationPeer::USR_UID, AppDelegationPeer::DEL_TYPE, AppDelegationPeer::DEL_THREAD, AppDelegationPeer::DEL_THREAD_STATUS, AppDelegationPeer::DEL_PRIORITY, AppDelegationPeer::DEL_DELEGATE_DATE, AppDelegationPeer::DEL_INIT_DATE, AppDelegationPeer::DEL_FINISH_DATE, AppDelegationPeer::DEL_TASK_DUE_DATE, AppDelegationPeer::DEL_RISK_DATE, AppDelegationPeer::DEL_DURATION, AppDelegationPeer::DEL_QUEUE_DURATION, AppDelegationPeer::DEL_DELAY_DURATION, AppDelegationPeer::DEL_STARTED, AppDelegationPeer::DEL_FINISHED, AppDelegationPeer::DEL_DELAYED, AppDelegationPeer::DEL_DATA, AppDelegationPeer::APP_OVERDUE_PERCENTAGE, AppDelegationPeer::USR_ID, AppDelegationPeer::PRO_ID, AppDelegationPeer::TAS_ID, AppDelegationPeer::DEL_TITLE, ),
BasePeer::TYPE_FIELDNAME => array ('APP_UID', 'DEL_INDEX', 'DELEGATION_ID', 'APP_NUMBER', 'DEL_PREVIOUS', 'DEL_LAST_INDEX', 'PRO_UID', 'TAS_UID', 'USR_UID', 'DEL_TYPE', 'DEL_THREAD', 'DEL_THREAD_STATUS', 'DEL_PRIORITY', 'DEL_DELEGATE_DATE', 'DEL_INIT_DATE', 'DEL_FINISH_DATE', 'DEL_TASK_DUE_DATE', 'DEL_RISK_DATE', 'DEL_DURATION', 'DEL_QUEUE_DURATION', 'DEL_DELAY_DURATION', 'DEL_STARTED', 'DEL_FINISHED', 'DEL_DELAYED', 'DEL_DATA', 'APP_OVERDUE_PERCENTAGE', 'USR_ID', 'PRO_ID', 'TAS_ID', ), BasePeer::TYPE_FIELDNAME => array ('APP_UID', 'DEL_INDEX', 'DELEGATION_ID', 'APP_NUMBER', 'DEL_PREVIOUS', 'DEL_LAST_INDEX', 'PRO_UID', 'TAS_UID', 'USR_UID', 'DEL_TYPE', 'DEL_THREAD', 'DEL_THREAD_STATUS', 'DEL_PRIORITY', 'DEL_DELEGATE_DATE', 'DEL_INIT_DATE', 'DEL_FINISH_DATE', 'DEL_TASK_DUE_DATE', 'DEL_RISK_DATE', 'DEL_DURATION', 'DEL_QUEUE_DURATION', 'DEL_DELAY_DURATION', 'DEL_STARTED', 'DEL_FINISHED', 'DEL_DELAYED', 'DEL_DATA', 'APP_OVERDUE_PERCENTAGE', 'USR_ID', 'PRO_ID', 'TAS_ID', 'DEL_TITLE', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, ) BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, )
); );
/** /**
@@ -142,10 +145,10 @@ abstract class BaseAppDelegationPeer
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/ */
private static $fieldKeys = array ( private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('AppUid' => 0, 'DelIndex' => 1, 'DelegationId' => 2, 'AppNumber' => 3, 'DelPrevious' => 4, 'DelLastIndex' => 5, 'ProUid' => 6, 'TasUid' => 7, 'UsrUid' => 8, 'DelType' => 9, 'DelThread' => 10, 'DelThreadStatus' => 11, 'DelPriority' => 12, 'DelDelegateDate' => 13, 'DelInitDate' => 14, 'DelFinishDate' => 15, 'DelTaskDueDate' => 16, 'DelRiskDate' => 17, 'DelDuration' => 18, 'DelQueueDuration' => 19, 'DelDelayDuration' => 20, 'DelStarted' => 21, 'DelFinished' => 22, 'DelDelayed' => 23, 'DelData' => 24, 'AppOverduePercentage' => 25, 'UsrId' => 26, 'ProId' => 27, 'TasId' => 28, ), BasePeer::TYPE_PHPNAME => array ('AppUid' => 0, 'DelIndex' => 1, 'DelegationId' => 2, 'AppNumber' => 3, 'DelPrevious' => 4, 'DelLastIndex' => 5, 'ProUid' => 6, 'TasUid' => 7, 'UsrUid' => 8, 'DelType' => 9, 'DelThread' => 10, 'DelThreadStatus' => 11, 'DelPriority' => 12, 'DelDelegateDate' => 13, 'DelInitDate' => 14, 'DelFinishDate' => 15, 'DelTaskDueDate' => 16, 'DelRiskDate' => 17, 'DelDuration' => 18, 'DelQueueDuration' => 19, 'DelDelayDuration' => 20, 'DelStarted' => 21, 'DelFinished' => 22, 'DelDelayed' => 23, 'DelData' => 24, 'AppOverduePercentage' => 25, 'UsrId' => 26, 'ProId' => 27, 'TasId' => 28, 'DelTitle' => 29, ),
BasePeer::TYPE_COLNAME => array (AppDelegationPeer::APP_UID => 0, AppDelegationPeer::DEL_INDEX => 1, AppDelegationPeer::DELEGATION_ID => 2, AppDelegationPeer::APP_NUMBER => 3, AppDelegationPeer::DEL_PREVIOUS => 4, AppDelegationPeer::DEL_LAST_INDEX => 5, AppDelegationPeer::PRO_UID => 6, AppDelegationPeer::TAS_UID => 7, AppDelegationPeer::USR_UID => 8, AppDelegationPeer::DEL_TYPE => 9, AppDelegationPeer::DEL_THREAD => 10, AppDelegationPeer::DEL_THREAD_STATUS => 11, AppDelegationPeer::DEL_PRIORITY => 12, AppDelegationPeer::DEL_DELEGATE_DATE => 13, AppDelegationPeer::DEL_INIT_DATE => 14, AppDelegationPeer::DEL_FINISH_DATE => 15, AppDelegationPeer::DEL_TASK_DUE_DATE => 16, AppDelegationPeer::DEL_RISK_DATE => 17, AppDelegationPeer::DEL_DURATION => 18, AppDelegationPeer::DEL_QUEUE_DURATION => 19, AppDelegationPeer::DEL_DELAY_DURATION => 20, AppDelegationPeer::DEL_STARTED => 21, AppDelegationPeer::DEL_FINISHED => 22, AppDelegationPeer::DEL_DELAYED => 23, AppDelegationPeer::DEL_DATA => 24, AppDelegationPeer::APP_OVERDUE_PERCENTAGE => 25, AppDelegationPeer::USR_ID => 26, AppDelegationPeer::PRO_ID => 27, AppDelegationPeer::TAS_ID => 28, ), BasePeer::TYPE_COLNAME => array (AppDelegationPeer::APP_UID => 0, AppDelegationPeer::DEL_INDEX => 1, AppDelegationPeer::DELEGATION_ID => 2, AppDelegationPeer::APP_NUMBER => 3, AppDelegationPeer::DEL_PREVIOUS => 4, AppDelegationPeer::DEL_LAST_INDEX => 5, AppDelegationPeer::PRO_UID => 6, AppDelegationPeer::TAS_UID => 7, AppDelegationPeer::USR_UID => 8, AppDelegationPeer::DEL_TYPE => 9, AppDelegationPeer::DEL_THREAD => 10, AppDelegationPeer::DEL_THREAD_STATUS => 11, AppDelegationPeer::DEL_PRIORITY => 12, AppDelegationPeer::DEL_DELEGATE_DATE => 13, AppDelegationPeer::DEL_INIT_DATE => 14, AppDelegationPeer::DEL_FINISH_DATE => 15, AppDelegationPeer::DEL_TASK_DUE_DATE => 16, AppDelegationPeer::DEL_RISK_DATE => 17, AppDelegationPeer::DEL_DURATION => 18, AppDelegationPeer::DEL_QUEUE_DURATION => 19, AppDelegationPeer::DEL_DELAY_DURATION => 20, AppDelegationPeer::DEL_STARTED => 21, AppDelegationPeer::DEL_FINISHED => 22, AppDelegationPeer::DEL_DELAYED => 23, AppDelegationPeer::DEL_DATA => 24, AppDelegationPeer::APP_OVERDUE_PERCENTAGE => 25, AppDelegationPeer::USR_ID => 26, AppDelegationPeer::PRO_ID => 27, AppDelegationPeer::TAS_ID => 28, AppDelegationPeer::DEL_TITLE => 29, ),
BasePeer::TYPE_FIELDNAME => array ('APP_UID' => 0, 'DEL_INDEX' => 1, 'DELEGATION_ID' => 2, 'APP_NUMBER' => 3, 'DEL_PREVIOUS' => 4, 'DEL_LAST_INDEX' => 5, 'PRO_UID' => 6, 'TAS_UID' => 7, 'USR_UID' => 8, 'DEL_TYPE' => 9, 'DEL_THREAD' => 10, 'DEL_THREAD_STATUS' => 11, 'DEL_PRIORITY' => 12, 'DEL_DELEGATE_DATE' => 13, 'DEL_INIT_DATE' => 14, 'DEL_FINISH_DATE' => 15, 'DEL_TASK_DUE_DATE' => 16, 'DEL_RISK_DATE' => 17, 'DEL_DURATION' => 18, 'DEL_QUEUE_DURATION' => 19, 'DEL_DELAY_DURATION' => 20, 'DEL_STARTED' => 21, 'DEL_FINISHED' => 22, 'DEL_DELAYED' => 23, 'DEL_DATA' => 24, 'APP_OVERDUE_PERCENTAGE' => 25, 'USR_ID' => 26, 'PRO_ID' => 27, 'TAS_ID' => 28, ), BasePeer::TYPE_FIELDNAME => array ('APP_UID' => 0, 'DEL_INDEX' => 1, 'DELEGATION_ID' => 2, 'APP_NUMBER' => 3, 'DEL_PREVIOUS' => 4, 'DEL_LAST_INDEX' => 5, 'PRO_UID' => 6, 'TAS_UID' => 7, 'USR_UID' => 8, 'DEL_TYPE' => 9, 'DEL_THREAD' => 10, 'DEL_THREAD_STATUS' => 11, 'DEL_PRIORITY' => 12, 'DEL_DELEGATE_DATE' => 13, 'DEL_INIT_DATE' => 14, 'DEL_FINISH_DATE' => 15, 'DEL_TASK_DUE_DATE' => 16, 'DEL_RISK_DATE' => 17, 'DEL_DURATION' => 18, 'DEL_QUEUE_DURATION' => 19, 'DEL_DELAY_DURATION' => 20, 'DEL_STARTED' => 21, 'DEL_FINISHED' => 22, 'DEL_DELAYED' => 23, 'DEL_DATA' => 24, 'APP_OVERDUE_PERCENTAGE' => 25, 'USR_ID' => 26, 'PRO_ID' => 27, 'TAS_ID' => 28, 'DEL_TITLE' => 29, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, ) BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, )
); );
/** /**
@@ -304,6 +307,8 @@ abstract class BaseAppDelegationPeer
$criteria->addSelectColumn(AppDelegationPeer::TAS_ID); $criteria->addSelectColumn(AppDelegationPeer::TAS_ID);
$criteria->addSelectColumn(AppDelegationPeer::DEL_TITLE);
} }
const COUNT = 'COUNT(APP_DELEGATION.APP_UID)'; const COUNT = 'COUNT(APP_DELEGATION.APP_UID)';

View File

@@ -170,6 +170,7 @@
<column name="USR_ID" type="INTEGER" required="false" default="0"/> <column name="USR_ID" type="INTEGER" required="false" default="0"/>
<column name="PRO_ID" type="INTEGER" required="false" default="0"/> <column name="PRO_ID" type="INTEGER" required="false" default="0"/>
<column name="TAS_ID" type="INTEGER" required="false" default="0"/> <column name="TAS_ID" type="INTEGER" required="false" default="0"/>
<column name="DEL_TITLE" type="VARCHAR" size="999" required="true"/>
<unique name="DELEGATION_ID"> <unique name="DELEGATION_ID">
<unique-column name="DELEGATION_ID"/> <unique-column name="DELEGATION_ID"/>
</unique> </unique>
@@ -201,6 +202,15 @@
<index-column name="DEL_THREAD_STATUS"/> <index-column name="DEL_THREAD_STATUS"/>
<index-column name="APP_NUMBER"/> <index-column name="APP_NUMBER"/>
</index> </index>
<fulltext name="indexDelTitle">
<index-column name="DEL_TITLE"/>
<vendor type="mysql">
<parameter name="Table" value="APP_DELEGATION"/>
<parameter name="Non_unique" value="1"/>
<parameter name="Key_name" value="indexDelTitle"/>
<parameter name="Seq_in_index" value="1"/>
</vendor>
</fulltext>
</table> </table>
<table name="APP_DOCUMENT"> <table name="APP_DOCUMENT">
<vendor type="mysql"> <vendor type="mysql">

View File

@@ -94,6 +94,7 @@ CREATE TABLE `APP_DELEGATION`
`USR_ID` INTEGER default 0, `USR_ID` INTEGER default 0,
`PRO_ID` INTEGER default 0, `PRO_ID` INTEGER default 0,
`TAS_ID` INTEGER default 0, `TAS_ID` INTEGER default 0,
`DEL_TITLE` VARCHAR(999) NOT NULL,
PRIMARY KEY (`APP_UID`,`DEL_INDEX`), PRIMARY KEY (`APP_UID`,`DEL_INDEX`),
UNIQUE KEY `DELEGATION_ID` (`DELEGATION_ID`), UNIQUE KEY `DELEGATION_ID` (`DELEGATION_ID`),
KEY `INDEX_APP_NUMBER`(`APP_NUMBER`), KEY `INDEX_APP_NUMBER`(`APP_NUMBER`),
@@ -101,7 +102,8 @@ CREATE TABLE `APP_DELEGATION`
KEY `INDEX_PRO_ID`(`PRO_ID`), KEY `INDEX_PRO_ID`(`PRO_ID`),
KEY `INDEX_TAS_ID`(`TAS_ID`), KEY `INDEX_TAS_ID`(`TAS_ID`),
KEY `INDEX_USR_UID`(`USR_UID`), KEY `INDEX_USR_UID`(`USR_UID`),
KEY `INDEX_THREAD_STATUS_APP_NUMBER`(`DEL_THREAD_STATUS`, `APP_NUMBER`) KEY `INDEX_THREAD_STATUS_APP_NUMBER`(`DEL_THREAD_STATUS`, `APP_NUMBER`),
FULLTEXT `indexDelTitle`(`DEL_TITLE`)
)ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='Delegation a task to user'; )ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='Delegation a task to user';
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
#-- APP_DOCUMENT #-- APP_DOCUMENT

View File

@@ -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"]);

View File

@@ -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();

View File

@@ -7,6 +7,7 @@ use G;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use ProcessMaker\Core\System; use ProcessMaker\Core\System;
use ProcessMaker\Model\Task;
class Delegation extends Model class Delegation extends Model
{ {
@@ -1026,7 +1027,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',
@@ -1082,12 +1083,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
@@ -1111,7 +1111,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) {
@@ -1412,7 +1411,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');
}); });
@@ -1433,7 +1432,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%");
} }
@@ -1467,7 +1466,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');
}); });
@@ -1488,7 +1487,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%");
} }
@@ -1671,6 +1670,25 @@ class Delegation extends Model
return ($query->count() > 0); 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 * Return the thread related to the specific task-index
* *
@@ -1720,7 +1738,6 @@ class Delegation extends Model
return $thread; return $thread;
} }
/** /**
* Return the open thread related to the task * Return the open thread related to the task
* *
@@ -1746,4 +1763,49 @@ class Delegation extends Model
return $results; 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; 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 * Get task data
* *
@@ -131,4 +152,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'];
}
} }

View File

@@ -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());

View File

@@ -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());