Ejemplo n.º 1
0
        public questStatus GetViewInfo(DatabaseId databaseId, TablesetView tablesetView, out View view)
        {
            // Initialize
            questStatus status = null;

            view = null;


            // Get view
            DbViewsMgr dbViewsMgr = new DbViewsMgr(this._userSession);

            status = dbViewsMgr.Read(databaseId, tablesetView.Schema, tablesetView.Name, out view);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            tablesetView.View = view;


            // Get view columns
            ViewId        viewId       = new ViewId(view.Id);
            List <Column> columnList   = null;
            DbColumnsMgr  dbColumnsMgr = new DbColumnsMgr(this._userSession);

            status = dbColumnsMgr.Read(viewId, out columnList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            view.ColumnList = columnList;

            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 2
0
        public questStatus GetTableInfo(DatabaseId databaseId, TablesetTable tablesetTable, out Table table)
        {
            // Initialize
            questStatus status = null;

            table = null;


            // Get table
            DbTablesMgr dbTablesMgr = new DbTablesMgr(this._userSession);

            status = dbTablesMgr.Read(databaseId, tablesetTable.Schema, tablesetTable.Name, out table);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            tablesetTable.Table = table;


            // Get table columns
            TableId       tableId      = new TableId(table.Id);
            List <Column> columnList   = null;
            DbColumnsMgr  dbColumnsMgr = new DbColumnsMgr(this._userSession);

            status = dbColumnsMgr.Read(tableId, out columnList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            table.ColumnList = columnList;

            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 3
0
        /* Used or useful? */
        public questStatus GetColumnInfo(TablesetColumn tablesetColumn, out Column column)
        {
            // Initialize
            questStatus status = null;

            column = null;


            DbTablesetTablesMgr dbTablesetTablesMgr = new DbTablesetTablesMgr(this._userSession);
            DbTablesetViewsMgr  dbTablesetViewsMgr  = new DbTablesetViewsMgr(this._userSession);
            TablesetId          tablesetId          = null;
            TablesetTable       tablesetTable       = null;
            TablesetView        tablesetView        = null;

            if (tablesetColumn.EntityTypeId == EntityType.Table)
            {
                // Get TablesetTable
                TablesetTableId tablesetTableId = new TablesetTableId(tablesetColumn.TableSetEntityId);
                status = dbTablesetTablesMgr.Read(tablesetTableId, out tablesetTable);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                tablesetId = new TablesetId(tablesetTable.TablesetId);
            }
            else if (tablesetColumn.EntityTypeId == EntityType.View)
            {
                // Get TablesetView
                TablesetViewId tablesetViewId = new TablesetViewId(tablesetColumn.TableSetEntityId);
                status = dbTablesetViewsMgr.Read(tablesetViewId, out tablesetView);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                tablesetId = new TablesetId(tablesetView.TablesetId);
            }
            else
            {
                return(new questStatus(Severity.Error, String.Format("ERROR: unsupported EntityTypeId {0} for TablesetColumn {1}",
                                                                     tablesetColumn.EntityTypeId, tablesetColumn.Id)));
            }

            // Get the Tableset
            DbTablesetsMgr dbTablesetsMgr = new DbTablesetsMgr(this._userSession);
            Tableset       tableset       = null;

            status = dbTablesetsMgr.Read(tablesetId, out tableset);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Get the database
            DatabaseId databaseId = new DatabaseId(tableset.DatabaseId);

            Quest.Functional.MasterPricing.Database database = null;
            DbDatabasesMgr dbDatabasesMgr = new DbDatabasesMgr(this._userSession);

            status = dbDatabasesMgr.Read(databaseId, out database);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }


            // Get the Table or View by identifier within this database
            DbTablesMgr  dbTablesMgr  = new DbTablesMgr(this._userSession);
            DbViewsMgr   dbViewsMgr   = new DbViewsMgr(this._userSession);
            EntityTypeId entityTypeId = null;
            EntityId     entityId     = null;

            if (tablesetColumn.EntityTypeId == EntityType.Table)
            {
                TableId tableId = new TableId();
                Table   table   = null;
                status = dbTablesMgr.Read(databaseId, tablesetTable.Schema, tablesetTable.Name, out table);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                entityTypeId = new EntityTypeId(EntityType.Table);
                entityId     = new EntityId(table.Id);
            }
            else if (tablesetColumn.EntityTypeId == EntityType.View)
            {
            }

            // Get column info
            DbColumnsMgr dbColumnsMgr = new DbColumnsMgr(this._userSession);

            status = dbColumnsMgr.Read(entityTypeId, entityId, tablesetColumn.Name, out column);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 4
0
        public questStatus GetTablesetView(DatabaseId databaseId, FilterViewTablesetViewId filterViewTablesetViewId, out TablesetView tablesetView)
        {
            // Initialize
            questStatus status = null;

            tablesetView = null;


            // Get tableset view
            DbTablesetViewsMgr dbTablesetViewsMgr = new DbTablesetViewsMgr(this._userSession);

            status = dbTablesetViewsMgr.Read(filterViewTablesetViewId, out tablesetView);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Get tableset columns
            EntityType entityType = new EntityType();

            entityType.Id = EntityType.View;
            TableSetEntityId      tableSetEntityId     = new TableSetEntityId(tablesetView.Id);
            DbTablesetColumnsMgr  dbTablesetColumnsMgr = new DbTablesetColumnsMgr(this._userSession);
            List <TablesetColumn> tablesetColumnList   = null;

            TablesetColumnId tablesetColumnId = new TablesetColumnId();

            status = dbTablesetColumnsMgr.Read(entityType, tableSetEntityId, out tablesetColumnList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            tablesetView.TablesetColumnList = tablesetColumnList;


            // Get view
            View view = null;

            status = GetViewInfo(databaseId, tablesetView, out view);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            tablesetView.View = view;


            // Get column info
            DbColumnsMgr dbColumnsMgr = new DbColumnsMgr(this._userSession);
            EntityTypeId entityTypeId = new EntityTypeId(EntityType.View);
            EntityId     entityId     = new EntityId(view.Id);

            foreach (TablesetColumn tablesetColumn in tablesetColumnList)
            {
                Column column = null;
                status = dbColumnsMgr.Read(entityTypeId, entityId, tablesetColumn.Name, out column);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                tablesetColumn.Column = column;
            }
            return(new questStatus(Severity.Success));
        }
Ejemplo n.º 5
0
        public questStatus ReadTablesetConfiguration(TablesetId tablesetId, out TablesetConfiguration tablesetConfiguration)
        {
            // Initialize
            questStatus status = null;

            tablesetConfiguration = null;


            // Read tableset
            Tableset       tableset       = null;
            DbTablesetsMgr dbTablesetsMgr = new DbTablesetsMgr(this._userSession);

            status = dbTablesetsMgr.Read(tablesetId, out tableset);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }


            // Read database
            DatabaseId databaseId = new DatabaseId(tableset.DatabaseId);

            Quest.Functional.MasterPricing.Database database = null;
            DbDatabasesMgr dbDatabasesMgr = new DbDatabasesMgr(this._userSession);

            status = dbDatabasesMgr.Read(databaseId, out database);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }



            /*
             * Load tableset entities.
             */
            DbTablesetColumnsMgr dbTablesetColumnsMgr = new DbTablesetColumnsMgr(this._userSession);


            // Read tables in tableset
            List <Quest.Functional.MasterPricing.TablesetTable> tablesetTableList = null;
            DbTablesetTablesMgr dbTablesetTablesMgr = new DbTablesetTablesMgr(this._userSession);

            status = dbTablesetTablesMgr.Read(tablesetId, out tablesetTableList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Read table info.
            EntityType entityType = new EntityType();

            entityType.Id = EntityType.Table;
            DbTablesMgr  dbTablesMgr  = new DbTablesMgr(this._userSession);
            DbColumnsMgr dbColumnsMgr = new DbColumnsMgr(this._userSession);

            foreach (TablesetTable tablesetTable in tablesetTableList)
            {
                TablesetId tableSetId = new TablesetId(tablesetTable.Id);
                List <Quest.Functional.MasterPricing.TablesetColumn> tablesetColumnList = null;

                TableSetEntityId tableSetEntityId = new TableSetEntityId(tablesetTable.Id);
                status = dbTablesetColumnsMgr.Read(entityType, tableSetEntityId, out tablesetColumnList);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                tablesetTable.TablesetColumnList = tablesetColumnList;

                Table table = null;
                status = dbTablesMgr.Read(databaseId, tablesetTable.Schema, tablesetTable.Name, out table);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                tablesetTable.Table = table;


                // Get column metadata
                EntityTypeId entityTypeId = new EntityTypeId(EntityType.Table);
                EntityId     entityId     = new EntityId(table.Id);
                foreach (TablesetColumn tablesetColumn in tablesetColumnList)
                {
                    Column column = null;
                    status = dbColumnsMgr.Read(entityTypeId, entityId, tablesetColumn.Name, out column);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                    tablesetColumn.Column = column;
                }
            }

            // Read views in tableset
            List <Quest.Functional.MasterPricing.TablesetView> tablesetViewList = null;
            DbTablesetViewsMgr dbTablesetViewsMgr = new DbTablesetViewsMgr(this._userSession);

            status = dbTablesetViewsMgr.Read(tablesetId, out tablesetViewList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            // Read views columns in tableset
            entityType.Id = EntityType.View;
            DbViewsMgr dbViewsMgr = new DbViewsMgr(this._userSession);

            foreach (TablesetView tablesetView in tablesetViewList)
            {
                TablesetViewId tablesetViewId = new TablesetViewId(tablesetView.Id);
                List <Quest.Functional.MasterPricing.TablesetColumn> tablesetColumnList = null;

                TableSetEntityId tableSetEntityId = new TableSetEntityId(tablesetView.Id);
                status = dbTablesetColumnsMgr.Read(entityType, tableSetEntityId, out tablesetColumnList);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                tablesetView.TablesetColumnList = tablesetColumnList;

                View view = null;
                status = dbViewsMgr.Read(databaseId, tablesetView.Schema, tablesetView.Name, out view);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                tablesetView.View = view;


                // Get column metadata
                EntityTypeId entityTypeId = new EntityTypeId(EntityType.View);
                EntityId     entityId     = new EntityId(view.Id);
                foreach (TablesetColumn tablesetColumn in tablesetColumnList)
                {
                    Column column = null;
                    status = dbColumnsMgr.Read(entityTypeId, entityId, tablesetColumn.Name, out column);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                    tablesetColumn.Column = column;
                }
            }

            // Build tableset configuration
            tablesetConfiguration                = new TablesetConfiguration();
            tablesetConfiguration.Tableset       = tableset;
            tablesetConfiguration.Database       = database;
            tablesetConfiguration.TablesetTables = tablesetTableList;
            tablesetConfiguration.TablesetViews  = tablesetViewList;


            return(new questStatus(Severity.Success));
        }