Author: mcantelon
Date: Wed Feb 1 20:35:18 2012
New Revision: 10791
Log:
Added in loading of alternate names in authory record import.
Modified:
trunk/lib/task/import/csvAuthorityRecordImportTask.class.php
Modified: trunk/lib/task/import/csvAuthorityRecordImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvAuthorityRecordImportTask.class.php Wed Feb
1 20:03:49 2012 (r10790)
+++ trunk/lib/task/import/csvAuthorityRecordImportTask.class.php Wed Feb
1 20:35:18 2012 (r10791)
@@ -35,6 +35,18 @@
EOF;
/**
+ * @see csvImportBaseTask
+ */
+ protected function configure()
+ {
+ parent::configure();
+
+ $this->addOptions(array(
+ new sfCommandOption('alias-file', null,
sfCommandOption::PARAMETER_OPTIONAL, 'CSV file containing aliases.')
+ ));
+ }
+
+ /**
* @see sfTask
*/
public function execute($arguments = array(), $options = array())
@@ -47,6 +59,44 @@
? $options['source-name']
: basename($arguments['filename']);
+ // if alias file option set, load aliases from CSV
+ $aliases = array();
+
+ if ($options['alias-file'])
+ {
+ // open alias CSV file
+ if (false === $fh = fopen($options['alias-file'], 'rb'))
+ {
+ throw new sfException('You must specify a valid filename');
+ } else {
+ print "Reading aliases\n";
+
+ // import name aliases, if specified
+ $import = new QubitFlatfileImport(array(
+ 'columnNames' => fgetcsv($fh, 60000),
+ 'status' => array(
+ 'aliases' => array()
+ ),
+ 'ignoreColumns' => array(
+ 'RecordID'
+ ),
+ 'variableColumns' => array(
+ 'parentAuthority',
+ 'OtherName'
+ ),
+ 'saveLogic' => function(&$self)
+ {
+ $aliases = $self->getStatus('aliases');
+ $aliases[($self->rowStatusVars['parentAuthority'])]
+ = $self->rowStatusVars['OtherName'];
+ $self->setStatus('aliases', $aliases);
+ }
+ ));
+ }
+ $import->csv($fh);
+ $aliases = $import->getStatus('aliases');
+ }
+
if (false === $fh = fopen($arguments['filename'], 'rb'))
{
throw new sfException('You must specify a valid filename');
@@ -76,7 +126,8 @@
from closure logic using the getStatus method */
'status' => array(
'sourceName' => $sourceName,
- 'actorTypes' => $termData['actorTypes']
+ 'actorTypes' => $termData['actorTypes'],
+ 'aliases' => $aliases
),
'columnNames' => fgetcsv($fh, 60000), // 1st row supplies column
names/order
'ignoreColumns' => array(
@@ -139,6 +190,12 @@
throw new sfException($entityType .' is not a valid actor entity
type.');
}
}
+
+ $aliases = $self->getStatus('aliases');
+ if (array_search($self->object->authorizedFormOfName, $aliases))
+ {
+print 'found';exit();
+ }
}
},
));
--
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.