This commit is contained in:
Julio Cesar Laura Avendaño
2019-04-12 16:17:21 -04:00
parent e03019b781
commit 3f0f513c7c

View File

@@ -2421,6 +2421,13 @@ class WorkspaceTools
* @param string $lang * @param string $lang
* *
* @return void * @return void
*
* @throws Exception
*
* @see \WorkspaceTools->upgrade
* @see \WorkspaceTools->restore
* @see workflow/engine/bin/tasks/cliWorkspaces.php:migrate_new_cases_lists()
* @link https://wiki.processmaker.com/3.3/processmaker_command#migrate-new-cases-lists
*/ */
public function migrateList($flagReinsert = false, $lang = 'en') public function migrateList($flagReinsert = false, $lang = 'en')
{ {
@@ -2433,7 +2440,7 @@ class WorkspaceTools
return; return;
} }
$arrayTable1 = ['ListInbox', 'ListMyInbox', 'ListCanceled', 'ListParticipatedLast', 'ListParticipatedHistory', 'ListPaused']; $arrayTable1 = ['ListCanceled', 'ListMyInbox', 'ListInbox', 'ListParticipatedHistory', 'ListPaused', 'ListParticipatedLast'];
$arrayTable2 = ['ListUnassigned', 'ListUnassignedGroup']; $arrayTable2 = ['ListUnassigned', 'ListUnassignedGroup'];
$arrayTable = array_merge($arrayTable1, $arrayTable2); $arrayTable = array_merge($arrayTable1, $arrayTable2);
@@ -2458,23 +2465,57 @@ class WorkspaceTools
} }
} }
$listQueries = [];
if ($flagReinsert || !$flagListAll) { if ($flagReinsert || !$flagListAll) {
$this->regenerateListCanceled($lang); // Regenerate lists
$this->regenerateListMyInbox(); //This list require no translation $listQueries[] = new RunProcessUpgradeQuery($this->name, $this->regenerateListCanceled($lang));
$this->regenerateListInbox(); //This list require no translation $listQueries[] = new RunProcessUpgradeQuery($this->name, $this->regenerateListMyInbox());
$this->regenerateListParticipatedHistory(); //This list require no translation $listQueries[] = new RunProcessUpgradeQuery($this->name, $this->regenerateListInbox());
$this->regenerateListParticipatedLast(); //This list require no translation $listQueries[] = new RunProcessUpgradeQuery($this->name, $this->regenerateListParticipatedHistory());
$this->regenerateListPaused(); //This list require no translation $listQueries[] = new RunProcessUpgradeQuery($this->name, $this->regenerateListPaused());
$listQueries[] = new RunProcessUpgradeQuery($this->name, $this->regenerateListParticipatedLast());
} }
if ($flagReinsert || !$flagListUnassigned) { if ($flagReinsert || !$flagListUnassigned) {
$this->regenerateListUnassigned(); //This list require no translation // This list always is truncated
$con = Propel::getConnection("workflow");
$stmt = $con->createStatement();
$stmt->executeQuery('TRUNCATE ' . $this->dbName . '.LIST_UNASSIGNED');
// Regenerate list
$listQueries[] = new RunProcessUpgradeQuery($this->name, $this->regenerateListUnassigned());
} }
// Run queries in multiple threads
$processesManager = new ProcessesManager($listQueries);
$processesManager->run();
// If exists an error throw an exception
if (!empty($processesManager->getErrors())) {
$errorMessage = '';
foreach ($processesManager->getErrors() as $error) {
$errorMessage .= $error['rawAnswer'] . PHP_EOL;
}
throw new Exception($errorMessage);
}
// This query cannot be launched in parallel, requires that the table already was populated
$this->updateListParticipatedLast();
$this->listFirstExecution('insert'); $this->listFirstExecution('insert');
$this->listFirstExecution('insert', 'unassigned'); $this->listFirstExecution('insert', 'unassigned');
} }
/**
* Return query to populate canceled list
*
* @param string $lang
*
* @return string
*
* @see \WorkspaceTools->migrateList()
*/
public function regenerateListCanceled($lang = 'en') public function regenerateListCanceled($lang = 'en')
{ {
$this->initPropel(true); $this->initPropel(true);
@@ -2537,12 +2578,17 @@ class WorkspaceTools
WHERE WHERE
ACV.APP_STATUS = \'CANCELLED\' ACV.APP_STATUS = \'CANCELLED\'
AND ACV.DEL_LAST_INDEX = 1'; AND ACV.DEL_LAST_INDEX = 1';
$con = Propel::getConnection("workflow");
$stmt = $con->createStatement(); return $query;
$stmt->executeQuery($query);
CLI::logging("> Completed table LIST_CANCELED\n");
} }
/**
* Return query to populate my inbox list
*
* @return string
*
* @see \WorkspaceTools->migrateList()
*/
public function regenerateListMyInbox() public function regenerateListMyInbox()
{ {
$this->initPropel(true); $this->initPropel(true);
@@ -2607,12 +2653,16 @@ class WorkspaceTools
' . $this->dbName . '.USERS PRE_USR ON ACV.PREVIOUS_USR_UID = PRE_USR.USR_UID ' . $this->dbName . '.USERS PRE_USR ON ACV.PREVIOUS_USR_UID = PRE_USR.USR_UID
WHERE ACV.DEL_INDEX=1'; WHERE ACV.DEL_INDEX=1';
$con = Propel::getConnection("workflow"); return $query;
$stmt = $con->createStatement();
$stmt->executeQuery($query);
CLI::logging("> Completed table LIST_MY_INBOX\n");
} }
/**
* Return query to populate inbox list
*
* @return string
*
* @see \WorkspaceTools->migrateList()
*/
public function regenerateListInbox() public function regenerateListInbox()
{ {
$this->initPropel(true); $this->initPropel(true);
@@ -2665,12 +2715,17 @@ class WorkspaceTools
' . $this->dbName . '.USERS USR ON ACV.PREVIOUS_USR_UID = USR.USR_UID ' . $this->dbName . '.USERS USR ON ACV.PREVIOUS_USR_UID = USR.USR_UID
WHERE WHERE
ACV.DEL_THREAD_STATUS = \'OPEN\''; ACV.DEL_THREAD_STATUS = \'OPEN\'';
$con = Propel::getConnection("workflow");
$stmt = $con->createStatement(); return $query;
$stmt->executeQuery($query);
CLI::logging("> Completed table LIST_INBOX\n");
} }
/**
* Return query to populate participated history list
*
* @return string
*
* @see \WorkspaceTools->migrateList()
*/
public function regenerateListParticipatedHistory() public function regenerateListParticipatedHistory()
{ {
$this->initPropel(true); $this->initPropel(true);
@@ -2723,12 +2778,17 @@ class WorkspaceTools
' . $this->dbName . '.USERS CUR_USR ON ACV.USR_UID = CUR_USR.USR_UID ' . $this->dbName . '.USERS CUR_USR ON ACV.USR_UID = CUR_USR.USR_UID
LEFT JOIN LEFT JOIN
' . $this->dbName . '.USERS PRE_USR ON ACV.PREVIOUS_USR_UID = PRE_USR.USR_UID'; ' . $this->dbName . '.USERS PRE_USR ON ACV.PREVIOUS_USR_UID = PRE_USR.USR_UID';
$con = Propel::getConnection("workflow");
$stmt = $con->createStatement(); return $query;
$stmt->executeQuery($query);
CLI::logging("> Completed table LIST_PARTICIPATED_HISTORY\n");
} }
/**
* Return query to populate participated last list
*
* @return string
*
* @see \WorkspaceTools->migrateList()
*/
public function regenerateListParticipatedLast() public function regenerateListParticipatedLast()
{ {
$this->initPropel(true); $this->initPropel(true);
@@ -2804,10 +2864,18 @@ class WorkspaceTools
) ACV ) ACV
LEFT JOIN ' . $this->dbName . '.USERS PRE_USR ON ACV.PREVIOUS_USR_UID = PRE_USR.USR_UID LEFT JOIN ' . $this->dbName . '.USERS PRE_USR ON ACV.PREVIOUS_USR_UID = PRE_USR.USR_UID
LEFT JOIN ' . $this->dbName . '.USERS CUR_USR ON ACV.USR_UID = CUR_USR.USR_UID'; LEFT JOIN ' . $this->dbName . '.USERS CUR_USR ON ACV.USR_UID = CUR_USR.USR_UID';
$con = Propel::getConnection("workflow");
$stmt = $con->createStatement(); return $query;
$stmt->executeQuery($query); }
CLI::logging("> Inserted data into table LIST_PARTICIPATED_LAST\n");
/**
* Update participated last list
*
* @see \WorkspaceTools->migrateList()
*/
public function updateListParticipatedLast()
{
$this->initPropel(true);
$query = 'UPDATE ' . $this->dbName . '.LIST_PARTICIPATED_LAST LPL, ( $query = 'UPDATE ' . $this->dbName . '.LIST_PARTICIPATED_LAST LPL, (
SELECT SELECT
TASK.TAS_TITLE, TASK.TAS_TITLE,
@@ -2833,18 +2901,19 @@ class WorkspaceTools
LPL.DEL_CURRENT_USR_LASTNAME = IFNULL(USERS_VALUES.USR_LASTNAME, \'\'), LPL.DEL_CURRENT_USR_LASTNAME = IFNULL(USERS_VALUES.USR_LASTNAME, \'\'),
LPL.DEL_CURRENT_TAS_TITLE = IFNULL(USERS_VALUES.TAS_TITLE, \'\') LPL.DEL_CURRENT_TAS_TITLE = IFNULL(USERS_VALUES.TAS_TITLE, \'\')
WHERE LPL.APP_UID = USERS_VALUES.APP_UID'; WHERE LPL.APP_UID = USERS_VALUES.APP_UID';
CLI::logging("> Updating the current users data on table LIST_PARTICIPATED_LAST\n");
$con = Propel::getConnection("workflow"); $con = Propel::getConnection("workflow");
$stmt = $con->createStatement(); $stmt = $con->createStatement();
CLI::logging("> Updating the current users data on table LIST_PARTICIPATED_LAST\n");
$stmt->executeQuery($query); $stmt->executeQuery($query);
CLI::logging("> Completed table LIST_PARTICIPATED_LAST\n");
} }
/** /**
* This function overwrite the table LIST_PAUSED * Return query to populate paused list
* Get the principal information in the tables appDelay, appDelegation *
* For the labels we use the tables user, process, task and application * @return string
* @return void *
* @see \WorkspaceTools->migrateList()
*/ */
public function regenerateListPaused() public function regenerateListPaused()
{ {
@@ -2923,17 +2992,22 @@ class WorkspaceTools
APP_DELAY.APP_DISABLE_ACTION_USER = "0" AND APP_DELAY.APP_DISABLE_ACTION_USER = "0" AND
APP_DELAY.APP_TYPE = "PAUSE" APP_DELAY.APP_TYPE = "PAUSE"
'; ';
$con = Propel::getConnection("workflow");
$stmt = $con->createStatement(); return $query;
$stmt->executeQuery($query);
CLI::logging("> Completed table LIST_PAUSED\n");
} }
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
/**
* Return query to populate unassigned list
*
* @return string
*
* @see \WorkspaceTools->migrateList()
*/
public function regenerateListUnassigned() public function regenerateListUnassigned()
{ {
$this->initPropel(true); $this->initPropel(true);
$truncate = 'TRUNCATE ' . $this->dbName . '.LIST_UNASSIGNED';
//This executeQuery is very fast than Propel //This executeQuery is very fast than Propel
$query = 'INSERT INTO ' . $this->dbName . '.LIST_UNASSIGNED $query = 'INSERT INTO ' . $this->dbName . '.LIST_UNASSIGNED
(APP_UID, (APP_UID,
@@ -2977,11 +3051,8 @@ class WorkspaceTools
WHERE WHERE
ACV.DEL_THREAD_STATUS = \'OPEN\' ACV.DEL_THREAD_STATUS = \'OPEN\'
AND ACV.USR_UID = \'\' '; AND ACV.USR_UID = \'\' ';
$con = Propel::getConnection("workflow");
$stmt = $con->createStatement(); return $query;
$stmt->executeQuery($truncate);
$stmt->executeQuery($query);
CLI::logging("> Completed table LIST_UNASSIGNED\n");
} }
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/