Author: mcantelon
Date: Fri Dec 30 17:48:47 2011
New Revision: 10493

Log:
Fixed issue with row status variables and added setting of history for multiple 
creators.

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

Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php      Fri Dec 30 15:59:31 2011        
(r10492)
+++ trunk/lib/task/csvImportTask.class.php      Fri Dec 30 17:48:47 2011        
(r10493)
@@ -168,7 +168,8 @@
           }
         }
 
-        if (sizeof($self->rowStatusVars['creators']))
+        if (isset($self->rowStatusVars['creators'])
+          && sizeof($self->rowStatusVars['creators']))
         {
 if (sizeof($self->rowStatusVars['creators']) > 1) {
   //print_r($self->rowStatusVars['creators']); exit();
@@ -197,7 +198,11 @@
 
               if(isset($self->rowStatusVars['creatorHistory']))
               {
-                $eventData['actorHistory'] = 
$self->rowStatusVars['creatorHistory'];
+                $creatorPosition = array_search($creator, 
$self->rowStatusVars['creators']);
+                if 
(isset($self->rowStatusVars['creatorHistory'][$creatorPosition]))
+                {
+                  $eventData['actorHistory'] = 
$self->rowStatusVars['creatorHistory'][$creatorPosition];
+                }
               }
 
               $event = $self->createEvent(
@@ -233,7 +238,10 @@
 
     $import->addColumnHandler('creatorHistory', function(&$self, $data)
     {
-      $self->rowStatusVars['creatorHistory'] = $data;
+      if ($data)
+      {
+        $self->rowStatusVars['creatorHistory'] = explode('|', $data);
+      }
     });
 
     $import->addColumnHandler('creationDatesStart', function(&$self, $data)
@@ -283,6 +291,9 @@
     $this->status = array(
       'rows' => 0
     );
+
+    // initialize row status variables
+    $this->rowStatusVars = array();
   }
 
   public function addColumnHandler($column, $handler)
@@ -431,13 +442,7 @@
     $this->status['rows']++;
 
     // get rid of row-specific status variables
-    if ($this->rowStatusVars)
-    {
-      foreach($this->rowStatusVars as $var => $value)
-      {
-        unset($this->status[$var]);
-      }
-    }
+    $this->rowStatusVars = array();
   }
 
   public function createNote($typeId, $text, $transformationLogic = false)
@@ -464,7 +469,8 @@
 
     if (isset($options['actorName']))
     {
-      $actor = $this->createOrFetchActor($options['actorName']);
+      $history = isset($options['actorHistory']) || false;
+      $actor = $this->createOrFetchActor($options['actorName'], $history);
       $event->actorId = $actor->id;
     }
 
@@ -481,7 +487,7 @@
     }
   }
 
-  public function createOrFetchActor($name)
+  public function createOrFetchActor($name, $history = false)
   {
     $connection = Propel::getConnection();
     $query = "SELECT id FROM actor_i18n WHERE authorized_form_of_name=?";
@@ -493,15 +499,20 @@
     {
       return $result;
     } else {
-      return $this->createActor($name);
+      return $this->createActor($name, $history);
     }
   }
 
-  public function createActor($name)
+  public function createActor($name, $history = false)
   {
     $actor = new QubitActor;
     $actor->parentId = QubitActor::ROOT_ID;
     $actor->authorizedFormOfName = $name;
+    if ($history)
+    {
+print 'SET';
+      $actor->history = $history;
+    }
     $actor->save();
     return $actor;
   }

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