builtinTypeDef.put(ExpressionViewUtil.EXPIRED_COUNT, Integer.class);
builtinTypeDef.put(ExpressionViewUtil.VIEW_REFERENCE, Object.class);
builtinTypeDef.put(ExpressionViewUtil.NEWEST_EVENT, eventType);
builtinTypeDef.put(ExpressionViewUtil.OLDEST_EVENT, eventType);
builtinMapType = statementContext.getEventAdapterService().createAnonymousMapType(statementContext.getStatementId() + "_exprview", builtinTypeDef);
StreamTypeService streamTypeService = new StreamTypeServiceImpl(new EventType[] {eventType, builtinMapType}, new String[2], new boolean[2], statementContext.getEngineURI(), false);
// validate expression
expiryExpression = ViewFactorySupport.validateExpr(getViewName(), statementContext, expiryExpression, streamTypeService, 0);
ExprNodeSummaryVisitor summaryVisitor = new ExprNodeSummaryVisitor();
expiryExpression.accept(summaryVisitor);
if (summaryVisitor.isHasSubselect() || summaryVisitor.isHasStreamSelect() || summaryVisitor.isHasPreviousPrior()) {
throw new ViewParameterException("Invalid expiry expression: Sub-select, previous or prior functions are not supported in this context");
}
Class returnType = expiryExpression.getExprEvaluator().getType();
if (JavaClassHelper.getBoxedType(returnType) != Boolean.class) {
throw new ViewParameterException("Invalid return value for expiry expression, expected a boolean return value but received " + JavaClassHelper.getParameterAsString(returnType));
}
// determine variables used, if any
ExprNodeVariableVisitor visitor = new ExprNodeVariableVisitor();
expiryExpression.accept(visitor);
variableNames = visitor.getVariableNames();
// determine aggregation nodes, if any
List<ExprAggregateNode> aggregateNodes = new ArrayList<ExprAggregateNode>();
ExprAggregateNodeUtil.getAggregatesBottomUp(expiryExpression, aggregateNodes);
if (!aggregateNodes.isEmpty()) {
try {
aggregationServiceFactoryDesc = AggregationServiceFactoryFactory.getService(Collections.<ExprAggregateNode>emptyList(), null, aggregateNodes, Collections.<ExprAggregateNode>emptyList(), Collections.<ExprAggregateNodeGroupKey>emptyList(), false, new ExprEvaluatorContextStatement(statementContext), statementContext.getAnnotations(), statementContext.getVariableService(), false, false, null, null, AggregationServiceFactoryServiceImpl.DEFAULT_FACTORY, streamTypeService.getEventTypes(), statementContext.getMethodResolutionService());
}
catch (ExprValidationException ex) {
throw new ViewParameterException(ex.getMessage(), ex);
}
}