Author: mcantelon
Date: Thu Dec 29 13:51:49 2011
New Revision: 10469
Log:
Fixed import logic so creation of child data happens after creation of parent.
Modified:
trunk/lib/task/csvImportTask.class.php
Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php Thu Dec 29 13:02:04 2011
(r10468)
+++ trunk/lib/task/csvImportTask.class.php Thu Dec 29 13:51:49 2011
(r10469)
@@ -179,6 +179,7 @@
'rowComplete',
'rowStatusVars',
'propertyMap',
+ 'noteMap',
'columnMap'
);
@@ -269,7 +270,7 @@
// execute row initialization logic
$this->executeClosurePropertyIfSet('rowInit');
- // deal with data in each of row's columns
+ // process import columns, except those that produce child data
for ($index = 0; $index < sizeof($row); $index++)
{
@@ -281,40 +282,43 @@
{
$this->informationObject->{$this->columnMap[$columnName]} =
$row[$index];
}
- else {
-
- // if column maps to a property, set the property
- if (isset($this->propertyMap) &&
isset($this->propertyMap[$columnName]))
- {
- $this->informationObject->addProperty(
- $this->propertyMap[$columnName],
- $row[$index]
- );
- }
- else if (isset($this->noteMap) && isset($this->noteMap[$columnName]))
- {
- $this->createNote($this->noteMap[$columnName], $row[index]);
- }
- else {
-
- // otherwise, if column is data and a handler is set, use it
- if (
- isset($this->columns[$index])
- && isset($this->handlers[($this->columns[$index])])
- )
- {
- call_user_func_array(
- $this->handlers[$columnName],
- array(&$this, $row[$index])
- );
- }
- }
+ else if (
+ isset($this->columns[$index])
+ && isset($this->handlers[($this->columns[$index])])
+ )
+ {
+ // otherwise, if column is data and a handler is set, use it
+ call_user_func_array(
+ $this->handlers[$columnName],
+ array(&$this, $row[$index])
+ );
}
}
// execute row completion logic
$this->executeClosurePropertyIfSet('rowComplete');
+ // process import columns that produce child data
+ for ($index = 0; $index < sizeof($row); $index++)
+ {
+ // determine what type of data should be in this column
+ $columnName = $this->columns[$index];
+
+ // if column maps to a property, set the property
+ if (isset($this->propertyMap) && isset($this->propertyMap[$columnName]))
+ {
+ $this->informationObject->addProperty(
+ $this->propertyMap[$columnName],
+ $row[$index]
+ );
+ }
+ else if (isset($this->noteMap) && isset($this->noteMap[$columnName]))
+ {
+ // otherwise, if maps to a note, create it
+ $this->createNote($this->noteMap[$columnName], $row[$index]);
+ }
+ }
+
// increment number of completed rows
$this->status['rows']++;
--
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.