/// <summary> /// Build summarization detail query /// </summary> /// <param name="mt"></param> /// <param name="mc"></param> /// <param name="level"></param> /// <param name="linkInfo"></param> /// <returns></returns> public override Query GetDrilldownDetailQuery( MetaTable mt, MetaColumn mc, int level, string linkInfo) { QueryTable qt, qt2; MetaTable mt2; QueryColumn qc, qc2; MetaColumn mc2; string resultIdColName = ""; Query q = new Query(); // Summarized MdbAssay table drilling down to unsummarized MdbAssay table if (UnpivotedAssayResult.IsSummarizedMdbAssayTable(mt.Name)) { if (UnpivotedAssayResult.IsCombinedMdbAssayTable(mt.Name)) // multiple tables { mt2 = MetaTableCollection.GetWithException(MultiDbAssayDataNames.CombinedNonSumTableName); resultIdColName = MultiDbAssayDataNames.SumResultId; } else // base unpivoted or pivoted by target { mt2 = MetaTableCollection.GetWithException(MultiDbAssayDataNames.BaseNonSumTableName); resultIdColName = MultiDbAssayDataNames.BaseSumResultId; } qt = new QueryTable(q, mt2); qc = qt.GetQueryColumnByNameWithException(resultIdColName); qc.Criteria = resultIdColName + " = " + linkInfo; return(q); } // Drilling down from old all_bioassay_unpivoted to specific source data else if (Lex.Eq(mt.Name, UnpivotedAssayView.UnsummarizedMetaTableName)) { // ResultId is formatted by the source with the first item being the source name Match m = Regex.Match(linkInfo, @"(.*),(.*),(.*)", RegexOptions.IgnoreCase | RegexOptions.RightToLeft); string mtName = m.Groups[1].Value; string mcId = m.Groups[2].Value; string linkInfo2 = m.Groups[3].Value; mt2 = MetaTableCollection.GetWithException(mtName); IMetaBroker imb = MetaBrokerUtil.GlobalBrokers[(int)mt2.MetaBrokerType]; q = imb.GetDrilldownDetailQuery(mt2, mcId, level, linkInfo2); return(q); } else { throw new ArgumentException("Invalid tableName: " + mt.Name); } }
public static string Databases = "All"; // list of databases to search /// <summary> /// Return true if table name is a summarized multidatabase assay table /// </summary> /// <param name="mtName"></param> /// <returns></returns> public bool IsSummarizedMdbAssayTable(string mtName) { return(UnpivotedAssayResult.IsSummarizedMdbAssayTable(mtName)); }
/// <summary> /// Prepare query /// </summary> /// <param name="parms"></param> public override string PrepareQuery( ExecuteQueryParms eqp) { List <MultiDbAssayMetaBroker> mbList; MultiTablePivotBrokerTypeData mpd; // multipivot data for this broker type Dictionary <string, MultiTablePivotBrokerTypeData> mbsi; QueryColumn qc; MetaTable mt; Eqp = eqp; Qt = eqp.QueryTable; mt = eqp.QueryTable.MetaTable; BuildActivityBinCondFormat(); MdbAssayVoMap = UnpivotedAssayResultFieldPositionMap.NewMdbAssayMap(Qt); MdbAssayVoMap.InitializeForQueryTable(Qt); LoadTargetMap(); if ( // check for basic conditions that disallow multipivoting !eqp.ReturnQNsInFullDetail || // no multipivot if part of calc field eqp.Qe == null || // need to be able to access queryengine info //!QueryEngine.AllowMultiTablePivot || // is multipivot even allowed !UnpivotedAssayResult.IsSummarizedMdbAssayTable(mt.Name)) // summarized tables only { return(base.PrepareQuery(eqp)); } int pivotedColCount = 0; foreach (QueryColumn qc1 in Qt.QueryColumns) { // if any non-key criteria then pivot individually rather than via multipivot if (qc1.Criteria != "" && !qc1.IsKey) { if (UnpivotedAssayResult.IsUnpivotedSummarizedMdbAssayTable(mt.Name) && Qt.Query.SingleStepExecution) { } // special case: allow criteria on unpivoted summary table which also apply to associated pivoted tables else { return(base.PrepareQuery(eqp)); } } if (IsPivotedColumn(qc1.MetaColumn)) { pivotedColCount++; } } if (pivotedColCount == 0) { return(base.PrepareQuery(eqp)); // must have at least one column to pivot } // Store pivot info for queryTable PivotInCode = true; Sql = BuildSql(eqp); if (eqp.Qe.MetaBrokerStateInfo == null) { eqp.Qe.MetaBrokerStateInfo = new Dictionary <string, MultiTablePivotBrokerTypeData>(); } mbsi = eqp.Qe.MetaBrokerStateInfo; MpGroupKey = MetaBrokerType.TargetAssay.ToString(); // key for broker for query if (!QueryEngine.AllowMultiTablePivot) { MpGroupKey += "_" + Qt.MetaTable.Name; } mpd = MultiTablePivotBrokerTypeData.GetMultiPivotData(eqp.Qe.MetaBrokerStateInfo, MpGroupKey, mt.Name); string geneSymbol = mt.Code; if (!Lex.IsNullOrEmpty(geneSymbol) && !mpd.TableCodeDict.ContainsKey(geneSymbol)) { mpd.TableCodeDict[geneSymbol] = new MpdResultTypeData(); // add key to hash list if (mpd.TableCodeCsvList.Length > 0) { mpd.TableCodeCsvList.Append(","); } mpd.TableCodeCsvList.Append(Lex.AddSingleQuotes(geneSymbol)); } mpd.AddMetaBroker(mt.Name, this); return(Sql); }