This commit is contained in:
Paula V. Quispe
2016-07-22 10:59:13 -04:00
96 changed files with 3526 additions and 3133 deletions

View File

@@ -123,6 +123,12 @@ class workspaceTools
$this->processFilesUpgrade();
$stop = microtime(true);
CLI::logging("<*> Updating Files Manager took " . ($stop - $start) . " seconds.\n");
$start = microtime(true);
CLI::logging("> Optimizing content data...\n");
$this->migrateContent($workSpace, $lang);
$stop = microtime(true);
CLI::logging("<*> Optimizing content data took " . ($stop - $start) . " seconds.\n");
}
/**
@@ -3192,6 +3198,111 @@ class workspaceTools
return $response;
}
public function migrateContent($workspace, $lang = SYS_LANG) {
if ((!class_exists('Memcache') || !class_exists('Memcached')) && !defined('MEMCACHED_ENABLED')) {
define('MEMCACHED_ENABLED', false);
}
$this->initPropel(true);
$conf = new Configuration();
if (!$conf->exists('MIGRATED_CONTENT', 'content')) {
$data["CFG_UID"] ='MIGRATED_CONTENT';
$data["OBJ_UID"] ='content';
$data["CFG_VALUE"]='true';
$data["PRO_UID"] ='';
$data["USR_UID"] ='';
$data["APP_UID"] ='';
$this->migrateContentRun($workspace, $lang);
$conf->create($data);
}
}
/**
* Migrate this workspace table Content.
*
* @param $className
* @param $fields
* @param mixed|string $lang
* @throws Exception
*/
public function migrateContentWorkspace($className, $fields, $lang = SYS_LANG)
{
try {
$this->initPropel(true);
$fieldUidName = $fields['uid'];
$oCriteria = new Criteria();
$oCriteria->clearSelectColumns();
$oCriteria->addAsColumn($fieldUidName, ContentPeer::CON_ID);
$oCriteria->addSelectColumn(ContentPeer::CON_CATEGORY);
$oCriteria->addSelectColumn(ContentPeer::CON_VALUE);
$oCriteria->add(ContentPeer::CON_CATEGORY, $fields['fields'], Criteria::IN);
$oCriteria->add(ContentPeer::CON_LANG, $lang);
$oDataset = ContentPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$methods = $fields['methods'];
while ($oDataset->next()) {
$row = $oDataset->getRow();
$fieldName = $row['CON_CATEGORY'];
$fieldName = isset($fields['alias']) && isset($fields['alias'][$fieldName]) ? $fields['alias'][$fieldName] : $fieldName;
unset($row['CON_CATEGORY']);
$fieldValue = $row['CON_VALUE'];
unset($row['CON_VALUE']);
$row[$fieldName] = $fieldValue;
$oTable = new $className();
$mExists = $methods['exists'];
if ($oTable->$mExists($row[$fieldUidName])){
$oTable->update($row);
}
}
$classNamePeer = $className . 'Peer';
CLI::logging("|--> Add content data in table " . $classNamePeer::TABLE_NAME . "\n");
} catch (Exception $e) {
throw ($e);
}
}
public function migrateContentRun($workspace, $lang = SYS_LANG) {
if ((!class_exists('Memcache') || !class_exists('Memcached')) && !defined('MEMCACHED_ENABLED')) {
define('MEMCACHED_ENABLED', false);
}
$content = array(
'Groupwf' => array(
'uid' => 'GRP_UID',
'fields' => array('GRP_TITLE'),
'methods' => array('exists' => 'GroupwfExists')
),
'Process' => array(
'uid' => 'PRO_UID',
'fields' => array('PRO_TITLE', 'PRO_DESCRIPTION'),
'methods' => array('exists' => 'exists')
),
'Department' => array(
'uid' => 'DEP_UID',
'fields' => array('DEPO_TITLE'),
'alias' => array('DEPO_TITLE' => 'DEP_TITLE'),
'methods' => array('exists' => 'existsDepartment')
),
'Task' => array(
'uid' => 'TAS_UID',
'fields' => array('TAS_TITLE', 'TAS_DESCRIPTION', 'TAS_DEF_TITLE', 'TAS_DEF_SUBJECT_MESSAGE', 'TAS_DEF_PROC_CODE', 'TAS_DEF_MESSAGE', 'TAS_DEF_DESCRIPTION'),
'methods' => array('exists' => 'taskExists')
),
'InputDocument' => array(
'uid' => 'INP_DOC_UID',
'fields' => array('INP_DOC_TITLE', 'INP_DOC_DESCRIPTION'),
'methods' => array('exists' => 'InputExists')
),
'Application' => array(
'uid' => 'APP_UID',
'fields' => array('APP_TITLE', 'APP_DESCRIPTION'),
'methods' => array('exists' => 'exists')
)
);
foreach ($content as $className => $fields) {
$this->migrateContentWorkspace($className, $fields, $lang);
}
}
public function migrateIteeToDummytask($workspaceName){
$this->initPropel(true);
if (!defined("SYS_SYS")) {
@@ -3238,4 +3349,5 @@ class workspaceTools
CLI::logging($message);
}
>>>>>>> HOR-1259: Migrate Itee to Dummytask
}