protected static bool IsResultTable(Type table) { return(ReportColumn.GetTableType(table) == TableType.result); }
/// <summary> /// Used when loading a saved Report, this method figures out what to display in the UI. /// The saved Report just has the information necessary to execute the query, which /// is the set of columns to query, and paired with the tables to query. /// This then needs to be transformed back into which columns in the big tree view were /// selected, and whether the "Pivot Results" checkbox was checked. /// </summary> public void GetColumnInfos(Report report, TreeView treeView, out List <NodeData> columnInfos) { // CONSIDER: Why have the base class? if (!(report is SimpleReport)) { throw new InvalidOperationException(Resources.ColumnSet_GetColumnInfos_Unexpected_report_type); } SimpleReport simpleReport = (SimpleReport)report; columnInfos = new List <NodeData>(); var allColumns = new List <ReportColumn>(simpleReport.Columns); var pivotReport = simpleReport as PivotReport; if (pivotReport != null) { allColumns.AddRange(pivotReport.CrossTabValues); } if (allColumns.Count == 0) { return; } var allTables = new HashSet <Type>(from reportColumn in allColumns select reportColumn.Table); Table table = MostManyTable; Identifier prefix = null; while (table != null) { if (allTables.Contains(table.PersistentClass) || allTables.Contains(table.ResultsClass) || allTables.Contains(table.ResultsSummaryClass)) { break; } if (table.Parent == null) { string tableNames = string.Join(", ", (from reportTable in allTables // Not L10N select reportTable.ToString()).ToArray()); throw new InvalidDataException(string.Format(Resources.ColumnSet_GetColumnInfos_Unable_to_find_table_for__0_, tableNames)); } table = table.Parent.ParentTable; prefix = new Identifier(prefix, table.Name); } foreach (var unqualifiedId in allColumns) { Identifier identifier; TableType type = ReportColumn.GetTableType(unqualifiedId.Table); switch (type) { case TableType.result: identifier = JoinIds(prefix, unqualifiedId.Column, ToResultsIdentifier); break; case TableType.summary: identifier = JoinIds(prefix, unqualifiedId.Column, ToResultsSummaryIdentifier); break; default: identifier = JoinIds(prefix, unqualifiedId.Column); break; } columnInfos.Add(FindNodeData(treeView, type, identifier)); } }