Esempio n. 1
0
        /// <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);
            }
        }
Esempio n. 2
0
/// <summary>
///  Setup/configure any needed secondary metabroker
/// </summary>
/// <param name="eqp"></param>
/// <param name="mpd"></param>
/// <param name="unpivotedTableIsFirst"></param>

        void SetupSecondaryMetaBroker(
            ExecuteQueryParms eqp,
            MultiTablePivotBrokerTypeData mpd,
            out bool unpivotedTableIsFirst)
        {
            QueryEngine qe2;
            Query       q2;
            QueryTable  qt2;
            QueryColumn qc2;
            MetaTable   mt2;

            string    firstMtName = mpd.FirstTableName;
            MetaTable firstMt     = MetaTableCollection.GetWithException(firstMtName);

            unpivotedTableIsFirst = UnpivotedAssayResult.IsUnpivotedSummarizedMdbAssayTable(firstMtName);

            if (unpivotedTableIsFirst) // just use unpivoted table as is
            {
                SecondaryMetaBroker = this;
                Eqp2 = eqp;
            }

            else // all pivoted tables, create secondary query on the summarized unpivoted table
            {
                if (SecondaryMetaBroker == null)
                {
                    MultiDbAssayMetaBroker mb2 = SecondaryMetaBroker = new MultiDbAssayMetaBroker();

                    if (UnpivotedAssayResult.IsCombinedMdbAssayTable(firstMtName))
                    {
                        mt2 = MetaTableCollection.GetWithException(MultiDbAssayDataNames.CombinedTableName);
                    }
                    else
                    {
                        mt2 = MetaTableCollection.GetWithException(MultiDbAssayDataNames.BaseTableName);
                    }

                    q2  = new Query();
                    qt2 = new QueryTable(mt2);

                    qc2 = qt2.GetQueryColumnByNameWithException(MultiDbAssayDataNames.GeneSymbol);
                    if (mpd.TableCodeCsvList.Length != 0) // limit by codes
                    {
                        qc2.Criteria = qc2.CriteriaDisplay = MultiDbAssayDataNames.GeneSymbol + " in (" + mpd.TableCodeCsvList + ")";
                    }

                    q2.AddQueryTable(qt2);

                    qe2       = new QueryEngine();
                    qe2.Query = q2;
                    Eqp2      = new ExecuteQueryParms(qe2, qt2);
                    mb2.PrepareQuery(Eqp2);

                    mb2.Sql += " where " + qc2.Criteria;
                }

                Eqp2.SearchKeySubset = eqp.SearchKeySubset;
            }

            return;
        }