/// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="lookupable">is the lookupable</param>
        /// <param name="filterOperator">is the type of compare</param>
        /// <param name="resultEventAsName">is the name of the result event from which to get a property value to compare</param>
        /// <param name="resultEventProperty">is the name of the property to get from the named result event</param>
        /// <param name="isMustCoerce">indicates on whether numeric coercion must be performed</param>
        /// <param name="coercionType">indicates the numeric coercion type to use</param>
        /// <param name="numberCoercer">interface to use to perform coercion</param>
        /// <param name="resultEventIndex">index</param>
        /// <param name="statementName">statement name</param>
        /// <param name="eventType">event type</param>
        /// <throws>ArgumentException if an operator was supplied that does not take a single constant value</throws>
        public FilterSpecParamEventPropIndexedForge(
            ExprFilterSpecLookupableForge lookupable,
            FilterOperator filterOperator,
            string resultEventAsName,
            int resultEventIndex,
            string resultEventProperty,
            EventType eventType,
            bool isMustCoerce,
            Coercer numberCoercer,
            Type coercionType,
            string statementName)
            : base(lookupable, filterOperator)
        {
            ResultEventAsName = resultEventAsName;
            ResultEventIndex = resultEventIndex;
            ResultEventProperty = resultEventProperty;
            EventType = eventType;
            IsMustCoerce = isMustCoerce;
            _numberCoercer = numberCoercer;
            CoercionType = coercionType;
            _statementName = statementName;

            if (filterOperator.IsRangeOperator()) {
                throw new ArgumentException(
                    "Illegal filter operator " +
                    filterOperator +
                    " supplied to " +
                    "event property filter parameter");
            }
        }
        public static List <FilterSpecParam> BuildList(EventType eventType, Object[] objects)
        {
            List <FilterSpecParam> filterParams = new List <FilterSpecParam>();

            int index = 0;

            while (objects.Length > index)
            {
                String         propertyName   = (String)objects[index++];
                FilterOperator filterOperator = (FilterOperator)objects[index++];

                if (!(filterOperator.IsRangeOperator()))
                {
                    Object filterForConstant = objects[index++];
                    filterParams.Add(new FilterSpecParamConstant(MakeLookupable(eventType, propertyName), filterOperator, filterForConstant));
                }
                else
                {
                    double min = objects[index++].AsDouble();
                    double max = objects[index++].AsDouble();
                    filterParams.Add(new FilterSpecParamRange(MakeLookupable(eventType, propertyName), filterOperator,
                                                              new RangeValueDouble(min),
                                                              new RangeValueDouble(max)));
                }
            }

            return(filterParams);
        }
示例#3
0
 public FilterParamIndexDoubleRange(FilterSpecLookupable lookupable, IReaderWriterLock readWriteLock, FilterOperator filterOperator)
     : base(lookupable, readWriteLock, filterOperator)
 {
     if (!(filterOperator.IsRangeOperator()))
     {
         throw new ArgumentException("Invalid filter operator " + filterOperator);
     }
 }
        /// <summary>Constructor. </summary>
        /// <param name="lookupable">is the lookupable</param>
        /// <param name="filterOperator">is the type of compare</param>
        /// <param name="filterConstant">contains the value to match against the event's property value</param>
        /// <throws>ArgumentException if an operator was supplied that does not take a single constant value</throws>
        public FilterSpecParamConstant(FilterSpecLookupable lookupable, FilterOperator filterOperator, Object filterConstant)
            : base(lookupable, filterOperator)
        {
            _filterConstant = filterConstant;

            if (filterOperator.IsRangeOperator())
            {
                throw new ArgumentException("Illegal filter operator " + filterOperator + " supplied to " +
                                            "constant filter parameter");
            }
        }
示例#5
0
        /// <summary>Constructor. </summary>
        /// <param name="lookupable">is the lookupable</param>
        /// <param name="filterOperator">is the type of range operator</param>
        /// <param name="min">is the begin point of the range</param>
        /// <param name="max">is the end point of the range</param>
        /// <throws>ArgumentException if an operator was supplied that does not take a double range value</throws>
        public FilterSpecParamRange(FilterSpecLookupable lookupable, FilterOperator filterOperator, FilterSpecParamRangeValue min, FilterSpecParamRangeValue max)
            : base(lookupable, filterOperator)
        {
            _min = min;
            _max = max;

            if (!(filterOperator.IsRangeOperator()) && (!filterOperator.IsInvertedRangeOperator()))
            {
                throw new ArgumentException("Illegal filter operator " + filterOperator + " supplied to " +
                                            "range filter parameter");
            }
        }
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="lookupable">is the lookupable</param>
        /// <param name="filterOperator">is the type of range operator</param>
        /// <param name="min">is the begin point of the range</param>
        /// <param name="max">is the end point of the range</param>
        /// <throws>IllegalArgumentException if an operator was supplied that does not take a double range value</throws>
        public SupportFilterSpecParamRange(
            ExprFilterSpecLookupable lookupable,
            FilterOperator filterOperator,
            FilterSpecParamFilterForEval min,
            FilterSpecParamFilterForEval max)
            : base(lookupable, filterOperator)
        {
            Min = min;
            Max = max;

            if (!filterOperator.IsRangeOperator() && !filterOperator.IsInvertedRangeOperator())
            {
                throw new ArgumentException(
                          "Illegal filter operator " +
                          filterOperator +
                          " supplied to " +
                          "range filter parameter");
            }
        }
示例#7
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="lookupable">is the property or function to get a lookup value</param>
        /// <param name="filterOperator">is the type of compare</param>
        /// <param name="resultEventAsName">is the name of the result event from which to get a property value to compare</param>
        /// <param name="resultEventProperty">is the name of the property to get from the named result event</param>
        /// <param name="isMustCoerce">indicates on whether numeric coercion must be performed</param>
        /// <param name="coercionType">indicates the numeric coercion type to use</param>
        /// <param name="numberCoercer">interface to use to perform coercion</param>
        /// <param name="statementName">statement name</param>
        /// <exception cref="ArgumentException">if an operator was supplied that does not take a single constant value</exception>
        public FilterSpecParamEventProp(FilterSpecLookupable lookupable, FilterOperator filterOperator, string resultEventAsName,
                                        string resultEventProperty, bool isMustCoerce,
                                        Coercer numberCoercer, Type coercionType,
                                        string statementName)
            : base(lookupable, filterOperator)
        {
            _resultEventAsName   = resultEventAsName;
            _resultEventProperty = resultEventProperty;
            _isMustCoerce        = isMustCoerce;
            _numberCoercer       = numberCoercer;
            _coercionType        = coercionType;
            _statementName       = statementName;

            if (filterOperator.IsRangeOperator())
            {
                throw new ArgumentException("Illegal filter operator " + filterOperator + " supplied to " +
                                            "event property filter parameter");
            }
        }
示例#8
0
        /// <summary>
        /// Factory for indexes that store filter parameter constants for a given event property and filter operator.
        /// <para />
        /// Does not perform any check of validity of property name.
        /// </summary>
        /// <param name="lookupable">The lookupable.</param>
        /// <param name="lockFactory">The lock factory.</param>
        /// <param name="filterOperator">is the type of index to use</param>
        /// <returns>
        /// the proper index based on the filter operator type
        /// </returns>
        /// <exception cref="System.ArgumentException">Cannot create filter index instance for filter operator  + filterOperator</exception>
        public static FilterParamIndexBase CreateIndex(FilterSpecLookupable lookupable, FilterServiceGranularLockFactory lockFactory, FilterOperator filterOperator)
        {
            FilterParamIndexBase index;
            Type returnValueType = lookupable.ReturnType;

            // Handle all EQUAL comparisons
            if (filterOperator == FilterOperator.EQUAL)
            {
                index = new FilterParamIndexEquals(lookupable, lockFactory.ObtainNew());
                return(index);
            }

            // Handle all NOT-EQUAL comparisons
            if (filterOperator == FilterOperator.NOT_EQUAL)
            {
                index = new FilterParamIndexNotEquals(lookupable, lockFactory.ObtainNew());
                return(index);
            }

            if (filterOperator == FilterOperator.IS)
            {
                index = new FilterParamIndexEqualsIs(lookupable, lockFactory.ObtainNew());
                return(index);
            }

            if (filterOperator == FilterOperator.IS_NOT)
            {
                index = new FilterParamIndexNotEqualsIs(lookupable, lockFactory.ObtainNew());
                return(index);
            }

            // Handle all GREATER, LESS etc. comparisons
            if ((filterOperator == FilterOperator.GREATER) ||
                (filterOperator == FilterOperator.GREATER_OR_EQUAL) ||
                (filterOperator == FilterOperator.LESS) ||
                (filterOperator == FilterOperator.LESS_OR_EQUAL))
            {
                if (returnValueType != typeof(String))
                {
                    index = new FilterParamIndexCompare(lookupable, lockFactory.ObtainNew(), filterOperator);
                }
                else
                {
                    index = new FilterParamIndexCompareString(lookupable, lockFactory.ObtainNew(), filterOperator);
                }
                return(index);
            }

            // Handle all normal and inverted RANGE comparisons
            if (filterOperator.IsRangeOperator())
            {
                if (returnValueType != typeof(String))
                {
                    index = new FilterParamIndexDoubleRange(lookupable, lockFactory.ObtainNew(), filterOperator);
                }
                else
                {
                    index = new FilterParamIndexStringRange(lookupable, lockFactory.ObtainNew(), filterOperator);
                }
                return(index);
            }
            if (filterOperator.IsInvertedRangeOperator())
            {
                if (returnValueType != typeof(String))
                {
                    return(new FilterParamIndexDoubleRangeInverted(lookupable, lockFactory.ObtainNew(), filterOperator));
                }
                else
                {
                    return(new FilterParamIndexStringRangeInverted(lookupable, lockFactory.ObtainNew(), filterOperator));
                }
            }

            // Handle all IN and NOT IN comparisons
            if (filterOperator == FilterOperator.IN_LIST_OF_VALUES)
            {
                return(new FilterParamIndexIn(lookupable, lockFactory.ObtainNew()));
            }
            if (filterOperator == FilterOperator.NOT_IN_LIST_OF_VALUES)
            {
                return(new FilterParamIndexNotIn(lookupable, lockFactory.ObtainNew()));
            }

            // Handle all bool expression
            if (filterOperator == FilterOperator.BOOLEAN_EXPRESSION)
            {
                return(new FilterParamIndexBooleanExpr(lockFactory.ObtainNew()));
            }
            throw new ArgumentException("Cannot create filter index instance for filter operator " + filterOperator);
        }
示例#9
0
        /// <summary>
        ///     Factory for indexes that store filter parameter constants for a given event property and filter
        ///     operator.
        ///     <para />
        ///     Does not perform any check of validity of property name.
        /// </summary>
        /// <param name="filterOperator">is the type of index to use</param>
        /// <param name="lockFactory">lock factory</param>
        /// <param name="lookupable">the lookup item</param>
        /// <returns>the proper index based on the filter operator type</returns>
        public static FilterParamIndexBase CreateIndex(
            ExprFilterSpecLookupable lookupable,
            FilterServiceGranularLockFactory lockFactory,
            FilterOperator filterOperator)
        {
            FilterParamIndexBase index;
            var returnValueType = lookupable.ReturnType;

            // Handle all EQUAL comparisons
            if (filterOperator == FilterOperator.EQUAL) {
                index = new FilterParamIndexEquals(lookupable, lockFactory.ObtainNew());
                return index;
            }

            // Handle all NOT-EQUAL comparisons
            if (filterOperator == FilterOperator.NOT_EQUAL) {
                index = new FilterParamIndexNotEquals(lookupable, lockFactory.ObtainNew());
                return index;
            }

            if (filterOperator == FilterOperator.IS) {
                index = new FilterParamIndexEqualsIs(lookupable, lockFactory.ObtainNew());
                return index;
            }

            if (filterOperator == FilterOperator.IS_NOT) {
                index = new FilterParamIndexNotEqualsIs(lookupable, lockFactory.ObtainNew());
                return index;
            }

            // Handle all GREATER, LESS etc. comparisons
            if (filterOperator == FilterOperator.GREATER ||
                filterOperator == FilterOperator.GREATER_OR_EQUAL ||
                filterOperator == FilterOperator.LESS ||
                filterOperator == FilterOperator.LESS_OR_EQUAL) {
                if (returnValueType != typeof(string)) {
                    index = new FilterParamIndexCompare(lookupable, lockFactory.ObtainNew(), filterOperator);
                }
                else {
                    index = new FilterParamIndexCompareString(lookupable, lockFactory.ObtainNew(), filterOperator);
                }

                return index;
            }

            // Handle all normal and inverted RANGE comparisons
            if (filterOperator.IsRangeOperator()) {
                if (returnValueType != typeof(string)) {
                    index = new FilterParamIndexDoubleRange(lookupable, lockFactory.ObtainNew(), filterOperator);
                }
                else {
                    index = new FilterParamIndexStringRange(lookupable, lockFactory.ObtainNew(), filterOperator);
                }

                return index;
            }

            if (filterOperator.IsInvertedRangeOperator()) {
                if (returnValueType != typeof(string)) {
                    return new FilterParamIndexDoubleRangeInverted(lookupable, lockFactory.ObtainNew(), filterOperator);
                }

                return new FilterParamIndexStringRangeInverted(lookupable, lockFactory.ObtainNew(), filterOperator);
            }

            // Handle all IN and NOT IN comparisons
            if (filterOperator == FilterOperator.IN_LIST_OF_VALUES) {
                return new FilterParamIndexIn(lookupable, lockFactory.ObtainNew());
            }

            if (filterOperator == FilterOperator.NOT_IN_LIST_OF_VALUES) {
                return new FilterParamIndexNotIn(lookupable, lockFactory.ObtainNew());
            }

            
            // Handle re-usable boolean expression
            if (filterOperator == FilterOperator.REBOOL) {
                if (lookupable.ReturnType == null) {
                    return new FilterParamIndexReboolNoValue(lookupable, lockFactory.ObtainNew());
                }
                return new FilterParamIndexReboolWithValue(lookupable, lockFactory.ObtainNew());
            }
            
            // Handle all boolean expression
            if (filterOperator == FilterOperator.BOOLEAN_EXPRESSION) {
                return new FilterParamIndexBooleanExpr(lockFactory.ObtainNew());
            }

            // Handle advanced-index
            if (filterOperator == FilterOperator.ADVANCED_INDEX) {
                var advLookable = (FilterSpecLookupableAdvancedIndex) lookupable;
                if (advLookable.IndexType.Equals(SettingsApplicationDotMethodPointInsideRectangle.INDEXTYPE_NAME)) {
                    return new FilterParamIndexQuadTreePointRegion(lockFactory.ObtainNew(), lookupable);
                }

                if (advLookable.IndexType.Equals(SettingsApplicationDotMethodRectangeIntersectsRectangle.INDEXTYPE_NAME)) {
                    return new FilterParamIndexQuadTreeMXCIF(lockFactory.ObtainNew(), lookupable);
                }

                throw new IllegalStateException("Unrecognized index type " + advLookable.IndexType);
            }

            throw new ArgumentException("Cannot create filter index instance for filter operator " + filterOperator);
        }