[Bps-public-commit] r11481 - in SVN-PropDB: . doc lib/Prophet

jesse at bestpractical.com jesse at bestpractical.com
Fri Apr 4 00:36:40 EDT 2008


Author: jesse
Date: Fri Apr  4 00:36:40 2008
New Revision: 11481

Modified:
   SVN-PropDB/   (props changed)
   SVN-PropDB/doc/todo
   SVN-PropDB/lib/Prophet/Change.pm
   SVN-PropDB/lib/Prophet/Sync/Source/RT.pm

Log:
 r29149 at 70-5-183-240:  jesse | 2008-04-03 18:31:36 -1000
 * RT. pm recoding. Change.pm let you set changesets


Modified: SVN-PropDB/doc/todo
==============================================================================
--- SVN-PropDB/doc/todo	(original)
+++ SVN-PropDB/doc/todo	Fri Apr  4 00:36:40 2008
@@ -70,8 +70,8 @@
      comments		RT: comment/correspond
    					RT: Queue
    					RT: priority
-   					RT: initial_priority
-   					RT: final_priority
+   NO					RT: initial_priority
+   NO					RT: final_priority
    					RT: time_estimated
    					RT: time_worked
    					RT: time_left
@@ -80,7 +80,7 @@
    					RT: started
    					RT: lastupdated
    					RT: resolved
-   					RT: told (last user contact)
+    NO				RT: told (last user contact)
 [csv] 				RT: links * many
 [csv]   				DependsOn
 [csv]   				DependedOnBy

Modified: SVN-PropDB/lib/Prophet/Change.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Change.pm	(original)
+++ SVN-PropDB/lib/Prophet/Change.pm	Fri Apr  4 00:36:40 2008
@@ -31,14 +31,15 @@
 One of create_file, add_dir, update_file, delete
 XXX TODO is it create_file or add_file?
 
-=head2 prop_changes
+=head2 prop_changes [\@PROPCHANGES]
 
-Returns a list of L<Prophet::PropChange/> associated with this Change
+Returns a list of L<Prophet::PropChange/> associated with this Change. Takes an optional arrayref to fully replace the set of propcahnges
 
 =cut
 
 sub prop_changes {
     my $self = shift;
+    $self->{prop_changes} = shift if @_;
     return @{ $self->{prop_changes} || [] };
 }
 

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	Fri Apr  4 00:36:40 2008
@@ -258,17 +258,29 @@
 sub _recode_txn_AddLink {
     my $self = shift;
     my %args = validate( @_, { ticket => 1, txn => 1, create_state => 1, changeset => 1 } );
-    warn "Recode links to actually be attributes rather than another table";
+    my $new_state = $args{'create_state'}->{ $args{'txn'}->{'Field'} };
+    $args{'create_state'}->{ $args{'txn'}->{'Field'} } = $self->warp_list_to_old_value(  $args{'create_state'}->{ $args{'txn'}->{'Field'} },
+                 $args{'txn'}->{'NewValue'},    $args{'txn'}->{'OldValue'});
+
     my $change = Prophet::Change->new(
-        {   node_type   => 'rt_link',
-            node_uuid   => $self->uuid_for_url( $self->rt_url . "/link/" . $args{'txn'}->{'id'} ),
-            change_type => 'add_file'
+        {   node_type   => 'ticket',
+            node_uuid   => $self->uuid_for_url( $self->rt_url . "/ticket/" . $args{'create_state'}->{'id'} ),
+            change_type => 'update_file'
         }
     );
     $args{'changeset'}->add_change( { change => $change } );
-    $change->add_prop_change( name => 'url',    old => undef, new => $args{'txn'}->{'NewValue'} );
-    $change->add_prop_change( name => 'type',   old => undef, new => $args{'txn'}->{'Field'} );
-    $change->add_prop_change( name => 'ticket', old => undef, new => $args{ticket}->{uuid} );
+    $change->add_prop_change(
+        name => $args{'txn'}->{'Field'},
+        old  => $args{'create_state'}->{ $args{'txn'}->{'Field'} },
+        new  => $new_state
+    );
+
+    
+    
+    
+    
+    
+    
 }
 
 sub _recode_content_update {
@@ -515,6 +527,30 @@
     return $t->ymd . " " . $t->hms;
 }
 
+
+our %PROP_MAP = (
+    subject => 'summary',
+    status => 'status',
+    owner => 'owner',
+    initialpriority => '_delete',
+    finalpriority => '_delete',
+    told => '_delete',
+    requestors => 'reported_by',
+    admincc => 'admin_cc',
+    refersto => 'refers_to',
+    referredtoby => 'referred_to_by',
+    dependson => 'depends_on',
+    dependedonby => 'depended_on_by',
+    hasmember => 'members',
+    memberof => 'member_of',
+    priority => 'priority_integer',
+    
+    resolved => 'completed',
+    lastupdated => '_delete',
+    created => '_delete', # we should be porting the create date as a metaproperty
+    
+);
+
 sub translate_prop_names {
     my $self = shift;
     my $changeset = shift;
@@ -522,7 +558,31 @@
     for my $change (@{$changeset->changes}) {
         next unless $change->node_type eq 'ticket';
         
-#        for my $prop
+    
+        my @new_props;
+
+        for my $prop (@$change->prop_changes) {
+            next if $PROP_MAP{lc{$prop->name}} eq '_delete';
+            $prop->name($PROP_MAP{lc($prop->name)}) if $PROP_MAP{lc($prop->name)};
+
+        if ($prop->name eq 'id') {
+                $prop->old_value($prop->old_value.'@'.$self->changeset->original_source_uuid) if $prop->old_value =~ /^\d+$/;
+                $prop->old_value($prop->new_value.'@'.$self->changeset->original_source_uuid) if $prop->new_value =~ /^\d+$/;
+
+                
+                }
+
+
+        if ($prop->name =~ /^cf-(.*)$/) {
+                    $prop->name('custom-'.$1);
+        };
+
+            push @new_props, $prop;
+            
+            
+        }
+        $change->prop_changes(\@new_props);
+
         
     }
 



More information about the Bps-public-commit mailing list