Now is possible upgrade the data in the tables, DASHLET is the first

This commit is contained in:
Julio Cesar Laura
2011-11-08 17:37:47 -04:00
parent 9b3921665f
commit 152ab8be7b
6 changed files with 2280 additions and 2206 deletions

View File

@@ -129,7 +129,7 @@ CLI::taskDescription(<<<EOT
If no workspace is specified, the command will be run in all workspaces. More
than one workspace can be specified.
This command is a shortcut to execute all upgrade commands for workspaces.
Upgrading a workspace will make it correspond to the current version of
ProcessMaker.
@@ -147,7 +147,7 @@ CLI::taskDescription(<<<EOT
If no workspace is specified, the command will be run in all workspaces. More
than one workspace can be specified.
This command will go through each language installed in ProcessMaker and
update this workspace translations to match the current version of
ProcessMaker.
@@ -257,7 +257,7 @@ function database_upgrade($command, $args) {
echo "- Indexes (add = " . count($changes['tablesWithNewIndex'])."";
echo ", alter = " . count($changes['tablesToAlterIndex']).")\n";
} else {
echo "> Schema fixed\n";
echo "-> Schema fixed\n";
}
} else {
echo "> OK\n";
@@ -276,11 +276,11 @@ function delete_app_from_table($con, $tableName, $appUid, $col="APP_UID") {
function run_drafts_clean($args, $opts) {
echo "Cleaning drafts\n";
if (count($args) < 1)
throw new Exception ("Please specify a workspace name");
$workspace = $args[0];
if (!file_exists(PATH_DB . $workspace . '/db.php')) {
throw new Exception('Could not find workspace ' . $workspace);
}
@@ -388,7 +388,7 @@ function run_workspace_backup($args, $opts) {
CLI::logging("\n");
$workspace->printMetadata(false);
}
}
function run_workspace_restore($args, $opts) {

File diff suppressed because it is too large Load Diff

View File

@@ -2,13 +2,13 @@
/**
* Utility functions to manage a workspace.
*
* @author Alexandre Rosenfeld
* @author Alexandre Rosenfeld
*/
G::LoadSystem('dbMaintenance');
G::LoadClass("cli");
/**
/**
* class workspaceTools
* @package workflow.engine.classes
*/
@@ -129,7 +129,7 @@ class workspaceTools {
* Reset the database information to that of a newly created workspace.
*
* This assumes this workspace already has a db.php file, which will be changed
* to contain the new information.
* to contain the new information.
* This function will reset the database hostname to the system database.
* If reseting database names, it will also use the the prefixes rp_,
* rb_ and wf_, with the workspace name as database names.
@@ -445,7 +445,7 @@ class workspaceTools {
$oCriteria = new Criteria();
$oCriteria->add(ConfigurationPeer::CFG_UID,'casesList');
ConfigurationPeer::doDelete($oCriteria);
// end of reset
// end of reset
}
/**
@@ -470,6 +470,7 @@ class workspaceTools {
public function upgradeDatabase($checkOnly = false) {
$systemSchema = System::getSystemSchema();
$this->upgradeSchema($systemSchema);
$this->upgradeData();
return true;
}
@@ -499,7 +500,7 @@ class workspaceTools {
if ($changed) {
return $changes;
} else {
CLI::logging("-> Nothing to change\n");
CLI::logging("-> Nothing to change in the data base structure\n");
return $changed;
}
}
@@ -560,6 +561,51 @@ class workspaceTools {
return true;
}
public function upgradeData() {
if (file_exists(PATH_CORE . 'data' . PATH_SEP . 'check.data')) {
$checkData = @unserialize(file_get_contents(PATH_CORE . 'data' . PATH_SEP . 'check.data'));
if (is_array($checkData)) {
foreach ($checkData as $checkThis) {
$this->updateThisRegistry($checkThis);
}
}
}
}
public function updateThisRegistry($data) {
$dataBase = $this->getDatabase();
$sql = '';
switch ($data['action']) {
case 1:
$sql = $dataBase->generateInsertSQL($data['table'], $data['data']);
$message = "-> Row added in {$data['table']}\n";
break;
case 2:
$sql = $dataBase->generateUpdateSQL($data['table'], $data['keys'], $data['data']);
$message = "-> Row updated in {$data['table']}\n";
break;
case 3:
$sql = $dataBase->generateDeleteSQL($data['table'], $data['keys'], $data['data']);
$message = "-> Row deleted in {$data['table']}\n";
break;
case 4:
$sql = $dataBase->generateSelectSQL($data['table'], $data['keys'], $data['data']);
$result = $dataBase->executeQuery($sql);
if (!$result) {
$sql = $dataBase->generateInsertSQL($data['table'], $data['data']);
$message = "-> Row updated in {$data['table']}\n";
}
else {
$sql = '';
}
break;
}
if ($sql != '') {
$dataBase->executeQuery($sql);
CLI::logging($message);
}
}
/**
* Get metadata from this workspace
*
@@ -607,9 +653,9 @@ class workspaceTools {
return $Fields;
}
/**
/**
* Print the system information gathered from getSysInfo
*/
*/
public static function printSysInfo() {
$fields = System::getSysInfo();
@@ -776,7 +822,7 @@ class workspaceTools {
CLI::logging("Copying database to backup...\n");
$this->addToBackup($backup, $tempDirectory, $tempDirectory);
CLI::logging("Copying files to backup...\n");
$this->addToBackup($backup, $this->path, $this->path, "{$this->name}.files");
//Remove leftovers.
G::rm_dir($tempDirectory);
@@ -821,7 +867,7 @@ class workspaceTools {
//TODO: Move to class.dbMaintenance.php
/**
* executes a mysql script
*
*
* This function supports scripts with -- comments in the beginning of a line
* and multi-line statements.
* It does not support other forms of comments (such as /*... or {{...}}).
@@ -879,7 +925,7 @@ class workspaceTools {
$metafiles[] = "$tempDirectory/$filename";
}
}
CLI::logging("Found " . count($metafiles) . " workspace(s) in backup\n");
foreach ($metafiles as $metafile) {
@@ -995,7 +1041,7 @@ class workspaceTools {
throw new Exception('Could not connect to system database: ' . mysql_error());
$newDBNames = $workspace->resetDBInfo($dbHost, $createWorkspace);
foreach ($metadata->databases as $db) {
$dbName = $newDBNames[$db->name];
CLI::logging("+> Restoring database {$db->name} to $dbName\n");
@@ -1003,7 +1049,7 @@ class workspaceTools {
$workspace->createDBUser($dbName, $db->pass, "localhost", $dbName);
$workspace->createDBUser($dbName, $db->pass, "%", $dbName);
}
$workspace->upgradeCacheView(false);
mysql_close($link);

View File

@@ -0,0 +1 @@
a:1:{i:0;a:5:{s:2:"db";s:2:"wf";s:5:"table";s:7:"DASHLET";s:4:"keys";a:1:{i:0;s:7:"DAS_UID";}s:4:"data";a:8:{i:0;a:3:{s:5:"field";s:7:"DAS_UID";s:4:"type";s:4:"text";s:5:"value";s:32:"00000000000000000000000000000001";}i:1;a:3:{s:5:"field";s:9:"DAS_CLASS";s:4:"type";s:4:"text";s:5:"value";s:22:"dashletOpenVSCompleted";}i:2;a:3:{s:5:"field";s:9:"DAS_TITLE";s:4:"type";s:4:"text";s:5:"value";s:29:"Open Cases VS Completed Cases";}i:3;a:3:{s:5:"field";s:15:"DAS_DESCRIPTION";s:4:"type";s:4:"text";s:5:"value";s:29:"Open Cases VS Completed Cases";}i:4;a:3:{s:5:"field";s:11:"DAS_VERSION";s:4:"type";s:4:"text";s:5:"value";s:3:"1.0";}i:5;a:3:{s:5:"field";s:15:"DAS_CREATE_DATE";s:4:"type";s:4:"date";s:5:"value";s:20:" 2011-10-28 00:00:00";}i:6;a:3:{s:5:"field";s:15:"DAS_UPDATE_DATE";s:4:"type";s:4:"date";s:5:"value";s:20:" 2011-10-28 00:00:00";}i:7;a:3:{s:5:"field";s:10:"DAS_STATUS";s:4:"type";s:3:"int";s:5:"value";i:1;}}s:6:"action";i:4;}}