Author: david
Date: Tue Jul 31 13:37:54 2012
New Revision: 12018
Log:
Save translated event data as a new i18n row instead of create a separate event
Modified:
trunk/lib/QubitFlatfileImport.class.php
trunk/lib/task/import/csvImportTask.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Tue Jul 31 08:12:46 2012
(r12017)
+++ trunk/lib/QubitFlatfileImport.class.php Tue Jul 31 13:37:54 2012
(r12018)
@@ -906,18 +906,34 @@
}
/**
- * Create a Qubit event
+ * Create a Qubit event, or add an i18n row to existing event
*
* @param integer $typeId term ID of event type
* @param array $options option parameter
*
* @return QubitEvent created event
*/
- public function createEvent($typeId, $options = array())
+ public function createOrUpdateEvent($typeId, $options = array())
{
- $event = new QubitEvent;
- $event->informationObjectId = $this->object->id;
- $event->typeId = $typeId;
+ if (isset($options['eventId']))
+ {
+ // Adding new i18n values to an existing event
+ $event = QubitEvent::getById($options['eventId']);
+ unset($options['eventId']);
+ }
+ else
+ {
+ // Create new event
+ $event = new QubitEvent;
+ $event->informationObjectId = $this->object->id;
+ $event->typeId = $typeId;
+ }
+
+ if (null === $event)
+ {
+ // Couldn't find event
+ return;
+ }
$allowedProperties = array('date', 'description', 'startDate', 'endDate');
$ignoreOptions = array('actorName', 'actorHistory');
@@ -926,9 +942,23 @@
if (isset($options['actorName']))
{
- $history = isset($options['actorHistory']) ? $options['actorHistory'] :
false;
- $actor = $this->createOrFetchActor($options['actorName'], $history);
- $event->actorId = $actor->id;
+ if (isset($event->actorId))
+ {
+ // Update i18n values
+ $event->actor->authorizedFormOfName = $options['actorName'];
+ if (isset($options['actorHistory']))
+ {
+ $event->actor->history = $options['actorHistory'];
+ }
+ $event->actor->save();
+ }
+ else
+ {
+ // Link actor
+ $history = isset($options['actorHistory']) ? $options['actorHistory']
: false;
+ $actor = $this->createOrFetchActor($options['actorName'], $history);
+ $event->actorId = $actor->id;
+ }
}
$event->save();
Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php Tue Jul 31 08:12:46
2012 (r12017)
+++ trunk/lib/task/import/csvImportTask.class.php Tue Jul 31 13:37:54
2012 (r12018)
@@ -853,7 +853,7 @@
$eventTypeId = $typeTerm->id;
// create event
- $event = $self->createEvent($eventTypeId, $eventData);
+ $event = $self->createOrUpdateEvent($eventTypeId, $eventData);
// create a place term if specified
if ($place)
@@ -906,9 +906,24 @@
// create events, if any
if (count($createEvents))
{
+ if ($self->rowStatusVars['culture'] !=
$self->object->sourceCulture)
+ {
+ // Add i18n data to existing event
+ $sql = "SELECT id FROM event WHERE information_object_id = ? and
type_id = ?;";
+ $stmt = QubitFlatfileImport::sqlQuery($sql, array(
+ $self->object->id,
+ QubitTerm::CREATION_ID));
+
+ $i = 0;
+ while ($eventId = $stmt->fetchColumn())
+ {
+ $createEvents[$i++]['eventId'] = $eventId;
+ }
+ }
+
foreach($createEvents as $eventData)
{
- $event = $self->createEvent(
+ $event = $self->createOrUpdateEvent(
QubitTerm::CREATION_ID,
$eventData
);
--
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.