Author: mcantelon
Date: Wed May 9 15:14:37 2012
New Revision: 11658
Log:
Re-added old logic needed for ad-hoc event importing.
Modified:
trunk/lib/task/import/csvImportTask.class.php
Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php Wed May 9 14:20:26
2012 (r11657)
+++ trunk/lib/task/import/csvImportTask.class.php Wed May 9 15:14:37
2012 (r11658)
@@ -288,7 +288,15 @@
'creatorDatesEnd' => '|',
'nameAccessPoints' => '|',
'placeAccessPoints' => '|',
- 'subjectAccessPoints' => '|'
+ 'subjectAccessPoints' => '|',
+
+ 'eventActors' => '|',
+ 'eventTypes' => '|',
+ 'eventPlaces' => '|',
+ 'eventDates' => '|',
+ 'eventStartDates' => '|',
+ 'eventEndDates' => '|',
+ 'eventDescriptions' => '|'
),
/* import logic to execute before saving information object */
@@ -682,6 +690,82 @@
}
}
+ // add ad-hoc events
+ if (isset($self->rowStatusVars['eventActors']))
+ {
+ foreach($self->rowStatusVars['eventActors'] as $index => $actor)
+ {
+ // initialize data that'll be used to create the event
+ $eventData = array(
+ 'actorName' => $actor
+ );
+
+ // define whether each event-related column's values go directly
+ // into an event property or put into a varibale for further
+ // processing
+ $eventColumns = array(
+ 'eventTypes' => array(
+ 'variable' => 'eventType',
+ 'requiredError' => 'You have populated the eventActors
column but not the eventTypes column.'
+ ),
+ 'eventPlaces' => array('variable' => 'place'),
+ 'eventDates' => array('property' => 'date'),
+ 'eventStartDates' => array('property' => 'startDate'),
+ 'eventEndDates' => array('property' => 'endDate'),
+ 'eventDescriptions' => array('property' => 'description')
+ );
+
+ // handle each of the event-related columns
+ $eventType = FALSE;
+ $place = FALSE;
+ 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];
+
+ // allow column value(s) to set event property
+ if (isset($definition['property']))
+ {
+ $eventData[($definition['property'])] = $value;
+ }
+
+ // allow column values(s) to set variable
+ if (isset($definition['variable']))
+ {
+ $$definition['variable'] = $value;
+ }
+ } else if (isset($definition['requiredError'])) {
+ throw new sfException('You have populated the eventActors
column but not the eventTypes column.');
+ }
+ }
+
+ // if an event type has been specified, attempt to create the
event
+ if ($eventType)
+ {
+ // do lookup of type ID
+ $typeTerm =
$self->createOrFetchTerm(QubitTaxonomy::EVENT_TYPE_ID, $eventType);
+ $eventTypeId = $typeTerm->id;
+
+ // create event
+ $event = $self->createEvent($eventTypeId, $eventData);
+
+ // create a place term if specified
+ if ($place)
+ {
+ // create place
+ $placeTerm = $self->createTerm(QubitTaxonomy::PLACE_ID,
$place);
+ $self->createObjectTermRelation($event->id, $placeTerm->id);
+ }
+ } else {
+ throw new sfException('eventTypes column need to be
populated.');
+ }
+ }
+ }
+
// add creators and create events
$createEvents = array();
if (isset($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.