Author: david
Date: Tue Jul 31 16:49:29 2012
New Revision: 12021
Log:
NOT WORKING. Update note import to handle i18n values
Modified:
trunk/lib/QubitFlatfileImport.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Tue Jul 31 14:59:35 2012
(r12020)
+++ trunk/lib/QubitFlatfileImport.class.php Tue Jul 31 16:49:29 2012
(r12021)
@@ -682,7 +682,7 @@
$transformationLogic =
(isset($self->noteMap[$columnName]['transformationLogic']))
? $self->noteMap[$columnName]['transformationLogic']
: false;
- $self->createNotes(
+ $self->createOrUpdateNotes(
$self->noteMap[$columnName]['typeId'],
explode('|', $value),
$transformationLogic
@@ -868,16 +868,43 @@
*
* @return array Notes created
*/
- public function createNotes($typeId, $textArray, $transformationLogic =
false)
+ public function createOrUpdateNotes($typeId, $textArray,
$transformationLogic = false)
{
- $notesCreated = array();
+ $notes = array();
+ $noteIds = array();
- foreach($textArray as $text)
+ // I18n row handler
+ if ($this->columnValue('culture') != $this->object->sourceCulture)
{
- $notesCreated[] = $this->createNote($typeId, $text,
$transformationLogic);
+ $query = "SELECT id FROM note WHERE object_id = ? AND type_id = ?;";
+
+ $statement = self::sqlQuery($query, array(
+ $this->object->id, $typeId));
+
+ while ($noteId = $statement->fetchColumn())
+ {
+ $noteIds[] = $noteId;
+ }
}
- return $notesCreated;
+ foreach($textArray as $i => $text)
+ {
+ $options = array();
+
+ if ($transformationLogic)
+ {
+ $options['transformationLogic'] = $transformationLogic;
+ }
+
+ if (isset($noteIds[$i]))
+ {
+ $options['noteId'] = $noteIds[$i];
+ }
+
+ $notes[] = $this->createOrUpdateNote($typeId, $text, $options);
+ }
+
+ return $notes;
}
/**
@@ -889,17 +916,26 @@
*
* @return QubitNote created note
*/
- public function createNote($typeId, $text, $transformationLogic = false)
+ public function createOrUpdateNote($typeId, $text, $options = array())
{
- $note = new QubitNote;
- $note->objectId = $this->object->id;
- $note->typeId = $typeId;
- if ($transformationLogic)
+ if (isset($options['noteId']))
+ {
+ $note = QubitNote::getById($options['noteId']);
+ }
+ else
{
- $text = $transformationLogic($this, $text);
+ $note = new QubitNote;
+ $note->objectId = $this->object->id;
+ $note->typeId = $typeId;
}
+
+ if (isset($options['transformationLogic']))
+ {
+ $transformer = $options['transformationLogic'];
+ $text = $transformer($this, $text);
+ }
+
$note->content = $this->content($text);
- $note->scope = 'QubitTerm'; # not sure if this is needed
$note->save();
return $note;
--
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.