Exemple #1
0
        /// <summary>
        /// build a XPTree Node for a data object entry name
        /// </summary>
        /// <param name="ctx"></param>
        /// <returns></returns>
        public bool BuildXPTNode(DataObjectEntryNameContext ctx)
        {
            string aClassName = String.Empty;

            /// build the entry name
            if (ctx.dataObjectClass() == null)
            {
                aClassName = GetDefaultClassName(ctx);
            }
            else
            {
                aClassName = ctx.dataObjectClass().ClassName;
            }
            // full entry name
            ctx.entryname = aClassName + "." + ctx.identifier().GetText();
            ctx.ClassName = aClassName;
            // get the symbol from the engine
            DataObjectEntrySymbol aSymbol = new DataObjectEntrySymbol(ctx.entryname, engine: this.Engine);

            ctx.XPTreeNode = aSymbol;
            if (aSymbol != null)
            {
                return(true);
            }
            return(false);
        }
Exemple #2
0
        /// <summary>
        /// increase the key position depending on the logical Operator
        /// </summary>
        /// <param name="ctx"></param>
        /// <returns></returns>
        public uint incIncreaseKeyNo(SelectConditionsContext ctx)
        {
            // increase only if the last operator was an AND/ANDALSO
            if (ctx.logicalOperator_2() != null)
            {
                // if there is an AND or ANDALSO
                if (ctx.logicalOperator_2().Last().Operator.Token.ToUint == Token.AND || ctx.logicalOperator_2().Last().Operator.Token.ToUint == Token.ANDALSO)
                {
                    // check if the last named entry is a key -> reposition for unamed defaults
                    // (100,200,uid=150,250) -> keypos 1,2,1,2
                    if (ctx.selectCondition() != null)
                    {
                        if (ctx.selectCondition().Last().dataObjectEntry != null)
                        {
                            DataObjectEntrySymbol aSymbol = (DataObjectEntrySymbol)ctx.selectCondition().Last().dataObjectEntry.XPTreeNode;
                            if (aSymbol.CheckValidity().HasValue&& aSymbol.IsValid.Value == true)
                            {
                                if (aSymbol.ObjectDefinition.Keys.Contains(aSymbol.Entryname))
                                {
                                    int pos = Array.FindIndex(aSymbol.ObjectDefinition.Keys, x => String.Compare(x, aSymbol.Entryname.ToUpper(), true) == 0);
                                    if (pos >= 0)
                                    {
                                        ctx.keypos = (uint)pos + 1;          // keypos is starting from 1 ... -> will be increased to next key lower down
                                    }
                                }
                            }
                        }
                    }

                    // simply increase and return
                    return(ctx.keypos++);
                }
            }


            return(ctx.keypos);
        }
Exemple #3
0
        /// <summary>
        /// visit the variable
        /// </summary>
        /// <param name="literal"></param>
        public void Visit(DataObjectEntrySymbol symbol)
        {
            VisitorEventArgs <T> args = new VisitorEventArgs <T>(currentNode: symbol, stack: _stack);

            VisitingDataObjectSymbol(this, args);
        }
Exemple #4
0
        /// <summary>
        /// build a XPT Node out of a selection condition
        /// </summary>
        /// <param name="ctx"></param>
        /// <returns></returns>
        public bool BuildXPTNode(SelectConditionContext ctx)
        {
            string entryName;

            //|   RPAREN selectConditions [$ClassName, $keypos] LPAREN
            if (ctx.selectConditions() != null)
            {
                if (ctx.NOT() == null)
                {
                    ctx.XPTreeNode = ctx.selectConditions().XPTreeNode;
                }
                else
                {
                    ctx.XPTreeNode = LogicalExpression.NOT((IExpression)ctx.selectConditions().XPTreeNode);
                }
                // set the max priority for disabling reshuffle
                ((OperationExpression)ctx.XPTreeNode).Priority = uint.MaxValue;
                return(true);
            }
            else
            {
                // determine the key name with the key is not provided by the key position
                //
                if (ctx.dataObjectEntry == null)
                {
                    string aClassName = GetDefaultClassName(ctx);
                    if (this.Engine.Repository.HasDataObjectDefinition(aClassName))
                    {
                        iObjectDefinition aObjectDefinition = this.Engine.GetDataObjectDefinition(aClassName);
                        if (ctx.keypos <= aObjectDefinition.Keys.Count())
                        {
                            entryName = aClassName + "." + aObjectDefinition.Keys[ctx.keypos - 1];
                        }
                        else
                        {
                            this.NotifyErrorListeners(String.Format(Messages.RCM_8, aClassName, aObjectDefinition.Keys.Count(), ctx.keypos));
                            return(false);
                        }
                    }
                    else
                    {
                        this.NotifyErrorListeners(String.Format(Messages.RCM_9, aClassName));
                        return(false);
                    }
                }
                else
                {
                    entryName = ctx.dataObjectEntry.entryname;
                }

                // get the symbol
                DataObjectEntrySymbol aSymbol = new DataObjectEntrySymbol(entryName, engine: this.Engine);

                // Operator
                Operator anOperator;
                // default operator is the EQ operator
                if (ctx.Operator == null)
                {
                    anOperator = Engine.GetOperator(new Token(Token.EQ));
                }
                else
                {
                    anOperator = ctx.Operator.Operator;
                }

                // build the comparer expression
                CompareExpression aCompare = null;
                if (aSymbol != null && ctx.select.XPTreeNode != null)
                {
                    aCompare = new CompareExpression(anOperator, aSymbol, (IExpression)ctx.select.XPTreeNode);
                }
                else
                {
                    return(false);
                }
                // set it
                ctx.XPTreeNode = aCompare;
                return(true);
            }
            return(false);
        }