private static View copyChildView( GroupByView groupView, String[] propertyNames, Object groupByValues, AgentInstanceViewFactoryChainContext agentInstanceContext, View originalChildView) { if (originalChildView instanceof MergeView) { String message = "Unexpected merge view as child of group-by view"; log.fatal(".copySubViews " + message); throw new EPException(message); } if (!(originalChildView instanceof CloneableView)) { throw new EPException( "Unexpected error copying subview " + originalChildView.getClass().getName()); } CloneableView cloneableView = (CloneableView) originalChildView; // Copy child node View copyChildView = cloneableView.cloneView(); copyChildView.setParent(groupView); // Make the sub views for child copying from the original to the child copySubViews( groupView.getCriteriaExpressions(), propertyNames, groupByValues, originalChildView, copyChildView, agentInstanceContext); return copyChildView; }
private static void copySubViews( ExprNode[] criteriaExpressions, String[] propertyNames, Object groupByValues, View originalView, View copyView, AgentInstanceViewFactoryChainContext agentInstanceContext) { for (View subView : originalView.getViews()) { // Determine if view is our merge view if (subView instanceof MergeViewMarker) { MergeViewMarker mergeView = (MergeViewMarker) subView; if (ExprNodeUtility.deepEquals(mergeView.getGroupFieldNames(), criteriaExpressions)) { // We found our merge view - install a new data merge view on top of it AddPropertyValueView mergeDataView = new AddPropertyValueView( agentInstanceContext, propertyNames, groupByValues, mergeView.getEventType()); // Add to the copied parent subview the view merge data view copyView.addView(mergeDataView); // Add to the new merge data view the actual single merge view instance that clients may // attached to mergeDataView.addView(mergeView); // Add a parent view to the single merge view instance mergeView.addParentView(mergeDataView); continue; } } if (!(subView instanceof CloneableView)) { throw new EPException("Unexpected error copying subview"); } CloneableView cloneableView = (CloneableView) subView; View copiedChild = cloneableView.cloneView(); copyView.addView(copiedChild); // Make the sub views for child copySubViews( criteriaExpressions, propertyNames, groupByValues, subView, copiedChild, agentInstanceContext); } }
protected static void updateChildViews( Object subViews, EventBean[] newData, EventBean[] oldData) { if (subViews instanceof List) { List<View> viewList = (List<View>) subViews; ViewSupport.updateChildren(viewList, newData, oldData); } else { ((View) subViews).update(newData, oldData); } }