Esempio n. 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;
        }
Esempio n. 2
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;
        }