示例#1
0
        public questStatus ClearTablesetEntities(DbMgrTransaction trans, TablesetId tablesetId)
        {
            // Initialize
            questStatus status = null;


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

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

            DbTablesetColumnsMgr dbTablesetColumnsMgr = new DbTablesetColumnsMgr(this.UserSession);


            // Read all tableset tables
            List <TablesetTable> tablesetTableList   = null;
            DbTablesetTablesMgr  dbTablesetTablesMgr = new DbTablesetTablesMgr(this.UserSession);

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

            // Delete all tablesetColumns to these tables. Then delete all tables in the tableset.
            EntityType entityType = new EntityType();

            entityType.Id = EntityType.Table;
            foreach (TablesetTable tablesetTable in tablesetTableList)
            {
                TableSetEntityId tableSetEntityId = new TableSetEntityId(tablesetTable.Id);
                status = dbTablesetColumnsMgr.Delete(trans, entityType, tableSetEntityId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            dbTablesetTablesMgr.Delete(trans, tablesetId);


            // Read all tableset views
            List <TablesetView> tablesetViewList   = null;
            DbTablesetViewsMgr  dbTablesetViewsMgr = new DbTablesetViewsMgr(this.UserSession);

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

            // Delete all tablesetColumns to these views. Then delete all views in the tableset.
            entityType.Id = EntityType.View;
            foreach (TablesetView tablesetView in tablesetViewList)
            {
                TableSetEntityId tableSetEntityId = new TableSetEntityId(tablesetView.Id);
                status = dbTablesetColumnsMgr.Delete(trans, entityType, tableSetEntityId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            dbTablesetViewsMgr.Delete(trans, tablesetId);


            return(new questStatus(Severity.Success));
        }
示例#2
0
        public questStatus GetTablesetTable(DatabaseId databaseId, FilterTableTablesetTableId filterTableTablesetTableId, out TablesetTable tablesetTable)
        {
            // Initialize
            questStatus status = null;

            tablesetTable = null;


            // Get tableset table
            DbTablesetTablesMgr dbTablesetTablesMgr = new DbTablesetTablesMgr(this._userSession);

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

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

            entityType.Id = EntityType.Table;
            TableSetEntityId      tableSetEntityId     = new TableSetEntityId(tablesetTable.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);
            }
            tablesetTable.TablesetColumnList = tablesetColumnList;


            // Get table
            Table table = null;

            status = GetTableInfo(databaseId, tablesetTable, out table);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            tablesetTable.Table = table;


            // Get column info
            DbColumnsMgr dbColumnsMgr = new DbColumnsMgr(this._userSession);
            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;
            }
            return(new questStatus(Severity.Success));
        }
示例#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));
        }
示例#4
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));
        }