Author: mcantelon
Date: Wed Jan 4 17:25:57 2012
New Revision: 10566
Log:
Got rid of redundant handlers that just stash data by adding specification of
varibleColumns during import setup.
Modified:
trunk/lib/QubitFlatfileImport.class.php
trunk/lib/task/csvImportTask.class.php
Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php Wed Jan 4 16:59:29 2012
(r10565)
+++ trunk/lib/QubitFlatfileImport.class.php Wed Jan 4 17:25:57 2012
(r10566)
@@ -40,7 +40,8 @@
'propertyMap',
'noteMap',
'columnMap',
- 'standardColumns'
+ 'standardColumns',
+ 'variableColumns'
);
// set properties from options, halting upon invalid option
@@ -96,7 +97,8 @@
&& !isset($this->columnMap[$column])
&& !isset($this->propertyMap[$column])
&& !isset($this->noteMap[$column])
- && !isset($this->handlers[$column]);
+ && !isset($this->handlers[$column])
+ && !in_array($column, $this->variableColumns);
}
public function determineUnhandledColumns()
@@ -206,7 +208,7 @@
&& isset($self->handlers[($self->columns[$index])])
)
{
- // otherwise, if column is data and a handler is set, use it
+ // otherwise, if column is data and a handler for it is set, use it
call_user_func_array(
$self->handlers[$columnName],
array($self, $value)
@@ -214,9 +216,17 @@
}
else if (
isset($self->columns[$index])
+ && in_array($self->columns[$index], $self->variableColumns)
+ )
+ {
+ $self->rowStatusVars[$self->columns[$index]] = $value;
+ }
+ else if (
+ isset($self->columns[$index])
&& in_array($self->columns[$index], $self->standardColumns)
)
{
+ // otherwise, if column is data and it's a standard column, use it
$self->informationObject->{$self->columns[$index]} = $value;
}
});
Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php Wed Jan 4 16:59:29 2012
(r10565)
+++ trunk/lib/task/csvImportTask.class.php Wed Jan 4 17:25:57 2012
(r10566)
@@ -173,6 +173,13 @@
}
)
),
+ 'variableColumns' => array(
+ 'datesOfCreation',
+ 'copyrightStatus',
+ 'copyrightExpires',
+ 'copyrightHolder',
+ 'datesOfCreationNote'
+ ),
'rowInit' => function(&$self)
{
$self->informationObject = new QubitInformationObject;
@@ -209,6 +216,7 @@
}
}
+ // add name access points
if (isset($self->rowStatusVars['nameAccessPoints']))
{
// add name access points
@@ -249,7 +257,7 @@
}
// add copyright info
- if (isset($self->rowStatusVars['copyrightStatus']))
+ if (isset($self->rowStatusVars['copyrightStatus']) &&
$self->rowStatusVars['copyrightStatus'])
{
switch ($self->rowStatusVars['copyrightStatus'])
{
@@ -284,7 +292,9 @@
break;
default:
- throw new sfException('Copyright status not handled: adjust
script or import data');
+ throw new sfException('Copyright status "'
+ . $self->rowStatusVars['copyrightStatus']
+ .'" not handled: adjust script or import data');
break;
}
}
@@ -402,34 +412,6 @@
$self->rowStatusVars['endYear'] = $data;
});
- $import->addColumnHandler('datesOfCreation', function(&$self, $data)
- {
- $self->rowStatusVars['datesOfCreation'] = $data;
- });
-
- $import->addColumnHandler('copyrightStatus', function(&$self, $data)
- {
- if (trim($data))
- {
- $self->rowStatusVars['copyrightStatus'] = $data;
- }
- });
-
- $import->addColumnHandler('copyrightExpires', function(&$self, $data)
- {
- $self->rowStatusVars['copyrightExpires'] = $data;
- });
-
- $import->addColumnHandler('copyrightHolder', function(&$self, $data)
- {
- $self->rowStatusVars['copyrightHolder'] = $data;
- });
-
- $import->addColumnHandler('datesOfCreationNote', function(&$self, $data)
- {
- $self->rowStatusVars['datesOfCreationNote'] = $data;
- });
-
$import->addColumnHandler('subjectAccessPoints', 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.