Author: mcantelon
Date: Fri Dec 30 14:48:18 2011
New Revision: 10491
Log:
Got actor/event creation working.
Modified:
trunk/lib/task/csvImportTask.class.php
Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php Fri Dec 30 13:58:37 2011
(r10490)
+++ trunk/lib/task/csvImportTask.class.php Fri Dec 30 14:48:18 2011
(r10491)
@@ -189,7 +189,8 @@
QubitTerm::CREATION_ID,
array(
'startDate' => $self->rowStatusVars['startYear'] .'-00-00',
- 'endDate' => $endDate
+ 'endDate' => $endDate,
+ 'actorName' => 'FGoat'
)
);
}
@@ -440,23 +441,48 @@
$event = new QubitEvent;
$event->informationObjectId = $this->informationObject->id;
$event->typeId = $typeId;
+
+ if (isset($options['actorName'])) {
+ $actor = $this->createOrFetchActor($options['actorName']);
+ $event->actorId = $actor->id;
+ }
+
$event->startDate = $options['startDate'];
+
if ($options['endDate'])
{
$event->endDate = $options['endDate'];
}
+
if (!isset($self->testing) || !$self->testing)
{
$event->save();
}
}
+ public function createOrFetchActor($name)
+ {
+ $connection = Propel::getConnection();
+ $query = "SELECT id FROM actor_i18n WHERE authorized_form_of_name=?";
+ $statement = $connection->prepare($query);
+ $statement->bindValue(1, $name);
+ $statement->execute();
+ $result = $statement->fetch(PDO::FETCH_OBJ);
+ if ($result)
+ {
+ return $result;
+ } else {
+ return $this->createActor($name);
+ }
+ }
+
public function createActor($name)
{
$actor = new QubitActor;
$actor->parentId = QubitActor::ROOT_ID;
$actor->authorizedFormOfName = $name;
$actor->save();
+ return $actor;
}
public function appendWithLineBreakIfNeeded($oldContent, $newContent)
--
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.