[Rt-commit] rt branch, 4.2/migrator-fixes, updated. rt-4.2.12-122-gcd06315
Shawn Moore
shawn at bestpractical.com
Thu Mar 24 21:32:30 EDT 2016
The branch, 4.2/migrator-fixes has been updated
via cd06315e3d98c6ee1094afa22776d5296c9c8f96 (commit)
from 1240499ed3e548486b2a857447c8db990a09a987 (commit)
Summary of changes:
lib/RT/Migrate/Importer.pm | 20 ++++++++++++++------
lib/RT/Migrate/Importer/File.pm | 2 +-
sbin/rt-importer.in | 18 +++++++++++++-----
3 files changed, 28 insertions(+), 12 deletions(-)
- Log -----------------------------------------------------------------
commit cd06315e3d98c6ee1094afa22776d5296c9c8f96
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Fri Mar 25 01:29:47 2016 +0000
--exclude-organization option for rt-importer
When records are already known to be unique this is unwanted noise.
Fixes: I#31813
Fixes: I#31812
diff --git a/lib/RT/Migrate/Importer.pm b/lib/RT/Migrate/Importer.pm
index 0e6456a..5c25d9a 100644
--- a/lib/RT/Migrate/Importer.pm
+++ b/lib/RT/Migrate/Importer.pm
@@ -65,17 +65,20 @@ sub new {
sub Init {
my $self = shift;
my %args = (
- OriginalId => undef,
- Progress => undef,
- Statefile => undef,
- DumpObjects => undef,
- HandleError => undef,
+ OriginalId => undef,
+ Progress => undef,
+ Statefile => undef,
+ DumpObjects => undef,
+ HandleError => undef,
+ ExcludeOrganization => undef,
@_,
);
# Should we attempt to preserve record IDs as they are created?
$self->{OriginalId} = $args{OriginalId};
+ $self->{ExcludeOrganization} = $args{ExcludeOrganization};
+
$self->{Progress} = $args{Progress};
$self->{HandleError} = sub { 0 };
@@ -294,6 +297,7 @@ sub Qualify {
my ($string) = @_;
return $string if $self->{Clone};
return $string if not defined $self->{Organization};
+ return $string if $self->{ExcludeOrganization};
return $string if $self->{Organization} eq $RT::Organization;
return $self->{Organization}.": $string";
}
@@ -402,9 +406,13 @@ sub ReadStream {
# If it's a ticket, we might need to create a
# TicketCustomField for the previous ID
if ($class eq "RT::Ticket" and $self->{OriginalId}) {
+ my $value = $self->{ExcludeOrganization}
+ ? $origid
+ : $self->Organization . ":$origid";
+
my ($id, $msg) = $obj->AddCustomFieldValue(
Field => $self->{OriginalId},
- Value => $self->Organization . ":$origid",
+ Value => $value,
RecordTransaction => 0,
);
warn "Failed to add custom field to $uid: $msg"
diff --git a/lib/RT/Migrate/Importer/File.pm b/lib/RT/Migrate/Importer/File.pm
index cfad9ae..3d36f3d 100644
--- a/lib/RT/Migrate/Importer/File.pm
+++ b/lib/RT/Migrate/Importer/File.pm
@@ -192,7 +192,7 @@ sub SaveState {
NewQueues NewCFs
SkipTransactions Pending Invalid
UIDs
- OriginalId Clone
+ OriginalId ExcludeOrganization Clone
/;
Storable::nstore(\%data, $self->{Statefile});
diff --git a/sbin/rt-importer.in b/sbin/rt-importer.in
index 6d3cda5..1f9e6e6 100644
--- a/sbin/rt-importer.in
+++ b/sbin/rt-importer.in
@@ -95,6 +95,7 @@ GetOptions(
"resume!",
"originalid|i=s",
+ "exclude-organization",
"ask",
"ignore-errors",
@@ -142,11 +143,12 @@ elsif ($OPT{'ignore-errors'}) {
}
my $import = RT::Migrate::Importer::File->new(
- Directory => $dir,
- OriginalId => $OPT{originalid},
- DumpObjects => $OPT{dump},
- Resume => $OPT{resume},
- HandleError => $error_handler,
+ Directory => $dir,
+ OriginalId => $OPT{originalid},
+ ExcludeOrganization => $OPT{'exclude-organization'},
+ DumpObjects => $OPT{dump},
+ Resume => $OPT{resume},
+ HandleError => $error_handler,
);
if ($import->Metadata and -t STDOUT and not $OPT{quiet}) {
@@ -236,6 +238,12 @@ Places the original ticket organization and ID into a global custom
field with the given name. If no global ticket custom field with that
name is found in the current database, it will create one.
+=item B<--exclude-organization>
+
+Ordinarily certain records (groups, queues, the B<--originalid> custom field)
+include the organization name of the original RT instance. Use this option to
+suppress that behavior and use the original name directly.
+
=item B<--ask>
Prompt for action when an error occurs inserting a record into the
-----------------------------------------------------------------------
More information about the rt-commit
mailing list