private static View CopyChildView(GroupByView groupView, String[] propertyNames, Object groupByValues, AgentInstanceViewFactoryChainContext agentInstanceContext, View originalChildView) { if (originalChildView is MergeView) { const string message = "Unexpected merge view as child of group-by view"; Log.Error(".copySubViews " + message); throw new EPException(message); } if (!(originalChildView is CloneableView)) { throw new EPException("Unexpected error copying subview " + originalChildView.GetType().FullName); } var cloneableView = (CloneableView)originalChildView; // Copy child node var copyChildView = cloneableView.CloneView(); copyChildView.Parent = groupView; // Make the sub views for child copying from the original to the child CopySubViews(groupView.CriteriaExpressions, propertyNames, groupByValues, originalChildView, copyChildView, agentInstanceContext); return(copyChildView); }
/// <summary> /// Instantiate subviews for the given group view and the given key value to group-by. Makes shallow /// copies of each child view and its subviews up to the merge point. Sets up merge data views for /// merging the group-by key value back in. /// </summary> /// <param name="groupView">is the parent view for which to copy subviews for</param> /// <param name="propertyNames">names of expressions or properties</param> /// <param name="groupByValues">is the key values to group-by</param> /// <param name="agentInstanceContext">is the view services that sub-views may need</param> /// <returns> /// a single view or a list of views that are copies of the original list, with copied children, withdata merge views added to the copied child leaf views. /// </returns> public static Object MakeSubViews( GroupByView groupView, String[] propertyNames, Object groupByValues, AgentInstanceViewFactoryChainContext agentInstanceContext) { if (!groupView.HasViews) { const string message = "Unexpected empty list of child nodes for group view"; Log.Error(".copySubViews " + message); throw new EPException(message); } Object subviewHolder; if (groupView.Views.Length == 1) { subviewHolder = CopyChildView(groupView, propertyNames, groupByValues, agentInstanceContext, groupView.Views[0]); } else { // For each child node var subViewList = new List <View>(4); subviewHolder = subViewList; foreach (var originalChildView in groupView.Views) { var copyChildView = CopyChildView(groupView, propertyNames, groupByValues, agentInstanceContext, originalChildView); subViewList.Add(copyChildView); } } return(subviewHolder); }
protected internal static View MakeSubView( GroupByView view, object groupKey) { var agentInstanceContext = view.AgentInstanceContext; var mergeView = view.MergeView; var factories = view.ViewFactory.Groupeds; View first = factories[0].MakeView(agentInstanceContext); first.Parent = view; var currentParent = first; for (var i = 1; i < factories.Length; i++) { View next = factories[i].MakeView(agentInstanceContext); next.Parent = currentParent; currentParent.Child = next; currentParent = next; } if (view.ViewFactory.IsAddingProperties) { var adder = new AddPropertyValueOptionalView(view.ViewFactory, agentInstanceContext, groupKey); currentParent.Child = adder; adder.Parent = currentParent; adder.Child = mergeView; mergeView.AddParentView(adder); } else { currentParent.Child = mergeView; mergeView.AddParentView(currentParent); } return first; }
public MergeView( GroupByView groupByView, EventType eventType) { this.groupByView = groupByView; EventType = eventType; parentViews = new List<View>(4); }
public bool CanReuse(View view, AgentInstanceContext agentInstanceContext) { if (!(view is GroupByView)) { return(false); } if (IsReclaimAged) { return(false); } GroupByView myView = (GroupByView)view; if (!ExprNodeUtility.DeepEquals(myView.CriteriaExpressions, _criteriaExpressions)) { return(false); } return(true); }
public void SetUp() { _statementContext = SupportStatementContextFactory.MakeContext(); _agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(); var expressions = SupportExprNodeFactory.MakeIdentNodesMD("Symbol"); _myGroupByView = new GroupByViewImpl(_agentInstanceContext, expressions, ExprNodeUtility.GetEvaluators(expressions)); var childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); var myMergeView = new MergeView(_agentInstanceContext, SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), false); _ultimateChildView = new SupportBeanClassView(typeof(SupportMarketDataBean)); // This is the view hierarchy _myGroupByView.AddView(childView); childView.AddView(myMergeView); myMergeView.AddView(_ultimateChildView); SupportBeanClassView.Instances.Clear(); }
public void Bind(Model model, GroupByView groupBy) { var currentSelection = GetSelectedObjects(); SuspendLayout(); _isBinding = true; DataSource = null; Rows.Clear(); _model = model; _gridBinding = new List<GridObject>(); List<IGrouping<string, ModelObject>> groupings; switch (groupBy) { case GroupByView.ObjectType: groupings = _model.Objects.OrderBy(x => x.Type).ThenBy(x => x.Name).GroupBy(modelObject => modelObject.Type) .ToList(); break; case GroupByView.Difference: groupings = _model.Objects.OrderBy(x => x.Type).ThenBy(x => x.Name).GroupBy( modelObject => modelObject.Difference.DisplayValue).ToList(); break; default: groupings = _model.Objects.OrderBy(x => x.Type).ThenBy(x => x.Name).GroupBy(x => "All").ToList(); break; } foreach (var grouping in groupings) { var group = new GridGroup(); group.HeaderText = string.Format("{0} : {1} objects", grouping.Key, grouping.Count()); group.Collapsed = true; _gridBinding.Add(group); foreach (ModelObject modelObject in grouping) { var o = modelObject; var currentValue = currentSelection.FirstOrDefault(x => x.Id == o.Id); var difference = new GridDifference { Include = currentValue == null ? modelObject.Difference.Action != Action.None : currentValue.Include, Object = modelObject, SourceName = modelObject.Name, TargetName = modelObject.Name, Type = modelObject.Type, Action = modelObject.Difference.Action.ToString() }; _gridBinding.Add(difference); } } AutoGenerateColumns = false; DataSource = _gridBinding; CollapseExpandAll(true); _isBinding = false; ResumeLayout(); }