}
// A grouping view requires a merge view and cannot be last since it would not group sub-views
if (specifications.size() > 0)
{
ViewSpec lastView = specifications.get(specifications.size() - 1);
ViewEnum viewEnum = ViewEnum.forName(lastView.getObjectNamespace(), lastView.getObjectName());
if ((viewEnum != null) && (viewEnum.getMergeView() != null))
{
throw new ViewProcessingException("Invalid use of the '" + lastView.getObjectNamespace() + ":" +
lastView.getObjectName() + "' view, the view requires one or more child views to group, or consider using the group-by clause");
}
}
LinkedList<ViewSpec> mergeViewSpecs = new LinkedList<ViewSpec>();
for (ViewSpec spec : specifications)
{
ViewEnum viewEnum = ViewEnum.forName(spec.getObjectNamespace(), spec.getObjectName());
if (viewEnum == null)
{
continue;
}
if (viewEnum.getMergeView() == null)
{
continue;
}
// The merge view gets the same parameters as the view that requires the merge
ViewSpec mergeViewSpec = new ViewSpec(viewEnum.getMergeView().getNamespace(), viewEnum.getMergeView().getName(),
spec.getObjectParameters());
// The merge views are added to the beginning of the list.
// This enables group views to stagger ie. marketdata.group("symbol").group("feed").xxx.merge(...).merge(...)
mergeViewSpecs.addFirst(mergeViewSpec);