PMCORE-2394

This commit is contained in:
Andrea Adamczyk
2020-12-02 17:15:01 -04:00
parent b55e95fa33
commit f65454d9b1
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 [
'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,6 +32,7 @@ $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,

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\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

@@ -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;
@@ -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,9 +599,19 @@ 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"]
)
)
);
@@ -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);
/*----------------------------------********---------------------------------*/
@@ -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");
@@ -2123,8 +2144,7 @@ class WorkspaceTools
$pmVersionWorkspaceToRestore . "",
$pmVersion . "",
"<"
) || empty($pmVersion)) || $pmVersion == "dev-version-backup"
) {
) || 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
@@ -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);
@@ -4821,6 +4850,7 @@ class WorkspaceTools
. "ASSIGNEE_TYPE=-1 "
. "WHERE ASSIGNEE_ID = 0");
$con->commit();
}
/**
@@ -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();
@@ -4950,8 +4981,8 @@ class WorkspaceTools
$className = '',
$pathWorkspace,
int $start = 0,
int $limit = 10)
{
int $limit = 10
) {
$this->initPropel();
$dbHost = explode(':', $this->dbHost);
config(['database.connections.workflow.host' => $dbHost[0]]);
@@ -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);
}
}
}