Merged in feature/PMCORE-2292 (pull request #7556)

PMCORE-2292

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
Paula Quispe
2020-12-08 18:47:44 +00:00
committed by Julio Cesar Laura Avendaño
26 changed files with 1012 additions and 612 deletions

View File

@@ -18,6 +18,7 @@ $factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
return [
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 1,
'DELEGATION_ID' => $faker->unique()->randomNumber,
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_PREVIOUS' => 0,
'PRO_UID' => $process->PRO_UID,
@@ -31,10 +32,12 @@ $factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
'DEL_INIT_DATE' => $faker->dateTime(),
'DEL_TASK_DUE_DATE' => $faker->dateTime(),
'DEL_RISK_DATE' => $faker->dateTime(),
'DEL_LAST_INDEX' => 0,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'TAS_ID' => $task->TAS_ID,
'DEL_DATA' => ''
'DEL_DATA' => '',
'DEL_TITLE' => $faker->word()
];
});
@@ -73,7 +76,8 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'foreign_keys', function
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_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_DURATION' => 1,
'TAS_ASSIGN_TYPE' => 'BALANCED',
'TAS_DEF_TITLE' => $faker->sentence(2),
'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED',
'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE',
'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_DURATION' => 1,
'TAS_ASSIGN_TYPE' => 'BALANCED',
'TAS_DEF_TITLE' => $faker->sentence(2),
'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED',
'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE',
'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE',

View File

@@ -144,6 +144,7 @@ class DerivationTest extends TestCase
];
$appFields = [
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appDelegation->DEL_INDEX,
'DEL_THREAD' => $appDelegation->DEL_THREAD,
'PRO_UID' => $process->PRO_UID,
'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;
$processUid = $application->PRO_UID;
$application = $application->APP_UID;
$appUid = $application->APP_UID;
$postForm = [
'ROU_TYPE' => 'SEQUENTIAL',
'TASKS' => [
@@ -229,9 +229,9 @@ class CasesTraitTest extends TestCase
$userLogged = $user->USR_UID;
$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);
}

View File

@@ -277,8 +277,7 @@ class DelegationTest extends TestCase
->states('foreign_keys')
->create();
$title = $delegations->last()
->application
->APP_TITLE;
->DEL_TITLE;
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
@@ -2372,4 +2371,33 @@ class DelegationTest extends TestCase
$result = Delegation::participation($application->APP_UID, $user->USR_UID);
$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 Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\ElementTaskRelation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
use Tests\TestCase;
@@ -124,4 +126,64 @@ class TaskTest extends TestCase
$result .= ' 01 '. G::LoadTranslation('ID_SECOND_ABBREVIATE');
$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\Core\JobsManager;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Validation\MySQL57;
@@ -10,8 +11,7 @@ CLI::taskDescription(<<<EOT
Print information about the current system and any specified workspaces.
If no workspace is specified, show information about all available workspaces
EOT
);
EOT);
CLI::taskArg('workspace-name', true, true);
CLI::taskRun("run_info");
@@ -27,8 +27,7 @@ CLI::taskDescription(<<<EOT
A backup archive will contain all information about the specified workspace
so that it can be restored later. The archive includes a database dump and
all the workspace files.
EOT
);
EOT);
CLI::taskArg('workspace', false);
CLI::taskArg('backup-file', true);
CLI::taskOpt("filesize", "Split the backup file in multiple files which are compressed. The maximum size of these files is set to MAX-SIZE in megabytes. If MAX-SIZE is not set, then it is 1000 megabytes by default. It may be necessary to use this option if using a 32 bit Linux/UNIX system which limits its maximum file size to 2GB. This option does not work on Windows systems.", "s:", "filesize=");
@@ -44,8 +43,7 @@ CLI::taskDescription(<<<EOT
Specify the WORKSPACE to restore to a different workspace name. Otherwise,
it will restore to the same workspace name as the original backup.
EOT
);
EOT);
CLI::taskArg('backup-file', false);
CLI::taskArg('workspace', true);
CLI::taskOpt("overwrite", "If a workspace already exists, overwrite it.", "o", "overwrite");
@@ -69,8 +67,7 @@ CLI::taskDescription(<<<EOT
to present the correct information in the cases inbox. This command will
create the table and populate it with the right information. This only needs
to be used after upgrading ProcessMaker or if the cases inbox is out of sync.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskOpt("lang", "Specify the language to rebuild the case cache list. If not specified, then 'en' (English) will be used by default.\n Ex: -lfr (French) Ex: --lang=zh-CN (Mainland Chinese)", "l:", "lang=");
CLI::taskRun("run_cacheview_upgrade");
@@ -87,8 +84,7 @@ CLI::taskDescription(<<<EOT
tables to match this new schema. Use this command to fix corrupted database
schemas or after ProcessMaker has been upgraded, so the database schemas will
be changed to match the new ProcessMaker code.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskRun("run_database_upgrade");
@@ -103,8 +99,7 @@ CLI::taskDescription(<<<EOT
This is the same as database-upgrade but it works with schemas provided
by plugins. This is useful if plugins are installed that include
database schemas.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskRun("run_plugins_database_upgrade");
@@ -118,8 +113,7 @@ CLI::taskDescription(<<<EOT
This command will go through each language installed in ProcessMaker and
update the translations for the workspace(s) to match the current version of
ProcessMaker.
EOT
);
EOT);
CLI::taskArg('workspace-name', true, true);
CLI::taskOpt('noxml', 'If this option is enabled, the XML files will not be modified.', 'NoXml', 'no-xml');
CLI::taskOpt('nomafe', 'If this option is enabled, the Front End (BPMN Designer and Bootstrap Forms) translation file will not be modified.', 'NoMafe', 'no-mafe');
@@ -130,8 +124,7 @@ CLI::taskDescription(<<<EOT
Migrating cases folders of the workspaces
Specify the WORKSPACE to migrate from a existing workspace.
EOT
);
EOT);
//CLI::taskArg('workspace', true);
CLI::taskOpt("workspace", "Select the workspace whose case folders will be migrated, if multiple workspaces are present in the server.\n Ex: -wworkflow. Ex: --workspace=workflow", "w:", "workspace=");
CLI::taskRun("runStructureDirectories");
@@ -146,8 +139,7 @@ CLI::taskDescription(<<<EOT
This command will read the system schema and data in an attempt to verify the database
integrity. Use this command to check the database data consistency before any costly
database-upgrade operation is planned to be executed.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskRun("run_database_verify_consistency");
@@ -162,8 +154,7 @@ CLI::taskDescription(<<<EOT
This command will read the Cancelled, Completed, Inbox, My Inbox, participated
unassigned data in an attempt to verify the database integrity. It's recommended
to run this script after the migrate cases job has been executed.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskRun("run_database_verify_migration_consistency");
@@ -174,8 +165,7 @@ CLI::taskDescription(<<<EOT
Specify the workspaces, the processes in this workspace will be updated.
If no workspace is specified, the command will be run in all workspaces.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_itee_to_dummytask");
@@ -188,8 +178,7 @@ CLI::taskDescription(<<<EOT
If no workspace is specified, the command will be run in all workspaces.
More than one workspace can be specified.
EOT
);
EOT);
CLI::taskArg("workspace-name", true, true);
CLI::taskRun("run_check_workspace_disabled_code");
@@ -201,8 +190,7 @@ CLI::taskDescription(<<<EOT
If no workspace is specified, then the tables schema will be upgraded or
migrate on all available workspaces.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_new_cases_lists");
@@ -214,8 +202,7 @@ CLI::taskDescription(<<<EOT
If no workspace is specified, then the tables schema will be upgraded or
migrate on all available workspaces.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_list_unassigned");
/*----------------------------------********---------------------------------*/
@@ -227,8 +214,7 @@ CLI::taskDescription(<<<EOT
Specify the workspace, the self-service cases in this workspace will be updated.
If no workspace is specified, the command will be running in all workspaces.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_indexing_acv");
@@ -240,8 +226,7 @@ CLI::taskDescription(<<<EOT
If no workspace is specified, then the tables schema will be upgraded or
migrate on all available workspaces.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskOpt("lang", "Specify the language to migrate the content data. If not specified, then 'en' (English) will be used by default.\n Ex: -lfr (French) Ex: --lang=zh-CN (Mainland Chinese)", "l:", "lang=");
CLI::taskRun("run_migrate_content");
@@ -254,8 +239,7 @@ CLI::taskDescription(<<<EOT
If no workspace is specified, then the tables schema will be upgraded or
migrated to all available workspaces.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_plugin");
@@ -266,8 +250,7 @@ CLI::taskDescription(<<<EOT
Specify the workspaces, the self-service cases in this workspace will be updated.
If no workspace is specified, the command will be run in all workspaces.
EOT
);
EOT);
CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_self_service_value");
@@ -279,8 +262,7 @@ CLI::taskRun("run_migrate_self_service_value");
CLI::taskName('list-ids');
CLI::taskDescription(<<<EOT
Complete the PRO_ID and USR_ID in the LIST_* tables.
EOT
);
EOT);
CLI::taskOpt("lang", "", "lLANG", "lang=LANG");
CLI::taskArg('workspace');
CLI::taskRun("cliListIds");
@@ -291,8 +273,7 @@ CLI::taskRun("cliListIds");
CLI::taskName('upgrade-content');
CLI::taskDescription(<<<EOT
Upgrade the content table
EOT
);
EOT);
CLI::taskArg('workspace');
CLI::taskRun("run_upgrade_content");
@@ -307,8 +288,7 @@ CLI::taskDescription(<<<EOT
incorrectly, which is caused by importing processes where the data directory
of ProcessMaker has different routes. Modified files are backed up with the
extension '.backup' in the same directory.
EOT
);
EOT);
CLI::taskArg('workspace');
CLI::taskRun("regenerate_pmtable_classes");
@@ -319,8 +299,7 @@ CLI::taskRun("regenerate_pmtable_classes");
CLI::taskName('migrate-history-data');
CLI::taskDescription(<<<EOT
Migrate the content of the APP_HISTORY table to the APP_DATA_CHANGE_LOG table.
EOT
);
EOT);
CLI::taskArg('workspace');
CLI::taskRun('migrate_history_data');
/*----------------------------------********---------------------------------*/
@@ -331,8 +310,7 @@ CLI::taskRun('migrate_history_data');
CLI::taskName('clear-dyn-content-history-data');
CLI::taskDescription(<<<EOT
Clear History of Use data from APP_HISTORY table
EOT
);
EOT);
CLI::taskArg('workspace');
CLI::taskRun("run_clear_dyn_content_history_data");
@@ -342,8 +320,7 @@ CLI::taskRun("run_clear_dyn_content_history_data");
CLI::taskName('sync-forms-with-info-from-input-documents');
CLI::taskDescription(<<<EOT
Sync JSON definition of the Forms with Input Documents information
EOT
);
EOT);
CLI::taskArg('workspace');
CLI::taskRun("run_sync_forms_with_info_from_input_documents");
@@ -353,8 +330,7 @@ CLI::taskRun("run_sync_forms_with_info_from_input_documents");
CLI::taskName('remove-unused-files');
CLI::taskDescription(<<<EOT
Remove the deprecated files.
EOT
);
EOT);
CLI::taskRun("remove_deprecated_files");
/*********************************************************************/
@@ -366,8 +342,7 @@ CLI::taskDescription(<<<EOT
If no workspace is specified, the command will be run in all workspaces.
More than one workspace can be specified.
EOT
);
EOT);
CLI::taskArg("workspace-name", true, true);
CLI::taskRun("run_check_queries_incompatibilities");
/*********************************************************************/
@@ -383,8 +358,7 @@ Example:
To see other command options please refer to the artisan help.
php artisan --help
EOT
);
EOT);
CLI::taskRun("run_artisan");
/**
@@ -393,16 +367,23 @@ CLI::taskRun("run_artisan");
CLI::taskName('documents-add-font');
CLI::taskDescription(<<<EOT
Add a font to be used in Documents generation (TinyMCE editor and/or TCPDF library).
EOT
);
CLI::taskOpt('type', <<<EOT
EOT);
CLI::taskOpt(
'type',
<<<EOT
Can be "TrueType" or "TrueTypeUnicode", if the option is not specified the default value is "TrueType"
EOT
,'t', 'type=');
CLI::taskOpt('tinymce', <<<EOT
EOT,
't',
'type='
);
CLI::taskOpt(
'tinymce',
<<<EOT
Can be "true" or "false", if the option is not specified the default value is "true". If the value is "false" the optional arguments [FRIENDLYNAME] [FONTPROPERTIES] are omitted.
EOT
,'tm', 'tinymce=');
EOT,
'tm',
'tinymce='
);
CLI::taskArg('fontFileName', false);
CLI::taskArg('friendlyName', true);
CLI::taskArg('fontProperties', true);
@@ -414,8 +395,7 @@ CLI::taskRun('documents_add_font');
CLI::taskName('documents-list-registered-fonts');
CLI::taskDescription(<<<EOT
List the registered fonts.
EOT
);
EOT);
CLI::taskRun('documents_list_registered_fonts');
/**
@@ -424,8 +404,7 @@ CLI::taskRun('documents_list_registered_fonts');
CLI::taskName('documents-remove-font');
CLI::taskDescription(<<<EOT
Remove a font used in Documents generation (TinyMCE editor and/or TCPDF library).
EOT
);
EOT);
CLI::taskArg('fontFileName', false);
CLI::taskRun('documents_remove_font');
@@ -450,6 +429,18 @@ EOT
);
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
*
@@ -1312,7 +1303,7 @@ function migrate_history_data($args, $opts)
* @param array $opts
*
* @return void
*/
*/
function run_clear_dyn_content_history_data($args, $opts)
{
$workspaces = get_workspaces_from_args($args);
@@ -1335,7 +1326,8 @@ function run_clear_dyn_content_history_data($args, $opts)
* @return void
* @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) {
//This variable is not defined and does not involve its value in this
//task, it is removed at the end of the method.
@@ -1689,3 +1681,15 @@ function convert_old_web_entries($args)
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\Core\System;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Plugins\PluginRegistry;
use ProcessMaker\Util\DateTime;
@@ -25,6 +26,7 @@ class Cases
public $dir = 'ASC';
public $sort = 'APP_MSG_DATE';
public $arrayTriggerExecutionTime = [];
public $caseTitle = '';
private $triggerMessageExecution = '';
public function __construct()
@@ -34,6 +36,27 @@ class Cases
$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
@@ -609,168 +632,36 @@ class Cases
}
/**
* This function loads the label case
* 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
* Update the thread title
*
* @param string $appUid
* @param array $fields
* @param array $lastFieldsCase
* @param int $appNumber
* @param int $delIndex
* @param array $caseData
*
* @return array
* @return void
*
* @see classes/Cases->startCase()
* @see classes/Cases->updateCase()
* @see Cases::updateCase()
*/
public function newRefreshCaseTitleAndDescription($appUid, $fields, $lastFieldsCase = [])
public function updateThreadTitle(string $appUid, int $appNumber, int $delIndex, $caseData = [])
{
$res = [];
$flagTitle = false;
$flagDescription = false;
$cri = new Criteria;
$cri->clearSelectColumns();
$cri->addSelectColumn(AppDelegationPeer::TAS_UID);
$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
$tasDefDescription = trim($row['TAS_DEF_DESCRIPTION']);
if (!empty($tasDefDescription) && !$flagDescription) {
$newAppProperty = G::replaceDataField($tasDefDescription, $lastFieldsCase, 'mysql', false);
$res['APP_DESCRIPTION'] = $newAppProperty;
if (!(isset($currentValue) && ($currentValue == $tasDefDescription))) {
$newValues['APP_DESCRIPTION'] = $newAppProperty;
$flagDescription = true;
}
}
if (!empty($newValues)) {
$application = new Application();
$newValues['APP_UID'] = $appUid;
$application->update($newValues);
}
$threadTitle = $this->getCaseTitle();
if (empty($threadTitle) && !empty($appNumber) && !empty($delIndex)) {
$thread = Delegation::getThreadInfo($appNumber, $delIndex);
$previous = $thread['DEL_PREVIOUS'];
$appNumber = $thread['APP_NUMBER'];
$tasUid = $thread['TAS_UID'];
if (!empty($tasUid)) {
$threadTitle = Delegation::getThreadTitle($tasUid, $appNumber, $previous, $caseData);
}
$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");
// Update thread title
$rows = [];
$rows['APP_UID'] = $appUid;
$rows['DEL_INDEX'] = $delIndex;
$rows['DEL_TITLE'] = $threadTitle;
$delegation = new AppDelegation();
$delegation->update($rows);
}
/**
@@ -906,12 +797,10 @@ class Cases
$appFields['DEL_INDEX'] = $Fields['DEL_INDEX'];
}
//Get the appTitle and appDescription
$newTitleOrDescription = $this->newRefreshCaseTitleAndDescription(
$appUid,
$appFields,
$appData
);
// Update case title
if (!empty($appUid) && !empty($appFields['APP_NUMBER']) && !empty($appFields['DEL_INDEX'])) {
$this->updateThreadTitle($appUid, $appFields['APP_NUMBER'], $appFields['DEL_INDEX'], $appFields['APP_DATA']);
}
//Start: Save History --By JHL
if (isset($Fields['CURRENT_DYNAFORM'])) {
@@ -1027,7 +916,7 @@ class Cases
$inbox = new ListInbox();
unset($Fields['DEL_INIT_DATE']);
unset($Fields['DEL_DELEGATE_DATE']);
$inbox->update(array_merge($Fields, $newTitleOrDescription));
$inbox->update($Fields);
/*----------------------------------********---------------------------------*/
//Return
@@ -1708,14 +1597,13 @@ class Cases
* This function creates a new row into APP_DELEGATION
*
* @name newAppDelegation
* @param string $sProUid,
* @param string $sAppUid,
* @param string $sTasUid,
* @param string $sUsrUid
* @param string $sPrevious
* @param string $iPriority
* @param string $sDelType
* @param string $iAppThreadIndex
* @param string $proUid
* @param string $appUid
* @param string $tasUid
* @param string $usrUid
* @param string $previous
* @param string $priority
* @param int $threadIndex
* @param string $nextDel
* @param boolean $flagControl
* @param boolean $flagControlMulInstance
@@ -1723,22 +1611,55 @@ class Cases
* @param int $appNumber
* @param int $proId
* @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 {
$user = UsersPeer::retrieveByPK($sUsrUid);
$appDel = new AppDelegation();
$result = $appDel->createAppDelegation(
$sProUid,
$sAppUid,
$sTasUid,
$sUsrUid,
$iAppThreadIndex,
$iPriority,
// Get case title
$threadTitle = $this->getCaseTitle();
if (empty($threadTitle)) {
$threadTitle = Delegation::getThreadTitle($tasUid, $appNumber, $previous, $caseData);
}
$user = UsersPeer::retrieveByPK($usrUid);
// Create new delegation
$delegation = new AppDelegation();
$delegation->setDelTitle($threadTitle);
$result = $delegation->createAppDelegation(
$proUid,
$appUid,
$tasUid,
$usrUid,
$threadIndex,
$priority,
false,
$sPrevious,
$previous,
$nextDel,
$flagControl,
$flagControlMulInstance,
@@ -1748,12 +1669,12 @@ class Cases
(empty($user)) ? 0 : $user->getUsrId(),
$proId
);
//update searchindex
// Update search index
if ($this->appSolr != null) {
$this->appSolr->updateApplicationSearchIndex($sAppUid);
$this->appSolr->updateApplicationSearchIndex($appUid);
}
return $result;
} catch (exception $e) {
} catch (Exception $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
*
* @param string $taskUid
* @param string $userUid
* @param bool $isSubProcess
* @param array $dataPreviousApplication
* @name startCase
* @param string $tasUid
* @param string $usrUid
* @param bool $isSubprocess
* @param array $previousInfo
* @param bool $isSelfService
* @param string $sequenceType
* @return array
* @throws Exception
* @param string $sequenceType
*
* @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 {
$task = TaskPeer::retrieveByPK($taskUid);
$user = UsersPeer::retrieveByPK($userUid);
$task = TaskPeer::retrieveByPK($tasUid);
$user = UsersPeer::retrieveByPK($usrUid);
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
$arrayTaskTypeToExclude = ["START-TIMER-EVENT"];
if (!is_null($task) && !in_array($task->getTasType(), $arrayTaskTypeToExclude) && $task->getTasAssignType() != "SELF_SERVICE" && $userUid == "") {
$tasksTypeToExclude = ["START-TIMER-EVENT"];
if (!is_null($task) && !in_array($task->getTasType(), $tasksTypeToExclude) && $task->getTasAssignType() != "SELF_SERVICE" && $usrUid == "") {
throw (new Exception('You tried to start a new case without send the USER UID!'));
}
// Process
$processUid = $task->getProUid();
// Load Process
$proUid = $task->getProUid();
$this->Process = new Process;
$proFields = $this->Process->Load($processUid);
$proFields = $this->Process->Load($proUid);
// Application
// Create application
$application = new Application;
$appUid = $application->create($processUid, $userUid, $sequenceType);
$appUid = $application->create($proUid, $usrUid, $sequenceType);
$fields = $application->toArray(BasePeer::TYPE_FIELDNAME);
// AppDelegation
$appDelegation = new AppDelegation;
$appThreadIndex = 1; // Start Thread
$appDelPriority = 3; // Priority
$delIndex = $appDelegation->createAppDelegation(
$processUid,
// Create appDelegation
$delIndex = $this->newAppDelegation(
$proUid,
$appUid,
$taskUid,
$userUid,
$appThreadIndex,
$appDelPriority,
$isSubProcess,
-1,
null,
false,
false,
0,
$tasUid,
$usrUid,
-1, // previous
3, // Priority
1, // Start Thread
null, // Next delegation
false, // Flag control
false, // Flag control multi-instance
0, // Thread previous
$application->getAppNumber(),
$this->Process->getProId(),
$task->getTasId(),
(empty($user)) ? 0 : $user->getUsrId(),
$this->Process->getProId()
$fields['APP_DATA']
);
// AppThread
$appThread = new AppThread;
$appThreadIndex = $appThread->createAppThread($appUid, $delIndex, 0);
$derivation = new Derivation();
// Instance appThread
$thread = new AppThread;
$threadIndex = $thread->createAppThread($appUid, $delIndex, 0);
// Instance Derivation
$routing = new Derivation();
// Multiple Instance
$usersFields = [];
$userFields = [];
$taskAssignType = $task->getTasAssignType();
$nextTaskAssignVariable = $task->getTasAssignVariable();
if ($taskAssignType == "MULTIPLE_INSTANCE" || $taskAssignType == "MULTIPLE_INSTANCE_VALUE_BASED") {
switch ($taskAssignType) {
case 'MULTIPLE_INSTANCE':
$userFields = $derivation->getUsersFullNameFromArray($derivation->getAllUsersFromAnyTask($taskUid));
$userFields = $routing->getUsersFullNameFromArray($routing->getAllUsersFromAnyTask($tasUid));
break;
default:
throw (new Exception('Invalid Task Assignment method'));
break;
}
$userFields = $derivation->getUsersFullNameFromArray($derivation->getAllUsersFromAnyTask($taskUid));
$userFields = $routing->getUsersFullNameFromArray($routing->getAllUsersFromAnyTask($tasUid));
$count = 0;
foreach ($userFields as $rowUser) {
if ($rowUser["USR_UID"] != $userUid) {
// AppDelegation
$appDelegation = new AppDelegation;
$appThreadIndex ++; // Start Thread
$appDelPriority = 3; // Priority
if ($rowUser["USR_UID"] != $usrUid) {
// Create appDelegation
$delegation = new AppDelegation;
$threadIndex ++; // Start Thread
$priority = 3; // Priority
$user = UsersPeer::retrieveByPK($rowUser["USR_UID"]);
$delIndex1 = $appDelegation->createAppDelegation(
$processUid,
// Create a new delegation
$delIndex1 = $this->newAppDelegation(
$proUid,
$appUid,
$taskUid,
$tasUid,
$rowUser["USR_UID"],
$appThreadIndex,
$appDelPriority,
$isSubProcess,
-1,
null,
false,
false,
0,
-1, // previous
$priority, // Priority
$threadIndex, // Start Thread
null, // Next delegation
false, // Flag control
false, // Flag control multi-instance
0, // Thread previous
$application->getAppNumber(),
$this->Process->getProId(),
$task->getTasId(),
(empty($user)) ? 0 : $user->getUsrId(),
$this->Process->getProId()
$fields['APP_DATA']
);
// AppThread
$appThread = new AppThread;
$appThreadIndex = $appThread->createAppThread($appUid, $delIndex1, 0);
// Create appThread
$thread = new AppThread;
$threadIndex = $thread->createAppThread($appUid, $delIndex1, 0);
// Save Information
$usersFields[$count] = $rowUser;
$usersFields[$count]["DEL_INDEX"] = $delIndex1;
$userFields[$count] = $rowUser;
$userFields[$count]["DEL_INDEX"] = $delIndex1;
$count++;
}
}
}
// Update the application
$fields = $application->toArray(BasePeer::TYPE_FIELDNAME);
$applicationFields = $fields['APP_DATA'];
$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);
// Get current case number
$caseNumber = $fields['APP_NUMBER'];
// Update the task last assigned (for web entry and web services)
$derivation->setTasLastAssigned($taskUid, $userUid);
$routing->setTasLastAssigned($tasUid, $usrUid);
// Execute Events
$event = new Event();
$event->createAppEvents($processUid, $appUid, $delIndex, $taskUid);
$event->createAppEvents($proUid, $appUid, $delIndex, $tasUid);
// Update search index
// Update solr
if ($this->appSolr != null) {
$this->appSolr->updateApplicationSearchIndex($appUid);
}
/*----------------------------------********---------------------------------*/
$fields['TAS_UID'] = $taskUid;
$fields['USR_UID'] = $userUid;
$fields['TAS_UID'] = $tasUid;
$fields['USR_UID'] = $usrUid;
$fields['DEL_INDEX'] = $delIndex;
$fields['APP_STATUS'] = 'TO_DO';
$fields['DEL_DELEGATE_DATE'] = $fields['APP_INIT_DATE'];
if (!$isSubProcess) {
if (!$isSubprocess) {
$fields['APP_STATUS'] = 'DRAFT';
} else {
$fields['APP_INIT_DATE'] = null;
}
$inbox = new ListInbox();
$inbox->newRow($fields, $userUid, $isSelfService);
$inbox->newRow($fields, $usrUid, $isSelfService);
// Multiple Instance
foreach ($usersFields as $rowUser) {
foreach ($userFields as $rowUser) {
$fields["USR_UID"] = $rowUser["USR_UID"];
$fields["DEL_INDEX"] = $rowUser["DEL_INDEX"];
$inbox = new ListInbox();
$inbox->newRow($fields, $userUid, $isSelfService);
$inbox->newRow($fields, $usrUid, $isSelfService);
}
/*----------------------------------********---------------------------------*/
} catch (Exception $e) {
throw ($e);
}
} 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
$message = 'Create case';
$context = $data = [
"appUid" => $appUid,
"usrUid" => $userUid,
"tasUid" => $taskUid,
"isSubProcess" => $isSubProcess,
"usrUid" => $usrUid,
"tasUid" => $tasUid,
"isSubprocess" => $isSubprocess,
"appNumber" => $caseNumber,
"delIndex" => $delIndex,
"appInitDate" => $fields['APP_INIT_DATE']
@@ -2291,16 +2202,16 @@ class Cases
Log::channel(':CreateCase')->info($message, Bootstrap::context($context));
// Call plugin
if (class_exists('folderData')) {
$folderData = new folderData($processUid, $proFields['PRO_TITLE'], $appUid, $newValues['APP_TITLE'], $userUid);
$pluginRegistry = PluginRegistry::loadSingleton();
$pluginRegistry->executeTriggers(PM_CREATE_CASE, $folderData);
$folderData = new folderData($proUid, $proFields['PRO_TITLE'], $appUid, '', $usrUid);
$oPluginRegistry = PluginRegistry::loadSingleton();
$oPluginRegistry->executeTriggers(PM_CREATE_CASE, $folderData);
}
$this->getExecuteTriggerProcess($appUid, 'CREATE');
// End plugin
//end plugin
return [
'APPLICATION' => $appUid,
'INDEX' => $delIndex,
'PROCESS' => $processUid,
'PROCESS' => $proUid,
'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)) {
G::SendTemporalMessage(
@@ -4246,14 +4146,16 @@ class Cases
$this->getExecuteTriggerProcess($sApplicationUID, 'PAUSED');
/*----------------------------------********---------------------------------*/
$threadTitle = Delegation::getDeltitle($aData['APP_NUMBER'], $aData['APP_DEL_INDEX']);
$data = array(
'APP_UID' => $sApplicationUID,
'DEL_INDEX' => $iDelegation,
'USR_UID' => $sUserUID,
'APP_RESTART_DATE' => $sUnpauseDate,
'APP_TITLE' => ($appTitle != null) ? $appTitle : $aFields['APP_TITLE']
'APP_TITLE' => $threadTitle,
);
$data = array_merge($aFields, $data);
$oListPaused = new ListPaused();
$oListPaused->create($data);
/*----------------------------------********---------------------------------*/
@@ -4263,112 +4165,113 @@ class Cases
* unpause a case
*
* @name unpauseCase
* @param string $sApplicationUID
* @param string $iDelegation
* @param string $sUserUID
* @param string $appUid
* @param int $index
* @param string $usrUid
* @return object
*/
public function unpauseCase($sApplicationUID, $iDelegation, $sUserUID)
public function unpauseCase($appUid, $index, $usrUid)
{
//Verify status of the case
$oDelay = new AppDelay();
if (method_exists($oDelay, 'isPaused')) {
if ($oDelay->isPaused($sApplicationUID, $iDelegation) === false) {
// Verify status of the case
$delay = new AppDelay();
if (method_exists($delay, 'isPaused')) {
if ($delay->isPaused($appUid, $index) === false) {
return false;
}
}
//get information about current $iDelegation row
$oAppDelegation = new AppDelegation();
$user = UsersPeer::retrieveByPK($sUserUID);
$aFieldsDel = $oAppDelegation->Load($sApplicationUID, $iDelegation);
// Get information about current $index row
$delegation = new AppDelegation();
$delRow = $delegation->Load($appUid, $index);
//and creates a new AppDelegation row with the same user, task, process, etc.
$proUid = $aFieldsDel['PRO_UID'];
$appUid = $aFieldsDel['APP_UID'];
$tasUid = $aFieldsDel['TAS_UID'];
$usrUid = $aFieldsDel['USR_UID'];
$delThread = $aFieldsDel['DEL_THREAD'];
$iIndex = $oAppDelegation->createAppDelegation(
$proUid = $delRow['PRO_UID'];
$appUid = $delRow['APP_UID'];
$tasUid = $delRow['TAS_UID'];
$usrUid = $delRow['USR_UID'];
// Load Application
$application = new Application();
$caseFields = $application->Load($appUid);
$caseData = unserialize($caseFields['APP_DATA']);
// Create a new delegation
$newIndex = $this->newAppDelegation(
$proUid,
$appUid,
$tasUid,
$usrUid,
$delThread,
3,
false,
-1,
null,
false,
false,
0,
$aFieldsDel['APP_NUMBER'],
$aFieldsDel['TAS_ID'],
(empty($user)) ? 0 : $user->getUsrId(),
$aFieldsDel['PRO_ID']
-1, // previous
3, // Priority
1, // Start Thread
null, // Next delegation
false, // Flag control
false, // Flag control multi-instance
0, // Thread previous
$delRow['APP_NUMBER'],
$delRow['PRO_ID'],
$delRow['TAS_ID'],
$caseData
);
//update other fields in the recent new appDelegation
$aData = array();
$aData['APP_UID'] = $aFieldsDel['APP_UID'];
$aData['DEL_INDEX'] = $iIndex;
$aData['DEL_PREVIOUS'] = $aFieldsDel['DEL_PREVIOUS'];
$aData['DEL_TYPE'] = $aFieldsDel['DEL_TYPE'];
$aData['DEL_PRIORITY'] = $aFieldsDel['DEL_PRIORITY'];
$aData['DEL_DELEGATE_DATE'] = $aFieldsDel['DEL_DELEGATE_DATE'];
$aData['DEL_INIT_DATE'] = date('Y-m-d H:i:s');
$aData['DEL_FINISH_DATE'] = null;
$oAppDelegation->update($aData);
// Update other fields in the recent new appDelegation
$row = [];
$row['APP_UID'] = $delRow['APP_UID'];
$row['DEL_INDEX'] = $newIndex;
$row['DEL_PREVIOUS'] = $delRow['DEL_PREVIOUS'];
$row['DEL_TYPE'] = $delRow['DEL_TYPE'];
$row['DEL_PRIORITY'] = $delRow['DEL_PRIORITY'];
$row['DEL_DELEGATE_DATE'] = $delRow['DEL_DELEGATE_DATE'];
$row['DEL_INIT_DATE'] = date('Y-m-d H:i:s');
$row['DEL_FINISH_DATE'] = null;
$delegation->update($row);
//get the APP_DELAY row ( with app_uid, del_index and app_type=pause
$oCriteria = new Criteria('workflow');
$oCriteria->clearSelectColumns();
$oCriteria->addSelectColumn(AppDelayPeer::APP_DELAY_UID);
$oCriteria->addSelectColumn(AppDelayPeer::APP_THREAD_INDEX);
$oCriteria->addSelectColumn(AppDelayPeer::APP_STATUS);
$oCriteria->add(AppDelayPeer::APP_UID, $sApplicationUID);
$oCriteria->add(AppDelayPeer::APP_DEL_INDEX, $iDelegation);
$oCriteria->add(AppDelayPeer::APP_TYPE, 'PAUSE');
$oCriteria->add(
$oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL)->addOr(
$oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL))
// Get the APP_DELAY row with app_uid, del_index and app_type=pause
$criteria = new Criteria('workflow');
$criteria->clearSelectColumns();
$criteria->addSelectColumn(AppDelayPeer::APP_DELAY_UID);
$criteria->addSelectColumn(AppDelayPeer::APP_THREAD_INDEX);
$criteria->addSelectColumn(AppDelayPeer::APP_STATUS);
$criteria->add(AppDelayPeer::APP_UID, $appUid);
$criteria->add(AppDelayPeer::APP_DEL_INDEX, $index);
$criteria->add(AppDelayPeer::APP_TYPE, 'PAUSE');
$criteria->add(
$criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL)->addOr(
$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();
$aFields = $oApplication->Load($sApplicationUID);
$aFields['APP_STATUS'] = $aRow['APP_STATUS'];
$oApplication->update($aFields);
$caseFields['APP_STATUS'] = $rowPaused['APP_STATUS'];
$application->update($caseFields);
//update the DEL_INDEX ? in APP_THREAD table?
$aUpdate = array(
'APP_UID' => $sApplicationUID,
'APP_THREAD_INDEX' => $aRow['APP_THREAD_INDEX'],
'DEL_INDEX' => $iIndex
);
$oAppThread = new AppThread();
$oAppThread->update($aUpdate);
// Update the DEL_INDEX ? in APP_THREAD table?
$rowUpdate = [
'APP_UID' => $appUid,
'APP_THREAD_INDEX' => $rowPaused['APP_THREAD_INDEX'],
'DEL_INDEX' => $newIndex
];
$thread = new AppThread();
$thread->update($rowUpdate);
$aData['APP_DELAY_UID'] = $aRow['APP_DELAY_UID'];
$aData['APP_DISABLE_ACTION_USER'] = $sUserUID;
$aData['APP_DISABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
$oAppDelay = new AppDelay();
$aFieldsDelay = $oAppDelay->update($aData);
$row['APP_DELAY_UID'] = $rowPaused['APP_DELAY_UID'];
$row['APP_DISABLE_ACTION_USER'] = $usrUid;
$row['APP_DISABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
$delay = new AppDelay();
$rowDelay = $delay->update($row);
//update searchindex
// Update searchindex
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);
$oListPaused = new ListPaused();
$oListPaused->remove($sApplicationUID, $iDelegation, $aData);
$row = array_merge($delRow, $row);
$listPaused = new ListPaused();
$listPaused->remove($appUid, $index, $row);
/*----------------------------------********---------------------------------*/
}
@@ -4510,28 +4413,26 @@ class Cases
//Get all the threads in the AppDelay
foreach ($threadsCanceled as $row){
//Load the thread CLOSED
// Load the thread CLOSED
$appDelegation = new AppDelegation();
$delegationClosed = $appDelegation->Load($appUid, $row['APP_DEL_INDEX']);
//Create an appDelegation for each thread
$appDelegation = new AppDelegation();
$delIndex = $appDelegation->createAppDelegation(
// Create an appDelegation for each thread
$delIndex = $this->newAppDelegation(
$delegationClosed['PRO_UID'],
$delegationClosed['APP_UID'],
$delegationClosed['TAS_UID'],
$usrUid,
$delegationClosed['DEL_THREAD'],
3,
false,
$delegationClosed['DEL_PREVIOUS'],
null,
false,
false,
0,
$delegationClosed['DEL_PREVIOUS'], // previous
3, // Priority
$delegationClosed['DEL_THREAD'], // Start Thread
null, // Next delegation
false, // Flag control
false, // Flag control multi-instance
0, // Thread previous
$delegationClosed['APP_NUMBER'],
$delegationClosed['PRO_ID'],
$delegationClosed['TAS_ID'],
$userId,
$delegationClosed['PRO_ID']
$caseFields['APP_DATA']
);
//Update the appThread
@@ -4663,23 +4564,29 @@ class Cases
$user = UsersPeer::retrieveByPK($newUserUid);
$appDelegation = new AppDelegation();
$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['APP_UID'],
$fieldsDel['TAS_UID'],
$newUserUid,
$fieldsDel['DEL_THREAD'],
3,
false,
-1,
null,
false,
false,
0,
-1, // previous
3, // Priority
$fieldsDel['DEL_THREAD'], // Start Thread
null, // Next delegation
false, // Flag control
false, // Flag control multi-instance
0, // Thread previous
$fieldsDel['APP_NUMBER'],
$fieldsDel['PRO_ID'],
$fieldsDel['TAS_ID'],
(empty($user)) ? 0 : $user->getUsrId(),
$fieldsDel['PRO_ID']
$caseData
);
$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['APP_UID'] = $appUid;
$newData['APP_THREAD_INDEX'] = $fieldsDel['DEL_THREAD'];

View File

@@ -1070,7 +1070,7 @@ class Derivation
break;
default:
$iNewDelIndex = $this->doDerivation($currentDelegation, $nextDel, $appFields, $aSP);
//Load Case Data again because the information could be change in method "doDerivation"
// Load Case Data again because the information could be change in method "doDerivation"
$verifyApplication = $this->case->loadCase($currentDelegation['APP_UID']);
$appFields['APP_DATA'] = $verifyApplication['APP_DATA'];
//When the users route the case in the same time
@@ -1286,7 +1286,6 @@ class Derivation
$newDelegationUser,
$currentDelegation['DEL_INDEX'],
$nextDel['DEL_PRIORITY'],
$delType,
$iAppThreadIndex,
$nextDel,
$this->flagControl,
@@ -2365,7 +2364,6 @@ class Derivation
(isset( $aValue['USR_UID'] ) ? $aValue['USR_UID'] : ''),
$currentDelegation['DEL_INDEX'],
$nextDel['DEL_PRIORITY'],
$delType,
$iNewAppThreadIndex,
$nextDel,
$appFields['APP_NUMBER'],

View File

@@ -12,6 +12,7 @@ use ProcessMaker\Core\Installer;
use ProcessMaker\Core\ProcessesManager;
use ProcessMaker\Core\System;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Fields;
use ProcessMaker\Plugins\Adapters\PluginAdapter;
use ProcessMaker\Project\Adapter\BpmnWorkflow;
@@ -365,7 +366,7 @@ class WorkspaceTools
$start = microtime(true);
$this->updateTriggers(true, $lang);
CLI::logging("* End updating MySQL triggers...(" . (microtime(true) - $start) . " seconds)\n");
CLI::logging("* Start adding +async option to scheduler commands...\n");
$start = microtime(true);
$this->addAsyncOptionToSchedulerCommands(true);
@@ -377,6 +378,11 @@ class WorkspaceTools
Propel::init(PATH_CONFIG . 'databases.php');
WebEntry::convertFromV1ToV2();
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,11 +599,21 @@ class WorkspaceTools
$rbDetails = $this->getDBCredentials("rb");
$rpDetails = $this->getDBCredentials("rp");
$config = array('datasources' => array('workflow' => array('connection' => $wfDetails["dsn"], 'adapter' => $wfDetails["adapter"]
), 'rbac' => array('connection' => $rbDetails["dsn"], 'adapter' => $rbDetails["adapter"]
), 'rp' => array('connection' => $rpDetails["dsn"], 'adapter' => $rpDetails["adapter"]
)
)
$config = array(
'datasources' => array(
'workflow' => array(
'connection' => $wfDetails["dsn"],
'adapter' => $wfDetails["adapter"]
),
'rbac' => array(
'connection' => $rbDetails["dsn"],
'adapter' => $rbDetails["adapter"]
),
'rp' => array(
'connection' => $rpDetails["dsn"],
'adapter' => $rpDetails["adapter"]
)
)
);
if ($root) {
@@ -1039,12 +1055,14 @@ class WorkspaceTools
$this->initPropel(true);
$conf = new Configurations();
if (!$conf->exists("ENVIRONMENT_SETTINGS")) {
$conf->aConfig = array("format" => '@userName (@firstName @lastName)',
$conf->aConfig = array(
"format" => '@userName (@firstName @lastName)',
"dateFormat" => 'd/m/Y',
"startCaseHideProcessInf" => false,
"casesListDateFormat" => 'Y-m-d H:i:s',
"casesListRowNumber" => 25,
"casesListRefreshTime" => 120);
"casesListRefreshTime" => 120
);
$conf->saveConfig('ENVIRONMENT_SETTINGS', '');
}
$conf->setDirectoryStructureVer(2);
@@ -1076,12 +1094,12 @@ class WorkspaceTools
P11835::$dbAdapter = $this->dbAdapter;
P11835::isApplicable();
$systemSchema = System::getSystemSchema($this->dbAdapter);
$systemSchemaRbac = System::getSystemSchemaRbac($this->dbAdapter);// Get the RBAC Schema
$systemSchemaRbac = System::getSystemSchemaRbac($this->dbAdapter); // Get the RBAC Schema
$this->registerSystemTables(array_merge($systemSchema, $systemSchemaRbac));
$this->upgradeSchema($systemSchema, false, false, $includeIndexes);
$this->upgradeSchema($systemSchemaRbac, false, true); // Perform upgrade to RBAC
$this->upgradeData();
$this->checkRbacPermissions();//check or add new permissions
$this->checkRbacPermissions(); //check or add new permissions
$this->checkSequenceNumber();
$this->migrateIteeToDummytask($this->name);
/*----------------------------------********---------------------------------*/
@@ -1215,8 +1233,8 @@ class WorkspaceTools
$changes = System::compareSchema($workspaceSchema, $schema);
$changed = (count($changes['tablesToAdd']) > 0 || count($changes['tablesToAlter']) > 0 ||
count($changes['tablesWithNewIndex']) > 0 || count($changes['tablesToAlterIndex']) > 0 ||
count($changes['tablesWithNewFulltext']) > 0 || count($changes['tablesToAlterFulltext']) > 0);
count($changes['tablesWithNewIndex']) > 0 || count($changes['tablesToAlterIndex']) > 0 ||
count($changes['tablesWithNewFulltext']) > 0 || count($changes['tablesToAlterFulltext']) > 0);
if ($checkOnly || (!$changed)) {
if ($changed) {
@@ -1299,8 +1317,12 @@ class WorkspaceTools
}
// Instantiate the class to execute the query in background
$upgradeQueries[] = new RunProcessUpgradeQuery($this->name, $database->generateAddColumnsSql($tableName,
$tableColumn, $indexes, $fulltextIndexes), $rbac);
$upgradeQueries[] = new RunProcessUpgradeQuery($this->name, $database->generateAddColumnsSql(
$tableName,
$tableColumn,
$indexes,
$fulltextIndexes
), $rbac);
}
// Run queries in multiple threads
@@ -1510,7 +1532,8 @@ class WorkspaceTools
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']);
} else {
$info = array('Workspace Name' => $fields['WORKSPACE_NAME'],
$info = array(
'Workspace Name' => $fields['WORKSPACE_NAME'],
//'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']
);
@@ -1648,9 +1671,7 @@ class WorkspaceTools
/* Write metadata to file, but make it prettier before. The metadata is just
* a JSON codified array.
*/
if (!file_put_contents($metaFilename, str_replace(array(",", "{", "}"
), array(",\n ", "{\n ", "\n}\n"
), G::json_encode($metadata)))) {
if (!file_put_contents($metaFilename, str_replace(array(",", "{", "}"), array(",\n ", "{\n ", "\n}\n"), G::json_encode($metadata)))) {
throw new Exception("Could not create backup metadata");
}
CLI::logging("Copying database to backup...\n");
@@ -2120,11 +2141,10 @@ class WorkspaceTools
}
if (!empty($pmVersionWorkspaceToRestore) && (version_compare(
$pmVersionWorkspaceToRestore . "",
$pmVersion . "",
"<"
) || empty($pmVersion)) || $pmVersion == "dev-version-backup"
) {
$pmVersionWorkspaceToRestore . "",
$pmVersion . "",
"<"
) || empty($pmVersion)) || $pmVersion == "dev-version-backup") {
// Upgrade the database schema and data
CLI::logging("* Start updating database schema...\n");
$start = microtime(true);
@@ -2234,6 +2254,11 @@ class WorkspaceTools
Propel::init(PATH_CONFIG . 'databases.php');
WebEntry::convertFromV1ToV2();
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");
@@ -3017,7 +3042,8 @@ class WorkspaceTools
*
* @throws Exception
*/
public function runUpdateListField(array $listTables, $methodName) {
public function runUpdateListField(array $listTables, $methodName)
{
// Clean the queries array
$listQueries = [];
@@ -3049,7 +3075,8 @@ class WorkspaceTools
*
* @see \WorkspaceTools->migrateList()
*/
public function updateListProId($list) {
public function updateListProId($list)
{
$query = 'UPDATE ' . $list . ' AS LT
INNER JOIN (
SELECT PROCESS.PRO_UID, PROCESS.PRO_ID
@@ -3070,7 +3097,8 @@ class WorkspaceTools
*
* @see \WorkspaceTools->migrateList()
*/
public function updateListUsrId($list) {
public function updateListUsrId($list)
{
$query = 'UPDATE ' . $list . ' AS LT
INNER JOIN (
SELECT USERS.USR_UID, USERS.USR_ID
@@ -3091,7 +3119,8 @@ class WorkspaceTools
*
* @see \WorkspaceTools->migrateList()
*/
public function updateListTasId($list) {
public function updateListTasId($list)
{
$query = 'UPDATE ' . $list . ' AS LT
INNER JOIN (
SELECT TASK.TAS_UID, TASK.TAS_ID
@@ -3112,7 +3141,8 @@ class WorkspaceTools
*
* @see \WorkspaceTools->migrateList()
*/
public function updateListAppStatusId($list) {
public function updateListAppStatusId($list)
{
$query = "UPDATE " . $list . "
SET APP_STATUS_ID = (case
when APP_STATUS = 'DRAFT' then 1
@@ -3384,8 +3414,8 @@ class WorkspaceTools
file_put_contents(
PATH_DATA . "/missing-users-" . $this->name . ".txt",
"APP_UID:[" . $item['APP_UID'] . "] - DEL_INDEX[" . $item['DEL_INDEX'] . "] have relation " .
"with invalid or non-existent user user with " .
"id [" . $item['USR_UID'] . "]"
"with invalid or non-existent user user with " .
"id [" . $item['USR_UID'] . "]"
);
}
CLI::logging("> Number of user related inconsistencies for workspace " . CLI::info($this->name) . ": " . CLI::info($counter) . "\n");
@@ -3420,8 +3450,8 @@ class WorkspaceTools
file_put_contents(
PATH_DATA . "/missing-tasks-" . $this->name . ".txt",
"APP_UID:[" . $item['APP_UID'] . "] - DEL_INDEX[" . $item['DEL_INDEX'] . "] have relation " .
"with invalid or non-existent task with " .
"id [" . $item['TAS_UID'] . "]"
"with invalid or non-existent task with " .
"id [" . $item['TAS_UID'] . "]"
);
}
@@ -3457,8 +3487,8 @@ class WorkspaceTools
file_put_contents(
PATH_DATA . "/missing-processes-" . $this->name . ".txt",
"APP_UID:[" . $item['APP_UID'] . "] - DEL_INDEX[" . $item['DEL_INDEX'] . "] have relation " .
"with invalid or non-existent process with " .
"id [" . $item['PRO_UID'] . "]"
"with invalid or non-existent process with " .
"id [" . $item['PRO_UID'] . "]"
);
}
CLI::logging("> Number of processes related data inconsistencies for workspace " . CLI::info($this->name) . ": " . CLI::info($counter) . "\n");
@@ -3493,8 +3523,8 @@ class WorkspaceTools
file_put_contents(
PATH_DATA . "/missing-app-delegation-" . $this->name . ".txt",
"APP_UID:[" . $item['APP_UID'] . "] - DEL_INDEX[" . $item['DEL_INDEX'] . "] have relation " .
"with invalid or non-existent process with " .
"id [" . $item['PRO_UID'] . "]"
"with invalid or non-existent process with " .
"id [" . $item['PRO_UID'] . "]"
);
}
CLI::logging("> Number of delegations related data inconsistencies for workspace " . CLI::info($this->name) . ": " . CLI::info($counter) . "\n");
@@ -4414,8 +4444,7 @@ class WorkspaceTools
if (is_dir($path)) {
$dir = opendir($path);
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");
$step = new Criteria("workflow");
$step->addSelectColumn(StepPeer::PRO_UID);
@@ -4568,7 +4597,7 @@ class WorkspaceTools
* @param boolean $keepDynContent
*
* @return void
*/
*/
public function clearDynContentHistoryData($force = false, $keepDynContent = false)
{
$this->initPropel(true);
@@ -4724,27 +4753,27 @@ class WorkspaceTools
. "LEFT JOIN " . $this->dbName . ".INPUT_DOCUMENT AS H ON (H.INP_DOC_UID=A.DYN_UID) ";
$delete = "DELETE FROM " . $this->dbName . ".APP_DATA_CHANGE_LOG "
. "WHERE "
. "ROW_MIGRATION=1";
. "WHERE "
. "ROW_MIGRATION=1";
$insert = "INSERT INTO " . $this->dbName . ".APP_DATA_CHANGE_LOG ( "
. " DATE, "
. " APP_NUMBER, "
. " DEL_INDEX, "
. " PRO_ID, "
. " TAS_ID, "
. " USR_ID, "
. " OBJECT_TYPE, "
. " OBJECT_ID, "
. " OBJECT_UID, "
. " EXECUTED_AT, "
. " SOURCE_ID, "
. " DATA, "
. " SKIN, "
. " LANGUAGE, "
. " ROW_MIGRATION "
. ") "
. $select;
. " DATE, "
. " APP_NUMBER, "
. " DEL_INDEX, "
. " PRO_ID, "
. " TAS_ID, "
. " USR_ID, "
. " OBJECT_TYPE, "
. " OBJECT_ID, "
. " OBJECT_UID, "
. " EXECUTED_AT, "
. " SOURCE_ID, "
. " DATA, "
. " SKIN, "
. " LANGUAGE, "
. " ROW_MIGRATION "
. ") "
. $select;
$con = Propel::getConnection("workflow");
$stmt = $con->createStatement();
@@ -4780,49 +4809,50 @@ class WorkspaceTools
$con->begin();
$stmt = $con->createStatement();
$stmt->executeQuery(""
. "UPDATE GROUPWF AS GW "
. "INNER JOIN GROUP_USER AS GU ON "
. " GW.GRP_UID=GU.GRP_UID "
. "SET GU.GRP_ID=GW.GRP_ID "
. "WHERE GU.GRP_ID = 0");
. "UPDATE GROUPWF AS GW "
. "INNER JOIN GROUP_USER AS GU ON "
. " GW.GRP_UID=GU.GRP_UID "
. "SET GU.GRP_ID=GW.GRP_ID "
. "WHERE GU.GRP_ID = 0");
$con->commit();
CLI::logging("-> Update table APP_ASSIGN_SELF_SERVICE_VALUE_GROUP\n");
$con->begin();
$stmt = $con->createStatement();
$stmt->executeQuery(""
. "UPDATE GROUPWF AS GW "
. "INNER JOIN APP_ASSIGN_SELF_SERVICE_VALUE_GROUP AS GU ON "
. " GW.GRP_UID=GU.GRP_UID "
. "SET "
. "GU.ASSIGNEE_ID=GW.GRP_ID, "
. "GU.ASSIGNEE_TYPE=2 "
. "WHERE GU.ASSIGNEE_ID = 0");
. "UPDATE GROUPWF AS GW "
. "INNER JOIN APP_ASSIGN_SELF_SERVICE_VALUE_GROUP AS GU ON "
. " GW.GRP_UID=GU.GRP_UID "
. "SET "
. "GU.ASSIGNEE_ID=GW.GRP_ID, "
. "GU.ASSIGNEE_TYPE=2 "
. "WHERE GU.ASSIGNEE_ID = 0");
$con->commit();
$con->begin();
$stmt = $con->createStatement();
$stmt->executeQuery(""
. "UPDATE USERS AS U "
. "INNER JOIN APP_ASSIGN_SELF_SERVICE_VALUE_GROUP AS GU ON "
. " U.USR_UID=GU.GRP_UID "
. "SET "
. "GU.ASSIGNEE_ID=U.USR_ID, "
. "GU.ASSIGNEE_TYPE=1 "
. "WHERE GU.ASSIGNEE_ID = 0");
. "UPDATE USERS AS U "
. "INNER JOIN APP_ASSIGN_SELF_SERVICE_VALUE_GROUP AS GU ON "
. " U.USR_UID=GU.GRP_UID "
. "SET "
. "GU.ASSIGNEE_ID=U.USR_ID, "
. "GU.ASSIGNEE_TYPE=1 "
. "WHERE GU.ASSIGNEE_ID = 0");
$con->commit();
$con->begin();
$stmt = $con->createStatement();
$stmt->executeQuery(""
. "UPDATE APP_ASSIGN_SELF_SERVICE_VALUE_GROUP "
. "SET "
. "ASSIGNEE_ID=-1, "
. "ASSIGNEE_TYPE=-1 "
. "WHERE ASSIGNEE_ID = 0");
. "UPDATE APP_ASSIGN_SELF_SERVICE_VALUE_GROUP "
. "SET "
. "ASSIGNEE_ID=-1, "
. "ASSIGNEE_TYPE=-1 "
. "WHERE ASSIGNEE_ID = 0");
$con->commit();
}
/**
* Remove deprecated files and directory.
*/
@@ -4850,7 +4880,8 @@ class WorkspaceTools
/**
* Sync JSON definition of the Forms with Input Documents information
*/
public function syncFormsWithInputDocumentInfo() {
public function syncFormsWithInputDocumentInfo()
{
// Initialize Propel and instance the required classes
$this->initPropel(true);
$processInstance = new Process();
@@ -4942,16 +4973,16 @@ class WorkspaceTools
* @throws Exception
*/
public function generateDataReport(
$tableName,
$type = 'NORMAL',
$processUid = '',
$gridKey = '',
$addTabUid = '',
$className = '',
$pathWorkspace,
int $start = 0,
int $limit = 10)
{
$tableName,
$type = 'NORMAL',
$processUid = '',
$gridKey = '',
$addTabUid = '',
$className = '',
$pathWorkspace,
int $start = 0,
int $limit = 10
) {
$this->initPropel();
$dbHost = explode(':', $this->dbHost);
config(['database.connections.workflow.host' => $dbHost[0]]);
@@ -4992,12 +5023,12 @@ class WorkspaceTools
//select cases for this Process, ordered by APP_NUMBER
$applications = Application::query()
->where('PRO_UID', '=', $processUid)
->where('APP_NUMBER', '>', 0)
->orderBy('APP_NUMBER', 'asc')
->offset($start)
->limit($limit)
->get();
->where('PRO_UID', '=', $processUid)
->where('APP_NUMBER', '>', 0)
->orderBy('APP_NUMBER', 'asc')
->offset($start)
->limit($limit)
->get();
foreach ($applications as $application) {
//getting the case data
$appData = $case->unserializeData($application->APP_DATA);
@@ -5127,4 +5158,43 @@ class WorkspaceTools
$conf->aConfig = ['updated' => true];
$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::PRO_UID);
$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_TAS_TITLE);
$criteria->addSelectColumn(ListParticipatedLastPeer::APP_STATUS);
@@ -405,7 +405,6 @@ class ListParticipatedLast extends BaseListParticipatedLast implements ListInter
$criteria->addSelectColumn(ListParticipatedLastPeer::DEL_PRIORITY);
$criteria->addSelectColumn(ListParticipatedLastPeer::DEL_THREAD_STATUS);
$criteria->add(ListParticipatedLastPeer::USR_UID, $usr_uid, Criteria::EQUAL);
//Check if the user was participated in a specific case
if ($appUid != '') {
$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_PRIORITY',
'APP_DELEGATION.DEL_PREVIOUS',
'APP_DELEGATION.DEL_TITLE AS APP_TITLE',
// TASK table
'TASK.TAS_TITLE',
// APPLICATION table
'APPLICATION.APP_TITLE',
'APPLICATION.APP_UPDATE_DATE',
// PROCESS table
'PROCESS.PRO_TITLE'
@@ -274,7 +274,7 @@ class ListUnassigned extends BaseListUnassigned implements ListInterface
'APP_NUMBER' => 'APP_NUMBER',
'DEL_DUE_DATE' => 'DEL_TASK_DUE_DATE',
'DEL_DELEGATE_DATE' => 'DEL_DELEGATE_DATE',
'APP_TITLE' => 'APP_TITLE',
'APP_DELEGATION.DEL_TITLE AS APP_TITLE',
'APP_PRO_TITLE' => 'PRO_TITLE',
'APP_TAS_TITLE' => 'TAS_TITLE',
'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('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_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;
/**
* The value for the del_title field.
* @var string
*/
protected $del_title;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -639,6 +645,17 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
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.
*
@@ -1288,6 +1305,28 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
} // 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.
*
@@ -1363,12 +1402,14 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
$this->tas_id = $rs->getInt($startcol + 28);
$this->del_title = $rs->getString($startcol + 29);
$this->resetModified();
$this->setNew(false);
// 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) {
throw new PropelException("Error populating AppDelegation object", $e);
@@ -1659,6 +1700,9 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
case 28:
return $this->getTasId();
break;
case 29:
return $this->getDelTitle();
break;
default:
return null;
break;
@@ -1708,6 +1752,7 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
$keys[26] => $this->getUsrId(),
$keys[27] => $this->getProId(),
$keys[28] => $this->getTasId(),
$keys[29] => $this->getDelTitle(),
);
return $result;
}
@@ -1826,6 +1871,9 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
case 28:
$this->setTasId($value);
break;
case 29:
$this->setDelTitle($value);
break;
} // switch()
}
@@ -1965,6 +2013,10 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
$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);
}
if ($this->isColumnModified(AppDelegationPeer::DEL_TITLE)) {
$criteria->add(AppDelegationPeer::DEL_TITLE, $this->del_title);
}
return $criteria;
}
@@ -2212,6 +2268,8 @@ abstract class BaseAppDelegation extends BaseObject implements Persistent
$copyObj->setTasId($this->tas_id);
$copyObj->setDelTitle($this->del_title);
$copyObj->setNew(true);

View File

@@ -25,7 +25,7 @@ abstract class BaseAppDelegationPeer
const CLASS_DEFAULT = 'classes.model.AppDelegation';
/** The total number of columns. */
const NUM_COLUMNS = 29;
const NUM_COLUMNS = 30;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@@ -118,6 +118,9 @@ abstract class BaseAppDelegationPeer
/** the column name for the TAS_ID field */
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 */
private static $phpNameMap = null;
@@ -129,10 +132,10 @@ abstract class BaseAppDelegationPeer
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
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_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_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_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_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, 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', '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, 29, )
);
/**
@@ -142,10 +145,10 @@ abstract class BaseAppDelegationPeer
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
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_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_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_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_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, 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, '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, 29, )
);
/**
@@ -304,6 +307,8 @@ abstract class BaseAppDelegationPeer
$criteria->addSelectColumn(AppDelegationPeer::TAS_ID);
$criteria->addSelectColumn(AppDelegationPeer::DEL_TITLE);
}
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="PRO_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-column name="DELEGATION_ID"/>
</unique>
@@ -201,6 +202,15 @@
<index-column name="DEL_THREAD_STATUS"/>
<index-column name="APP_NUMBER"/>
</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 name="APP_DOCUMENT">
<vendor type="mysql">

View File

@@ -94,6 +94,7 @@ CREATE TABLE `APP_DELEGATION`
`USR_ID` INTEGER default 0,
`PRO_ID` INTEGER default 0,
`TAS_ID` INTEGER default 0,
`DEL_TITLE` VARCHAR(999) NOT NULL,
PRIMARY KEY (`APP_UID`,`DEL_INDEX`),
UNIQUE KEY `DELEGATION_ID` (`DELEGATION_ID`),
KEY `INDEX_APP_NUMBER`(`APP_NUMBER`),
@@ -101,7 +102,8 @@ CREATE TABLE `APP_DELEGATION`
KEY `INDEX_PRO_ID`(`PRO_ID`),
KEY `INDEX_TAS_ID`(`TAS_ID`),
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';
#-----------------------------------------------------------------------------
#-- APP_DOCUMENT

View File

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

View File

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

View File

@@ -7,6 +7,7 @@ use G;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Core\System;
use ProcessMaker\Model\Task;
class Delegation extends Model
{
@@ -186,7 +187,7 @@ class Delegation extends Model
'APPLICATION.APP_CREATE_DATE',
'APPLICATION.APP_FINISH_DATE',
'APPLICATION.APP_UPDATE_DATE',
'APPLICATION.APP_TITLE',
'APP_DELEGATION.DEL_TITLE AS APP_TITLE',
'APP_DELEGATION.USR_UID',
'APP_DELEGATION.TAS_UID',
'APP_DELEGATION.USR_ID',
@@ -239,12 +240,11 @@ class Delegation extends Model
// Build the "fulltext" expression
$search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"';
// Searching using "fulltext" index
$join->whereRaw("MATCH(APPLICATION.APP_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)");
$join->whereRaw("MATCH(APP_DELEGATION.DEL_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)");
} else {
// Searching using "like" operator
$join->where('APPLICATION.APP_TITLE', 'LIKE', "%${search}%");
$join->where('APP_DELEGATION.DEL_TITLE', 'LIKE', "%${search}%");
}
}
// Based on the below, we can further limit the join so that we have a smaller data set based on join criteria
@@ -268,7 +268,6 @@ class Delegation extends Model
// Don't do anything here, we'll need to do the more advanced where below
}
});
// Add join for process, but only for certain scenarios such as category or process
if ($category || $process || $sort == 'APP_PRO_TITLE') {
$query->join('PROCESS', function ($join) use ($category) {
@@ -561,7 +560,7 @@ class Delegation extends Model
});
// Add join clause with APPLICATION table if required
if (array_search('APPLICATION.APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') {
if (array_search('APP_DELEGATION.DEL_TITLE AS APP_TITLE', $selectedColumns) !== false || array_search('APPLICATION.APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') {
$query1->join('APPLICATION', function ($join) {
$join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER');
});
@@ -582,7 +581,7 @@ class Delegation extends Model
// Build where clause for the text to search
if (!empty($textToSearch)) {
$query1->where('APPLICATION.APP_TITLE', 'LIKE', "%$textToSearch%")
$query1->where('APP_DELEGATION.DEL_TITLE', 'LIKE', "%$textToSearch%")
->orWhere('TASK.TAS_TITLE', 'LIKE', "%$textToSearch%")
->orWhere('PROCESS.PRO_TITLE', 'LIKE', "%$textToSearch%");
}
@@ -617,7 +616,7 @@ class Delegation extends Model
}
// Add join clause with APPLICATION table if required
if (array_search('APPLICATION.APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') {
if (array_search('APP_DELEGATION.DEL_TITLE AS APP_TITLE', $selectedColumns) !== false || !empty($textToSearch) || $sort == 'APP_TITLE') {
$query2->join('APPLICATION', function ($join) {
$join->on('APP_DELEGATION.APP_NUMBER', '=', 'APPLICATION.APP_NUMBER');
});
@@ -638,7 +637,7 @@ class Delegation extends Model
// Build where clause for the text to search
if (!empty($textToSearch)) {
$query2->where('APPLICATION.APP_TITLE', 'LIKE', "%$textToSearch%")
$query2->where('APP_DELEGATION.DEL_TITLE', 'LIKE', "%$textToSearch%")
->orWhere('TASK.TAS_TITLE', 'LIKE', "%$textToSearch%")
->orWhere('PROCESS.PRO_TITLE', 'LIKE', "%$textToSearch%");
}
@@ -803,6 +802,25 @@ class Delegation extends Model
return ($query->count() > 0);
}
/**
* Return the task related to the thread
*
* @param int $appNumber
* @param int $index
*
* @return array
*/
public static function getThreadInfo(int $appNumber, int $index)
{
$query = Delegation::query()->select(['APP_NUMBER', 'TAS_UID', 'TAS_ID', 'DEL_PREVIOUS', 'DEL_TITLE']);
$query->where('APP_NUMBER', $appNumber);
$query->where('DEL_INDEX', $index);
$query->limit(1);
$result = $query->get()->toArray();
return head($result);
}
/**
* Return the thread related to the specific task-index
*
@@ -851,4 +869,49 @@ class Delegation extends Model
return $thread;
}
/**
* 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

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

View File

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

View File

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