From 038cae6aecf6b9f1e3a82a2b37cbfd927f60d52f Mon Sep 17 00:00:00 2001
From: miker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Thu, 23 Sep 2010 02:12:02 +0000
Subject: [PATCH] only flesh up to, but not including, the leaf for the
 group_field

git-svn-id: svn://svn.open-ils.org/ILS/trunk@17903 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm       | 8 ++++----
 Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm | 3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
index 6a916c079e..a4d022ac67 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger.pm
@@ -656,16 +656,16 @@ sub grouped_events {
 
             # split the grouping link steps
             my @steps = split /\./, $group;
+            my $group_field = pop(@steps); # we didn't flesh to this, it's a field not an object
 
             # find the grouping object
             my $node = $e->target;
             $node = $node->$_() for ( @steps );
 
-            # get the pkey value for the grouping object on this event
-            my $node_ident = $node->Identity;
-            my $ident_value = $node->$node_ident();
+            # get the grouping value for the grouping object on this event
+            my $ident_value = $node->$group_field();
 
-            # push this event onto the event+grouping_pkey_value stack
+            # push this event onto the event+grouping_value stack
             $groups{$e->event->event_def->id}{$ident_value} ||= [];
             push @{ $groups{$e->event->event_def->id}{$ident_value} }, $e;
         } else {
diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
index 5faef1bf6a..244df30db5 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Event.pm
@@ -397,7 +397,8 @@ sub build_environment {
 
         if ($self->event->event_def->group_field) {
             my @group_path = split(/\./, $self->event->event_def->group_field);
-            my $group_object = $self->_object_by_path( $self->target, undef, [], \@group_path );
+            pop(@group_path); # the last part is a field, should not get fleshed
+            my $group_object = $self->_object_by_path( $self->target, undef, [], \@group_path ) if (@group_path);
         }
     
         $self->environment->{complete} = 1;
-- 
2.11.0