Author: mcantelon
Date: Fri Dec 30 15:59:31 2011
New Revision: 10492

Log:
Fixed issues with actor/event creation and added support 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 14:48:18 2011        
(r10491)
+++ trunk/lib/task/csvImportTask.class.php      Fri Dec 30 15:59:31 2011        
(r10492)
@@ -137,10 +137,6 @@
       {
         $self->informationObject = new QubitInformationObject;
       },
-      'rowStatusVars' => array(
-        'startYear',
-        'endYear'
-      ),
       'rowComplete' => function(&$self)
       {
         // set to default status
@@ -172,27 +168,44 @@
           }
         }
 
-        // add create event if specified
-        if (
-          isset($self->rowStatusVars['startYear'])
-          || (
-            isset($self->rowStatusVars['startYear'])
-            && isset($self->rowStatusVars['endYear'])
-          )
-        )
+        if (sizeof($self->rowStatusVars['creators']))
         {
-          $endDate = (isset($self->rowStatusVars['endYear']))
-             ? $self->rowStatusVars['endYear'] .'-00-00'
-             : false;
-
-          $event = $self->createEvent(
-            QubitTerm::CREATION_ID,
-            array(
-              'startDate' => $self->rowStatusVars['startYear'] .'-00-00',
-              'endDate' => $endDate,
-              'actorName' => 'FGoat'
+if (sizeof($self->rowStatusVars['creators']) > 1) {
+  //print_r($self->rowStatusVars['creators']); exit();
+}
+
+          foreach($self->rowStatusVars['creators'] as $creator)
+          {
+            // add create event if specified
+            if (
+              isset($self->rowStatusVars['startYear'])
+              || (
+                isset($self->rowStatusVars['startYear'])
+                && isset($self->rowStatusVars['endYear'])
+              )
             )
-          );
+            {
+              $endDate = (isset($self->rowStatusVars['endYear']))
+                ? $self->rowStatusVars['endYear'] .'-00-00'
+                : false;
+
+              $eventData = array(
+                'startDate' => $self->rowStatusVars['startYear'] .'-00-00',
+                'endDate' => $endDate,
+                'actorName' => $creator
+              );
+
+              if(isset($self->rowStatusVars['creatorHistory']))
+              {
+                $eventData['actorHistory'] = 
$self->rowStatusVars['creatorHistory'];
+              }
+
+              $event = $self->createEvent(
+                QubitTerm::CREATION_ID,
+                $eventData
+              );
+            }
+          }
         }
       }
     ));
@@ -210,6 +223,14 @@
       }
     });
 
+    $import->addColumnHandler('creators', function(&$self, $data)
+    {
+      if ($data)
+      {
+        $self->rowStatusVars['creators'] = explode('|', $data);
+      }
+    });
+
     $import->addColumnHandler('creatorHistory', function(&$self, $data)
     {
       $self->rowStatusVars['creatorHistory'] = $data;
@@ -241,7 +262,6 @@
       'testing',
       'rowInit',
       'rowComplete',
-      'rowStatusVars',
       'propertyMap',
       'noteMap',
       'columnMap'
@@ -413,7 +433,7 @@
     // get rid of row-specific status variables
     if ($this->rowStatusVars)
     {
-      foreach($this->rowStatusVars as $var)
+      foreach($this->rowStatusVars as $var => $value)
       {
         unset($this->status[$var]);
       }
@@ -442,14 +462,15 @@
     $event->informationObjectId = $this->informationObject->id;
     $event->typeId = $typeId;
 
-    if (isset($options['actorName'])) {
+    if (isset($options['actorName']))
+    {
       $actor = $this->createOrFetchActor($options['actorName']);
       $event->actorId = $actor->id;
     }
 
     $event->startDate = $options['startDate'];
 
-    if ($options['endDate'])
+    if (isset($options['endDate']))
     {
       $event->endDate = $options['endDate'];
     }

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