{
return new OutputConditionNullFactory();
}
// Check if a variable is present
VariableReader reader = null;
if (outputLimitSpec.getVariableName() != null)
{
reader = statementContext.getVariableService().getReader(outputLimitSpec.getVariableName());
if (reader == null)
{
throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' has not been declared");
}
}
if(outputLimitSpec.getDisplayLimit() == OutputLimitLimitType.FIRST)
{
if (isGrouped) {
return new OutputConditionNullFactory();
}
if (!isWithHavingClause) {
return new OutputConditionFirstFactory(outputLimitSpec, statementContext, isGrouped, isWithHavingClause);
}
}
if(outputLimitSpec.getRateType() == OutputLimitRateType.CRONTAB)
{
return new OutputConditionCrontabFactory(outputLimitSpec.getCrontabAtSchedule(), statementContext);
}
else if(outputLimitSpec.getRateType() == OutputLimitRateType.WHEN_EXPRESSION)
{
return new OutputConditionExpressionFactory(outputLimitSpec.getWhenExpressionNode(), outputLimitSpec.getThenExpressions(), statementContext);
}
else if(outputLimitSpec.getRateType() == OutputLimitRateType.EVENTS)
{
if (log.isDebugEnabled())
{
log.debug(".createCondition creating OutputConditionCount with event rate " + outputLimitSpec);
}
if ((reader != null) && (!JavaClassHelper.isNumericNonFP(reader.getType())))
{
throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' must be type integer, long or short");
}
int rate = -1;
if (outputLimitSpec.getRate() != null)
{
rate = outputLimitSpec.getRate().intValue();
}
return new OutputConditionCountFactory(rate, reader);
}
else if (outputLimitSpec.getRateType() == OutputLimitRateType.TERM)
{
return new OutputConditionTermFactory();
}
else {
if (log.isDebugEnabled())
{
log.debug(".createCondition creating OutputConditionTime with interval length " + outputLimitSpec.getRate());
}
if ((reader != null) && (!JavaClassHelper.isNumeric(reader.getType())))
{
throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' must be of numeric type");
}
return new OutputConditionTimeFactory(outputLimitSpec.getTimePeriodExpr(), statementContext);