/// <summary> /// Get the internal database result type id /// </summary> /// <param name="mc"></param> /// <param name="sharedTypeId"></param> /// <param name="internalDbTypeId"></param> /// <returns></returns> static int GetInternalResultTypeId(MetaColumn mc) { Dictionary <int, QueryEngineLibrary.AssayResultType> dict; bool parseOk; int iTypeId = NullValue.NullNumber, typeId = NullValue.NullNumber; MetaBrokerType mbt = mc.MetaTable.MetaBrokerType; if (mbt == MetaBrokerType.Assay) { parseOk = int.TryParse(mc.ResultCode, out typeId); if (parseOk) { iTypeId = typeId; } } else { LogMessage("Unexpected MetaBrokerType: " + mbt + " for " + mc.MetaTable.Name + "." + mc.Name); } return(iTypeId); }
/// <summary> /// Get the shared result type id associated with the supplied metacolumn (e.g. AssayMetadata result type id) /// </summary> /// <param name="mc"></param> /// <returns></returns> static int GetAssayResultTypeId(MetaColumn mc) { string[] sa; int typeId = -1; bool parseOk = false; MetaBrokerType mbt = mc.MetaTable.MetaBrokerType; if (mbt == MetaBrokerType.Assay) { typeId = AssayMetaFactory.GetAssayMetadataResultTypeId(mc); } else { LogMessage("Unexpected MetaBrokerType: " + mbt + " for " + mc.MetaTable.Name + "." + mc.Name); } return(typeId); }
/// <summary> /// Return true if global broker type exists /// </summary> /// <param name="mbType"></param> /// <returns></returns> /// public static bool GlobalBrokerExists( MetaBrokerType mbType) { if (GlobalBrokers == null) { return(false); } if (mbType <= MetaBrokerType.Unknown || mbType > MetaBrokerType.MaxBrokerType) { return(false); } if (GlobalBrokers[(int)mbType] == null) { return(false); } return(true); }
/// <summary> /// Get metabroker object for metatable & initialize /// </summary> /// <param name="mt"></param> /// <returns></returns> public static IMetaBroker GetGlobalBroker(MetaBrokerType mbType) { if (mbType == MetaBrokerType.Unknown) { return(null); } if (GlobalBrokers == null) { return(null); } int gbi = (int)mbType; if (gbi < 0 || gbi > GlobalBrokers.Length) { return(null); } IMetaBroker mb = GlobalBrokers[gbi]; return(mb); }
/// <summary> /// Gets a dictionary by MetaBrokerType of the assay metatables in a query that can be retrieved in an unpivoted form /// </summary> /// <param name="q"></param> Dictionary <MetaBrokerType, List <MetaTable> > GetUnpivotedAssayMetaTables (Query q) { QueryTable qt; MetaTable mt; int qti; Dictionary <MetaBrokerType, List <MetaTable> > dict = new Dictionary <MetaBrokerType, List <MetaTable> >(); for (qti = 0; qti < q.Tables.Count; qti++) { qt = Query.Tables[qti]; mt = qt.MetaTable; MetaBrokerType mbt = mt.MetaBrokerType; IMetaBroker mb = MetaBrokerUtil.GetGlobalBroker(mbt); if (mb == null) { continue; } if (!mb.CanBuildUnpivotedAssayResultsSql) { continue; } if (!dict.ContainsKey(mbt)) { dict[mbt] = new List <MetaTable>(); } dict[mbt].Add(mt); } return(dict); }
/// <summary> /// Format a hyperlink for a metacolumn where details are available /// </summary> /// <param name="qc"></param> /// <param name="mdt"></param> /// <returns></returns> public static string FormatDetailsAvailableHyperlink( QueryColumn qc, MobiusDataType mdt) { string hyperlink, uri = ""; int drilldownLevel = 1; if (qc == null || qc.MetaColumn == null || qc.MetaColumn.MetaTable == null) { return(""); } MetaColumn mc = qc.MetaColumn; MetaTable mt = mc.MetaTable; MetaColumnType mcType = mc.DataType; MetaBrokerType mbt = qc.MetaColumn.MetaTable.MetaBrokerType; // Annotation table broker if (mbt == MetaBrokerType.Annotation) { return(mdt.Hyperlink); // just return already formatted hyperlink value } // Target-Assay broker else if (mbt == MetaBrokerType.TargetAssay) { if (Lex.Eq(qc.MetaColumn.Name, "assy_nm")) { if (mdt.DbLink != "") { string[] sa = mdt.DbLink.Split(','); string mtName = sa[0].Trim() + "_" + sa[1].Trim(); uri = "http://Mobius/command?" + "ClickFunction ShowTableDescription " + mtName; } } else if (qc.MetaColumn.DetailsAvailable) { if (Lex.Eq(qc.MetaColumn.MetaTable.Name, MultiDbAssayDataNames.CombinedNonSumTableName)) { drilldownLevel = 2; // level 2 goes from unsummarized unpivoted to warehouse details } else { drilldownLevel = 1; // level 1 goes from summarized to unsummarized (UNPIVOTED_ASSAY_RESULTS) } uri = "http://Mobius/command?" + "ClickFunction DisplayDrilldownDetail " + qc.MetaColumn.MetaTable.Name + " " + qc.MetaColumn.Name + " " + drilldownLevel + " " + Lex.AddSingleQuotes(mdt.DbLink); } } // Pivot broker else if (mbt == MetaBrokerType.Pivot) { string[] sa = mdt.DbLink.Split(','); if (sa.Length < 2 || sa[1] == "") { return(""); } uri = sa[1]; if (uri.ToLower().StartsWith("www.")) { uri = "http://" + uri; // fix shortcut for proper linking } } // All other broker types else { int nValue = -1; if (mdt is QualifiedNumber) { nValue = ((QualifiedNumber)mdt).NValue; } if ((qc.QueryTable.MetaTable.UseSummarizedData && nValue >= 0) || // link if there is a non-null n-value associated with number qc.MetaColumn.DetailsAvailable) // or we explicitly know that details are available { uri = "http://Mobius/command?" + "ClickFunction DisplayDrilldownDetail " + qc.QueryTable.MetaTable.Name + " " + qc.MetaColumn.Name + (qc.QueryTable.MetaTable.UseSummarizedData ? " 1 " : " 2 ") + Lex.AddSingleQuotes(mdt.DbLink); } } return(uri); }
/// <summary> /// Create broker of specified type /// </summary> /// <param name="mt"></param> /// <returns></returns> public static GenericMetaBroker Create( MetaBrokerType type) { GenericMetaBroker mb = null; if (type == MetaBrokerType.Generic) { return(new GenericMetaBroker()); } if (type == MetaBrokerType.Pivot) { PivotMetaBroker pivotMb = new PivotMetaBroker(); mb = (PivotMetaBroker)pivotMb; return(mb); } if (type == MetaBrokerType.Annotation) { AnnotationMetaBroker aMb = new AnnotationMetaBroker(); mb = (GenericMetaBroker)aMb; return(mb); } if (type == MetaBrokerType.CalcField) { CalcFieldMetaBroker cfMb = new CalcFieldMetaBroker(); mb = (GenericMetaBroker)cfMb; return(mb); } if (type == MetaBrokerType.CalcTable) { CalcTableMetaBroker ctMb = new CalcTableMetaBroker(); mb = (GenericMetaBroker)ctMb; return(mb); } if (type == MetaBrokerType.MultiTable) { MultiTableMetaBroker mtMb = new MultiTableMetaBroker(); mb = (GenericMetaBroker)mtMb; return(mb); } if (type == MetaBrokerType.TargetAssay) { QueryEngineLibrary.MultiDbAssayMetaBroker taMb = new MultiDbAssayMetaBroker(); mb = (GenericMetaBroker)taMb; return(mb); } if (type == MetaBrokerType.Assay) { AssayMetaBroker assayMb = new AssayMetaBroker(); mb = (GenericMetaBroker)assayMb; return(mb); } if (type == MetaBrokerType.UnpivotedAssay) { UnpivotedAssayMetaBroker urMb = new UnpivotedAssayMetaBroker(); mb = (GenericMetaBroker)urMb; return(mb); } if (type == MetaBrokerType.SpotfireLink) { SpotfireLinkMetaBroker slMb = new SpotfireLinkMetaBroker(); mb = (GenericMetaBroker)slMb; return(mb); } if (type == MetaBrokerType.NoSql) { NoSqlMetaBroker nsMb = new NoSqlMetaBroker(); mb = (GenericMetaBroker)nsMb; return(mb); } if (type == MetaBrokerType.RgroupDecomp) { RgroupMetaBroker rgMb = new RgroupMetaBroker(); mb = (GenericMetaBroker)rgMb; return(mb); } throw new QueryException("Unknown metabroker type " + type.ToString()); }
/// <summary> /// Return true if this metabroker operates against a non-sql SQL source /// </summary> public static bool IsNonSqlMetaBroker(MetaBrokerType mbt) { bool isNonSql = (mbt == MetaBrokerType.NoSql); return(isNonSql); }
/// <summary> /// Return true if this metabroker operates against a SQL source /// </summary> public static bool IsSqlMetaBroker(MetaBrokerType mbt) { bool isSql = !IsNonSqlMetaBroker(mbt); return(isSql); }