[Rt-commit] [svn] r1706 - in rt/branches/3.2-RELEASE: . lib/RT

jesse at pallas.eruditorum.org jesse at pallas.eruditorum.org
Sun Oct 31 23:43:02 EST 2004


Author: jesse
Date: Sun Oct 31 23:43:02 2004
New Revision: 1706

Modified:
   rt/branches/3.2-RELEASE/   (props changed)
   rt/branches/3.2-RELEASE/lib/RT/Scrip_Overlay.pm
   rt/branches/3.2-RELEASE/lib/RT/Scrips_Overlay.pm
   rt/branches/3.2-RELEASE/lib/RT/Ticket_Overlay.pm
   rt/branches/3.2-RELEASE/lib/RT/Transaction_Overlay.pm
Log:
 r6152 at tinbook:  jesse | 2004-11-01T04:43:38.864654Z
 RT-Ticket: 6230
 RT-Status: resolved
 RT-Update: correspond
 
 New "batch transactions" core from Ruslan. This update makes it much easier to use stock conditions for bulk updates
 
 


Modified: rt/branches/3.2-RELEASE/lib/RT/Scrip_Overlay.pm
==============================================================================
--- rt/branches/3.2-RELEASE/lib/RT/Scrip_Overlay.pm	(original)
+++ rt/branches/3.2-RELEASE/lib/RT/Scrip_Overlay.pm	Sun Oct 31 23:43:02 2004
@@ -417,16 +417,19 @@
 	    $RT::Logger->error( "Unknown Scrip stage:" . $self->Stage );
 	    return (undef);
 	}
-
+	my $ConditionObj = $self->ConditionObj;
 	foreach my $TransactionObj ( @Transactions ) {
+	    # in TxnBatch stage we can select scrips that are not applicable to all txns
+	    my $txn_type = $TransactionObj->Type;
+	    next unless( $ConditionObj->ApplicableTransTypes =~ /(?:^|,)(?:Any|\Q$txn_type\E)(?:,|$)/i );
 	    # Load the scrip's Condition object
-	    $self->ConditionObj->LoadCondition(
+	    $ConditionObj->LoadCondition(
 		ScripObj       => $self,
 		TicketObj      => $args{'TicketObj'},
 		TransactionObj => $TransactionObj,
 	    );
 
-            if ( $self->ConditionObj->IsApplicable() ) {
+            if ( $ConditionObj->IsApplicable() ) {
 	        # We found an application Transaction -- return it
                 $return = $TransactionObj;
                 last;

Modified: rt/branches/3.2-RELEASE/lib/RT/Scrips_Overlay.pm
==============================================================================
--- rt/branches/3.2-RELEASE/lib/RT/Scrips_Overlay.pm	(original)
+++ rt/branches/3.2-RELEASE/lib/RT/Scrips_Overlay.pm	Sun Oct 31 23:43:02 2004
@@ -328,14 +328,16 @@
     );
 
     #We only want things where the scrip applies to this sort of transaction
-    $self->Limit(
-        ALIAS           => $ConditionsAlias,
-        FIELD           => 'ApplicableTransTypes',
-        OPERATOR        => 'LIKE',
-        VALUE           => $args{'Type'},
-        ENTRYAGGREGATOR => 'OR',
-      )
-      if $args{'Type'};
+    # TransactionBatch stage can define list of transaction
+    foreach( split /\s*,\s*/, ($args{'Type'} || '') ) {
+	$self->Limit(
+	    ALIAS           => $ConditionsAlias,
+	    FIELD           => 'ApplicableTransTypes',
+	    OPERATOR        => 'LIKE',
+	    VALUE           => $_,
+	    ENTRYAGGREGATOR => 'OR',
+	)
+    }
 
     # Or where the scrip applies to any transaction
     $self->Limit(

Modified: rt/branches/3.2-RELEASE/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/3.2-RELEASE/lib/RT/Ticket_Overlay.pm	(original)
+++ rt/branches/3.2-RELEASE/lib/RT/Ticket_Overlay.pm	Sun Oct 31 23:43:02 2004
@@ -3782,6 +3782,7 @@
 	Stage		=> 'TransactionBatch',
 	TicketObj	=> $self,
 	TransactionObj	=> $batch->[0],
+	Type		=> join(',', (map { $_->Type } @{$batch}) )
     );
 }
 

Modified: rt/branches/3.2-RELEASE/lib/RT/Transaction_Overlay.pm
==============================================================================
--- rt/branches/3.2-RELEASE/lib/RT/Transaction_Overlay.pm	(original)
+++ rt/branches/3.2-RELEASE/lib/RT/Transaction_Overlay.pm	Sun Oct 31 23:43:02 2004
@@ -137,11 +137,11 @@
 
 
     #Provide a way to turn off scrips if we need to
-        $RT::Logger->debug('About to think about scrips for transaction' .$self->Id);            
+        $RT::Logger->debug('About to think about scrips for transaction #' .$self->Id);
     if ( $args{'ActivateScrips'} ) {
        $self->{'scrips'} = RT::Scrips->new($RT::SystemUser);
 
-        $RT::Logger->debug('About to prepare scrips for transaction' .$self->Id);            
+        $RT::Logger->debug('About to prepare scrips for transaction #' .$self->Id); 
 
         $self->{'scrips'}->Prepare(
             Stage       => 'TransactionCreate',
@@ -150,7 +150,7 @@
             Transaction => $self->id,
         );
         if ($args{'CommitScrips'} ) {
-            $RT::Logger->debug('About to commit scrips for transaction' .$self->Id);
+            $RT::Logger->debug('About to commit scrips for transaction #' .$self->Id);
             $self->{'scrips'}->Commit();
         }
     }


More information about the Rt-commit mailing list