diff options
author | Ivan Kohler <ivan@freeside.biz> | 2017-08-06 10:11:28 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2017-08-06 10:11:28 -0700 |
commit | de9d037528895f7151a9aead6724ce2df95f9586 (patch) | |
tree | 3ba47a923a1d6033605ffc5586ed1af439d8c141 /rt/lib/RT/Migrate | |
parent | b226bc6bd81f999176cdbfa53a799033ff0a0307 (diff) |
rt 4.2.14 (#13852)
Diffstat (limited to 'rt/lib/RT/Migrate')
-rw-r--r-- | rt/lib/RT/Migrate/Importer.pm | 27 | ||||
-rw-r--r-- | rt/lib/RT/Migrate/Importer/File.pm | 4 | ||||
-rw-r--r-- | rt/lib/RT/Migrate/Incremental.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Migrate/Serializer.pm | 43 | ||||
-rw-r--r-- | rt/lib/RT/Migrate/Serializer/File.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Migrate/Serializer/IncrementalRecord.pm | 2 | ||||
-rw-r--r-- | rt/lib/RT/Migrate/Serializer/IncrementalRecords.pm | 2 |
7 files changed, 65 insertions, 17 deletions
diff --git a/rt/lib/RT/Migrate/Importer.pm b/rt/lib/RT/Migrate/Importer.pm index 7897434..c0faade 100644 --- a/rt/lib/RT/Migrate/Importer.pm +++ b/rt/lib/RT/Migrate/Importer.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -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 }; @@ -179,6 +182,9 @@ sub Resolve { Field => $ref->{uri}, Value => $self->LookupObj($uid)->URI, ) if defined $ref->{uri}; + if (my $method = $ref->{method}) { + $obj->$method($self, $ref, $class, $id); + } } delete $self->{Pending}{$uid}; } @@ -291,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"; } @@ -332,7 +339,7 @@ sub Create { # Load it back to get real values into the columns $obj = $class->new( RT->SystemUser ); $obj->Load( $id ); - $obj->PostInflate( $self ); + $obj->PostInflate( $self, $uid ); return $obj; } @@ -399,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/rt/lib/RT/Migrate/Importer/File.pm b/rt/lib/RT/Migrate/Importer/File.pm index cfad9ae..cf3362b 100644 --- a/rt/lib/RT/Migrate/Importer/File.pm +++ b/rt/lib/RT/Migrate/Importer/File.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -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/rt/lib/RT/Migrate/Incremental.pm b/rt/lib/RT/Migrate/Incremental.pm index f4ea8d2..b1e5c87 100644 --- a/rt/lib/RT/Migrate/Incremental.pm +++ b/rt/lib/RT/Migrate/Incremental.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) diff --git a/rt/lib/RT/Migrate/Serializer.pm b/rt/lib/RT/Migrate/Serializer.pm index f938bc1..3855ee9 100644 --- a/rt/lib/RT/Migrate/Serializer.pm +++ b/rt/lib/RT/Migrate/Serializer.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) @@ -58,6 +58,7 @@ sub cmp_version($$) { RT::Handle::cmp_version($_[0],$_[1]) }; use RT::Migrate::Incremental; use RT::Migrate::Serializer::IncrementalRecord; use RT::Migrate::Serializer::IncrementalRecords; +use List::MoreUtils 'none'; sub Init { my $self = shift; @@ -88,6 +89,9 @@ sub Init { FollowScrips FollowTickets FollowACL + Queues + CustomFields + HyperlinkUnmigrated Clone Incremental /; @@ -251,6 +255,11 @@ sub PushBasics { OPERATOR => 'IN', VALUE => [ qw/RT::User RT::Group RT::Queue/ ], ); + + if ($self->{CustomFields}) { + $cfs->Limit(FIELD => 'id', OPERATOR => 'IN', VALUE => $self->{CustomFields}); + } + $self->PushObj( $cfs ); # Global attributes @@ -293,7 +302,14 @@ sub PushBasics { $self->PushCollections(qw(Topics Classes)); } - $self->PushCollections(qw(Queues)); + if ($self->{Queues}) { + my $queues = RT::Queues->new(RT->SystemUser); + $queues->Limit(FIELD => 'id', OPERATOR => 'IN', VALUE => $self->{Queues}); + $self->PushObj($queues); + } + else { + $self->PushCollections(qw(Queues)); + } } sub InitStream { @@ -400,7 +416,25 @@ sub Observe { my $from = $args{from}; if ($obj->isa("RT::Ticket")) { return 0 if $obj->Status eq "deleted" and not $self->{FollowDeleted}; + my $queue = $obj->Queue; + return 0 if $self->{Queues} && none { $queue == $_ } @{ $self->{Queues} }; return $self->{FollowTickets}; + } elsif ($obj->isa("RT::Queue")) { + my $id = $obj->Id; + return 0 if $self->{Queues} && none { $id == $_ } @{ $self->{Queues} }; + return 1; + } elsif ($obj->isa("RT::CustomField")) { + my $id = $obj->Id; + return 0 if $self->{CustomFields} && none { $id == $_ } @{ $self->{CustomFields} }; + return 1; + } elsif ($obj->isa("RT::ObjectCustomFieldValue")) { + my $id = $obj->CustomField; + return 0 if $self->{CustomFields} && none { $id == $_ } @{ $self->{CustomFields} }; + return 1; + } elsif ($obj->isa("RT::ObjectCustomField")) { + my $id = $obj->CustomField; + return 0 if $self->{CustomFields} && none { $id == $_ } @{ $self->{CustomFields} }; + return 1; } elsif ($obj->isa("RT::ACE")) { return $self->{FollowACL}; } elsif ($obj->isa("RT::Scrip") or $obj->isa("RT::Template") or $obj->isa("RT::ObjectScrip")) { @@ -473,10 +507,13 @@ sub Visit { \%data, ); } else { + my %serialized = $obj->Serialize(serializer => $self); + return unless %serialized; + @store = ( ref($obj), $obj->UID, - { $obj->Serialize }, + \%serialized, ); } diff --git a/rt/lib/RT/Migrate/Serializer/File.pm b/rt/lib/RT/Migrate/Serializer/File.pm index c8642ea..f5f503e 100644 --- a/rt/lib/RT/Migrate/Serializer/File.pm +++ b/rt/lib/RT/Migrate/Serializer/File.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) diff --git a/rt/lib/RT/Migrate/Serializer/IncrementalRecord.pm b/rt/lib/RT/Migrate/Serializer/IncrementalRecord.pm index 4bbd4e8..111acf6 100644 --- a/rt/lib/RT/Migrate/Serializer/IncrementalRecord.pm +++ b/rt/lib/RT/Migrate/Serializer/IncrementalRecord.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) diff --git a/rt/lib/RT/Migrate/Serializer/IncrementalRecords.pm b/rt/lib/RT/Migrate/Serializer/IncrementalRecords.pm index 3bb19c6..e3f5300 100644 --- a/rt/lib/RT/Migrate/Serializer/IncrementalRecords.pm +++ b/rt/lib/RT/Migrate/Serializer/IncrementalRecords.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC # <sales@bestpractical.com> # # (Except where explicitly superseded by other copyright notices) |