A/T Event Revalidation shouldn't change event states from complete to found
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 5 Jan 2012 23:39:07 +0000 (18:39 -0500)
committerMike Rylander <mrylander@gmail.com>
Mon, 9 Jan 2012 19:07:32 +0000 (14:07 -0500)
Ideally, revalidation should be guaranteed not to change anything about
the event itself at the database level, but I'm not sure we're there
yet.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Event.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/EventGroup.pm

index ffb45b7..2f28416 100644 (file)
@@ -605,7 +605,7 @@ sub revalidate_event_group_test {
     my $client = shift;
     my $events = shift;
 
-    my $e = OpenILS::Application::Trigger::EventGroup->new(@$events);
+    my $e = OpenILS::Application::Trigger::EventGroup->new_nochanges(@$events);
 
     my $result = $e->revalidate_test;
 
index 3e98ad7..1aca73e 100644 (file)
@@ -14,6 +14,7 @@ sub new {
     my $class = shift;
     my $id = shift;
     my $editor = shift;
+    my $nochanges = shift; # no guarantees, yet...
     $class = ref($class) || $class;
 
     my $standalone = $editor ? 0 : 1;
@@ -27,7 +28,7 @@ sub new {
         return $id;
     }
 
-    my $self = bless { id => $id, editor => $editor, standalone => $standalone } => $class;
+    my $self = bless { id => $id, editor => $editor, standalone => $standalone, nochanges => $nochanges } => $class;
 
     return $self->init()
 }
@@ -93,8 +94,9 @@ sub init {
         $self->cleanedup(0);
     }
 
-
-    $self->update_state('found') || die 'Unable to update event state';
+    unless ($self->nochanges) {
+        $self->update_state('found') || die 'Unable to update event state';
+    }
 
     my $class = $self->_fm_class_by_hint( $self->event->event_def->hook->core_type );
     
@@ -112,8 +114,8 @@ sub init {
         $self->editor->xact_rollback || return undef;
     }
 
-    unless($self->target) {
-        $self->update_state('invalid');
+    unless ($self->target) {
+        $self->update_state('invalid') unless $self->nochanges;
         $self->valid(0);
     }
 
@@ -325,6 +327,16 @@ sub editor {
     return $self->{editor};
 }
 
+sub nochanges {
+    # no guarantees, yet.
+    my $self = shift;
+    return undef unless (ref $self);
+
+    my $e = shift;
+    $self->{nochanges} = $e if (defined $e);
+    return $self->{nochanges};
+}
+
 sub unfind {
     my $self = shift;
     return undef unless (ref $self);
index 5703854..08adc5c 100644 (file)
@@ -12,9 +12,11 @@ use OpenILS::Application::Trigger::ModRunner;
 
 my $log = 'OpenSRF::Utils::Logger';
 
-sub new {
+sub new_impl {
     my $class = shift;
-    my @ids = @_;
+    my @ids = @{shift()};
+    my $nochanges = shift;
+
     $class = ref($class) || $class;
 
     my $editor = new_editor(xact=>1);
@@ -25,7 +27,7 @@ sub new {
             map {
                 ref($_) ?
                     do { $_->standalone(0); $_->editor($editor); $_ } :
-                    OpenILS::Application::Trigger::Event->new($_, $editor)
+                    OpenILS::Application::Trigger::Event->new($_, $editor, $nochanges)
             } @ids
         ],
         ids         => [ map { ref($_) ? $_->id : $_ } @ids ],
@@ -39,6 +41,20 @@ sub new {
     return $self;
 }
 
+sub new_nochanges {
+    my $class = shift;
+    my @ids = @_;
+
+    return new_impl($class, \@ids, 1);
+}
+
+sub new {
+    my $class = shift;
+    my @ids = @_;
+
+    return new_impl($class, \@ids);
+}
+
 sub react {
     my $self = shift;