Author: mcantelon
Date: Thu Jan 5 11:25:36 2012
New Revision: 10570
Log:
Replaced a bunch of redundant column handlers with an abstraction.
Modified:
trunk/lib/QubitFlatfileImport.class.php
trunk/lib/task/csvImportTask.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Thu Jan 5 00:03:40 2012
(r10569)
+++ trunk/lib/QubitFlatfileImport.class.php Thu Jan 5 11:25:36 2012
(r10570)
@@ -41,7 +41,8 @@
'noteMap',
'columnMap',
'standardColumns',
- 'variableColumns'
+ 'variableColumns',
+ 'arrayColumns'
);
// set properties from options, halting upon invalid option
@@ -98,7 +99,8 @@
&& !isset($this->propertyMap[$column])
&& !isset($this->noteMap[$column])
&& !isset($this->handlers[$column])
- && !in_array($column, $this->variableColumns);
+ && !in_array($column, $this->variableColumns)
+ && !isset($this->arrayColumns[$column]);
}
public function determineUnhandledColumns()
@@ -193,6 +195,14 @@
}
}
+ public function arrayColumnHandler($column, $arrayDefinition, $value)
+ {
+ if ($value)
+ {
+ $this->rowStatusVars[$column] = explode($arrayDefinition, $value);
+ }
+ }
+
protected function rowProcessingBeforeSave($row)
{
// process import columns that don't produce child data
@@ -223,6 +233,13 @@
}
else if (
isset($self->columns[$index])
+ && isset($self->arrayColumns[($self->columns[$index])])
+ )
+ {
+ $self->arrayColumnHandler($columnName,
$self->arrayColumns[$columnName], $value);
+ }
+ else if (
+ isset($self->columns[$index])
&& in_array($self->columns[$index], $self->standardColumns)
)
{
Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php Thu Jan 5 00:03:40 2012
(r10569)
+++ trunk/lib/task/csvImportTask.class.php Thu Jan 5 11:25:36 2012
(r10570)
@@ -173,6 +173,7 @@
}
)
),
+ /* these values get stored to ZZZZ */
'variableColumns' => array(
'datesOfCreation',
'copyrightStatus',
@@ -182,6 +183,14 @@
'datesOfCreationStart',
'datesOfCreationEnd'
),
+ /* these values get stored to ZZZZ */
+ 'arrayColumns' => array(
+ 'creators' => '|',
+ 'creatorHistory' => '|',
+ 'subjectAccessPoints' => '|',
+ 'placeAccessPoints' => '|',
+ 'nameAccessPoints' => '|'
+ ),
'rowInit' => function(&$self)
{
$self->informationObject = new QubitInformationObject;
@@ -388,46 +397,6 @@
}
});
- $import->addColumnHandler('creators', function(&$self, $data)
- {
- if ($data)
- {
- $self->rowStatusVars['creators'] = explode('|', $data);
- }
- });
-
- $import->addColumnHandler('creatorHistory', function(&$self, $data)
- {
- if ($data)
- {
- $self->rowStatusVars['creatorHistory'] = explode('|', $data);
- }
- });
-
- $import->addColumnHandler('subjectAccessPoints', function(&$self, $data)
- {
- if ($data)
- {
- $self->rowStatusVars['subjectAccessPoints'] = explode('|', $data);
- }
- });
-
- $import->addColumnHandler('placeAccessPoints', function(&$self, $data)
- {
- if ($data)
- {
- $self->rowStatusVars['placeAccessPoints'] = explode('|', $data);
- }
- });
-
- $import->addColumnHandler('nameAccessPoints', function(&$self, $data)
- {
- if ($data)
- {
- $self->rowStatusVars['nameAccessPoints'] = explode('|', $data);
- }
- });
-
$import->addColumnHandler('radGeneralMaterialDesignation',
function(&$self, $data)
{
if ($data)
--
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.