Author: mcantelon
Date: Mon Jan 16 11:23:17 2012
New Revision: 10680

Log:
Refactored to use new helper.

Modified:
   trunk/lib/task/csvImportTask.class.php

Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php      Mon Jan 16 11:22:45 2012        
(r10679)
+++ trunk/lib/task/csvImportTask.class.php      Mon Jan 16 11:23:17 2012        
(r10680)
@@ -541,6 +541,8 @@
       $self->object->setLevelOfDescriptionByName($data);
     });
 
+    /* create function to deal with columns whose names begin with
+       "relatedActor", parsing out name of role from column name */
     $relatedActorHandler = function(&$self, $data)
     {
       if ($data)
@@ -566,6 +568,7 @@
     $import->addColumnHandler('relatedActorCommissionedBy', 
$relatedActorHandler);
     $import->addColumnHandler('relatedActorPhotographer', 
$relatedActorHandler);
 
+    // map value to taxonomy term name and take note of taxonomy term's ID
     $import->addColumnHandler('radGeneralMaterialDesignation', 
function(&$self, $data)
     {
       if ($data)
@@ -580,20 +583,12 @@
           'Map'               => 'Cartographic material'
         );
 
-        if (isset($cvaToQubit[$data]))
-        {
-          $materialTermName = $cvaToQubit[$data];
-          if (in_array($materialTermName, $self->getStatus('materialTypes')))
-          {
-            $termId = array_search($materialTermName, 
$self->getStatus('materialTypes'));
-            // lookup material taxonomy ID from materialTypes
-            $self->rowStatusVars['radGeneralMaterialDesignation'] = $termId;
-          } else {
-            die('Could not find "'. $materialTermName .'" in materialTypes 
array.');
-          }
-        } else {
-          die('Could not find a way to handle radGeneralMaterialDesignation 
value "'. $data .'".');
-        }
+        $self->rowStatusVars['radGeneralMaterialDesignation'] = 
$self->translateNameToTermId(
+          'material types',
+          $data,
+          $cvaToQubit,
+          $self->getStatus('materialTypes')
+        );
       }
     });
 

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