Author: david
Date: Fri Jul 22 14:48:18 2011
New Revision: 9352

Log:
Set checksum_type column for legacy data

Modified:
   trunk/data/fixtures/settings.yml
   trunk/lib/task/migrate/QubitMigrate110.class.php

Modified: trunk/data/fixtures/settings.yml
==============================================================================
--- trunk/data/fixtures/settings.yml    Fri Jul 22 14:42:03 2011        (r9351)
+++ trunk/data/fixtures/settings.yml    Fri Jul 22 14:48:18 2011        (r9352)
@@ -3,7 +3,7 @@
     name: version
     editable: 0
     deleteable: 0
-    value: 64
+    value: 65
   QubitSetting_2:
     name: upload_dir
     editable: 0

Modified: trunk/lib/task/migrate/QubitMigrate110.class.php
==============================================================================
--- trunk/lib/task/migrate/QubitMigrate110.class.php    Fri Jul 22 14:42:03 
2011        (r9351)
+++ trunk/lib/task/migrate/QubitMigrate110.class.php    Fri Jul 22 14:48:18 
2011        (r9352)
@@ -55,6 +55,9 @@
 
       case 63:
         $this->moveRelationNotesToI18n();
+
+      case 64:
+        $this->setChecksumType();
     }
 
     // Delete "stub" objects
@@ -396,6 +399,37 @@
   }
 
   /**
+   * Migrate checksumTypeId to checksumType.  Set md5 checksum type previous to
+   * revision 9340
+   *
+   * @return QubitMigrate110 SELF 
+   */
+  protected function setChecksumType()
+  {
+    foreach ($this->data['QubitDigitalObject'] as $key => &$item)
+    {
+      if (!isset($item['checksum']) || 0 == strlen($item['checksum']))
+      {
+        // No checksum, skip 
+        continue;
+      }
+
+      if (isset($item['checksumTypeId']) && 0 < 
strlen($item['checksumTypeId']))
+      {
+        $item['checksumType'] = $item['checksumTypeId'];
+        unset($item['checksumTypeId']);
+      }
+      else 
+      {
+        // Used md5 for all checksums previous to r9340
+        $item['checksumType'] = 'md5';
+      }
+    }
+
+    return $this;
+  }
+
+  /**
    * Slugs are inserted when some resources are inserted, but slugs are dumped
    * separately when data is dumped. So loading slug data will try to insert
    * duplicate slugs. To work around this, turn slugs into resource properties

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

Reply via email to