Author: mcantelon
Date: Tue Sep  4 11:29:35 2012
New Revision: 12254

Log:
Fixed so flatfile import class works with imports without legacy IDs.

Modified:
   trunk/lib/QubitFlatfileImport.class.php

Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php     Tue Sep  4 00:33:24 2012        
(r12253)
+++ trunk/lib/QubitFlatfileImport.class.php     Tue Sep  4 11:29:35 2012        
(r12254)
@@ -210,6 +210,20 @@
   }
 
   /**
+   * Determine whether or not a column exists
+   *
+   * @param string $column  name of column
+   *
+   * @return boolean
+   */
+  function columnExists($column)
+  {
+    $columnIndex = array_search($column, $this->columnNames);
+
+    return is_numeric($columnIndex);
+  }
+
+  /**
    * Get/set values in internal representation of current row
    */
   function columnValue($column, $value =  false)
@@ -515,11 +529,14 @@
     {
       $tableName = sfInflector::underscore(substr($this->className, 5));
 
-      if ($mapEntry = $this->fetchKeymapEntryBySourceAndTargetName(
-        $this->columnValue('legacyId'),
-        $this->status['sourceName'],
-        $tableName
-      ))
+      if (
+        $this->columnExists('legacyId')
+        && $mapEntry = $this->fetchKeymapEntryBySourceAndTargetName(
+          $this->columnValue('legacyId'),
+          $this->status['sourceName'],
+          $tableName
+        )
+      )
       {
         // Lookup existing object
         $this->object = QubitInformationObject::getById($mapEntry->target_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.com/group/qubit-commits?hl=en.

Reply via email to