Author: mcantelon
Date: Mon Jan 16 11:22:45 2012
New Revision: 10679

Log:
Added helper function to map values to taxonomy terms.

Modified:
   trunk/lib/QubitFlatfileImport.class.php

Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php     Mon Jan 16 00:03:26 2012        
(r10678)
+++ trunk/lib/QubitFlatfileImport.class.php     Mon Jan 16 11:22:45 2012        
(r10679)
@@ -386,6 +386,9 @@
 
   public function row($row = array())
   {
+    // stash raw row data so it's accessible to closure logic
+    $this->status['row'] = $row;
+
     if (isset($this->className))
     {
       // create new object
@@ -698,4 +701,21 @@
 
     return $str;
   }
+
+  public function translateNameToTermId($description, $value, 
$valueToTermNameMap, $terms)
+  {
+    if (isset($valueToTermNameMap[$value]))
+    {
+      $termName = $valueToTermNameMap[$value];
+      if (in_array($termName, $terms))
+      {
+        $termId = array_search($termName, $terms);
+        return $termId;
+      } else {
+        die('Could not find "'. $termName .'" in '. $description .' terms 
array.');
+      }
+    } else {
+      die('Could not find a way to handle '. $description .' value "'. $value 
.'".');
+    }
+  }
 }

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