Ejemplo n.º 1
0
 /// <summary>
 /// returns the selectionrule by handle
 /// </summary>
 /// <param name="handle"></param>
 /// <returns></returns>
 public iObjectDefinition GetDataObjectDefinition(String id)
 {
     Initialize();
     foreach (iDataObjectRepository aRepository in _dataobjectRepositories)
     {
         iObjectDefinition aDefinition = aRepository.GetIObjectDefinition(CanonicalName.ClassName(id));
         if (aDefinition != null)
         {
             return(aDefinition);
         }
     }
     throw new RulezException(RulezException.Types.IdNotFound, arguments: new object[] { id, "DataObjectEntrySymbol Repositories" });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// check if the ID exists - returns true or false and if !HasValue then not checkable
        /// </summary>
        /// <returns></returns>
        public bool? CheckValidity()
        {
            if (_isChecked.HasValue) return _isChecked;
            if (this.Engine == null) return _isChecked.HasValue;

            /// get the data object definition
            if (ID.Contains('.'))
            {
                string[] names = ID.Split('.');
                if (Engine.Repository.HasDataObjectDefinition(names[0]))
                {
                    _objectdefinition = Engine.Repository.GetDataObjectDefinition(names[0]);
                    if (_objectdefinition == null)
                    {
                        throw new RulezException(RulezException.Types.IdNotFound, arguments: new object[]
                        {
                            names[1],
                            names[0]
                        });
                    }

                }
                else
                { throw new RulezException(RulezException.Types.IdNotFound, arguments: new object[] { names[0], "data object repository" }); }

            }
            else
            {
                if (Engine.Repository.HasDataObjectDefinition(ID))
                    _objectdefinition = Engine.Repository.GetDataObjectDefinition(ID);
                else
                    throw new RulezException(RulezException.Types.IdNotFound, arguments: new object[] { ID, "data object repository" });
            }
            _isChecked = true;
            return _isChecked;
        }
Ejemplo n.º 3
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);
        }