Author: mcantelon
Date: Mon Jan 2 16:49:41 2012
New Revision: 10523
Log:
Refactoring.
Modified:
trunk/lib/QubitFlatfileImport.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Mon Jan 2 15:47:38 2012
(r10522)
+++ trunk/lib/QubitFlatfileImport.class.php Mon Jan 2 16:49:41 2012
(r10523)
@@ -79,19 +79,21 @@
}
}
+ public function unhandledColumn($column) {
+ return !in_array($column, $this->ignoreColumns)
+ && !in_array($column, $this->standardColumns)
+ && !isset($this->columnMap[$column])
+ && !isset($this->propertyMap[$column])
+ && !isset($this->noteMap[$column])
+ && !isset($this->handlers[$column]);
+ }
+
public function determineUnhandledColumns()
{
$ignored = array();
foreach($this->columns as $column)
{
- if (
- !in_array($column, $this->ignoreColumns)
- && !in_array($column, $this->standardColumns)
- && !isset($this->columnMap[$column])
- && !isset($this->propertyMap[$column])
- && !isset($this->noteMap[$column])
- && !isset($this->handlers[$column])
- )
+ if ($this->unhandledColumn($column))
{
array_push($ignored, $column);
}
@@ -108,11 +110,8 @@
if (count($ignored))
{
- print count($ignored) . " columns aren't handled or ignored:\n";
- foreach($ignored as $ignore)
- {
- $output .= ' '. $ignore ."\n";
- }
+ $output .= count($ignored) . " columns aren't handled or ignored:\n";
+ $output .= ' '. implode("\n ", $ignored) ."\n";
}
return $output;
@@ -144,6 +143,22 @@
}
}
+ public function mappedColumnHandler($mapDefinition, $value) {
+ if (is_array($mapDefinition))
+ {
+ // tranform value is logic provided to do so
+ if (is_callable($mapDefinition['transformationLogic']))
+ {
+ $this->informationObject->{$mapDefinition['column']}
+ = $mapDefinition['transformationLogic']($this, $value);
+ } else {
+ $this->informationObject->{$mapDefinition['column']} = $value;
+ }
+ } else {
+ $this->informationObject->{$mapDefinition} = $value;
+ }
+ }
+
public function row($row = array())
{
// execute row initialization logic
@@ -155,19 +170,7 @@
// if column maps to an attribute, set the attribute
if (isset($self->columnMap) && isset($self->columnMap[$columnName]))
{
- if (is_array($self->columnMap[$columnName]))
- {
- // tranform value is logic provided to do so
- if
(is_callable($self->columnMap[$columnName]['transformationLogic']))
- {
- $self->informationObject->{$self->columnMap[$columnName]['column']}
- = $self->columnMap[$columnName]['transformationLogic']($self,
$value);
- } else {
-
$self->informationObject->{$self->columnMap[$columnName]['column']} = $value;
- }
- } else {
- $self->informationObject->{$self->columnMap[$columnName]} = $value;
- }
+ $self->mappedColumnHandler($self->columnMap[$columnName], $value);
}
else if (
isset($self->columns[$index])
--
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.