Author: peter
Date: Tue Sep 22 13:55:16 2009
New Revision: 3468

Log:
update migrate task to add Status taxonomies and terms and set the publication 
status of pre-existing information objects to 'published'. Fixes issue#940

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

Modified: trunk/lib/task/migrate/QubitMigrate107to108.class.php
==============================================================================
--- trunk/lib/task/migrate/QubitMigrate107to108.class.php       Tue Sep 22 
11:28:32 2009        (r3467)
+++ trunk/lib/task/migrate/QubitMigrate107to108.class.php       Tue Sep 22 
13:55:16 2009        (r3468)
@@ -41,6 +41,7 @@
     $this->addActorRelationTaxonomyTerms();
     $this->addActorRelationNoteTaxonomyTerms();
     $this->addTermRelationTaxonomyTerms();
+    $this->addStatusTaxonomyTerms();
     $this->addRootTaxonomyTerms();
 
     // Alter qubit classes (methods ordered alphabetically)
@@ -48,6 +49,7 @@
     $this->alterQubitProperties();
     $this->alterQubitSettings();
     $this->alterQubitStaticPages();
+    $this->alterQubitStatus();
     $this->alterQubitTerms();
 
     return $this;
@@ -177,6 +179,51 @@
   }
 
   /**
+   * Add 'Status' taxonomies and terms
+   *
+   * @return QubitMigrate107to108 this object
+   */
+  protected function addStatusTaxonomyTerms()
+  {
+    // Add taxonomies
+    $this->data['QubitTaxonomy']['QubitTaxonomy_status_types'] = array(
+      'source_culture' => 'en',
+      'id' => '<?php echo QubitTaxonomy::STATUS_TYPE_ID."\n" ?>',
+      'name' => array('en' => 'Status types')
+    );
+
+    $this->data['QubitTaxonomy']['QubitTaxonomy_publication_status'] = array(
+      'source_culture' => 'en',
+      'id' => '<?php echo QubitTaxonomy::PUBLICATION_STATUS_ID."\n" ?>',
+      'name' => array('en' => 'Publication status')
+    );
+
+    // Add related terms
+    $this->data['QubitTerm']['QubitTerm_status_type_publication'] = array(
+      'taxonomy_id' => '<?php echo QubitTaxonomy::STATUS_TYPE_ID."\n" ?>',
+      'id' => '<?php echo QubitTerm::STATUS_TYPE_PUBLICATION_ID."\n" ?>',
+      'source_culture' => 'en',
+      'name' => array('en' => 'publication')
+    );
+
+    $this->data['QubitTerm']['QubitTerm_publication_status_draft'] = array(
+      'taxonomy_id' => '<?php echo QubitTaxonomy::PUBLICATION_STATUS_ID."\n" 
?>',
+      'id' => '<?php echo QubitTerm::PUBLICATION_STATUS_DRAFT_ID."\n" ?>',
+      'source_culture' => 'en',
+      'name' => array('de' => 'Entwurf', 'en' => 'draft', 'es' => 'Minuta', 
'fr' => 'Ébauche', 'it' => 'Bozza', 'nl' => 'Klad', 'pt' => 'Preliminar', 'sl' 
=> 'Osnutek')
+    );
+
+    $this->data['QubitTerm']['QubitTerm_publication_status_published'] = array(
+      'taxonomy_id' => '<?php echo QubitTaxonomy::PUBLICATION_STATUS_ID."\n" 
?>',
+      'id' => '<?php echo QubitTerm::PUBLICATION_STATUS_PUBLISHED_ID."\n" ?>',
+      'source_culture' => 'en',
+      'name' => array('en' => 'published')
+    );
+
+    return $this;
+  }
+
+  /**
    * Add root taxonomy and term objects.
    *
    * @return QubitMigrate107to108 this object
@@ -516,6 +563,38 @@
   }
 
   /**
+   * Alter QubitStatus data
+   *
+   * @return QubitMigrate107to108 this object
+   */
+  protected function alterQubitStatus()
+  {
+    // Assign default status to information object root
+    $this->data['QubitStatus']['root_status'] = array(
+      'object_id' => '<?php echo QubitInformationObject::ROOT_ID."\n" ?>',
+      'type_id' => '<?php echo QubitTerm::STATUS_TYPE_PUBLICATION_ID."\n" ?>',
+      'status_id' => '<?php echo QubitTerm::PUBLICATION_STATUS_DRAFT_ID."\n" 
?>'
+    );
+
+    // Assume all pre-existing information objects are published
+    foreach ($this->data['QubitInformationObject'] as $key => $value)
+    {
+      // Publication status is inherited by descendants so we only need to set 
it for
+      // collection roots and orphans
+      if ($value['parent_id'] == 'QubitInformationObject_1')
+      {
+        $this->data['QubitStatus']['publication_status_'.$key] = array(
+          'object_id' => $key,
+          'type_id' => '<?php echo QubitTerm::STATUS_TYPE_PUBLICATION_ID."\n" 
?>',
+          'status_id' => '<?php echo 
QubitTerm::PUBLICATION_STATUS_PUBLISHED_ID."\n" ?>'
+        );
+      }
+    }
+
+    return $this;
+  }
+
+  /**
    * Alter QubitTerms data
    *
    * @return QubitMigrate107to108 this object

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