Author: mcantelon
Date: Mon Jan 2 17:10:43 2012
New Revision: 10525
Log:
Refactored row processing, creating new methods for pre-save (of information
object) and post-save logic.
Modified:
trunk/lib/QubitFlatfileImport.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Mon Jan 2 17:08:59 2012
(r10524)
+++ trunk/lib/QubitFlatfileImport.class.php Mon Jan 2 17:10:43 2012
(r10525)
@@ -79,7 +79,8 @@
}
}
- public function unhandledColumn($column) {
+ public function unhandledColumn($column)
+ {
return !in_array($column, $this->ignoreColumns)
&& !in_array($column, $this->standardColumns)
&& !isset($this->columnMap[$column])
@@ -143,7 +144,8 @@
}
}
- public function mappedColumnHandler($mapDefinition, $value) {
+ public function mappedColumnHandler($mapDefinition, $value)
+ {
if (is_array($mapDefinition))
{
// tranform value is logic provided to do so
@@ -159,11 +161,8 @@
}
}
- public function row($row = array())
- {
- // execute row initialization logic
- $this->executeClosurePropertyIfSet('rowInit');
-
+ protected function rowProcessingBeforeSave($row)
+ {
// process import columns that don't produce child data
$this->forEachRowColumn($row, function(&$self, $index, $columnName, $value)
{
@@ -191,11 +190,10 @@
$self->informationObject->{$self->columns[$index]} = $value;
}
});
+ }
- // execute row completion logic
- $this->executeClosurePropertyIfSet('rowComplete');
-
- // process import columns that produce child data
+ protected function rowProcessingAfterSave($row)
+ {
$this->forEachRowColumn($row, function(&$self, $index, $columnName, $value)
{
@@ -216,11 +214,26 @@
$self->createNote($self->noteMap[$columnName]['typeId'], $value,
$transformationLogic);
}
});
+ }
+
+ public function row($row = array())
+ {
+ // execute row initialization logic
+ $this->executeClosurePropertyIfSet('rowInit');
+
+ // set fields in information object and execute custom column handlers
+ $this->rowProcessingBeforeSave($row);
+
+ // execute row completion logic
+ $this->executeClosurePropertyIfSet('rowComplete');
+
+ // process import columns that produce child data (properties and notes)
+ $this->rowProcessingAfterSave($row);
// increment number of completed rows
$this->status['rows']++;
- // get rid of row-specific status variables
+ // reset row-specific status variables
$this->rowStatusVars = array();
}
--
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.