Author: david
Date: Thu Dec  8 13:26:13 2011
New Revision: 10379

Log:
Finish fix to migrating digital objects when repository slugs are not defined.

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

Modified: trunk/lib/task/migrate/QubitMigrate110.class.php
==============================================================================
--- trunk/lib/task/migrate/QubitMigrate110.class.php    Thu Dec  8 09:28:49 
2011        (r10378)
+++ trunk/lib/task/migrate/QubitMigrate110.class.php    Thu Dec  8 13:26:13 
2011        (r10379)
@@ -643,13 +643,10 @@
 
     foreach ($this->data['QubitDigitalObject'] as $key => &$item)
     {
-      var_dump($key);
-
       if (!isset($item['information_object_id']))
       {
         continue;
       }
-var_dump('BBBBB');
 
       // Get the related information object
       $infoObject = $this->getRowByKeyOrId('QubitInformationObject', 
$item['information_object_id']);
@@ -658,22 +655,28 @@
         continue;
       }
 
-var_dump('CCCCC');
       // Recursively check info object ancestors for repository foreign key
       while (!isset($infoObject['repository_id']) && 
isset($infoObject['parent_id']))
       {
         $infoObject = $this->getRowByKeyOrId('QubitInformationObject', 
$infoObject['parent_id']);
       }
 
-var_dump('DDDDD');
       // Get repository
       if (isset($infoObject['repository_id']))
       {
-        $repo = $this->getRowByKeyOrId('QubitRepository', 
$infoObject['repository_id']);
+        $repo =& $this->data['QubitRepository'][$infoObject['repository_id']];
 
         if (!isset($repo['slug']))
         {
-          $repo['slug'] = 
$this->getUniqueSlug($repo['authorized_form_of_name']);
+          $slug = 
$this->getUniqueSlug($repo['authorized_form_of_name'][$repo['source_culture']]);
+          if (!isset($slug) || 0 == strlen($slug))
+          {
+            continue;
+          }
+          else
+          {
+            $repo['slug'] = $slug;
+          }
         }
 
         $repoName = $repo['slug'];
@@ -683,8 +686,6 @@
         $repoName = 'null';
       }
 
-var_dump($repoName);
-
       // Update digital object and derivatives paths
       foreach ($this->data['QubitDigitalObject'] as $key2 => &$item2)
       {
@@ -1136,15 +1137,15 @@
     return $this;
   }
 
-  function getUniqueSlug($string)
+  protected function getUniqueSlug($str)
   {
-    $slug = $root = QubitSlug::slugify($string);
+    $slug = $root = QubitSlug::slugify($str);
 
     for ($i = 0; $i < 100; $i++)
     {
       foreach ($this->data['QubitRepository'] as $item)
       {
-        if (isset($item['slug'] == $slug))
+        if (isset($item['slug']) && $item['slug'] == $slug)
         {
           $slug = $root.'-'.($i + 1);
 
@@ -1155,7 +1156,8 @@
       // If $slug hasn't been incremented this pass
       if ($slug == $root || $slug == $root.'-'.$i)
       {
-        return $slug
+        return $slug;
       }
     }
   }
+}

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