public static Group createGroup(object[] items, LogicalOperator logicalOperator)
 {
     Group gr1 = new Group();
     gr1.logicRelation = logicalOperator;
     gr1.Items = items;
     return gr1;
 }
 /// <summary>
 /// Creates a new instance of a CriteriaValue object, and initializes it with the specified properties.
 /// </summary>
 /// <param name="logicalOperator"></param>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public CriteriaValue(LogicalOperator logicalOperator, string key, object value)
 {
     this.LogicalOperator = LogicalOperator;
     this.Key             = key;
     this.Value           = $"{value}";   // TODO: serialize.
     this.ValueType       = value?.GetType().FullName;
 }
Example #3
0
    public PrimitiveTask(string n, CompoundTask p)
    {
        name = n;

        arguments          = new List <Term>();
        arguments.Capacity = 3;


        preconditions   = new List <Atom>();
        effects         = new List <Atom>();
        cuncurrentTasks = new List <CuncurrentTask> ();


        cost = 1;

        loop = false;

        logicalOperator = LogicalOperator.AND;

        actionType = ActionTypes.MOVEMENT;

        groundData = new GroundData();
        groundData.animationState = "";
        groundData.name           = "";

        parent = p;
    }
Example #4
0
        /// <summary>
        /// Instantiates a new atom group.
        /// </summary>
        /// <param name="logicalOperator">The operator that characterizes the relationship between the atoms and atoms group.</param>
        /// <param name="members">An array containing atoms and atom groups.</param>
        internal AtomGroup(LogicalOperator logicalOperator, object[] members, object[] runningMembers)
        {
            // order atoms & groups so naf-atoms are at the end
            foreach(object o in members) {
                if (o == null)
                    throw new BREException("An atom group can not contain a null member");
                else if (o is AtomGroup) {
                    if (((AtomGroup)o).logicalOperator == logicalOperator)
                        throw new BREException("An atom group can not contain another group with the same logical operator");
                }
                else if (o is Atom) {
                    if (((Atom)o).HasFormula)
                        throw new BREException("An atom group can not contain an atom that contains a formula");
                }
                else
                    throw new BREException("An atom group can not hold objects of type: " + o.GetType());
            }

            this.logicalOperator = logicalOperator;
            this.members = members;

            orderedMembers = (object[])runningMembers.Clone();
            Array.Sort(orderedMembers, new AtomComparer());
            this.orderedMembers = orderedMembers;

            resolvedMembers = new object[orderedMembers.Length];

            for(int i=0; i<orderedMembers.Length; i++) {
                if (orderedMembers[i] is Atom) resolvedMembers[i] = Atom.ResolveFunctions((Atom)orderedMembers[i]);
                else resolvedMembers[i] = orderedMembers[i];
            }
        }
Example #5
0
 public PartExtractor(LogicalOperator logicalOperator)
 {
     if (logicalOperator == LogicalOperator.And)
         _operatorToBreakAt = BinaryOperator.LogicalAnd;
     else
         _operatorToBreakAt = BinaryOperator.LogicalOr;
 }
 public FilterCondition(string fieldName, object value, FilterOperator @operator, LogicalOperator whereoperator)
 {
     FieldName     = fieldName;
     Value         = value;
     Operator      = @operator;
     WhereOperator = whereoperator;
 }
Example #7
0
 /// <summary>
 /// 创建一个Between And条件
 /// </summary>
 /// <param name="logicalOperator">与上个条件的关系</param>
 /// <param name="isNot">是否求反</param>
 /// <param name="propertyName">属性名称</param>
 /// <param name="startValue">起始值</param>
 /// <param name="endValue">结束值</param>
 /// <returns>创建的条件</returns>
 public static ICondition BetweenAnd(string propertyName,
                                     object startValue, object endValue,
                                     LogicalOperator logicalOperator = LogicalOperator.And, bool isNot = false)
 {
     return(new DoubleValueCondition(logicalOperator, isNot, propertyName, Operator.BetweenAnd, startValue,
                                     endValue));
 }
Example #8
0
        protected override void AddBetweenFilterCondition <T, TMember>(
            Expression <Func <T, TMember> > selector,
            TMember start,
            TMember end,
            string alias = null,
            LogicalOperator logicalOperator = LogicalOperator.NotSet)
        {
            var conditions1      = currentFilterGroup.Conditions;
            var filterCondition1 = new FilterCondition();

            filterCondition1.Alias           = alias;
            filterCondition1.EntityType      = typeof(T);
            filterCondition1.Operator        = ">=";
            filterCondition1.Left            = GetMemberName(selector);
            filterCondition1.LocigalOperator = logicalOperator;
            filterCondition1.Right           = FormatValue(start);
            var filterCondition2 = filterCondition1;

            conditions1.Add(filterCondition2);
            var conditions2      = currentFilterGroup.Conditions;
            var filterCondition3 = new FilterCondition();

            filterCondition3.Alias           = alias;
            filterCondition3.EntityType      = typeof(T);
            filterCondition3.Operator        = "<=";
            filterCondition3.Left            = GetMemberName(selector);
            filterCondition3.LocigalOperator = LogicalOperator.And;
            filterCondition3.Right           = FormatValue(end);
            var filterCondition4 = filterCondition3;

            conditions2.Add(filterCondition4);
        }
Example #9
0
 // Constructors
 public QueryStrings(int fieldId, ComparisonOperator comparisonOp, string matchingValue, LogicalOperator logicalOp)
 {
     FieldId       = fieldId;
     ComparisonOp  = comparisonOp;
     MatchingValue = matchingValue;
     LogicalOp     = logicalOp;
 }
Example #10
0
        private void ConcatConditionGroup(ref string conditionString, LogicalOperator concatOperator,
                                          IConditionGroup conditionGroup, string groupPrefix = "(", string groupPostfix = ")")
        {
            var groupString = string.Empty;

            foreach (var condition in conditionGroup.Conditions)
            {
                if (condition is IConditionGroup)
                {
                    ConcatConditionGroup(ref groupString, conditionGroup.ConcatOperator, (IConditionGroup)condition);
                }
                else if (condition is IFieldCondition)
                {
                    ConcatFieldCondition(ref groupString, conditionGroup.ConcatOperator, (IFieldCondition)condition);
                }
                else if (condition is IConditionString)
                {
                    ConcatConditionString(ref groupString, conditionGroup.ConcatOperator, (IConditionString)condition);
                }
            }

            if (string.IsNullOrEmpty(groupString))
            {
                return;
            }

            conditionString = string.Concat(conditionString, GetOperatorStringIfStringIsNotEmpty(conditionString, concatOperator), groupPrefix, groupString, groupPostfix);
        }
Example #11
0
        public QueryCriteria AddFilter(LogicalOperator logicalOperator)
        {
            var filter = new QueryCriteria(logicalOperator, EntityName);

            Filters.Add(filter);
            return(filter);
        }
Example #12
0
        /// <summary>
        /// 转换为sql条件字符串
        /// </summary>
        /// <param name="key">关键字.</param>
        /// <param name="oper">条件运算符</param>
        /// <param name="link">操作类型.</param>
        /// <returns>
        /// System.String
        /// </returns>
        public string ToWhereString(string key, ConditionalOperator oper, LogicalOperator link)
        {
            if (Value == null)
            {
                return("");
            }
            string result = "";
            string column = !string.IsNullOrEmpty(key) ? key : Name;
            string query  = ToCriteria(column, Value, oper);

            #region 处理逻辑运算符
            if (query != "")
            {
                switch (link)
                {
                case LogicalOperator.Or:
                    result = " OR (" + query + ")";
                    break;

                case LogicalOperator.And:
                default:
                    result = " AND (" + query + ")";
                    break;
                }
            }
            #endregion
            return(result);
        }
Example #13
0
        public LogicalExpression MakeLogical(string op, LogicalExpression lhs, LogicalExpression rhs)
        {
            LogicalOperator logicalOp = new LogicalOperator();

            if (op == "And")
            {
                logicalOp.AddAnd(new Altova.Types.SchemaString("And"));
            }
            else
            {
                logicalOp.AddOr(new Altova.Types.SchemaString("Or"));
            }

            LogicalType newLogicalExpression = new LogicalType();

            newLogicalExpression.AddLHSLogicalExpression(lhs);
            newLogicalExpression.AddLogicalOperator(logicalOp);
            newLogicalExpression.AddRHSLogicalExpression(rhs);

            LogicalExpression newLogical = new LogicalExpression();

            newLogical.AddLogical(newLogicalExpression);

            return(newLogical);
        }
Example #14
0
 private void AddBetweenFilterCondition <T, TMember>(Expression <Func <T, TMember> > selector,
                                                     TMember start,
                                                     TMember end,
                                                     string @alias = null,
                                                     LogicalOperator logicalOperator = LogicalOperator.NotSet)
 {
     this.currentFilterGroup.Conditions.Add(new FilterCondition
     {
         Alias           = @alias,
         EntityType      = typeof(T),
         Operator        = ">=",
         Left            = this.GetMemberName(selector),
         LocigalOperator = logicalOperator,
         Right           = this.FormatValue(start)
     });
     this.currentFilterGroup.Conditions.Add(new FilterCondition
     {
         Alias           = @alias,
         EntityType      = typeof(T),
         Operator        = "<=",
         Left            = this.GetMemberName(selector),
         LocigalOperator = LogicalOperator.And,
         Right           = this.FormatValue(end)
     });
 }
Example #15
0
 public ExpressionBlock(LogicalOperator _operator, List <ExpressionBase <T> > _expressions = null, List <ExpressionBlock <T> > _blocks = null)
 {
     id          = Guid.NewGuid().ToString();
     @operator   = _operator;
     blocks      = _blocks ?? new List <ExpressionBlock <T> >();
     expressions = _expressions ?? new List <ExpressionBase <T> >();
 }
Example #16
0
        private IWhereClauseBuilder AddConditionToCurrentGroup <TEntity>(
            Expression <Func <TEntity, bool> > expression,
            LogicalOperator locigalOperator,
            string alias       = null,
            string tableName   = null,
            string tableSchema = null)
        {
            ThrowIfNotInitialised();
            IsClean = false;

            var operatorString = GetOperator(expression);
            var @value         = FormatValue(GetExpressionValue(expression));
            var actualOperator = GetActualOperator(operatorString, @value);

            currentGroup.Conditions.Add(new WhereClauseCondition
            {
                Alias           = alias,
                LocigalOperator = locigalOperator,
                LeftTable       =
                    string.IsNullOrWhiteSpace(tableName)
                        ? TableNameFromType <TEntity>()
                        : tableName,
                LeftSchema =
                    string.IsNullOrWhiteSpace(tableSchema)
                        ? ClauseBuilder.DefaultSchema
                        : tableSchema,
                Left     = GetMemberName(expression),
                Operator = actualOperator,
                Right    = @value
            });
            return(this);
        }
        protected override void AddBetweenConditionToCurrentGroup <TEntity, TMember>(
            Expression <Func <TEntity, TMember> > selector,
            TMember start,
            TMember end,
            LogicalOperator locigalOperator,
            string alias,
            string tableName,
            string tableSchema)
        {
            var conditions1           = currentGroup.Conditions;
            var whereClauseCondition1 = new WhereClauseCondition();

            whereClauseCondition1.Alias           = alias;
            whereClauseCondition1.LocigalOperator = locigalOperator;
            whereClauseCondition1.LeftTable       = string.IsNullOrWhiteSpace(tableName) ? TableNameFromType <TEntity>() : tableName;
            whereClauseCondition1.LeftSchema      = string.IsNullOrWhiteSpace(tableSchema) ? "dbo" : tableSchema;
            whereClauseCondition1.Left            = GetMemberColumnName(ConvertExpression(selector));
            whereClauseCondition1.Operator        = ">=";
            whereClauseCondition1.Right           = FormatValue(start);
            conditions1.Add(whereClauseCondition1);
            var conditions2           = currentGroup.Conditions;
            var whereClauseCondition2 = new WhereClauseCondition();

            whereClauseCondition2.Alias           = alias;
            whereClauseCondition2.LocigalOperator = LogicalOperator.And;
            whereClauseCondition2.LeftTable       = string.IsNullOrWhiteSpace(tableName) ? TableNameFromType <TEntity>() : tableName;
            whereClauseCondition2.LeftSchema      = string.IsNullOrWhiteSpace(tableSchema) ? "dbo" : tableSchema;
            whereClauseCondition2.Left            = GetMemberColumnName(ConvertExpression(selector));
            whereClauseCondition2.Operator        = "<=";
            whereClauseCondition2.Right           = FormatValue(end);
            conditions2.Add(whereClauseCondition2);
            IsClean = false;
        }
        protected override void AddInConditionToCurrentGroup <TEntity, TMember>(
            Expression <Func <TEntity, TMember> > selector,
            TMember[] values,
            LogicalOperator locigalOperator,
            string alias,
            string tableName,
            string tableSchema)
        {
            if (values == null || !values.Any())
            {
                return;
            }
            var conditions           = currentGroup.Conditions;
            var whereClauseCondition = new WhereClauseCondition();

            whereClauseCondition.Alias           = alias;
            whereClauseCondition.LocigalOperator = locigalOperator;
            whereClauseCondition.LeftTable       = string.IsNullOrWhiteSpace(tableName) ? TableNameFromType <TEntity>() : tableName;
            whereClauseCondition.LeftSchema      = string.IsNullOrWhiteSpace(tableSchema) ? "dbo" : tableSchema;
            whereClauseCondition.Left            = GetMemberColumnName(ConvertExpression(selector));
            whereClauseCondition.Operator        = "IN";
            whereClauseCondition.Right           = "(" + string.Join(", ", values.Select(v => FormatValue(v))) + ")";
            conditions.Add(whereClauseCondition);
            IsClean = false;
        }
        private LogicalExpression(LogicalOperator op, BooleanExpression oper1, BooleanExpression oper2)
        {
            boolean_expression_type = OperatorType.Logical;
            switch (op)
            {
            case LogicalOperator.True:
                boolean_operation_arity = OperatorArity.Zero;
                break;

            case LogicalOperator.False:
                boolean_operation_arity = OperatorArity.Zero;
                break;

            case LogicalOperator.And:
                boolean_operation_arity = OperatorArity.Two;
                break;

            case LogicalOperator.Or:
                boolean_operation_arity = OperatorArity.Two;
                break;

            case LogicalOperator.Not:
                boolean_operation_arity = OperatorArity.One;
                break;
            }

            logical_operator = op;
            operand1         = oper1;
            operand2         = oper2;
            boolean_operand1 = oper1;
            boolean_operand2 = oper2;
        }
        public override string ToString()
        {
            var    str1 = LogicalOperator == LogicalOperator.NotSet ? "ON" : LogicalOperator.ToString().ToUpperInvariant();
            string str2;

            if (!string.IsNullOrWhiteSpace(LeftTableAlias))
            {
                str2 = "[" + LeftTableAlias + "].[" + LeftIdentifier + "]";
            }
            else
            {
                str2 = "[" + LeftTableSchema + "].[" + LeftTableName + "].[" + LeftIdentifier + "]";
            }
            var    str3 = str2;
            string str4;

            if (!string.IsNullOrWhiteSpace(RightTableAlias))
            {
                str4 = "[" + RightTableAlias + "].[" + RightIdentifier + "]";
            }
            else
            {
                str4 = "[" + RightTableSchema + "].[" + RightTableName + "].[" + RightIdentifier + "]";
            }
            var str5 = str4;

            return(string.Format("{0} {1} {2} {3}", (object)str1, (object)str3, (object)Operator, (object)str5));
        }
Example #21
0
        private Func <JObject, bool> BuildCompositeFilterDefinition(LogicalOperator logicalOperator, List <Func <JObject, bool> > filters)

        {
            return(logicalOperator switch
            {
                LogicalOperator.And => document =>
                {
                    var result = true;
                    foreach (var filter in filters)
                    {
                        result = result && filter(document);
                    }
                    return result;
                }

                ,
                LogicalOperator.Or => document =>
                {
                    var result = false;
                    foreach (var filter in filters)
                    {
                        result = result || filter(document);
                    }
                    return result;
                }

                ,
                LogicalOperator.Not => document => !filters.FirstOrDefault()(document),
                _ => throw new NotImplementedException(nameof(logicalOperator)),
            });
        /// <summary>
        /// Gets a <c>QueryExpression</c> instance for retrieving a <c>uom</c>.
        /// </summary>
        /// <param name="operand">The <c>LogicalOperand</c> to use for this query.</param>
        /// <param name="entityName">The logical name for the entity to be queried for.</param>
        /// <param name="propertyValues">The array of <c>KeyValuePair</c>s that contains the properties and their values to be queried for.</param>
        /// <returns>An instance of a <c>QueryExpression</c> that can used as a parameter to a <c>RetrieveMultipleRequest</c>.</returns>
        /// <exception cref="ArgumentException">Thrown if the unitName or scheduleId parameters are null or empty.</exception>
        /// <remarks>This method sets the Distinct property of the returned <c>QueryExpression</c> to <c>true</c>.</remarks>
        public static QueryExpression GetMultipartQueryExpression(LogicalOperator operand, string entityName, KeyValuePair <string, string>[] propertyValues)
        {
            if (propertyValues == null)
            {
                throw new AdapterException(string.Format(CultureInfo.CurrentCulture, Resources.ArgumentNullExceptionMessage), new ArgumentNullException("propertyValues"))
                      {
                          ExceptionId = AdapterException.SystemExceptionGuid
                      };
            }

            QueryExpression queryHelper = new QueryExpression(entityName)
            {
                Distinct = false
            };

            queryHelper.Criteria = new FilterExpression()
            {
                FilterOperator = operand
            };
            queryHelper.ColumnSet.AllColumns = true;
            foreach (KeyValuePair <string, string> propertyValue in propertyValues)
            {
                ValidatePropertyQueryParameters(entityName, propertyValue.Key);
                queryHelper.Criteria.Conditions.Add(new ConditionExpression(propertyValue.Key, ConditionOperator.Equal, propertyValue.Value));
            }

            return(queryHelper);
        }
Example #23
0
 private void AddInFilterCondition <T, TMember>(Expression <Func <T, TMember> > selector,
                                                TMember[] values,
                                                string alias = null,
                                                LogicalOperator locigalOperator = LogicalOperator.NotSet)
 {
     if (values != null && values.Any())
     {
         this.currentFilterGroup.Conditions.Add(new FilterCondition
         {
             Alias           = alias,
             EntityType      = typeof(T),
             LocigalOperator =
                 locigalOperator,
             Left = this.GetMemberName(this
                                       .ConvertExpression(
                                           selector)),
             Operator = "IN",
             Right    = "(" + string.Join(", ",
                                          values.Select(
                                              v => this
                                              .FormatValue(
                                                  v)))
                        + ")"
         });
     }
 }
Example #24
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="name"></param>
 /// <param name="value"></param>
 /// <param name="oper"></param>
 /// <param name="link"></param>
 public Condition(string name, string value, ConditionalOperator oper, LogicalOperator link)
 {
     Name  = name;
     Value = value;
     Oper  = oper;
     Link  = link;
 }
Example #25
0
        public SearchQueryGrouping(LogicalOperator logicalOperator, ICollection <ISearchQueryElement <T> > searchQueryElements)
        {
            Assert.ArgumentNotNull(searchQueryElements, "searchQueryElements");

            LogicalOperator     = logicalOperator;
            SearchQueryElements = searchQueryElements;
        }
        private void AssertJoinConditionIsValid <TLeft, TRight>(int index,
                                                                string expectedLeftIdentifier,
                                                                string expectedOperator,
                                                                string expectedRightIdentifier,
                                                                string expectedRightTableAlias          = null,
                                                                string expectedLeftTableAlias           = null,
                                                                LogicalOperator expectedLogicalOperator = LogicalOperator.NotSet)
        {
            this.Statement.Specification.Joins.Should()
            .NotBeNullOrEmpty();
            var condition = this.Statement.Specification.Joins[index];

            condition.LeftEntityType.Should()
            .Be(typeof(TLeft));
            condition.LeftIdentifier.Should()
            .Be(expectedLeftIdentifier);
            condition.LeftTableAlias.Should()
            .Be(expectedLeftTableAlias);
            condition.LogicalOperator.Should()
            .Be(expectedLogicalOperator);
            condition.Operator.Should()
            .Be(expectedOperator);
            condition.RightIdentifier.Should()
            .Be(expectedRightIdentifier);
            condition.RightTableAlias.Should()
            .Be(expectedRightTableAlias);
            condition.RightEntityType.Should()
            .Be(typeof(TRight));
        }
 protected abstract void AddInConditionToCurrentGroup <TEntity, TMember>(
     Expression <Func <TEntity, TMember> > selector,
     TMember[] values,
     LogicalOperator locigalOperator,
     string alias,
     string tableName,
     string tableSchema);
        public Filter AddFilters(LogicalOperator logicalOperator, params Filter[] filters)
        {
            InnerFilter.FilterOperator = logicalOperator;
            InnerFilter.Filters.AddRange(filters.Select(f => f.InnerFilter));

            return(this);
        }
 private bool CompareFilter(QueryLogicalFilter filter, LogicalOperator logicalOperator, string field, ComparisonOperator comparisonOperator, string value)
 {
     return(filter.Operator == logicalOperator &&
            filter.Filter.Field == field &&
            filter.Filter.Operator == comparisonOperator &&
            Enumerable.SequenceEqual(filter.Filter.Values, (value != null ? value.Split(',') : new string[] { })));
 }
 // Constructors
 public QueryStrings(int fieldId, ComparisonOperator comparisonOp, string matchingValue, LogicalOperator logicalOp)
 {
     FieldId = fieldId;
     ComparisonOp = comparisonOp;
     MatchingValue = matchingValue;
     LogicalOp = logicalOp;
 }
 public FilterCondition(string fieldName, object value, FilterOperator @operator, LogicalOperator whereoperator)
 {
     FieldName = fieldName;
     Value = value;
     Operator = @operator;
     WhereOperator = whereoperator;
 }
Example #32
0
        public void PushNAry(LogicalOperator logicalOperator)
        {
            BinaryOperator binaryOperator;

            if (logicalOperator == LogicalOperator.And)
            {
                binaryOperator = BinaryOperator.LogicalAnd;
            }
            else
            {
                binaryOperator = BinaryOperator.LogicalOr;
            }

            List <ExpressionNode> arguments = new List <ExpressionNode>();

            while (_expressionStack.Count > 0)
            {
                arguments.Add(_expressionStack.Pop());
            }

            foreach (ExpressionNode argument in arguments)
            {
                Push(argument);
                if (Count > 1)
                {
                    PushBinary(binaryOperator);
                }
            }
        }
Example #33
0
 private void AddInConditionToCurrentGroup <TEntity, TMember>(
     Expression <Func <TEntity, TMember> > selector,
     TMember[] values,
     LogicalOperator locigalOperator,
     string alias,
     string tableName,
     string tableSchema)
 {
     if (values != null && values.Any())
     {
         currentGroup.Conditions.Add(new WhereClauseCondition
         {
             Alias           = alias,
             LocigalOperator = locigalOperator,
             LeftTable       =
                 string.IsNullOrWhiteSpace(tableName)
                     ? TableNameFromType <TEntity>()
                     : tableName,
             LeftSchema =
                 string.IsNullOrWhiteSpace(tableSchema)
                     ? ClauseBuilder.DefaultSchema
                     : tableSchema,
             Left =
                 GetMemberName(ConvertExpression(selector)),
             Operator = "IN",
             Right    =
                 "("
                 + string.Join(", ",
                               values.Select(v => FormatValue(v))) + ")"
         });
         IsClean = false;
     }
 }
Example #34
0
        public IConditionGroup BeginGroup(LogicalOperator concatOperator = LogicalOperator.And)
        {
            var group = new ConditionGroup(concatOperator);

            Add(group);
            return(group);
        }
Example #35
0
    //Match the rule condition against state, and return bindings
    public static bool MatchCondition(List <Atom> ruleConditions, State state, LogicalOperator op)
    {
        if (op == LogicalOperator.AND)
        {
            foreach (Atom condition in ruleConditions)
            {
                if (!condition.isVerified(state))
                {
                    return(false);
                }
            }
        }

        else
        {
            foreach (Atom condition in ruleConditions)
            {
                if (condition.isVerified(state))
                {
                    return(true);
                }
            }
        }

        return(true);
    }
Example #36
0
		/// <summary>
		/// Costruttore con tutti i parametri necessari per inzializzare la struttura prima di conoscere il valore dei parametri di filtro
		/// </summary>
		/// <param name="nometabella">Nome della tabella</param>
		/// <param name="nomeCampo">Nome del campo del dataset oggetto di filtro</param>
		/// <param name="operatore">Nome dell'operatore da applicare (es. "Like", "=", ">", ">=")</param>
		/// <param name="valore">Valore di confronto</param>
		public SQuery(string nomeTabella, string nomeCampo, string operatore, string valore)
		{
			_table  = nomeTabella;
			_nomeCampo = nomeCampo;
			_operatore = operatore;
			_valore = valore;
			_externalOperatorBefore = LogicalOperator.And;
		}
		/// <summary>
		/// Constructs the filter
		/// </summary>
		/// <param name="logicalOperator">
		/// Logical operator used in the filter
		/// </param>
		/// <param name="innerFilters">
		/// Collection of conditions or filters that will be merged 
		/// with the and operator
		/// </param>
		public LogicalOperatorFilter(List<Filters.FilterBase> innerFilters, LogicalOperator logicalOperator)
		{
			if (innerFilters != null)
			{
				InnerFilters = innerFilters;
			}

			LogicalOperator = logicalOperator;
		}
Example #38
0
		/// <summary>
		/// Costruttore con tutti i parametri necessari per inzializzare la struttura prima di conoscere il valore dei parametri di filtro
		/// </summary>
		/// <param name="nomeCampo">Nome del campo del dataset oggetto di filtro</param>
		/// <param name="operatore">Nome dell'operatore da applicare (es. "Like", "=", ">", ">=")</param>
		/// <param name="type">Tipo di dato (es. "Numeric", "String", "Date")</param>
		public SQuery(string nomeCampo, string operatore, DataType type)
		{
			_table  = string.Empty;
			_nomeCampo = nomeCampo;
			_operatore = operatore;
			_valore = string.Empty;
			_type = type;
			_externalOperatorBefore = LogicalOperator.And;
		}
        public LogicalBindaryExpression(Expression left, Expression right, LogicalOperator @operator)
        {
            Require.NotNull(left, "left");
            Require.NotNull(right, "right");

            Left = left;
            Right = right;
            Operator = @operator;
        }
Example #40
0
		/// <summary>
		/// Costruttore con tutti i parametri necessari per inzializzare la struttura prima di conoscere il valore dei parametri di filtro
		/// </summary>
		/// <param name="nometabella">Nome della tabella</param>
		/// <param name="nomeCampo">Nome del campo del dataset oggetto di filtro</param>
		/// <param name="operatore">Nome dell'operatore da applicare (es. "Like", "=", ">", ">=")</param>
		/// <param name="valore">Valore di confronto</param>
        public SQuery(string nomeTabella, string nomeCampo, string operatore, string valore, DataType type, object valoreObject)
		{
			_table  = nomeTabella;
			_nomeCampo = nomeCampo;
			_operatore = operatore;
			_valore = valore;
			_type = type;
            _valoreObject = valoreObject;
            _externalOperatorBefore = LogicalOperator.And;
		}
Example #41
0
        public FilterItem(string key, string value, SizeOperator op, string expression, SizeKeyType filterSizeKeyType, LogicalOperator logicalOperator)
        {
            _operator = op;
            _key = key;
            _value = value;

            _expression = expression;
            _logicalOperator = logicalOperator;
            _filterSizeKeyType = filterSizeKeyType;
        }
Example #42
0
        public FilterExpression ConditionHelper(LogicalOperator op, Dictionary<string, object> keyValues)
        {
            FilterExpression filter = new FilterExpression();
            filter.FilterOperator = op;

            foreach (KeyValuePair<string, object> item in keyValues)
            {
                filter.Conditions.Add(new ConditionExpression(item.Key, ConditionOperator.Equal, item.Value));
            }
            return filter;
        }
Example #43
0
		public SQueryCollection(LogicalOperator operatore) : base()
		{
			switch((int)operatore)
			{
				case 1:
					_operatore = "AND";
					break;
				case 2:
					_operatore = "OR";
					break;
			}
		}
        public static string CombineQuery(IEnumerable<SearchCriteria> searches, LogicalOperator logical, IEnumerable<SortDescription> sorting, int? pageCount)
        {
            var queries = new List<string>();
            if (pageCount.HasValue)
                queries.Add(GetPagingQueryString(pageCount.Value));
            if (searches != null && searches.Count() > 0)
                queries.Add(searches.ConstructFilterQueryString(logical));
            if (sorting != null && sorting.Count() > 0)
                queries.Add(sorting.ConstructOrderByQueryString());

            return CombineQuery(queries);
        }
Example #45
0
        /// <summary>
        /// Instantiates a new atom group.
        /// </summary>
        /// <param name="logicalOperator">The operator that characterizes the relationship between the atoms and atoms group.</param>
        /// <param name="members">An array containing atoms and atom groups.</param>
        /// <param name="runningMembers">An array containing atoms and atom groups that will actually be run (they can be different
        /// from the members because of atom equivalence).</param>
        internal AtomGroup(LogicalOperator logicalOperator, object[] members, object[] runningMembers)
        {
            this.logicalOperator = logicalOperator;
            this.members = members;

            HashCodeBuilder hcb = new HashCodeBuilder();
            hcb.Append(logicalOperator);
            SortedList<int, object> sortedMembers = new SortedList<int, object>(Comparer<int>.Default);

            // check the members, compute hashcode and build sorted members list
            for(int i=0; i < members.Length; i++) {
                object member =members[i];

                if (member == null) {
                    throw new BREException("An atom group can not contain a null member");
                }
                else if (member is AtomGroup) {
                    if (((AtomGroup)member).logicalOperator == logicalOperator)
                        throw new BREException("An atom group can not contain another group with the same logical operator");
                }
                else if (member is Atom) {
                    if (((Atom)member).HasFormula)
                        throw new BREException("An atom group can not contain an atom that contains a formula");
                }
                else {
                    throw new BREException("An atom group can not hold objects of type: " + member.GetType());
                }

                hcb.Append(member);

                if (runningMembers == null) sortedMembers.Add(GetMemberSortedIndex(members, i), member);
            }

            hashCode = hcb.Value;

            // the members actually used when processing the atom group are not the ones defined in the rule file (usually because of equivalent atoms definitions)
            if (runningMembers != null) {
                for(int i=0; i < runningMembers.Length; i++) sortedMembers.Add(GetMemberSortedIndex(runningMembers, i), runningMembers[i]);
            }

            orderedMembers = sortedMembers.Values;

            allAtoms = new List<Atom>();
            foreach(object member in orderedMembers) {
                if (member is Atom) allAtoms.Add((Atom)member);
                else if (member is AtomGroup) allAtoms.AddRange(((AtomGroup)member).AllAtoms);
            }
        }
Example #46
0
        public CriteriaItem(LogicalOperator logicalOperator, string parameter, Clause clause, object value)
            : base(logicalOperator)
        {
            Clause newClause = clause;

            if (value == null)
            {
                if (clause == Clause.Eq)
                {
                    newClause = Clause.IsNull;
                }
            }
            this.clause = newClause;
            this.parameter = parameter;
            this.value = value;
        }
 public void Logical(LogicalOperator op)
 {
   if (_ops.Count < 1 || (int)op != _ops.Peek())
   {
     if (op == LogicalOperator.Not)
     {
       _ops.Push(_ops.Peek() | (int)op);
       _writer.Write(" NOT (");
     }
     else
     {
       _ops.Push((int)op);
       _writer.Write(" (");
     }
   }
 }
Example #48
0
		public static ExpressionNode CombineConditions(LogicalOperator logicalOperator, IList<ExpressionNode> conditions)
		{
			if (conditions == null || conditions.Count == 0)
				return null;

			ExpressionBuilder expressionBuilder = new ExpressionBuilder();
			foreach (ExpressionNode condition in conditions)
			{
				if (condition != null)
					expressionBuilder.Push(condition);
			}

			if (expressionBuilder.Count == 0)
				return null;

			expressionBuilder.PushNAry(logicalOperator);
			return expressionBuilder.Pop();
		}
Example #49
0
        public void PushNAry(LogicalOperator logicalOperator)
        {
            BinaryOperator binaryOperator;
            if (logicalOperator == LogicalOperator.And)
                binaryOperator = BinaryOperator.LogicalAnd;
            else
                binaryOperator = BinaryOperator.LogicalOr;
            
            List<ExpressionNode> arguments = new List<ExpressionNode>();
            while (_expressionStack.Count > 0)
                arguments.Add(_expressionStack.Pop());

            foreach (ExpressionNode argument in arguments)
            {
                Push(argument);
                if (Count > 1)
                    PushBinary(binaryOperator);
            }
        }
 public FilterExpression AddFilter(LogicalOperator logicalOperator)
 {
     FilterExpression filterExpression = new FilterExpression()
     {
         FilterOperator = logicalOperator
     };
     this.Filters.Add(filterExpression);
     return filterExpression;
 }
Example #51
0
 public Criteria(LogicalOperator logicalOperator, string parameter, Clause clause, object value)
     : this(parameter, clause, value)
 {
     LogicalOperator = logicalOperator;
 }
 public FilterExpression(LogicalOperator filterOperator)
     : this()
 {
     this.FilterOperator = filterOperator;
 }
 internal LogicalExpression(LogicalOperator loperator, string expression)
 {
     this.loperator = loperator;
     this.expression = expression.Trim();
 }
 public static Group createGroup(Attribute attr, LogicalOperator logicalOperator)
 {
     return createGroup(new object[] { attr }, logicalOperator);
 }
 public static Group createGroup(Association asso, LogicalOperator logicalOperator)
 {
     return createGroup(new object[] { asso }, logicalOperator);
 }
        private void VisitBinaryLogicalOperator(BinaryExpression b, LogicalOperator logicalOperator)
        {
            //if it's empty just use it
            if (_filterExpression.Filters.Count == 0)
                _filterExpression.FilterOperator = logicalOperator;

            var epression = _filterExpression;
            //we are now in a "and" as part of an "or" chain
            if (_filterExpression.FilterOperator != logicalOperator)
                _filterExpression = new FilterExpression(logicalOperator);

            base.Visit(b.Left);
            base.Visit(b.Right);

            //restore the changed item
            _filterExpression = epression;
        }
		/// <summary>
		/// Constructs the filter
		/// <para xml:lang="es">
		/// Construye el filtro
		/// </para>
		/// </summary>
		/// <param name="logicalOperator">
		/// Logical operator used in the filter
		/// <para xml:lang="es">
		/// Operador logico utilizado en el filtro
		/// </para>
		/// </param>
		/// <param name="innerFilters">
		/// Collection of conditions or filters that will be merged 
		/// with the and operator
		/// <para xml:lang="es">
		/// Coleccion de condiciones o filtros que se fucionan
		/// con el operador and.
		/// </para>
		/// </param>
		public LogicalOperatorFilter(List<Filter> innerFilters, LogicalOperator logicalOperator)
		{
			InnerFilters = innerFilters;
			LogicalOperator = logicalOperator;
		}
Example #58
0
 protected BaseCriteria(LogicalOperator logicalOperator)
 {
     LogicalOperator = logicalOperator;
 }
 public Form1()
 {
     InitializeComponent();
     processing = new LogicalOperator();
 }
Example #60
0
 /// <summary>
 /// Instantiates a new atom group.
 /// </summary>
 /// <param name="logicalOperator">The operator that characterizes the relationship between the atoms and atoms group.</param>
 /// <param name="members">An array containing atoms and atom groups.</param>
 public AtomGroup(LogicalOperator logicalOperator, params object[] members)
     : this(logicalOperator, members, null)
 {
 }