Author: mcantelon
Date: Thu Jan 12 11:03:47 2012
New Revision: 10655
Log:
Added error logging to import tool.
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 12 10:33:29 2012
(r10654)
+++ trunk/lib/QubitFlatfileImport.class.php Thu Jan 12 11:03:47 2012
(r10655)
@@ -39,6 +39,7 @@
$this->arrayColumns = array();
$allowedOptions = array(
+ 'errorLog',
'className',
'rowInitLogic',
'rowsUntilProgressDisplay',
@@ -428,6 +429,12 @@
$this->rowStatusVars = array();
}
+ public function logError($message)
+ {
+ $message = 'Row '. $this->getStatus('rows') .': '. $message ."\n";
+ if ($this->errorLog) file_put_contents($this->errorLog, $message,
FILE_APPEND);
+ }
+
public function progressDescription()
{
// return empty string if no intermittant progress display
Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php Thu Jan 12 10:33:29 2012
(r10654)
+++ trunk/lib/task/csvImportTask.class.php Thu Jan 12 11:03:47 2012
(r10655)
@@ -41,7 +41,8 @@
$this->addOptions(array(
new sfCommandOption('rows-until-update', null,
sfCommandOption::PARAMETER_OPTIONAL, 'Output total rows imported every n
rows.'),
- new sfCommandOption('skip-rows', null,
sfCommandOption::PARAMETER_OPTIONAL, 'Skip n rows before importing.')
+ new sfCommandOption('skip-rows', null,
sfCommandOption::PARAMETER_OPTIONAL, 'Skip n rows before importing.'),
+ new sfCommandOption('error-log', null,
sfCommandOption::PARAMETER_OPTIONAL, 'File to log errors to.')
));
$this->namespace = 'csv';
@@ -64,6 +65,11 @@
throw new sfException($option .' must be an integer');
}
}
+
+ if ($options['error-log'] && !is_dir(dirname($options['error-log'])))
+ {
+ throw new sfException('Path to error log is invalid.');
+ }
}
/**
@@ -109,6 +115,8 @@
'className' => 'QubitInformationObject',
/* How many rows should import until we display an import status update?
*/
'rowsUntilProgressDisplay' => $options['rows-until-update'],
+ /* Where to log errors to */
+ 'errorLog' => $options['error-log'],
/* the status array is a place to put data that should be accessible
from closure logic using the getStatus method */
'status' => array(
@@ -243,8 +251,7 @@
{
$parentId = $mapEntry->target_id;
} else {
- print "\nERROR: COULD NOT FIND PARENT\n";
- //throw new sfException('Could not find parent '.
$self->rowStatusVars['PARENT_ID'] .'in key_map table');
+ $self->logError('Could not find parent '.
$self->rowStatusVars['PARENT_ID'] .'in key_map table');
}
}
@@ -381,15 +388,11 @@
'copyrightStatusId' => 306
));
} else {
- print "\nERROR: COPYRIGHT HOLDER NOT FOUND\n";
- // throw new sfException('Copyright holder not specified');
+ $this->logError('Copyright holder not specified.');
}
break;
case 'unknown':
- print "\ERROR: UNKNOWN COPYRIGHT HOLDER\n";
- break;
-
case 'public domain':
$self->createRightAndRelation(array(
'restriction' => 1,
@@ -480,6 +483,8 @@
}
));
+$import->logError('dfdfdfdf');
+
$import->addColumnHandler('levelOfDescription', function(&$self, $data)
{
$self->object->setLevelOfDescriptionByName($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.