Ejemplo n.º 1
0
        private void HandleEvent(
            EventBean theEvent,
            bool isNew)
        {
            var groupByValuesKey = GetGroupKey(theEvent);

            // Get child views that belong to this group-by value combination
            var subViews = subViewPerKey.Get(groupByValuesKey);

            // If this is a new group-by value, the list of subviews is null and we need to make clone sub-views
            if (subViews == null) {
                var subview = GroupByViewUtil.MakeSubView(this, groupByValuesKey);
                var currentTime = AgentInstanceContext.StatementContext.TimeProvider.Time;
                subViews = new GroupByViewAgedEntry(subview, currentTime);
                subViewPerKey.Put(groupByValuesKey, subViews);
            }
            else {
                subViews.SetLastUpdateTime(AgentInstanceContext.StatementContext.TimeProvider.Time);
            }

            // Construct a pair of lists to hold the events for the grouped value if not already there
            var pair = groupedEvents.Get(subViews);
            if (pair == null) {
                pair = new Pair<object, object>(null, null);
                groupedEvents.Put(subViews, pair);
            }

            // Add event to a child view event list for later child update that includes new and old events
            if (isNew) {
                pair.First = GroupByViewImpl.AddUpgradeToDequeIfPopulated(pair.First, theEvent);
            }
            else {
                pair.Second = GroupByViewImpl.AddUpgradeToDequeIfPopulated(pair.Second, theEvent);
            }
        }