Esempio n. 1
0
        public void Attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, IList <ViewFactory> parentViewFactories)
        {
            String windowName = ViewName;

            ExprNode[] validated = ViewFactorySupport.Validate(windowName, parentEventType, statementContext, _viewParameters, true);
            if (_viewParameters.Count < 2 || _viewParameters.Count > 3)
            {
                throw new ViewParameterException(ViewParamMessage);
            }

            // validate first parameter: timestamp expression
            if (!validated[0].ExprEvaluator.ReturnType.IsNumeric())
            {
                throw new ViewParameterException(ViewParamMessage);
            }
            TimestampExpression     = validated[0];
            TimestampExpressionEval = TimestampExpression.ExprEvaluator;
            ViewFactorySupport.AssertReturnsNonConstant(windowName, validated[0], 0);

            TimeDeltaComputation = ViewFactoryTimePeriodHelper.ValidateAndEvaluateTimeDelta(ViewName, statementContext, _viewParameters[1], ViewParamMessage, 1);

            // validate optional parameters
            if (validated.Length == 3)
            {
                Object constant = ViewFactorySupport.ValidateAndEvaluate(windowName, statementContext, validated[2]);
                if ((!constant.IsNumber()) || (TypeHelper.IsFloatingPointNumber(constant)))
                {
                    throw new ViewParameterException("Externally-timed batch view requires a Long-typed reference point in msec as a third parameter");
                }
                OptionalReferencePoint = constant.AsLong();
            }

            this._eventType = parentEventType;
        }
        public void SetViewParameters(ViewFactoryContext viewFactoryContext, IList <ExprNode> expressionParameters)
        {
            IList <Object> viewParameters = ViewFactorySupport.ValidateAndEvaluate(ViewName, viewFactoryContext.StatementContext, expressionParameters);

            if (viewParameters.Count != 1)
            {
                throw new ViewParameterException(ViewParamMessage);
            }

            Object parameter = viewParameters[0];

            if (!(parameter.IsNumber()))
            {
                throw new ViewParameterException(ViewParamMessage);
            }
            var numParam = parameter;

            if ((numParam.IsFloatingPointNumber()) ||
                (numParam.IsLongNumber()))
            {
                throw new ViewParameterException(ViewParamMessage);
            }

            Size = numParam.AsInt();
            if (Size <= 0)
            {
                throw new ViewParameterException(ViewName + " view requires a positive number");
            }
        }
        public void SetViewParameters(ViewFactoryContext viewFactoryContext, IList <ExprNode> expressionParameters)
        {
            var viewParameters = new Object[expressionParameters.Count];

            for (var i = 1; i < expressionParameters.Count; i++)
            {
                viewParameters[i] = ViewFactorySupport.ValidateAndEvaluate(
                    ViewName, viewFactoryContext.StatementContext, expressionParameters[i]);
            }
            var errorMessage = ViewName +
                               " view requires a numeric or time period parameter as a time interval size, and an integer parameter as a maximal number-of-events, and an optional list of control keywords as a string parameter (please see the documentation)";

            if ((viewParameters.Length != 2) && (viewParameters.Length != 3))
            {
                throw new ViewParameterException(errorMessage);
            }

            TimeDeltaComputation = ViewFactoryTimePeriodHelper.ValidateAndEvaluateTimeDelta(
                ViewName, viewFactoryContext.StatementContext, expressionParameters[0], errorMessage, 0);

            // parameter 2
            var parameter = viewParameters[1];

            if (!(parameter.IsNumber()) || (TypeHelper.IsFloatingPointNumber(parameter)))
            {
                throw new ViewParameterException(errorMessage);
            }
            _numberOfEvents = parameter.AsLong();

            if (viewParameters.Length > 2)
            {
                ProcessKeywords(viewParameters[2], errorMessage);
            }
        }
Esempio n. 4
0
 public void SetViewParameters(ViewFactoryContext viewFactoryContext, IList <ExprNode> expressionParameters)
 {
     if (expressionParameters.Count != 1)
     {
         throw new ViewParameterException("View requires a single parameter indicating unbound or not");
     }
     _isUnbound = (bool)ViewFactorySupport.ValidateAndEvaluate(ViewName, viewFactoryContext.StatementContext, expressionParameters[0]);
 }
Esempio n. 5
0
        public void SetViewParameters(ViewFactoryContext viewFactoryContext, IList <ExprNode> expressionParameters)
        {
            IList <Object> viewParameters = ViewFactorySupport.ValidateAndEvaluate(ViewName, viewFactoryContext.StatementContext, expressionParameters);

            if (viewParameters.IsNotEmpty())
            {
                String errorMessage = ViewName + " view does not take any parameters";
                throw new ViewParameterException(errorMessage);
            }
        }
Esempio n. 6
0
        public void SetViewParameters(ViewFactoryContext viewFactoryContext, IList <ExprNode> expressionParameters)
        {
            var viewParameters = ViewFactorySupport.ValidateAndEvaluate(ViewName, viewFactoryContext.StatementContext, expressionParameters);

            if (viewParameters.Count != 0)
            {
                String errorMessage = ViewName + " view requires an empty parameter list";
                throw new ViewParameterException(errorMessage);
            }
        }
Esempio n. 7
0
        public void SetViewParameters(ViewFactoryContext viewFactoryContext, IList <ExprNode> expressionParameters)
        {
            if ((expressionParameters.Count < 1) || (expressionParameters.Count > 3))
            {
                throw new ViewParameterException(ViewParamMessage);
            }

            var viewParamValues = new Object[expressionParameters.Count];

            for (int i = 1; i < viewParamValues.Length; i++)
            {
                viewParamValues[i] = ViewFactorySupport.ValidateAndEvaluate(
                    ViewName, viewFactoryContext.StatementContext, expressionParameters[i]);
            }

            TimeDeltaComputation = ViewFactoryTimePeriodHelper.ValidateAndEvaluateTimeDelta(
                ViewName, viewFactoryContext.StatementContext, expressionParameters[0],
                ViewParamMessage, 0);

            if ((viewParamValues.Length == 2) && (viewParamValues[1] is String))
            {
                ProcessKeywords(viewParamValues[1], ViewParamMessage);
            }
            else
            {
                if (viewParamValues.Length >= 2)
                {
                    Object paramRef = viewParamValues[1];
                    if ((!(paramRef.IsNumber())) || (paramRef.IsFloatingPointNumber()))
                    {
                        throw new ViewParameterException(
                                  ViewName + " view requires a Long-typed reference point in msec as a second parameter");
                    }
                    OptionalReferencePoint = paramRef.AsLong();
                }
                if (viewParamValues.Length == 3)
                {
                    ProcessKeywords(viewParamValues[2], ViewParamMessage);
                }
            }
        }