Author: david
Date: 2008-12-15 14:02:24 -0800 (Mon, 15 Dec 2008)
New Revision: 1685

Modified:
   trunk/qubit/lib/task/migrate/QubitMigrate103to104.class.php
Log:
Initial version of 1.0.3->1.0.4 migration task complete and ready for testing.

Modified: trunk/qubit/lib/task/migrate/QubitMigrate103to104.class.php
===================================================================
--- trunk/qubit/lib/task/migrate/QubitMigrate103to104.class.php 2008-12-15 
20:22:52 UTC (rev 1684)
+++ trunk/qubit/lib/task/migrate/QubitMigrate103to104.class.php 2008-12-15 
22:02:24 UTC (rev 1685)
@@ -69,24 +69,28 @@
   private function getRowKey($className, $searchColumn, $searchKey)
   {
     return QubitMigrateData::findRowKeyForColumnValue(
-    $this->data[$className], $searchColumn, $searchKey);
+      $this->data[$className], $searchColumn, $searchKey);
   }
 
   /**
+   * Convienience method for grabbing a QubitTerm row key based on the value of
+   * the 'id' column
+   *
+   * @param string $searchKey
+   * @return string key for matched row
+   */
+  private function getTermKey($searchKey)
+  {
+    return $this->getRowKey('QubitTerm', 'id',  $searchKey);
+  }
+
+  /**
    * Controller for calling methods to alter data
    *
    * @return QubitMigrate103to104 this object
    */
   private function alterData()
   {
-    // Move QubitTaxonomy to front of the line
-    if (key($this->data) != 'QubitTaxonomy')
-    {
-      $taxonomy = array('QubitTaxonomy' => $this->data['QubitTaxonomy']);
-      unset($this->data['QubitTaxonomy']);
-      $this->data = array_merge_recursive($taxonomy, $this->data);
-    }
-
     // Alter qubit classes (methods ordered alphabetically)
     $this->alterQubitActors();
     $this->alterQubitEvents();
@@ -136,7 +140,7 @@
    */
   private function alterQubitEvents()
   {
-    // re-map data QubitEvent::description -> QubitEvent::date_display
+    // Re-map data QubitEvent::description -> QubitEvent::date_display
     foreach ($this->data['QubitEvent'] as $key => $event)
     {
       if (isset($this->data['QubitEvent'][$key]['description']))
@@ -170,7 +174,7 @@
     $existenceTermKey = $this->getTermExistenceKey();
     foreach ($this->data['QubitEvent'] as $key => $columns)
     {
-      if ($columns['type_id'] == $existenceTermKey)
+      if ($columns['type_id'] == $existenceTermKey && 
isset($columns['date_display']))
       {
         $this->data['QubitActor'][$columns['actor_id']]['dates_of_existence'] 
= $columns['date_display'];
         unset($this->data['QubitEvent'][$key]);
@@ -179,20 +183,29 @@
 
     // Switch from assigning actor_role_id to event to determining actor role
     // based on event type (eg. event type = creation then actor role = 
creator)
+    $oldSubjectKey = $this->getTermKey('<?php echo QubitTerm::SUBJECT_ID."\n" 
?>');
     foreach ($this->data['QubitEvent'] as $key => $columns)
     {
-      // Remove actor_role_id column from existing events (deprecated)
       if (isset($columns['actor_role_id']))
       {
+        // If this was a subject access point relationship, then give the 1.0.4
+        // event type_id = 'subject'
+        var_dump($columns['actor_role_id']);
+        if ($columns['actor_role_id'] == $oldSubjectKey && 
!isset($columns['type_id']))
+        {
+          $this->data['QubitEvent'][$key]['type_id'] = 'QubitTerm_subject';
+        }
+
+        // Remove actor_role_id column from existing events (deprecated)
         unset($this->data['QubitEvent'][$key]['actor_role_id']);
       }
 
-      // Add event type_id of "creation" to events that don't already have an
+      // Add event type_id of "creation" to events that don't have an
       // assigned type_id
-      if (!isset($columns['type_id']))
+      if (!isset($this->data['QubitEvent'][$key]['type_id']))
       {
         $this->data['QubitEvent'][$key] = array_merge(
-        array('type_id' => $creationEventTermKey), 
$this->data['QubitEvent'][$key]);
+          array('type_id' => $creationEventTermKey), 
$this->data['QubitEvent'][$key]);
       }
     }
 
@@ -514,12 +527,21 @@
    */
   private function alterQubitTerms()
   {
-    // Swap Term EXISTENCE_ID for SUBJECT_ID in the Event type taxonomy
+    // Swap Term EXISTENCE_ID for SUBJECT_ID in the Event type taxonomy (they
+    // share analogous primary keys 12 vs. 112)
     if ($existenceKey = $this->getTermExistenceKey())
     {
-      $this->data['QubitTerm'][$existenceKey]['id'] = '<?php echo 
QubitTerm::SUBJECT_ID."\n" ?>';
-      $this->data['QubitTerm'][$existenceKey]['name'] = array(
+      $existenceArrayKeyIndex = 
QubitMigrateData::getArrayKeyIndex($this->data['QubitTerm'], $existenceKey);
+      $newTerm = $this->data['QubitTerm'][$existenceKey];
+      $newTerm['id'] = '<?php echo QubitTerm::SUBJECT_ID."\n" ?>';
+      $newTerm['name'] = array(
         'en'=>'Subject', 'fr' => 'Sujet', 'nl' => 'Onderwerp', 'pt' => 
'Assunto');
+
+      // Splice subject_id term into data array where existenceKey lives now
+      QubitMigrateData::array_insert($this->data['QubitTerm'], 
$existenceArrayKeyIndex, array('QubitTerm_subject' => $newTerm));
+
+      // Delete existence term
+      unset($this->data['QubitTerm'][$existenceKey]);
     }
 
     // Event Types


--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to