Author: mcantelon
Date: Wed Aug 22 16:56:20 2012
New Revision: 12172
Log:
Added CSV CLI import option to specify a legacy parent ID.
Modified:
trunk/lib/task/import/csvImportTask.class.php
Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php Wed Aug 22 15:30:04
2012 (r12171)
+++ trunk/lib/task/import/csvImportTask.class.php Wed Aug 22 16:56:20
2012 (r12172)
@@ -43,8 +43,24 @@
parent::configure();
$this->addOptions(array(
- new sfCommandOption('source-name', null,
sfCommandOption::PARAMETER_OPTIONAL, 'Source name to use when inserting keymap
entries.'),
- new sfCommandOption('parent-slug', null,
sfCommandOption::PARAMETER_OPTIONAL, 'Parent slug under which imported items
will be added.')
+ new sfCommandOption(
+ 'source-name',
+ null,
+ sfCommandOption::PARAMETER_OPTIONAL,
+ 'Source name to use when inserting keymap entries.'
+ ),
+ new sfCommandOption(
+ 'parent-slug',
+ null,
+ sfCommandOption::PARAMETER_OPTIONAL,
+ 'Parent slug under which imported items will be added.'
+ ),
+ new sfCommandOption(
+ 'legacy-parent-id',
+ null,
+ sfCommandOption::PARAMETER_OPTIONAL,
+ 'Legacy parent ID under which imported items will be added.'
+ )
));
}
@@ -384,6 +400,7 @@
throw new sfException('Both parentId and qubitParentSlug are set:
only one should be set.');
}
+ // if a parent slug has been specified in the row or via the
command-line, attempt lookup
if (
(
isset($self->rowStatusVars['qubitParentSlug'])
@@ -414,7 +431,14 @@
throw new sfException('Could not find information object matching
slug "'. $parentSlug .'"');
}
} else {
- if (!isset($self->rowStatusVars['parentId']) ||
!$self->rowStatusVars['parentId'])
+ // if a legacy parent ID hasn't been specified in the row or via the
commandline, don't lookup
+ if (
+ (
+ !isset($self->rowStatusVars['parentId'])
+ || !$self->rowStatusVars['parentId']
+ )
+ && !$self->status['options']['legacy-parent-id']
+ )
{
// Don't overwrite valid parentId when adding an i18n row
if (!isset($self->object->parentId))
@@ -422,8 +446,15 @@
$parentId = QubitInformationObject::ROOT_ID;
}
} else {
+ // if a legacy parent ID is specified by the command-line, that
will
+ // override any legacy parent ID specified in the current CSV row
+ $legacyParentId = ($self->status['options']['legacy-parent-id'])
+ ? $self->status['options']['legacy-parent-id']
+ : $self->rowStatusVars['parentId'];
+
+ // lookup Qubit parent ID using legacy parent ID
if ($mapEntry = $self->fetchKeymapEntryBySourceAndTargetName(
- $self->rowStatusVars['parentId'],
+ $legacyParentId,
$self->getStatus('sourceName'),
'information_object'
))
@@ -433,7 +464,7 @@
$error = 'For legacyId '
. $self->rowStatusVars['legacyId']
.' Could not find parentId '
- . $self->rowStatusVars['parentId']
+ . $legacyParentId
.' in key_map table';
print $self->logError($error);
}
--
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.