Author: mcantelon
Date: Wed Feb 22 16:56:41 2012
New Revision: 10957

Log:
Added logic to amalgamate ad-hoc event data from related columns.

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

Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php       Wed Feb 22 00:03:02 
2012        (r10956)
+++ trunk/lib/task/import/csvImportTask.class.php       Wed Feb 22 16:56:41 
2012        (r10957)
@@ -215,7 +215,12 @@
         'datesOfCreationEnd'   => '|',
         'nameAccessPoints'     => '|',
         'placeAccessPoints'    => '|',
-        'subjectAccessPoints'  => '|'
+        'subjectAccessPoints'  => '|',
+        'eventActors'          => '|',
+        'eventTypes'           => '|',
+        'eventPlaces'          => '|',
+        'eventDates'           => '|',
+        'eventDescriptions'    => '|'
       ),
 
       /* import logic to execute before saving information object */
@@ -505,6 +510,43 @@
             }
           }
 
+          // add ad-hoc events
+          if (isset($self->rowStatusVars['eventActors']))
+          {
+            foreach($self->rowStatusVars['eventActors'] as $index => $actor)
+            {
+              $eventData = array(
+                'actor' => $actor
+              );
+
+              $eventColumns = array(
+                'eventTypes' => array(
+                  'property' => 'typeId',
+                  'requiredError' => 'You have populated the eventActors 
column but not the eventTypes column.'
+                ),
+                'eventPlaces'        => array('property' => 'place'),
+                'eventDates'         => array('property' => 'date'),
+                'eventDescriptions'  => array('property' => 'description')
+              );
+
+              foreach($eventColumns as $column => $definition)
+              {
+                if (isset($self->rowStatusVars[$column]))
+                {
+                  $value
+                    = (count($self->rowStatusVars['eventActors']) == 
count($self->rowStatusVars[$column]))
+                      ? $self->rowStatusVars[$column][$index]
+                      : $self->rowStatusVars[$column][0];
+                  $eventData[($definition['property'])] = $value;
+                } else if (isset($definition['requiredError'])) {
+                  throw new sfException('You have populated the eventActors 
column but not the eventTypes column.');
+                }
+              }
+
+              // add event/place creation here
+            }
+          }
+
           // add creators and create events
           if (isset($self->rowStatusVars['creators'])
             && count($self->rowStatusVars['creators']))

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