Merged in feature/PMCORE-2394 (pull request #7571)

PMCORE-2394

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Andrea Adamczyk
2020-12-08 14:40:12 +00:00
committed by Julio Cesar Laura Avendaño
4 changed files with 328 additions and 168 deletions

View File

@@ -18,6 +18,7 @@ $factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
return [ return [
'APP_UID' => $application->APP_UID, 'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 1, 'DEL_INDEX' => 1,
'DELEGATION_ID' => $faker->unique()->randomNumber,
'APP_NUMBER' => $application->APP_NUMBER, 'APP_NUMBER' => $application->APP_NUMBER,
'DEL_PREVIOUS' => 0, 'DEL_PREVIOUS' => 0,
'PRO_UID' => $process->PRO_UID, 'PRO_UID' => $process->PRO_UID,
@@ -31,6 +32,7 @@ $factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
'DEL_INIT_DATE' => $faker->dateTime(), 'DEL_INIT_DATE' => $faker->dateTime(),
'DEL_TASK_DUE_DATE' => $faker->dateTime(), 'DEL_TASK_DUE_DATE' => $faker->dateTime(),
'DEL_RISK_DATE' => $faker->dateTime(), 'DEL_RISK_DATE' => $faker->dateTime(),
'DEL_LAST_INDEX' => 0,
'USR_ID' => $user->USR_ID, 'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID, 'PRO_ID' => $process->PRO_ID,
'TAS_ID' => $task->TAS_ID, 'TAS_ID' => $task->TAS_ID,

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

@@ -2,6 +2,7 @@
use ProcessMaker\BusinessModel\WebEntry; use ProcessMaker\BusinessModel\WebEntry;
use ProcessMaker\Core\JobsManager; use ProcessMaker\Core\JobsManager;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process; use ProcessMaker\Model\Process;
use ProcessMaker\Validation\MySQL57; use ProcessMaker\Validation\MySQL57;
@@ -10,8 +11,7 @@ CLI::taskDescription(<<<EOT
Print information about the current system and any specified workspaces. Print information about the current system and any specified workspaces.
If no workspace is specified, show information about all available workspaces If no workspace is specified, show information about all available workspaces
EOT EOT);
);
CLI::taskArg('workspace-name', true, true); CLI::taskArg('workspace-name', true, true);
CLI::taskRun("run_info"); CLI::taskRun("run_info");
@@ -27,8 +27,7 @@ CLI::taskDescription(<<<EOT
A backup archive will contain all information about the specified workspace 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 so that it can be restored later. The archive includes a database dump and
all the workspace files. all the workspace files.
EOT EOT);
);
CLI::taskArg('workspace', false); CLI::taskArg('workspace', false);
CLI::taskArg('backup-file', true); 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="); 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, Specify the WORKSPACE to restore to a different workspace name. Otherwise,
it will restore to the same workspace name as the original backup. it will restore to the same workspace name as the original backup.
EOT EOT);
);
CLI::taskArg('backup-file', false); CLI::taskArg('backup-file', false);
CLI::taskArg('workspace', true); CLI::taskArg('workspace', true);
CLI::taskOpt("overwrite", "If a workspace already exists, overwrite it.", "o", "overwrite"); 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 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 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. to be used after upgrading ProcessMaker or if the cases inbox is out of sync.
EOT EOT);
);
CLI::taskArg('workspace', true, true); 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::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"); 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 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 schemas or after ProcessMaker has been upgraded, so the database schemas will
be changed to match the new ProcessMaker code. be changed to match the new ProcessMaker code.
EOT EOT);
);
CLI::taskArg('workspace', true, true); CLI::taskArg('workspace', true, true);
CLI::taskRun("run_database_upgrade"); 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 This is the same as database-upgrade but it works with schemas provided
by plugins. This is useful if plugins are installed that include by plugins. This is useful if plugins are installed that include
database schemas. database schemas.
EOT EOT);
);
CLI::taskArg('workspace', true, true); CLI::taskArg('workspace', true, true);
CLI::taskRun("run_plugins_database_upgrade"); CLI::taskRun("run_plugins_database_upgrade");
@@ -118,8 +113,7 @@ CLI::taskDescription(<<<EOT
This command will go through each language installed in ProcessMaker and This command will go through each language installed in ProcessMaker and
update the translations for the workspace(s) to match the current version of update the translations for the workspace(s) to match the current version of
ProcessMaker. ProcessMaker.
EOT EOT);
);
CLI::taskArg('workspace-name', true, true); 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('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'); 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 Migrating cases folders of the workspaces
Specify the WORKSPACE to migrate from a existing workspace. Specify the WORKSPACE to migrate from a existing workspace.
EOT EOT);
);
//CLI::taskArg('workspace', true); //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::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"); 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 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 integrity. Use this command to check the database data consistency before any costly
database-upgrade operation is planned to be executed. database-upgrade operation is planned to be executed.
EOT EOT);
);
CLI::taskArg('workspace', true, true); CLI::taskArg('workspace', true, true);
CLI::taskRun("run_database_verify_consistency"); CLI::taskRun("run_database_verify_consistency");
@@ -162,8 +154,7 @@ CLI::taskDescription(<<<EOT
This command will read the Cancelled, Completed, Inbox, My Inbox, participated This command will read the Cancelled, Completed, Inbox, My Inbox, participated
unassigned data in an attempt to verify the database integrity. It's recommended 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. to run this script after the migrate cases job has been executed.
EOT EOT);
);
CLI::taskArg('workspace', true, true); CLI::taskArg('workspace', true, true);
CLI::taskRun("run_database_verify_migration_consistency"); 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. Specify the workspaces, the processes in this workspace will be updated.
If no workspace is specified, the command will be run in all workspaces. If no workspace is specified, the command will be run in all workspaces.
EOT EOT);
);
CLI::taskArg('workspace', true, true); CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_itee_to_dummytask"); 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. If no workspace is specified, the command will be run in all workspaces.
More than one workspace can be specified. More than one workspace can be specified.
EOT EOT);
);
CLI::taskArg("workspace-name", true, true); CLI::taskArg("workspace-name", true, true);
CLI::taskRun("run_check_workspace_disabled_code"); 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 If no workspace is specified, then the tables schema will be upgraded or
migrate on all available workspaces. migrate on all available workspaces.
EOT EOT);
);
CLI::taskArg('workspace', true, true); CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_new_cases_lists"); 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 If no workspace is specified, then the tables schema will be upgraded or
migrate on all available workspaces. migrate on all available workspaces.
EOT EOT);
);
CLI::taskArg('workspace', true, true); CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_list_unassigned"); 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. 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. If no workspace is specified, the command will be running in all workspaces.
EOT EOT);
);
CLI::taskArg('workspace', true, true); CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_indexing_acv"); 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 If no workspace is specified, then the tables schema will be upgraded or
migrate on all available workspaces. migrate on all available workspaces.
EOT EOT);
);
CLI::taskArg('workspace', true, true); 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::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"); 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 If no workspace is specified, then the tables schema will be upgraded or
migrated to all available workspaces. migrated to all available workspaces.
EOT EOT);
);
CLI::taskArg('workspace', true, true); CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_plugin"); 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. 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. If no workspace is specified, the command will be run in all workspaces.
EOT EOT);
);
CLI::taskArg('workspace', true, true); CLI::taskArg('workspace', true, true);
CLI::taskRun("run_migrate_self_service_value"); CLI::taskRun("run_migrate_self_service_value");
@@ -279,8 +262,7 @@ CLI::taskRun("run_migrate_self_service_value");
CLI::taskName('list-ids'); CLI::taskName('list-ids');
CLI::taskDescription(<<<EOT CLI::taskDescription(<<<EOT
Complete the PRO_ID and USR_ID in the LIST_* tables. Complete the PRO_ID and USR_ID in the LIST_* tables.
EOT EOT);
);
CLI::taskOpt("lang", "", "lLANG", "lang=LANG"); CLI::taskOpt("lang", "", "lLANG", "lang=LANG");
CLI::taskArg('workspace'); CLI::taskArg('workspace');
CLI::taskRun("cliListIds"); CLI::taskRun("cliListIds");
@@ -291,8 +273,7 @@ CLI::taskRun("cliListIds");
CLI::taskName('upgrade-content'); CLI::taskName('upgrade-content');
CLI::taskDescription(<<<EOT CLI::taskDescription(<<<EOT
Upgrade the content table Upgrade the content table
EOT EOT);
);
CLI::taskArg('workspace'); CLI::taskArg('workspace');
CLI::taskRun("run_upgrade_content"); CLI::taskRun("run_upgrade_content");
@@ -307,8 +288,7 @@ CLI::taskDescription(<<<EOT
incorrectly, which is caused by importing processes where the data directory incorrectly, which is caused by importing processes where the data directory
of ProcessMaker has different routes. Modified files are backed up with the of ProcessMaker has different routes. Modified files are backed up with the
extension '.backup' in the same directory. extension '.backup' in the same directory.
EOT EOT);
);
CLI::taskArg('workspace'); CLI::taskArg('workspace');
CLI::taskRun("regenerate_pmtable_classes"); CLI::taskRun("regenerate_pmtable_classes");
@@ -319,8 +299,7 @@ CLI::taskRun("regenerate_pmtable_classes");
CLI::taskName('migrate-history-data'); CLI::taskName('migrate-history-data');
CLI::taskDescription(<<<EOT CLI::taskDescription(<<<EOT
Migrate the content of the APP_HISTORY table to the APP_DATA_CHANGE_LOG table. Migrate the content of the APP_HISTORY table to the APP_DATA_CHANGE_LOG table.
EOT EOT);
);
CLI::taskArg('workspace'); CLI::taskArg('workspace');
CLI::taskRun('migrate_history_data'); CLI::taskRun('migrate_history_data');
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
@@ -331,8 +310,7 @@ CLI::taskRun('migrate_history_data');
CLI::taskName('clear-dyn-content-history-data'); CLI::taskName('clear-dyn-content-history-data');
CLI::taskDescription(<<<EOT CLI::taskDescription(<<<EOT
Clear History of Use data from APP_HISTORY table Clear History of Use data from APP_HISTORY table
EOT EOT);
);
CLI::taskArg('workspace'); CLI::taskArg('workspace');
CLI::taskRun("run_clear_dyn_content_history_data"); 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::taskName('sync-forms-with-info-from-input-documents');
CLI::taskDescription(<<<EOT CLI::taskDescription(<<<EOT
Sync JSON definition of the Forms with Input Documents information Sync JSON definition of the Forms with Input Documents information
EOT EOT);
);
CLI::taskArg('workspace'); CLI::taskArg('workspace');
CLI::taskRun("run_sync_forms_with_info_from_input_documents"); 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::taskName('remove-unused-files');
CLI::taskDescription(<<<EOT CLI::taskDescription(<<<EOT
Remove the deprecated files. Remove the deprecated files.
EOT EOT);
);
CLI::taskRun("remove_deprecated_files"); 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. If no workspace is specified, the command will be run in all workspaces.
More than one workspace can be specified. More than one workspace can be specified.
EOT EOT);
);
CLI::taskArg("workspace-name", true, true); CLI::taskArg("workspace-name", true, true);
CLI::taskRun("run_check_queries_incompatibilities"); CLI::taskRun("run_check_queries_incompatibilities");
/*********************************************************************/ /*********************************************************************/
@@ -383,8 +358,7 @@ Example:
To see other command options please refer to the artisan help. To see other command options please refer to the artisan help.
php artisan --help php artisan --help
EOT EOT);
);
CLI::taskRun("run_artisan"); CLI::taskRun("run_artisan");
/** /**
@@ -393,16 +367,23 @@ CLI::taskRun("run_artisan");
CLI::taskName('documents-add-font'); CLI::taskName('documents-add-font');
CLI::taskDescription(<<<EOT CLI::taskDescription(<<<EOT
Add a font to be used in Documents generation (TinyMCE editor and/or TCPDF library). Add a font to be used in Documents generation (TinyMCE editor and/or TCPDF library).
EOT EOT);
); CLI::taskOpt(
CLI::taskOpt('type', <<<EOT 'type',
<<<EOT
Can be "TrueType" or "TrueTypeUnicode", if the option is not specified the default value is "TrueType" Can be "TrueType" or "TrueTypeUnicode", if the option is not specified the default value is "TrueType"
EOT EOT,
,'t', 'type='); 't',
CLI::taskOpt('tinymce', <<<EOT '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. 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 EOT,
,'tm', 'tinymce='); 'tm',
'tinymce='
);
CLI::taskArg('fontFileName', false); CLI::taskArg('fontFileName', false);
CLI::taskArg('friendlyName', true); CLI::taskArg('friendlyName', true);
CLI::taskArg('fontProperties', true); CLI::taskArg('fontProperties', true);
@@ -414,8 +395,7 @@ CLI::taskRun('documents_add_font');
CLI::taskName('documents-list-registered-fonts'); CLI::taskName('documents-list-registered-fonts');
CLI::taskDescription(<<<EOT CLI::taskDescription(<<<EOT
List the registered fonts. List the registered fonts.
EOT EOT);
);
CLI::taskRun('documents_list_registered_fonts'); CLI::taskRun('documents_list_registered_fonts');
/** /**
@@ -424,8 +404,7 @@ CLI::taskRun('documents_list_registered_fonts');
CLI::taskName('documents-remove-font'); CLI::taskName('documents-remove-font');
CLI::taskDescription(<<<EOT CLI::taskDescription(<<<EOT
Remove a font used in Documents generation (TinyMCE editor and/or TCPDF library). Remove a font used in Documents generation (TinyMCE editor and/or TCPDF library).
EOT EOT);
);
CLI::taskArg('fontFileName', false); CLI::taskArg('fontFileName', false);
CLI::taskRun('documents_remove_font'); CLI::taskRun('documents_remove_font');
@@ -450,6 +429,18 @@ EOT
); );
CLI::taskRun('convert_old_web_entries'); CLI::taskRun('convert_old_web_entries');
/**
* Populate the column APP_DELEGATION.DEL_TITLE with the case title APPLICATION.APP_TITLE
*/
CLI::taskName('migrate-case-title-to-threads');
CLI::taskDescription(<<<EOT
Populate the new column APPLICATION.APP_TITLE into the APP_DELEGATION table
EOT);
CLI::taskArg('WORKSPACE', false);
CLI::taskArg('caseNumberFrom', true);
CLI::taskArg('caseNumberTo', true);
CLI::taskRun('migrate_case_title_to_threads');
/** /**
* Function run_info * Function run_info
* *
@@ -1312,7 +1303,7 @@ function migrate_history_data($args, $opts)
* @param array $opts * @param array $opts
* *
* @return void * @return void
*/ */
function run_clear_dyn_content_history_data($args, $opts) function run_clear_dyn_content_history_data($args, $opts)
{ {
$workspaces = get_workspaces_from_args($args); $workspaces = get_workspaces_from_args($args);
@@ -1335,7 +1326,8 @@ function run_clear_dyn_content_history_data($args, $opts)
* @return void * @return void
* @see workflow/engine/bin/tasks/cliWorkspaces.php CLI::taskRun() * @see workflow/engine/bin/tasks/cliWorkspaces.php CLI::taskRun()
*/ */
function run_sync_forms_with_info_from_input_documents($args, $opts) { function run_sync_forms_with_info_from_input_documents($args, $opts)
{
if (count($args) === 1) { if (count($args) === 1) {
//This variable is not defined and does not involve its value in this //This variable is not defined and does not involve its value in this
//task, it is removed at the end of the method. //task, it is removed at the end of the method.
@@ -1689,3 +1681,15 @@ function convert_old_web_entries($args)
CLI::logging($e->getMessage() . PHP_EOL . PHP_EOL); CLI::logging($e->getMessage() . PHP_EOL . PHP_EOL);
} }
} }
/**
* Populate the new column APPLICATION.APP_TITLE into the APP_DELEGATION table
*
* @param array $args
*/
function migrate_case_title_to_threads($args)
{
//The constructor requires an argument, so we send an empty value in order to use the class.
$workspaceTools = new WorkspaceTools('');
$workspaceTools->migrateCaseTitleToThreads($args);
}

View File

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