Author: david
Date: Fri Apr 1 17:48:49 2011
New Revision: 9057
Log:
Add skeleton for 1.2 migrations
Added:
trunk/lib/task/migrate/QubitMigrate110.class.php
- copied, changed from r9054,
trunk/lib/task/migrate/QubitMigrate109.class.php
Modified:
trunk/lib/task/migrate/MigrateTask.class.php
trunk/lib/task/migrate/QubitMigrator.class.php
Modified: trunk/lib/task/migrate/MigrateTask.class.php
==============================================================================
--- trunk/lib/task/migrate/MigrateTask.class.php Fri Apr 1 17:19:35
2011 (r9056)
+++ trunk/lib/task/migrate/MigrateTask.class.php Fri Apr 1 17:48:49
2011 (r9057)
@@ -36,7 +36,8 @@
'1.0.7',
'1.0.8',
'1.0.9',
- '1.1'
+ '1.1',
+ '1.2'
);
/**
@@ -144,6 +145,10 @@
$migrator->migrate109();
$this->logSection('migrate', 'Data migrated to version 1.1');
break;
+ case '1.1.0':
+ $migrator->migrate110();
+ $this->logSection('migrate', 'Data migrated to version 1.2');
+ break;
}
}
}
Copied and modified: trunk/lib/task/migrate/QubitMigrate110.class.php (from
r9054, trunk/lib/task/migrate/QubitMigrate109.class.php)
==============================================================================
--- trunk/lib/task/migrate/QubitMigrate109.class.php Fri Apr 1 00:02:56
2011 (r9054, copy source)
+++ trunk/lib/task/migrate/QubitMigrate110.class.php Fri Apr 1 17:48:49
2011 (r9057)
@@ -18,208 +18,26 @@
*/
/**
- * Upgrade qubit data from version 1.0.9 to 1.1 schema
+ * Upgrade qubit version 1.1 data for version 1.2 schema
*
* @package qubit
* @subpackage migration
* @version svn: $Id$
* @author David Juhasz <[email protected]>
*/
-class QubitMigrate109 extends QubitMigrate
+class QubitMigrate110 extends QubitMigrate
{
/**
* Controller for calling methods to alter data
*
- * @return QubitMigrate109 this object
+ * @return QubitMigrate110 this object
*/
protected function alterData($version)
{
switch ($version)
{
- case 39:
- $this->updateStaticPageVersionNumber();
-
- case 40:
- $this->mergeTermAltLabels();
-
- case 41:
- $this->renameEquivalenceTermConstant();
-
- case 42:
- $this->activateEacIsaarIsdiahAndSkosPlugins();
-
- case 43:
- $this->updateTaxonomyPaths();
-
- case 44:
- $this->addCheckForUpdatesSetting();
-
- case 45:
- $this->updateFunctionRelationTaxonomyName();
-
- case 46:
- $this->guessSourceStandard();
-
- case 47:
- $this->addExplodeMultipageFilesSetting();
-
- case 48:
- $this->addShowTooltipsSetting();
-
- case 49:
- $this->addFunctionUiLabel();
-
- case 50:
- $this->addDescriptionUpdatesToAdminMenu();
-
- case 51:
- $this->addDefaultPubStatusSetting();
-
- case 52:
- $this->setPubStatusExplictly();
-
- case 53:
- $this->activateIsdfPlugin();
-
- case 54:
-
- // Replace "permalink" property with "slug"
- foreach ($this->data['QubitStaticPage'] as $key => $value)
- {
- if (isset($value['permalink']))
- {
- $this->data['QubitStaticPage'][$key]['slug'] = $value['permalink'];
- if ('homepage' == $value['permalink'])
- {
- $this->data['QubitStaticPage'][$key]['slug'] = 'home';
- }
-
- unset($this->data['QubitStaticPage'][$key]['permalink']);
- }
- }
-
- case 55:
-
- // Update "home" and "about" links
- foreach ($this->data['QubitMenu'] as $key => $value)
- {
- switch (@$value['path'])
- {
- case 'staticpage/static?permalink=about':
- $this->data['QubitMenu'][$key]['path'] =
'staticpage/index?slug=about';
-
- break;
-
- case 'staticpage/static?permalink=homepage':
- $this->data['QubitMenu'][$key]['path'] = '@homepage';
-
- break;
- }
- }
-
- case 56:
-
- foreach ($this->data['QubitMenu'] as $key => $value)
- {
- if (isset($value['path']))
- {
- $this->data['QubitMenu'][$key]['path'] =
str_replace(array('create', 'duplicate'), array('add', 'copy'), $value['path']);
- }
- }
-
- case 57:
-
- // Update tab links in user module
- foreach ($this->data['QubitMenu'] as $key => $value)
- {
- switch (@$value['path'])
- {
- case 'user/index?id=%currentId%':
- $this->data['QubitMenu'][$key]['path'] =
'user/index?slug=%currentSlug%';
-
- break;
-
- case 'user/indexInformationObjectAcl?id=%currentId%':
- $this->data['QubitMenu'][$key]['path'] =
'user/indexInformationObjectAcl?slug=%currentSlug%';
-
- break;
-
- case 'user/indexActorAcl?id=%currentId%':
- $this->data['QubitMenu'][$key]['path'] =
'user/indexActorAcl?slug=%currentSlug%';
-
- break;
-
- case 'user/indexTermAcl?id=%currentId%':
- $this->data['QubitMenu'][$key]['path'] =
'user/indexTermAcl?slug=%currentSlug%';
-
- break;
- }
- }
-
- case 58:
-
- if (isset($this->data['QubitEvent']))
- {
- foreach ($this->data['QubitEvent'] as $key => $value)
- {
- if (isset($value['date_display']))
- {
- $this->data['QubitEvent'][$key]['date'] = $value['date_display'];
-
- unset($this->data['QubitEvent'][$key]['date_display']);
- }
- }
- }
-
- case 59:
-
- if (isset($this->data['QubitEvent']))
- {
- foreach ($this->data['QubitEvent'] as $key => $value)
- {
- if (isset($value['date']))
- {
- foreach ($value['date'] as $culture => $date)
- {
- if (0 == strlen($date))
- {
- unset($this->data['QubitEvent'][$key]['date'][$culture]);
- }
- }
-
- if (0 == count($this->data['QubitEvent'][$key]['date']))
- {
- unset($this->data['QubitEvent'][$key]['date']);
- }
- }
-
- if ('0000-00-00' == @$value['end_date'])
- {
- unset($this->data['QubitEvent'][$key]['end_date']);
- }
-
- if ('0000-00-00' == @$value['start_date'])
- {
- unset($this->data['QubitEvent'][$key]['start_date']);
- }
- }
- }
-
- case 60:
-
- if (isset($ths->data['QubitEvent']))
- {
- foreach ($this->data['QubitEvent'] as $key => $value)
- {
- if (!isset($value['end_date']) && isset($value['start_date']))
- {
- $this->data['QubitEvent'][$key]['end_date'] =
$value['start_date'];
- }
- }
- }
-
- case 61:
- $this->renameRelationNoteDateConstant();
+ case 62:
+ // Place holder
}
// Delete "stub" objects
@@ -266,7 +84,7 @@
/**
* Call all sort methods
*
- * @return QubitMigrate109 this object
+ * @return QubitMigrate110 this object
*/
protected function sortData()
{
@@ -308,434 +126,10 @@
}
/**
- * Ver 40: Update static page release number to 1.1
- *
- * @return QubitMigrate109 this object
- */
- protected function updateStaticPageVersionNumber()
- {
- // Update version number
- foreach ($this->data['QubitStaticPage'] as $key => $page)
- {
- if ($page['permalink'] == 'homepage' || $page['permalink'] == 'about')
- {
- array_walk($this->data['QubitStaticPage'][$key]['content'],
create_function('&$x', '$x=preg_replace(\'/1\\.0\\.9/\', \'1.1\', $x);'));
- }
- }
-
- return $this;
- }
-
- /**
- * Ver 41: Merge alternate labels from related terms into other_name table
- *
- * @return QubitMigrate109 this object
- */
- protected function mergeTermAltLabels()
- {
- $eqKey = $this->getRowKey('QubitTerm', 'id', '<?php echo
QubitTerm::TERM_RELATION_EQUIVALENCE_ID."\n" ?>');
-
- if (!$eqKey)
- {
- return $this;
- }
-
- foreach ($this->data['QubitRelation'] as $key => $row)
- {
- if (!isset($row['type_id']) || $eqKey != $row['type_id'] || null ===
$eqTerm = $this->data['QubitTerm'][$row['object_id']])
- {
- continue;
- }
-
- $otherName = array(
- 'object_id' => $row['subject_id'],
- 'type_id' => $row['type_id'],
- 'source_culture' => $eqTerm['source_culture'],
- 'name' => $eqTerm['name']
- );
-
- $this->data['QubitOtherName'][rand()] = $otherName;
- unset($this->data['QubitRelation'][$key]);
- unset($this->data['QubitTerm'][$row['object_id']]);
- }
-
- return $this;
- }
-
- /**
- * Ver 42: Change Term constant "TERM_RELATION_EQUIVALENCE_ID" to
- * "ALTERNATIVE_LABEL_ID"
- *
- * @return QubitMigrate109 this object
- */
- protected function renameEquivalenceTermConstant()
- {
- if ($key = $this->getRowKey('QubitTerm', 'id', '<?php echo
QubitTerm::TERM_RELATION_EQUIVALENCE_ID."\n" ?>'))
- {
- $this->data['QubitTerm'][$key]['id'] = '<?php echo
QubitTerm::ALTERNATIVE_LABEL_ID."\n" ?>';
- $this->data['QubitTerm'][$key]['source_culture'] = 'en';
- $this->data['QubitTerm'][$key]['name'] = array('en' => 'alternative
label');
- }
-
- return $this;
- }
-
- /**
- * Ver 43: Activate sfEacPlugin, sfIsaarPlugin, sfIsdiahPlugin
- * and sfSkosPlugin plugins
- *
- * @return QubitMigrate109 this object
- */
- protected function activateEacIsaarIsdiahAndSkosPlugins()
- {
- $plugins = array('sfEacPlugin', 'sfIsaarPlugin', 'sfIsdiahPlugin',
'sfSkosPlugin');
-
- // Find setting
- $found = false;
- foreach ($this->data['QubitSetting'] as $key => $value)
- {
- if ('plugins' == $value['name'])
- {
- // Found setting, add new plugins
- $found = true;
- $this->data['QubitSetting'][$key]['value'][$value['source_culture']] =
serialize(array_unique(array_merge(unserialize($value['value'][$value['source_culture']]),
$plugins)));
-
- break;
- }
- }
-
- if (!$found)
- {
- // No setting, add one
- $value = array();
- $value['name'] = 'plugins';
- $value['source_culture'] = 'en';
- $value['value']['en'] = serialize($plugins);
-
- $this->data['QubitSetting'][rand()] = $value;
- }
- }
-
- /**
- * Ver 44: Update taxonomy paths like revision 7131 and 7132
- *
- * @return QubitMigrate109 this object
- */
- protected function updateTaxonomyPaths()
- {
- if ($key = $this->getRowKey('QubitMenu', 'path', 'term/list'))
- {
- $this->data['QubitMenu'][$key]['path'] = 'taxonomy/list';
- }
-
- foreach ($this->data['QubitMenu'] as $key => $row)
- {
- if (isset($row['path']) && null !== strpos($row['path'],
'term/browseTaxonomy'))
- {
- $this->data['QubitMenu'][$key]['path'] =
str_replace('term/browseTaxonomy', 'taxonomy/browse', $row['path']);
- }
- }
- }
-
- /**
- * Ver 45: Add check_for_updates QubitSetting
- *
- * @return QubitMigrate109 this object
- */
- protected function addCheckForUpdatesSetting()
- {
- if (false === $this->getRowKey('QubitSetting', 'name',
'QubitSetting_checkForUpdates'))
- {
- $this->data['QubitSetting']['QubitSetting_checkForUpdates'] = array(
- 'name' => 'check_for_updates',
- 'value' => 1
- );
- }
-
- return $this;
- }
-
- /**
- * Ver 46: Change taxonomy name "ISDF Relation Type" -> "Function Relation
- * Type"
- *
- * @return QubitMigrate109 this object
- */
- protected function updateFunctionRelationTaxonomyName()
- {
- if ($key = $this->getRowKey('QubitTaxonomy', 'name', array('en' => 'ISDF
Relation Type')))
- {
- $this->data['QubitTaxonomy'][$key]['name']['en'] = 'Function Relation
Type';
- }
-
- return $this;
- }
-
- /**
- * Ver 47: Make an educated guess at source_standard for legacy data
- *
- * @return QubitMigrate109 this object
- */
- protected function guessSourceStandard()
- {
- $standards = array(
- 'dc' => 'Dublin Core Simple version 1.1',
- 'isad' => 'ISAD(G) 2nd edition',
- 'isaar' => 'ISAAR(CPF) 2nd edition',
- 'isdiah' => 'ICA-ISDIAH 1st edition',
- 'mods' => 'MODS version 3.3',
- 'rad' => 'RAD version Jul2008'
- );
-
- foreach ($this->data['QubitSetting'] as $key => $row)
- {
- if (isset($row['scope']) && 'default_template' != $row['scope'])
- {
- continue;
- }
-
- switch ($row['name'])
- {
- case 'informationobject':
- $className = 'QubitInformationObject';
- $standard = $standards['isad'];
- break;
-
- case 'actor':
- $className = 'QubitActor';
- $standard = $standards['isaar'];
- break;
-
- case 'repository':
- $className = 'QubitRepository';
- $standard = $standards['isdiah'];
- break;
-
- default:
- continue;
- }
-
- if (isset($row['value']['en']) && isset($standards[$row['value']['en']]))
- {
- $standard = $standards[$row['value']['en']];
- }
-
- if (isset($className))
- {
- foreach ($this->data[$className] as $key2 => $row2)
- {
- if (!isset($row2['source_standard']) && false ===
strpos(@$row2['id'], 'ROOT_ID') && !in_array(@$row2['id'],
array(QubitInformationObject::ROOT_ID, QubitActor::ROOT_ID,
QubitRepository::ROOT_ID)))
- {
- $this->data[$className][$key2]['source_standard'] = $standard;
- }
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Ver 48: Add explode_multipage_files QubitSetting
- *
- * @return QubitMigrate109 this object
- */
- protected function addExplodeMultipageFilesSetting()
- {
- if (false === $this->getRowKey('QubitSetting', 'name',
'QubitSetting_explodeMultipageFiles'))
- {
- $this->data['QubitSetting']['QubitSetting_explodeMultipageFiles'] =
array(
- 'name' => 'explode_multipage_files',
- 'value' => 0
- );
- }
-
- return $this;
- }
-
- /**
- * Ver 49: Add show_tooltips QubitSetting
- *
- * @return QubitMigrate109 this object
- */
- protected function addShowTooltipsSetting()
- {
- if (false === $this->getRowKey('QubitSetting', 'name',
'QubitSetting_showTooltips'))
- {
- $this->data['QubitSetting']['QubitSetting_showTooltips'] = array(
- 'name' => 'show_tooltips',
- 'value' => 1
- );
- }
-
- return $this;
- }
-
- /**
- * Ver 50: Add "function" UI label QubitSetting
- *
- * @return QubitMigrate109 this object
- */
- protected function addFunctionUiLabel()
- {
- $this->data['QubitSetting']['function_ui_label'] = array(
- 'name' => 'function',
- 'scope' => 'ui_label',
- 'editable' => 1,
- 'deleteable' => 0,
- 'source_culture' => 'en',
- 'value' => array(
- 'en' => 'Function',
- 'es' => 'Función',
- 'fr' => 'Fonction',
- 'pt' => 'Funçao'));
-
- return $this;
- }
-
- /**
- * Ver 51: Add descriptionUpdates to Admin menu
- *
- * @return QubitMigrate109 this object
- */
- protected function addDescriptionUpdatesToAdminMenu()
- {
- // $recentUpdatesMenu = array(
- $this->data['QubitMenu']['QubitMenu_admin_descriptionUpdates'] = array(
- 'parent_id' => '<?php echo QubitMenu::ADMIN_ID."\n" ?>',
- 'source_culture' => 'en',
- 'name' => 'descriptionUpdates',
- 'label' => array('en' => 'Description updates'),
- 'path' => 'search/descriptionUpdates');
-
- return $this;
- }
-
- /**
- * Ver 52: Add default publication status with initial value "draft"
- *
- * @return QubitMigrate109 this object
- */
- protected function addDefaultPubStatusSetting()
- {
- $this->data['QubitSetting']['QubitSetting_default_pub_status'] = array(
- 'name' => 'defaultPubStatus',
- 'editable' => 1,
- 'value' => '<?php echo QubitTerm::PUBLICATION_STATUS_DRAFT_ID."\n" ?>'
- );
-
- return $this;
- }
-
- /**
- * Ver 53: Explicitly set publication status on all info objects
- *
- * @return QubitMigrate109 this object
- */
- protected function setPubStatusExplictly()
- {
- foreach ($this->data['QubitInformationObject'] as $key => $item)
- {
- if (false === $this->getRowKey('QubitStatus', 'object_id', $key))
- {
- $keys = array($key);
-
- // Build array of all descriptions from the current one until we reach
- // an ancestor with a publication status
- while
(isset($this->data['QubitInformationObject'][$keys[0]]['parent_id']))
- {
- $parentKey =
$this->data['QubitInformationObject'][$keys[0]]['parent_id'];
- $statusKey = $this->getRowKey('QubitStatus', 'object_id',
$parentKey);
-
- if ($statusKey)
- {
- break;
- }
- else
- {
- array_unshift($keys, $parentKey);
- }
- }
-
- // Duplicate ancestor's publication status
- if ($statusKey)
- {
- $status = array();
- $status['type_id'] =
$this->data['QubitStatus'][$statusKey]['type_id'];
- $status['status_id'] =
$this->data['QubitStatus'][$statusKey]['status_id'];
-
- // Assign status to all descendents in $keys stack
- while (0 < count($keys))
- {
- $status['object_id'] = array_shift($keys);
-
- $this->data['QubitStatus']["QubitStatus_{$status['object_id']}"] =
$status;
- }
- }
- }
- }
-
- return $this;
- }
-
- /**
- * Ver 54: Activate sfIsdfPlugin plugin
- *
- * @return QubitMigrate109 this object
- */
- protected function activateIsdfPlugin()
- {
- $plugin = array('sfIsdfPlugin');
-
- // Find setting
- $found = false;
- foreach ($this->data['QubitSetting'] as $key => $value)
- {
- if ('plugins' == $value['name'])
- {
- // Found setting, add new plugins
- $found = true;
- $this->data['QubitSetting'][$key]['value'][$value['source_culture']] =
serialize(array_unique(array_merge(unserialize($value['value'][$value['source_culture']]),
$plugin)));
-
- break;
- }
- }
-
- if (!$found)
- {
- // No setting, add one
- $value = array();
- $value['name'] = 'plugins';
- $value['source_culture'] = 'en';
- $value['value']['en'] = serialize($plugin);
-
- $this->data['QubitSetting'][rand()] = $value;
- }
- }
-
- /**
- * Ver 62: Update name of QubitTerm::RELATION_NOTE_DATE_ID
- *
- * @return QubitMigrate109 this object
- */
- protected function renameRelationNoteDateConstant()
- {
- foreach ($this->data['QubitTerm'] as $key => &$item)
- {
- if (isset($item['id']) && false !== strpos($item['id'],
'RELATION_NOTE_DATE_DISPLAY_ID'))
- {
- $item['id'] = str_replace('RELATION_NOTE_DATE_DISPLAY_ID',
'RELATION_NOTE_DATE_ID', $item['id']);
- }
- }
-
- return $this;
- }
-
- /**
* Sort information objects by lft value so that parent objects are inserted
* before their children.
*
- * @return QubitMigrate109 this object
+ * @return QubitMigrate110 this object
*/
protected function sortQubitInformationObjects()
{
@@ -748,7 +142,7 @@
* Sort term objects with pre-defined IDs to start of array to prevent
* pre-emptive assignment by auto-increment
*
- * @return QubitMigrate109 this object
+ * @return QubitMigrate110 this object
*/
protected function sortQubitTerms()
{
@@ -860,7 +254,7 @@
/**
* Sort ORM classes to avoid foreign key constraint failures on data load
*
- * @return QubitMigrate109 this object
+ * @return QubitMigrate110 this object
*/
protected function sortClasses()
{
Modified: trunk/lib/task/migrate/QubitMigrator.class.php
==============================================================================
--- trunk/lib/task/migrate/QubitMigrator.class.php Fri Apr 1 17:19:35
2011 (r9056)
+++ trunk/lib/task/migrate/QubitMigrator.class.php Fri Apr 1 17:48:49
2011 (r9057)
@@ -115,4 +115,13 @@
return $this;
}
+
+ public function migrate110()
+ {
+ $migrator = new QubitMigrate110($this->data);
+ $this->data = $migrator->execute();
+ $this->dataModified = true;
+
+ return $this;
+ }
}
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.