Author: david
Date: Wed Jul 11 17:21:10 2012
New Revision: 11913

Log:
BROKEN. Start work on allowing multiple culture rows for same archival 
description

Modified:
   trunk/lib/QubitFlatfileImport.class.php

Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php     Wed Jul 11 16:33:05 2012        
(r11912)
+++ trunk/lib/QubitFlatfileImport.class.php     Wed Jul 11 17:21:10 2012        
(r11913)
@@ -498,13 +498,44 @@
       }
     }
 
+    // Default culture is English
+    $cultureKey = array_search('culture', $this->columnNames);
+    if (isset($cultureKey) && !isset($this->status['row'][$cultureKey]))
+    {
+      $this->status['row'][$cultureKey] = 'en';
+    }
+
     // set row status variables that are based on column values
     $this->rowProcessingBeforeObjectCreation($row);
 
     if (isset($this->className))
     {
-      // create new object
-      $this->object = new $this->className;
+      $tableName = sfInflector::underscore(substr($this->className, 5));
+
+      if ($mapEntry = $this->fetchKeymapEntryBySourceAndTargetName(
+        $this->status['row']['legacyId'],
+        $this->status['sourceName'],
+        $tableName
+      ))
+      {
+        var_dump("Found id {$mapEntry->target_id}");
+        // Lookup existing object
+        $this->object = QubitInformationObject::getById($mapEntry->target_id);
+
+        // Log error if object exists with current culture
+        if ($this->object->source_culture == $this->status['row']['culture'])
+        {
+          print $this->logError(sprintf('Duplicate entry for information 
object id:%s, culture: %s',
+            $this->object->id,
+            $this->object->source_culture));
+        }
+      }
+      else
+      {
+        var_dump("Create new object!");
+        // create new object
+        $this->object = new $this->className;
+      }
 
       // disable nested set updating, if applicable to object type
       if (property_exists(get_class($this->object), 
'disableNestedSetUpdating'))

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