This commit is contained in:
Paula Quispe
2018-07-18 10:17:29 -04:00
parent ad14fc7f0a
commit c45dc666ff
7 changed files with 200 additions and 235 deletions

View File

@@ -50,9 +50,6 @@ CLI::taskOpt("workspace", "Specify which workspace to restore if multiple worksp
Ex: -wworkflow.", "w:", "workspace=");
CLI::taskOpt("lang", "Specify the language which will be used to rebuild the case cache list. If this option isn't included, then 'en' (English) will be used by default.", "l:", "lang=");
CLI::taskOpt("port", "Specify the port number used by MySQL. If not specified, then the port 3306 will be used by default.", "p:");
/*----------------------------------********---------------------------------*/
CLI::taskOpt('keep_dyn_content', "Include the DYN_CONTENT_HISTORY value. Ex: --keep_dyn_content", 'd', 'keep_dyn_content');
/*----------------------------------********---------------------------------*/
CLI::taskRun("run_workspace_restore");
CLI::taskName('cacheview-repair');
@@ -356,9 +353,19 @@ EOT
);
CLI::taskArg('workspace');
CLI::taskRun('migrate_history_data');
CLI::taskOpt('keep_dyn_content', "Include the DYN_CONTENT_HISTORY value. Ex: --keep_dyn_content", 'i', 'keep_dyn_content');
/*----------------------------------********---------------------------------*/
/**
* Remove the DYN_CONTENT_HISTORY
*/
CLI::taskName('clear-dyn-content-history-data');
CLI::taskDescription(<<<EOT
Clear History of Use data from APP_HISTORY table
EOT
);
CLI::taskArg('workspace');
CLI::taskRun("run_clear_dyn_content_history_data");
/**
* Function run_info
*
@@ -1300,19 +1307,6 @@ function regenerate_pmtable_classes($args, $opts)
*/
function migrate_history_data($args, $opts)
{
foreach ($args as $key => $value) {
if ($args[$key] === '--keep_dyn_content' || $args[$key] === '-i') {
unset($args[$key]);
$opts['keep_dyn_content'] = '';
}
}
$option = '';
$removedDynContentHistory = true;
$exist = array_key_exists('keep_dyn_content', $opts);
if ($exist) {
$removedDynContentHistory = false;
$option = '--keep_dyn_content';
}
if (count($args) === 1) {
$start = microtime(true);
CLI::logging("> Migrating history data...\n");
@@ -1320,15 +1314,37 @@ function migrate_history_data($args, $opts)
Bootstrap::setConstantsRelatedWs($args[0]);
$workspaceTools = new WorkspaceTools($args[0]);
$workspaceTools->migrateAppHistoryToAppDataChangeLog(true, $removedDynContentHistory);
$workspaceTools->migrateAppHistoryToAppDataChangeLog(true);
$stop = microtime(true);
CLI::logging("<*> Migrating history data took " . ($stop - $start) . " seconds.\n");
} else {
$workspaces = get_workspaces_from_args($args);
foreach ($workspaces as $workspace) {
passthru(PHP_BINARY . ' processmaker migrate-history-data ' . $workspace->name . ' ' . $option);
passthru(PHP_BINARY . ' processmaker migrate-history-data ' . $workspace->name);
}
}
}
/*----------------------------------********---------------------------------*/
/**
* Will be clean the History of use from the table
* Will be remove the DYN_CONTENT_HISTORY from APP_HISTORY
*
* @param array $args
* @param array $opts
*
* @return void
*/
function run_clear_dyn_content_history_data($args, $opts)
{
$workspaces = get_workspaces_from_args($args);
$start = microtime(true);
CLI::logging("> Cleaning history data from APP_HISTORY...\n");
foreach ($workspaces as $workspace) {
CLI::logging('Remove history of use: ' . pakeColor::colorize($workspace->name, 'INFO') . "\n");
$workspace->clearDynContentHistoryData(true);
}
$stop = microtime(true);
CLI::logging("<*> Cleaning history data from APP_HISTORY process took " . ($stop - $start) . " seconds.\n");
}

View File

@@ -898,7 +898,6 @@ class Cases
$appHistory = new AppHistory();
$aFieldsHistory = $Fields;
$appDataWithoutDynContentHistory = serialize($FieldsDifference);
$FieldsDifference['DYN_CONTENT_HISTORY'] = base64_encode($currentDynaform["DYN_CONTENT"]);
$aFieldsHistory['APP_DATA'] = serialize($FieldsDifference);
$appHistory->insertHistory($aFieldsHistory);

View File

@@ -51,12 +51,6 @@ class PmDynaform
if (is_array($this->fields) && !isset($this->fields["APP_UID"])) {
$this->fields["APP_UID"] = null;
}
if (isset($this->fields["APP_DATA"]["DYN_CONTENT_HISTORY"])) {
$decode = base64_decode($this->fields["APP_DATA"]["DYN_CONTENT_HISTORY"], true);
if ($decode !== false) {
$this->record["DYN_CONTENT"] = $decode;
}
}
//todo: compatibility checkbox
if ($this->record !== null && isset($this->record["DYN_CONTENT"]) && $this->record["DYN_CONTENT"] !== "") {

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
INSERT INTO USERS (USR_UID,USR_USERNAME,USR_PASSWORD,USR_FIRSTNAME,USR_LASTNAME,USR_EMAIL,USR_DUE_DATE,USR_CREATE_DATE,USR_UPDATE_DATE,USR_STATUS,USR_COUNTRY,USR_CITY,USR_LOCATION,USR_ADDRESS,USR_PHONE,USR_FAX,USR_CELLULAR,USR_ZIP_CODE,DEP_UID,USR_POSITION,USR_RESUME,USR_BIRTHDAY,USR_ROLE,USR_REPORTS_TO,USR_REPLACED_BY ) VALUES
INSERT INTO USERS (USR_UID,USR_USERNAME,USR_PASSWORD,USR_FIRSTNAME,USR_LASTNAME,USR_EMAIL,USR_DUE_DATE,USR_CREATE_DATE,USR_UPDATE_DATE,USR_STATUS,USR_COUNTRY,USR_CITY,USR_LOCATION,USR_ADDRESS,USR_PHONE,USR_FAX,USR_CELLULAR,USR_ZIP_CODE,DEP_UID,USR_POSITION,USR_RESUME,USR_BIRTHDAY,USR_ROLE,USR_REPORTS_TO,USR_REPLACED_BY ) VALUES
('00000000000000000000000000000001','admin','21232f297a57a5a743894a0e4a801fc3','Administrator',' ', 'admin@processmaker.com','2020-01-01','1999-11-30 00:00:00','2008-05-23 18:36:19','ACTIVE', 'US','FL','MMK','','', '1-305-402-0282','1-305-675-1400','','','Administrator', '','1999-02-25','PROCESSMAKER_ADMIN','',''),
('00000000000000000000000000000002','guest','674ba9750749d735ec9787d606170d78','Guest',' ', 'guest@processmaker.com','2030-01-01','2009-02-01 12:24:36','2009-02-01 12:24:36','INACTIVE', 'US','FL','MMK','','', '1-305-402-0282','1-305-675-1400','','','Guest', '','2009-02-01','PROCESSMAKER_GUEST','','');
@@ -61540,6 +61540,7 @@ INSERT INTO DASHLET_INSTANCE (DAS_INS_UID,DAS_UID,DAS_INS_OWNER_TYPE,DAS_INS_OWN
INSERT INTO CONFIGURATION (CFG_UID,OBJ_UID,CFG_VALUE,PRO_UID,USR_UID,APP_UID) VALUES
('AUDIT_LOG','log','s:5:"false";','','',''),
('CLEAN_DYN_CONTENT_HISTORY', 'history', 'a:1:{s:7:\"updated\";b:1;}', '', '', ''),
('ENTERPRISE_SETTING_ENCRYPT','','a:2:{s:7:"current";s:6:"sha256";s:8:"previous";s:3:"md5";}','','',''),
('ENVIRONMENT_SETTINGS','','a:1:{s:18:"directoryStructure";i:2;}','','',''),
('MIGRATED_APP_HISTORY', 'history', 'a:1:{s:7:\"updated\";b:1;}', '', '', ''),

View File

@@ -1131,70 +1131,4 @@ class DynaForm
throw $e;
}
}
/**
* Get data of a DynaForm History
*
* @param string $dynaFormUid Unique id of DynaForm
*
* return array Return an array with data of a DynaForm History
*/
public function getDynaFormHistory($prj_uid, $dynaFormUid, array $arrayData = array())
{
try {
$filter = "";
if (isset($arrayData["filter"])) {
$filter = $arrayData["filter"];
}
$start = 0;
if (isset($arrayData["start"])) {
$start = $arrayData["start"];
}
$limit = 50;
if (isset($arrayData["limit"])) {
$limit = $arrayData["limit"];
}
$this->throwExceptionIfNotExistsDynaForm($dynaFormUid, "", $this->arrayFieldNameForException["dynaFormUid"]);
$criteria = new \Criteria("workflow");
$subcriteria = $criteria->getNewCriterion(\AppHistoryPeer::HISTORY_DATE, "%" . $filter . "%", \Criteria::LIKE);
$criteria->addSelectColumn(\AppHistoryPeer::DYN_UID);
$criteria->addSelectColumn(\AppHistoryPeer::HISTORY_DATA);
$criteria->addSelectColumn(\AppHistoryPeer::HISTORY_DATE);
$criteria->addAnd(\AppHistoryPeer::DYN_UID, $dynaFormUid, \Criteria::EQUAL);
$criteria->addAnd(\AppHistoryPeer::OBJ_TYPE, "DYNAFORM", \Criteria::EQUAL);
$criteria->addAnd(\AppHistoryPeer::HISTORY_DATA, "%DYN_CONTENT_HISTORY%", \Criteria::LIKE);
$criteria->addAnd($subcriteria);
$criteria->addDescendingOrderByColumn(\AppHistoryPeer::HISTORY_DATE);
$criteria->setOffset($start);
$criteria->setLimit($limit);
$rsCriteria = \AppHistoryPeer::doSelectRS($criteria);
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$data = array();
while ($rsCriteria->next()) {
$row = $rsCriteria->getRow();
$d = @unserialize($row["HISTORY_DATA"]);
$jsonData = "";
if (isset($d["DYN_CONTENT_HISTORY"])) {
$decode = base64_decode($d["DYN_CONTENT_HISTORY"], true);
if ($decode !== false) {
$jsonData = $decode;
}
}
$data[] = array(
"history_date" => $row["HISTORY_DATE"],
"dyn_uid" => $row["DYN_UID"],
"dyn_content_history" => $jsonData
);
}
return $data;
} catch (\Exception $e) {
throw $e;
}
}
}

View File

@@ -220,33 +220,4 @@ class DynaForm extends Api
}
}
/**
* Get Dynaform's history.
*
* @url POST /:prj_uid/dynaform/:dyn_uid/history
*
* @param string $dyn_uid {@min 32}{@max 32}
* @param string $prj_uid {@min 32}{@max 32}
* @param array $request_data
*
* @return array
* @throws RestException
*
* @access protected
* @class AccessControl {@permission PM_FACTORY}
*/
public function doGetDynaFormHistory($dyn_uid, $prj_uid, $request_data)
{
try {
$dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
$dynaForm->setFormatFieldNameInUppercase(false);
$response = $dynaForm->getDynaFormHistory($prj_uid, $dyn_uid, $request_data);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
}