[Bps-public-commit] r11450 - in SVN-PropDB/lib/Prophet/Sync: Source

clkao at bestpractical.com clkao at bestpractical.com
Thu Apr 3 19:35:49 EDT 2008


Author: clkao
Date: Thu Apr  3 19:35:45 2008
New Revision: 11450

Modified:
   SVN-PropDB/lib/Prophet/Sync/Source.pm
   SVN-PropDB/lib/Prophet/Sync/Source/RT.pm

Log:
new rt server description scheme.

Modified: SVN-PropDB/lib/Prophet/Sync/Source.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Sync/Source.pm	(original)
+++ SVN-PropDB/lib/Prophet/Sync/Source.pm	Thu Apr  3 19:35:45 2008
@@ -48,13 +48,13 @@
     my $class;
     
     # XXX TODO HACK NEED A PROPER WAY TO DETERMINE SYNC SOURCE
-    if ($args->{url} =~ /^http/) {
+    if ($args->{url} =~ /^rt:/) {
             $class    = 'Prophet::Sync::Source::RT';
         } 
         else { 
             $class    = 'Prophet::Sync::Source::SVN';
         }
-    $class->require;
+    $class->require or die $@;
     bless $self, $class;
 }
 

Modified: SVN-PropDB/lib/Prophet/Sync/Source/RT.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Sync/Source/RT.pm	(original)
+++ SVN-PropDB/lib/Prophet/Sync/Source/RT.pm	Thu Apr  3 19:35:45 2008
@@ -12,7 +12,7 @@
 use Prophet::ChangeSet;
 use Prophet::Conflict;
 
-__PACKAGE__->mk_accessors(qw/url prophet_handle ressource is_resdb rt/);
+__PACKAGE__->mk_accessors(qw/prophet_handle ressource is_resdb rt rt_url rt_query/);
 
 our $DEBUG = $Prophet::Handle::DEBUG;
 
@@ -28,7 +28,11 @@
 
 sub setup {
     my $self = shift;
-    $self->rt(RT::Client::REST->new(server => 'http://rt3.fsck.com' ));
+    my ($server, $type, $query) = $self->{url} =~ m/^rt:(.*?):(tickets):(.*)$/
+        or die "Can't parse rt server spec";
+    $self->rt_url( $server );
+    $self->rt_query( $query );
+    $self->rt( RT::Client::REST->new(server => $server) );
     $self->rt->login(username => 'guest', password => 'guest');
     my $orz = tempdir();
     $self->{___Orz} = $orz;
@@ -102,7 +106,7 @@
         if ( $txn->{'Type'} eq 'Set' ) {
             my $change = Prophet::Change->new(
                 {   node_type   => 'RT_Ticket',
-                    node_uuid   => $self->url . "/Ticket/" . $create_state->{'id'},
+                    node_uuid   => $self->rt_url . "/Ticket/" . $create_state->{'id'},
                     change_type => 'update_file'
                 }
             );
@@ -122,7 +126,7 @@
         } elsif ( $txn->{'Type'} eq 'Create' ) {
             my $change = Prophet::Change->new(
                 {   node_type   => 'RT_Ticket',
-                    node_uuid   => $self->url . "/Ticket/" . $create_state->{'id'},
+                    node_uuid   => $self->rt_url . "/Ticket/" . $create_state->{'id'},
                     change_type => 'create_file'
                 }
             );
@@ -140,7 +144,7 @@
         } elsif ( $txn->{'Type'} eq 'AddLink' ) {
             my $change = Prophet::Change->new(
                 {   node_type   => 'RT_Link',
-                    node_uuid   => $self->url . "/Link/" . $txn->{'id'},
+                    node_uuid   => $self->rt_url . "/Link/" . $txn->{'id'},
                     change_type => 'create_file'
                 }
             );
@@ -150,7 +154,7 @@
         } elsif ( $txn->{'Type'} eq 'Correspond' ) {
             my $change = Prophet::Change->new(
                 {   node_type   => 'RT_Comment',
-                    node_uuid   => $self->url . "/Transaction/" . $txn->{'id'},
+                    node_uuid   => $self->rt_url . "/Transaction/" . $txn->{'id'},
                     change_type => 'create_file'
                 }
             );
@@ -177,7 +181,7 @@
 
             my $change = Prophet::Change->new(
                 {   node_type   => 'RT_Ticket',
-                    node_uuid   => $self->url . "/Ticket/" . $create_state->{'id'},
+                    node_uuid   => $self->rt_url . "/Ticket/" . $create_state->{'id'},
                     change_type => 'update_file'
                 }
             );
@@ -215,13 +219,13 @@
 
 sub _find_matching_tickets {
     my $self = shift;
-    
-             # Find all stalled tickets
-             my @tix = $self->rt->search(
-               type => 'ticket',
-               query => "id > 6000 AND id < 6010",
-             );
-return @tix;
+
+    # Find all stalled tickets
+    my @tix = $self->rt->search(
+        type  => 'ticket',
+        query => $self->rt_query,
+    );
+    return @tix;
 
 }
 



More information about the Bps-public-commit mailing list