Esempio n. 1
0
 public virtual void addColumn(ResultColumn column)
 {
     if (column != null && !columns.Contains(column))
     {
         this.columns.Add(column);
     }
 }
Esempio n. 2
0
        public static ResultColumn createUpdateResultColumn(ResultSet resultSet, TObjectName resultColumn)
        {
            if (ModelBindingManager.getUpdateModel(resultColumn) is ResultColumn)
            {
                return((ResultColumn)ModelBindingManager.getUpdateModel(resultColumn));
            }
            ResultColumn column = new ResultColumn(resultSet, resultColumn);

            ModelBindingManager.bindUpdateModel(resultColumn, column);
            return(column);
        }
Esempio n. 3
0
        public static ResultColumn createSelectSetResultColumn(ResultSet resultSet, ResultColumn resultColumn)
        {
            if (ModelBindingManager.getModel(resultColumn) is ResultColumn)
            {
                return((ResultColumn)ModelBindingManager.getModel(resultColumn));
            }
            ResultColumn column = new SelectSetResultColumn(resultSet, resultColumn);

            ModelBindingManager.bindModel(resultColumn, column);
            return(column);
        }
Esempio n. 4
0
        public static ResultColumn createStarResultColumn(SelectResultSet resultSet, Tuple <TResultColumn, TObjectName> starColumnPair)
        {
            if (ModelBindingManager.getModel(starColumnPair) is ResultColumn)
            {
                return((ResultColumn)ModelBindingManager.getModel(starColumnPair));
            }
            ResultColumn column = new ResultColumn(resultSet, starColumnPair);

            ModelBindingManager.bindModel(starColumnPair, column);
            return(column);
        }
Esempio n. 5
0
        public static ResultColumn createResultColumn(QueryTable queryTableModel, TResultColumn resultColumn)
        {
            if (ModelBindingManager.getModel(resultColumn) is ResultColumn)
            {
                return((ResultColumn)ModelBindingManager.getModel(resultColumn));
            }
            ResultColumn column = new ResultColumn(queryTableModel, resultColumn);

            ModelBindingManager.bindModel(resultColumn, column);
            return(column);
        }
        public static TObjectName[] getTableColumns(TTable table)
        {
            Table createTable = ModelBindingManager.getCreateTable(table);

            if (createTable != null)
            {
                IList <TableColumn> columnList = createTable.Columns;
                TObjectName[]       columns    = new TObjectName[columnList.Count];
                for (int i = 0; i < columns.Length; i++)
                {
                    columns[i] = columnList[i].ColumnObject;
                }
                Array.Sort(columns, new ComparatorAnonymousInnerClass());
                return(columns);
            }
            else
            {
                TObjectNameList    list    = table.ObjectNameReferences;
                List <TObjectName> columns = new List <TObjectName>();

                if (list.size() == 0 && table.Subquery != null)
                {
                    ResultSet resultSet = (ResultSet)ModelBindingManager.getModel(table.Subquery);
                    if (resultSet != null)
                    {
                        IList <ResultColumn> columnList = resultSet.Columns;
                        for (int i = 0; i < columnList.Count; i++)
                        {
                            ResultColumn resultColumn = columnList[i];
                            if (resultColumn.ColumnObject is TResultColumn)
                            {
                                TResultColumn columnObject = ((TResultColumn)resultColumn.ColumnObject);
                                TAliasClause  alias        = columnObject.AliasClause;
                                if (alias != null && alias.AliasName != null)
                                {
                                    columns.Add(alias.AliasName);
                                }
                                else
                                {
                                    if (columnObject.FieldAttr != null)
                                    {
                                        columns.Add(columnObject.FieldAttr);
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                            }
                            else if (resultColumn.ColumnObject is TObjectName)
                            {
                                columns.Add((TObjectName)resultColumn.ColumnObject);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < list.size(); i++)
                    {
                        columns.Add(list.getObjectName(i));
                    }
                }

                TObjectName[] columnArray = columns.ToArray();
                Array.Sort(columnArray, new ComparatorAnonymousInnerClass());
                return(columnArray);
            }
        }
        public SelectSetResultColumn(ResultSet resultSet, ResultColumn resultColumn)
        {
            if (resultColumn == null || resultSet == null)
            {
                throw new System.ArgumentException("ResultColumn arguments can't be null.");
            }

            id = ++TableColumn.TABLE_COLUMN_ID;

            this.resultSet = resultSet;
            resultSet.addColumn(this);

            if (resultColumn.ColumnObject is TResultColumn)
            {
                TResultColumn resultColumnObject = (TResultColumn)resultColumn.ColumnObject;
                if (resultColumnObject.AliasClause != null)
                {
                    this.alias = resultColumnObject.AliasClause.ToString();
                    TSourceToken aliasStartToken = resultColumnObject.AliasClause.startToken;
                    TSourceToken aliasEndToken   = resultColumnObject.AliasClause.endToken;
                    this.aliasStartPosition = new Tuple <long, long>(aliasStartToken.lineNo, aliasStartToken.columnNo);
                    this.aliasEndPosition   = new Tuple <long, long>(aliasEndToken.lineNo, aliasEndToken.columnNo + aliasEndToken.astext.Length);

                    this.name = this.alias;
                }
                else
                {
                    if (resultColumnObject.Expr.ExpressionType == EExpressionType.simple_constant_t)
                    {
                        if (resultSet is SelectResultSet)
                        {
                            this.name = "DUMMY" + getIndexOf(((SelectResultSet)resultSet).ResultColumnObject, resultColumnObject);
                        }
                        else if (resultSet is SelectSetResultSet)
                        {
                            this.name = "DUMMY" + getIndexOf(((SelectSetResultSet)resultSet).ResultColumnObject, resultColumnObject);
                        }
                        else
                        {
                            this.name = resultColumnObject.ToString();
                        }
                    }
                    else if (resultColumnObject.Expr.ExpressionType == EExpressionType.function_t)
                    {
                        this.name = resultColumnObject.Expr.FunctionCall.FunctionName.ToString();
                    }
                    else if (resultColumnObject.ColumnNameOnly != null && !"".Equals(resultColumnObject.ColumnNameOnly))
                    {
                        this.name = resultColumnObject.ColumnNameOnly;
                    }
                    else
                    {
                        this.name = resultColumnObject.ToString();
                    }
                }

                if (resultColumnObject.Expr.ExpressionType == EExpressionType.function_t)
                {
                    this.fullName = resultColumnObject.Expr.FunctionCall.FunctionName.ToString();
                }
                else
                {
                    this.fullName = resultColumnObject.ToString();
                }

                TSourceToken startToken = resultColumnObject.startToken;
                TSourceToken endToken   = resultColumnObject.endToken;
                this.startPosition = new Tuple <long, long>(startToken.lineNo, startToken.columnNo);
                this.endPosition   = new Tuple <long, long>(endToken.lineNo, endToken.columnNo + endToken.astext.Length);
                this.columnObject  = resultColumnObject;
            }
            else if (resultColumn.ColumnObject is TObjectName)
            {
                TObjectName resultColumnObject = (TObjectName)resultColumn.ColumnObject;

                if (resultColumnObject.ColumnNameOnly != null && !"".Equals(resultColumnObject.ColumnNameOnly))
                {
                    this.name = resultColumnObject.ColumnNameOnly;
                }
                else
                {
                    this.name = resultColumnObject.ToString();
                }

                this.fullName = this.name;

                TSourceToken startToken = resultColumnObject.startToken;
                TSourceToken endToken   = resultColumnObject.endToken;
                this.startPosition = new Tuple <long, long>(startToken.lineNo, startToken.columnNo);
                this.endPosition   = new Tuple <long, long>(endToken.lineNo, endToken.columnNo + endToken.astext.Length);
                this.columnObject  = resultColumnObject;
            }
            else
            {
                this.name     = resultColumn.Name;
                this.fullName = this.name;

                TSourceToken startToken = resultColumn.ColumnObject.startToken;
                TSourceToken endToken   = resultColumn.ColumnObject.endToken;
                this.startPosition = new Tuple <long, long>(startToken.lineNo, startToken.columnNo);
                this.endPosition   = new Tuple <long, long>(endToken.lineNo, endToken.columnNo + endToken.astext.Length);
                this.columnObject  = resultColumn.ColumnObject;
            }
        }