[Bps-public-commit] r15364 - in sd/trunk: . lib/App/SD lib/App/SD/ForeignReplica lib/App/SD/Replica/debbugs lib/App/SD/Replica/hm lib/App/SD/Replica/rt

jesse at bestpractical.com jesse at bestpractical.com
Fri Aug 22 09:19:50 EDT 2008


Author: jesse
Date: Fri Aug 22 09:19:48 2008
New Revision: 15364

Added:
   sd/trunk/lib/App/SD/ForeignReplica/
   sd/trunk/lib/App/SD/ForeignReplica.pm
   sd/trunk/lib/App/SD/ForeignReplica/PullEncoder.pm
   sd/trunk/lib/App/SD/ForeignReplica/PushEncoder.pm
   sd/trunk/lib/App/SD/Replica/debbugs/
   sd/trunk/lib/App/SD/Replica/debbugs.pm
   sd/trunk/lib/App/SD/Replica/debbugs/PullEncoder.pm
   sd/trunk/lib/App/SD/Replica/debbugs/PushEncoder.pm
Modified:
   sd/trunk/   (props changed)
   sd/trunk/lib/App/SD/Replica/hm.pm
   sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm
   sd/trunk/lib/App/SD/Replica/rt.pm
   sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm

Log:
Meregdown from the debbugs to get us the extractions of common foreignreplica code

Added: sd/trunk/lib/App/SD/ForeignReplica.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/ForeignReplica.pm	Fri Aug 22 09:19:48 2008
@@ -0,0 +1,127 @@
+package App::SD::ForeignReplica;
+use Moose;
+use Params::Validate;
+
+extends 'Prophet::ForeignReplica';
+
+=head2 prophet_has_seen_transaction $transaction_id
+
+Given an transaction id, will return true if this transaction originated in Prophet 
+and was pushed to RT or originated in RT and has already been pulled to the prophet replica.
+
+=cut
+
+# This is a mapping of all the transactions we have pushed to the
+# remote replica we'll only ever care about remote sequence #s greater
+# than the last transaction # we've pulled from the remote replica
+# once we've done a pull from the remote replica, we can safely expire
+# all records of this type for the remote replica (they'll be
+# obsolete)
+
+# we use this cache to avoid integrating changesets we've pushed to the remote replica when doing a subsequent pull
+
+my $TXN_METATYPE = 'txn-source';
+
+sub _txn_storage {
+    my $self = shift;
+    return $self->state_handle->metadata_storage( $TXN_METATYPE,
+        'prophet-txn-source' );
+}
+
+sub prophet_has_seen_transaction {
+    my $self = shift;
+    my ($id) = validate_pos( @_, 1 );
+    return $self->_txn_storage->( $self->uuid . '-txn-' . $id );
+}
+
+sub record_pushed_transaction {
+    my $self = shift;
+    my %args = validate( @_,
+        { transaction => 1, changeset => { isa => 'Prophet::ChangeSet' } } );
+
+    $self->_txn_storage->(
+        $self->uuid . '-txn-' . $args{transaction},
+        join( ':',
+            $args{changeset}->original_source_uuid,
+            $args{changeset}->original_sequence_no )
+    );
+}
+
+
+sub remote_uri_path_for_id {
+    die "your subclass needds to implement this to be able to map a remote id to /ticket/id or soemthing";
+
+}
+
+sub uuid_for_remote_id {
+    my ( $self, $id ) = @_;
+    return $self->_lookup_uuid_for_remote_id($id)
+        || $self->uuid_for_url(
+        $self->remote_url . $self->remote_uri_path_for_id($id) );
+}
+
+sub _lookup_uuid_for_remote_id {
+    my $self = shift;
+    my ($id) = validate_pos( @_, 1 );
+
+    return $self->_remote_id_storage(
+        $self->uuid_for_url(
+            $self->remote_url . $self->remote_uri_path_for_id($id)
+        )
+    );
+}
+
+sub _set_uuid_for_remote_id {
+    my $self = shift;
+    my %args = validate( @_, { uuid => 1, remote_id => 1 } );
+    return $self->_remote_id_storage(
+        $self->uuid_for_url(
+                  $self->remote_url
+                . $self->remote_uri_path_for_id( $args{'remote_id'} )
+        ),
+        $args{uuid}
+    );
+}
+
+# This cache stores uuids for tickets we've synced from a remote RT
+# Basically, if we created the ticket to begin with, then we'll know its uuid
+# if we pulled the ticket from RT then its uuid will be generated based on a UUID-from-ticket-url scheme
+# This cache is PERMANENT. - aka not a cache but a mapping table
+
+sub remote_id_for_uuid {
+    my ( $self, $uuid_for_remote_id ) = @_;
+
+
+    # XXX: should not access CLI handle
+    my $ticket = Prophet::Record->new(
+        handle => Prophet::CLI->new->app_handle->handle,
+        type   => 'ticket'
+    );
+    $ticket->load( uuid => $uuid_for_remote_id );
+    my $id =  $ticket->prop( $self->uuid . '-id' );
+    return $id;
+}
+
+sub _set_remote_id_for_uuid {
+    my $self = shift;
+    my %args = validate(
+        @_,
+        {   uuid      => 1,
+            remote_id => 1
+        }
+    );
+
+    # XXX: should not access CLI handle
+    my $ticket = Prophet::Record->new(
+        handle => Prophet::CLI->new->app_handle->handle,
+        type   => 'ticket'
+    );
+    $ticket->load( uuid => $args{'uuid'});
+    $ticket->set_props( props => {  $self->uuid.'-id' => $args{'remote_id'}});
+
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;

Added: sd/trunk/lib/App/SD/ForeignReplica/PullEncoder.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/ForeignReplica/PullEncoder.pm	Fri Aug 22 09:19:48 2008
@@ -0,0 +1,17 @@
+package App::SD::ForeignReplica::PullEncoder;
+use Moose;
+
+sub warp_list_to_old_value {
+    my $self         = shift;
+    my $current_value = shift ||'';
+    my $add          = shift;
+    my $del          = shift;
+
+    my @new = grep { defined } split( /\s*,\s*/, $current_value );
+    my @old = (grep { defined $_ && $_ ne $add } @new, $del ) || ();
+    return join( ", ", @old );
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+1;

Added: sd/trunk/lib/App/SD/ForeignReplica/PushEncoder.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/ForeignReplica/PushEncoder.pm	Fri Aug 22 09:19:48 2008
@@ -0,0 +1,10 @@
+package App::SD::ForeignReplica::PushEncoder;
+use Moose;
+
+
+
+
+no Moose;
+__PACKAGE__->meta->make_immutable;
+
+1;

Added: sd/trunk/lib/App/SD/Replica/debbugs.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/Replica/debbugs.pm	Fri Aug 22 09:19:48 2008
@@ -0,0 +1,46 @@
+package App::SD::Replica::debbugs;
+use Moose;
+extends qw/App::SD::ForeignReplica/;
+
+use Params::Validate qw(:all);
+use Memoize;
+
+use Prophet::ChangeSet;
+
+use constant scheme => 'debbugs';
+
+# FIXME: what should this actually be?
+has debbugs => ( isa => 'Net::Debbugs', is => 'rw');
+has remote_url => ( isa => 'Str', is => 'rw');
+has debbugs_query => ( isa => 'Str', is => 'rw');
+
+sub setup {
+    my $self = shift;
+
+    # require any specific libs needed by this foreign replica
+
+    # parse the given url
+    # my ($foo, $bar, $baz) = $self->{url} =~ m/regex-here/
+
+    # ...
+}
+
+sub record_pushed_transactions {}
+
+# XXX record_pushed_tikcet should go up to the base class
+
+sub record_pushed_ticket {
+    my $self = shift;
+    my %args = validate(
+        @_,
+        {   uuid      => 1,
+            remote_id => 1,
+        }
+    );
+    $self->_set_uuid_for_remote_id(%args);
+    $self->_set_remote_id_for_uuid(%args);
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+1;

Added: sd/trunk/lib/App/SD/Replica/debbugs/PullEncoder.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/Replica/debbugs/PullEncoder.pm	Fri Aug 22 09:19:48 2008
@@ -0,0 +1,87 @@
+package App::SD::Replica::debbugs::PullEncoder;
+use Moose;
+
+use Params::Validate qw(:all);
+use Memoize;
+
+has sync_source => (
+    isa => 'App::SD::Replica::debbugs',
+    is => 'rw',
+);
+
+our $DEBUG = $Prophet::Handle::DEBUG;
+
+sub run {
+    my $self = shift;
+    my %args = validate( @_, {
+            # mandatory args go here
+            example => 1,
+        }
+    );
+
+    # TODO: code goes here
+}
+
+our %PROP_MAP = (
+    remote_prop             => 'sd_prop',
+    # ...
+}
+
+=head2 translate_prop_names L<Prophet::ChangeSet>
+
+=cut
+
+sub translate_prop_names {
+    my $self      = shift;
+    my $changeset = shift;
+
+    # ...
+
+    return $changeset;
+}
+
+=head2 resolve_user_id_to_email ID
+
+This is only implemented in Hiveminder::PullEncoder; in RT::PullEncoder
+it's resolve_user_id_to. What's this for, actually?
+
+=cut
+
+sub resolve_user_id_to_email {
+    my $self = shift;
+    my $id   = shift;
+    return undef unless ($id);
+
+    # ...
+
+    # returns email address mapping to user id
+}
+
+memoize 'resolve_user_id_to_email';
+
+=head2 find_matching_tickets QUERY
+
+=cut
+
+sub find_matching_tickets {
+    my $self = shift;
+    my ($query) = validate_pos(@_, 1);
+    return $self->sync_source->rt->search( type => 'ticket', query => $query );
+}
+
+=head2 find_matching_transactions TASK, START
+
+=cut
+
+sub find_matching_transactions {
+    my $self = shift;
+    my %args = validate( @_, { task => 1, starting_transaction => 1 } );
+
+    # ...
+
+    return \@matched;
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+1;

Added: sd/trunk/lib/App/SD/Replica/debbugs/PushEncoder.pm
==============================================================================
--- (empty file)
+++ sd/trunk/lib/App/SD/Replica/debbugs/PushEncoder.pm	Fri Aug 22 09:19:48 2008
@@ -0,0 +1,131 @@
+package App::SD::Replica::debbugs::PushEncoder;
+use Moose;
+
+use Params::Validate;
+use Path::Class;
+
+has sync_source => 
+    ( isa => 'App::SD::Replica::debbugs',
+      is => 'rw');
+
+=head2 integrate_change L<Prophet::Change>, L<Prophet::ChangeSet>
+
+Should be able to leave as-is, theoretically.
+
+=cut
+
+sub integrate_change {
+    my $self = shift;
+    my ( $change, $changeset ) = validate_pos(
+        @_,
+        { isa => 'Prophet::Change' },
+        { isa => 'Prophet::ChangeSet' }
+    );
+    my $id;
+    eval {
+        if (    $change->record_type eq 'ticket'
+            and $change->change_type eq 'add_file'
+    )
+        {
+            $id = $self->integrate_ticket_create( $change, $changeset );
+            $self->sync_source->record_pushed_ticket(
+                uuid      => $change->record_uuid,
+                remote_id => $id
+            );
+
+        } elsif ( $change->record_type eq 'attachment'
+            and $change->change_type eq 'add_file'
+
+        ) {
+            $id = $self->integrate_attachment( $change, $changeset );
+        } elsif ( $change->record_type eq 'comment'
+            and $change->change_type eq 'add_file'
+        ) {
+            $id = $self->integrate_comment( $change, $changeset );
+        } elsif ( $change->record_type eq 'ticket' ) {
+            $id = $self->integrate_ticket_update( $change, $changeset );
+
+        } else {
+            return undef;
+        }
+
+        $self->sync_source->record_pushed_transactions(
+            ticket    => $id,
+            changeset => $changeset
+        );
+
+    };
+    warn $@ if $@;
+    return $id;
+}
+
+=head2 integrate_ticket_create L<Prophet::Change>, L<Prophet::ChangeSet>
+
+=cut
+
+sub integrate_ticket_create {
+    my $self = shift;
+    my ( $change, $changeset ) = validate_pos(
+        @_,
+        { isa => 'Prophet::Change' },
+        { isa => 'Prophet::ChangeSet' }
+    );
+
+    # ...
+
+    # returns the id of the new ticket
+    # XXX is this uuid or what?
+}
+
+=head2 integrate_comment L<Prophet::Change>, L<Prophet::ChangeSet>
+
+=cut
+
+sub integrate_comment {
+    my $self = shift;
+    my ( $change, $changeset ) = validate_pos(
+        @_,
+        { isa => 'Prophet::Change' },
+        { isa => 'Prophet::ChangeSet' }
+    );
+
+    # ...
+
+    # returns the remote id of the ticket for this change
+}
+
+=head2 integrate_attachment L<Prophet::Change>, L<Prophet::ChangeSet>
+
+=cut
+
+sub integrate_attachment {
+    my $self = shift;
+    my ( $change, $changeset ) = validate_pos(
+        @_,
+        { isa => 'Prophet::Change' },
+        { isa => 'Prophet::ChangeSet' }
+    );
+
+    # ...
+
+    # returns the remote id of the ticket for this change
+}
+
+=head2 integrate_ticket_update L<Prophet::Change>, L<Prophet::ChangeSet>
+
+=cut
+
+sub integrate_ticket_update {
+    my $self = shift;
+    my ( $change, $changeset ) = validate_pos(
+        @_,
+        { isa => 'Prophet::Change' },
+        { isa => 'Prophet::ChangeSet' }
+    );
+
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;

Modified: sd/trunk/lib/App/SD/Replica/hm.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/hm.pm	Fri Aug 22 09:19:48 2008
@@ -1,6 +1,6 @@
 package App::SD::Replica::hm;
 use Moose;
-extends 'Prophet::ForeignReplica';
+extends 'App::SD::ForeignReplica';
 use Params::Validate qw(:all);
 use UNIVERSAL::require;
 use URI;
@@ -9,7 +9,7 @@
 use File::Temp 'tempdir';
 
 has hm => ( isa => 'Net::Jifty', is => 'rw');
-has hm_url => ( isa => 'Str', is => 'rw');
+has remote_url => ( isa => 'Str', is => 'rw');
 has hm_username => ( isa => 'Str', is => 'rw');
 
 use constant scheme => 'hm';
@@ -37,13 +37,13 @@
         ( $username, $password ) = split /:/, $auth, 2;
         $uri->userinfo(undef);
     }
-    $self->hm_url("$uri");
+    $self->remote_url("$uri");
 
     ( $username, $password ) = $self->prompt_for_login( $uri, $username ) unless $password;
 
     $self->hm(
         Net::Jifty->new(
-            site        => $self->hm_url,
+            site        => $self->remote_url,
             cookie_name => 'JIFTY_SID_HIVEMINDER',
 
             email    => $username,
@@ -62,7 +62,7 @@
 
 sub uuid {
     my $self = shift;
-    return $self->uuid_for_url( join( '/', $self->hm_url, $self->hm_username ) );
+    return $self->uuid_for_url( join( '/', $self->remote_url, $self->hm_username ) );
 }
 
 sub traverse_changesets {
@@ -103,23 +103,11 @@
     return $tasks;
 }
 
-sub prophet_has_seen_transaction {
-    goto \&App::SD::Replica::rt::prophet_has_seen_transaction;
-}
-
-sub record_pushed_transaction {
-    goto \&App::SD::Replica::rt::record_pushed_transaction;
-}
-
 sub record_pushed_transactions {
 
     # don't need this for hm
 }
 
-sub _txn_storage {
-    goto \&App::SD::Replica::rt::_txn_storage;
-}
-
 # hiveminder transaction ~= prophet changeset
 # hiveminder taskhistory ~= prophet change
 # hiveminder taskemail ~= prophet change
@@ -155,49 +143,14 @@
     $recoder->integrate_change($change,$changeset);
 }
 
-
-
-{
-
-    # XXXXXXXX
-    # XXXXXXXXX
-    # XXX todo code in this block cargo culted from the RT Replica type
-
-    sub remote_id_for_uuid {
-        my ( $self, $uuid_for_remote_id ) = @_;
-
-        # XXX: should not access CLI handle
-        my $ticket = Prophet::Record->new( handle => Prophet::CLI->new->handle, type => 'ticket' );
-        $ticket->load( uuid => $uuid_for_remote_id );
-        return $ticket->prop( $self->uuid . '-id' );
-    }
-
-    sub uuid_for_remote_id {
-        my ( $self, $id ) = @_;
-        return $self->_lookup_remote_id($id) || $self->uuid_for_url( $self->hm_url . "/task/$id" );
-    }
-
-    sub _lookup_remote_id {
-        my $self = shift;
-        my ($id) = validate_pos( @_, 1 );
-
-        return $self->_remote_id_storage( $self->uuid_for_url( $self->hm_url . "/task/$id" ) );
-    }
-
-    sub _set_remote_id {
-        my $self = shift;
-        my %args = validate(
-            @_,
-            {   uuid      => 1,
-                remote_id => 1
-            }
-        );
-        return $self->_remote_id_storage( $self->uuid_for_url( $self->hm_url . "/task/" . $args{'remote_id'} ),
-            $args{uuid} );
-    }
-
+sub remote_uri_path_for_id {
+    my $self = shift;
+    my $id = shift;
+    return "/task/".$id;
 }
 
+
+# XXX TODO, can this get generalized out (take the rt one to ForeignReplica.pm?
 sub record_pushed_ticket {
     my $self = shift;
     my %args = validate(
@@ -206,7 +159,7 @@
             remote_id => 1
         }
     );
-    $self->_set_remote_id(%args);
+    $self->_set_uuid_for_remote_id(%args);
 }
 
 __PACKAGE__->meta->make_immutable;

Modified: sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm	Fri Aug 22 09:19:48 2008
@@ -140,7 +140,7 @@
     my $change = Prophet::Change->new(
         {   record_type => 'comment',
             record_uuid =>
-                $self->sync_source->uuid_for_url( $self->sync_source->rt_url . "/transaction/" . $args{'txn'}->{'id'} ),
+                $self->sync_source->uuid_for_url( $self->sync_source->remote_url . "/transaction/" . $args{'txn'}->{'id'} ),
             change_type => 'add_file'
         }
     );

Modified: sd/trunk/lib/App/SD/Replica/rt.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/rt.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/rt.pm	Fri Aug 22 09:19:48 2008
@@ -1,6 +1,6 @@
 package App::SD::Replica::rt;
 use Moose;
-extends qw/Prophet::ForeignReplica/;
+extends qw/App::SD::ForeignReplica/;
 
 use Params::Validate qw(:all);
 use Path::Class;
@@ -12,7 +12,7 @@
 use Prophet::ChangeSet;
 
 has rt => ( isa => 'RT::Client::REST', is => 'rw');
-has rt_url => ( isa => 'Str', is => 'rw');
+has remote_url => ( isa => 'Str', is => 'rw');
 has rt_queue => ( isa => 'Str', is => 'rw');
 has rt_query => ( isa => 'Str', is => 'rw');
 
@@ -41,7 +41,7 @@
         ( $username, $password ) = split /:/, $auth, 2;
         $uri->userinfo(undef);
     }
-    $self->rt_url($uri->as_string);
+    $self->remote_url($uri->as_string);
     $self->rt_queue($type);
     $self->rt_query( ( $query ?  "($query) AND " :"") . " Queue = '$type'" );
     $self->rt( RT::Client::REST->new( server => $server ) );
@@ -74,107 +74,6 @@
         );
     }
 }
-
-=head2 prophet_has_seen_transaction $transaction_id
-
-Given an transaction id, will return true if this transaction originated in Prophet 
-and was pushed to RT or originated in RT and has already been pulled to the prophet replica.
-
-=cut
-
-# This is a mapping of all the transactions we have pushed to the
-# remote replica we'll only ever care about remote sequence #s greater
-# than the last transaction # we've pulled from the remote replica
-# once we've done a pull from the remote replica, we can safely expire
-# all records of this type for the remote replica (they'll be
-# obsolete)
-
-# we use this cache to avoid integrating changesets we've pushed to the remote replica when doing a subsequent pull
-
-my $TXN_METATYPE = 'txn-source';
-
-sub _txn_storage {
-    my $self = shift;
-    return $self->state_handle->metadata_storage( $TXN_METATYPE,
-        'prophet-txn-source' );
-}
-
-sub prophet_has_seen_transaction {
-    my $self = shift;
-    my ($id) = validate_pos( @_, 1 );
-    return $self->_txn_storage->( $self->uuid . '-txn-' . $id );
-}
-
-sub record_pushed_transaction {
-    my $self = shift;
-    my %args = validate( @_,
-        { transaction => 1, changeset => { isa => 'Prophet::ChangeSet' } } );
-
-    $self->_txn_storage->(
-        $self->uuid . '-txn-' . $args{transaction},
-        join( ':',
-            $args{changeset}->original_source_uuid,
-            $args{changeset}->original_sequence_no )
-    );
-}
-
-# This cache stores uuids for tickets we've synced from a remote RT
-# Basically, if we created the ticket to begin with, then we'll know its uuid
-# if we pulled the ticket from RT then its uuid will be generated based on a UUID-from-ticket-url scheme
-# This cache is PERMANENT. - aka not a cache but a mapping table
-
-sub remote_id_for_uuid {
-    my ( $self, $uuid_for_remote_id ) = @_;
-
-
-    # XXX: should not access CLI handle
-    my $ticket = Prophet::Record->new(
-        handle => Prophet::CLI->new->app_handle->handle,
-        type   => 'ticket'
-    );
-    $ticket->load( uuid => $uuid_for_remote_id );
-    my $id =  $ticket->prop( $self->uuid . '-id' );
-    return $id;
-}
-
-sub _set_remote_id_for_uuid {
-    my $self = shift;
-    my %args = validate(
-        @_,
-        {   uuid      => 1,
-            remote_id => 1
-        }
-    );
-
-    # XXX: should not access CLI handle
-    my $ticket = Prophet::Record->new(
-        handle => Prophet::CLI->new->app_handle->handle,
-        type   => 'ticket'
-    );
-    $ticket->load( uuid => $args{'uuid'});
-    $ticket->set_props( props => {  $self->uuid.'-id' => $args{'remote_id'}});
-
-}
-
-
-sub uuid_for_remote_id {
-    my ( $self, $id ) = @_;
-    return $self->_lookup_uuid_for_remote_id($id) || $self->uuid_for_url( $self->rt_url . "/ticket/$id" );
-}
-
-sub _lookup_uuid_for_remote_id {
-    my $self = shift;
-    my ($id) = validate_pos( @_, 1 );
-
-    return $self->_remote_id_storage( $self->uuid_for_url( $self->rt_url . "/ticket/$id" ) );
-}
-
-sub _set_uuid_for_remote_id {
-    my $self = shift;
-    my %args = validate( @_, {   uuid      => 1, remote_id => 1 });
-    return $self->_remote_id_storage( $self->uuid_for_url( $self->rt_url . "/ticket/" . $args{'remote_id'} ), $args{uuid});
-}
-
 sub record_pushed_ticket {
     my $self = shift;
     my %args = validate(
@@ -208,7 +107,7 @@
 
 sub uuid {
     my $self = shift;
-    return $self->uuid_for_url( join( '/', $self->rt_url, $self->rt_query ) );
+    return $self->uuid_for_url( join( '/', $self->remote_url, $self->rt_query ) );
 
 }
 
@@ -226,6 +125,12 @@
 
 }
 
+sub remote_uri_path_for_id {
+    my $self = shift;
+    my $id = shift;
+    return "/ticket/".$id;
+}
+
 
 =head1 NOTES ON PUSH
 

Modified: sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm	Fri Aug 22 09:19:48 2008
@@ -1,5 +1,6 @@
 package App::SD::Replica::rt::PullEncoder;
 use Moose;
+extends 'App::SD::ForeignReplica::PullEncoder';
 
 use Params::Validate qw(:all);
 use Memoize;
@@ -166,7 +167,7 @@
     my %args   = validate( @_, { ticket => 1, txn => 1, changeset => 1, attachment => 1 } );
     my $change = Prophet::Change->new(
         {   record_type => 'attachment',
-            record_uuid => $self->sync_source->uuid_for_url( $self->sync_source->rt_url . "/attachment/" . $args{'attachment'}->{'id'} ),
+            record_uuid => $self->sync_source->uuid_for_url( $self->sync_source->remote_url . "/attachment/" . $args{'attachment'}->{'id'} ),
             change_type => 'add_file'
         }
     );
@@ -309,7 +310,7 @@
     my %args   = validate( @_, { txn => 1, ticket => 1, changeset => 1 } );
     my $change = Prophet::Change->new(
         {   record_type => 'comment',
-            record_uuid => $self->sync_source->uuid_for_url( $self->sync_source->rt_url . "/transaction/" . $args{'txn'}->{'id'} ),
+            record_uuid => $self->sync_source->uuid_for_url( $self->sync_source->remote_url . "/transaction/" . $args{'txn'}->{'id'} ),
             change_type => 'add_file'
         }
     );
@@ -417,17 +418,6 @@
 
 memoize 'resolve_user_id_to';
 
-sub warp_list_to_old_value {
-    my $self         = shift;
-    my $current_value = shift ||'';
-    my $add          = shift;
-    my $del          = shift;
-
-    my @new = grep { defined } split( /\s*,\s*/, $current_value );
-    my @old = (grep { defined $_ && $_ ne $add } @new, $del ) || ();
-    return join( ", ", @old );
-}
-
 use HTTP::Date;
 
 sub date_to_iso {
@@ -481,12 +471,6 @@
                 }
             next if ( $prop->old_value eq $prop->new_value);
 
-#
-#            if ( $prop->name eq 'id' || $prop->name eq 'queue') {
-#                $prop->old_value( $prop->old_value . '@' . $changeset->original_source_uuid ) if ( $prop->old_value);
-#                $prop->old_value( $prop->new_value . '@' . $changeset->original_source_uuid ) if ( $prop->new_value);
-#            }
-
             if ( $prop->name =~ /^cf-(.*)$/ ) {
                 $prop->name( 'custom-' . $1 );
             }



More information about the Bps-public-commit mailing list