Author: david
Date: Wed Aug 12 18:52:16 2009
New Revision: 3021

Log:
Add taxonomy and term root to 1.0.8 migration script. Root term adopts all 
orphan terms.

Modified:
   trunk/lib/task/migrate/QubitMigrate107to108.class.php

Modified: trunk/lib/task/migrate/QubitMigrate107to108.class.php
==============================================================================
--- trunk/lib/task/migrate/QubitMigrate107to108.class.php       Wed Aug 12 
12:30:19 2009        (r3020)
+++ trunk/lib/task/migrate/QubitMigrate107to108.class.php       Wed Aug 12 
18:52:16 2009        (r3021)
@@ -41,6 +41,7 @@
     $this->addActorRelationTaxonomyTerms();
     $this->addActorRelationNoteTaxonomyTerms();
     $this->addTermRelationTaxonomyTerms();
+    $this->addRootTaxonomyTerms();
 
     // Alter qubit classes (methods ordered alphabetically)
     $this->alterQubitMenus();
@@ -107,6 +108,8 @@
       'source_culture' => 'en',
       'name' => array('en' => 'associative')
     );
+
+    return $this;
   }
 
   /**
@@ -136,6 +139,8 @@
       'source_culture' => 'en',
       'name' => array('en' => 'date display')
     );
+
+    return $this;
   }
 
   /**
@@ -165,6 +170,38 @@
       'source_culture' => 'en',
       'name' => array('en' => 'associative')
     );
+
+    return $this;
+  }
+
+  /**
+   * Add root taxonomy and term objects.
+   *
+   * @return QubitMigrate107to108 this object
+   */
+  protected function addRootTaxonomyTerms()
+  {
+    // Add root taxonomy
+    $this->data['QubitTaxonomy']['QubitTaxonomy_root'] = array(
+      'id' => '<?php echo QubitTaxonomy::ROOT_ID."\n" ?>',
+    );
+
+    // Add root term
+    $this->data['QubitTerm']['QubitTerm_root'] = array(
+      'taxonomy_id' => 'QubitTaxonomy_root',
+      'id' => '<?php echo QubitTerm::ROOT_ID."\n" ?>',
+    );
+
+    // Assign root term as parent for orphan terms
+    foreach ($this->data['QubitTerm'] as $key => $term)
+    {
+      if (!isset($term['parent_id']) && '<?php echo QubitTerm::ROOT_ID."\n" 
?>' != $term['id'])
+      {
+        $this->data['QubitTerm'][$key]['parent_id'] = 'QubitTerm_root';
+      }
+    }
+
+    return $this;
   }
 
   /**
@@ -230,6 +267,8 @@
         'path' => 'digitalobject/multiFileUpload',
         'label' => array('en' => 'digital objects')
     );
+
+    return $this;
   }
 
   /**
@@ -292,6 +331,7 @@
   protected function sortQubitTerms()
   {
     $qubitTermConstantIds = array(
+      'ROOT_ID',
       //EventType taxonomy
       'CREATION_ID',
       'SUBJECT_ID',

--~--~---------~--~----~------------~-------~--~----~
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