From: Lebbeous Fogle-Weekley Date: Thu, 5 Jan 2012 23:39:07 +0000 (-0500) Subject: A/T Event Revalidation shouldn't change event states from complete to found X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d4a2d2cd5ea5e42d2be6480c5507a22a7ee83ab8;p=contrib%2FConifer.git A/T Event Revalidation shouldn't change event states from complete to found 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 Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger.pm index ffb45b7fb6..2f2841616d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger.pm @@ -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; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Event.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Event.pm index 3e98ad7c78..1aca73e0a0 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Event.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Event.pm @@ -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); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/EventGroup.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/EventGroup.pm index 5703854915..08adc5cc84 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/EventGroup.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/EventGroup.pm @@ -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;