/// <summary> /// Build unpivoted subquery QueryManager including the DataTableManger, /// ResultsFormat and ResultsFormatter. /// Build empty DataTable /// </summary> /// <returns></returns> QueryManager InitializeUnpivotedSubqueryQm() { Query q2 = null; DataTableManager dtm2; DataTableMx dt2; ResultsFormat rf2; ResultsFormatFactory rff; ResultsFormatter rfmtr; QueryTable qt; MetaTable mt; QueryManager qm2 = new QueryManager(); // build output query here // Setup unpivoted output query q2 = new Query(qm2); mt = MetaTableCollection.GetWithException(MultiDbAssayDataNames.CombinedNonSumTableName); qt = new QueryTable(q2, mt); // be sure proper cols are selected dtm2 = new DataTableManager(qm2); dt2 = DataTableManager.BuildDataTable(qm2); rff = new ResultsFormatFactory(qm2, OutputDest.WinForms); rff.Build(); rfmtr = new ResultsFormatter(qm2); return(qm2); }
/// <summary> /// Build a basic database query for the user database /// </summary> /// <param name="uo"></param> /// <returns></returns> internal static bool BuildDatabaseQuery( UserObject uo) { List <UserObject> luo = UserDataEditor.GetUcdbUserObjects(uo.Id); if (luo == null || luo.Count == 0) { MessageBoxMx.ShowError("No tables found for database"); return(false); } Query q = new Query(); foreach (UserObject uo2 in luo) { if (!UserObject.IsMetaTableType(uo2.Type)) { continue; } string mtName = uo2.Type.ToString() + "_" + uo2.Id; MetaTable mt = MetaTableCollection.Get(mtName); if (mt == null) { continue; } QueryTable qt = new QueryTable(mt); q.AddQueryTable(qt); } QbUtil.NewQuery(uo.Name); QbUtil.SetCurrentQueryInstance(q); return(true); }
/// <summary> /// Create MetaTable from template /// </summary> public MetaTable GetMetaTable( string mtName) { if (!Lex.StartsWith(mtName, UnpivotedAssayView.UnsummarizedMetaTableName)) { return(null); } MetaTable mt0 = MetaTableCollection.Get(UnpivotedAssayView.UnsummarizedMetaTableName + "_TEMPLATE"); // get template metatable if (mt0 == null) { return(null); } MetaTable mt = mt0.Clone(); string labelSuffix = ""; // default to integrated view of these mt.Label += labelSuffix; List <MetaColumn> mcList = new List <MetaColumn>(); // Build summarized version of table if (Lex.EndsWith(mtName, MetaTable.SummarySuffix)) // summarized version { mt.Name = mtName; mt.Label += " Summary"; mt.UseSummarizedData = true; foreach (MetaColumn mc in mt.MetaColumns) { if (mc.SummarizedExists) { mcList.Add(mc); } } mt.MetaColumns = mcList; return(mt); } // Build unsummarized version of table else { mt.Name = mtName; foreach (MetaColumn mc in mt.MetaColumns) { if (mc.UnsummarizedExists) { mcList.Add(mc); } } mt.MetaColumns = mcList; return(mt); } }
/// <summary> /// General table / gene symbol query builder /// </summary> /// <param name="tableName"></param> /// <param name="geneSymbol"></param> /// <returns></returns> public static Query BuildTargetAssayQuery( string tableName, string geneSymbol) { Query q = new Query(); MetaTable mt = MetaTableCollection.GetWithException(tableName); QueryTable qt = new QueryTable(q, mt); QueryColumn qc = qt.GetQueryColumnByNameWithException(MultiDbAssayDataNames.GeneSymbol); qc.Criteria = MultiDbAssayDataNames.GeneSymbol + " = " + Lex.AddSingleQuotes(geneSymbol); qc.CriteriaDisplay = "= " + geneSymbol; if (qc.IsKey) // if key column store for that as well { q.KeyCriteria = " = " + Lex.AddSingleQuotes(geneSymbol); q.KeyCriteriaDisplay = "= " + geneSymbol; } //qc = qt.GetQueryColumnByNameWithException("top_lvl_rslt"); //qc.Criteria = "top_lvl_rslt = 'Y'"; // only top level results //qc.CriteriaDisplay = "= Y"; return(q); }
/// <summary> /// Let the user select an existing annotation and edit it /// </summary> /// <returns></returns> public static MetaTable OpenExistingAnnotationTable( UserObject uo) { if (uo == null) // prompt if not supplied { uo = UserObjectOpenDialog.ShowDialog(UserObjectType.Annotation, "Open Annotation"); } if (uo == null) { return(null); } if (!Permissions.UserHasWriteAccess(SS.I.UserName, uo)) { MessageBoxMx.ShowError("You are not authorized to edit this annotation table."); return(null); } UserDataEditor editor = new UserDataEditor(); UserObject uo2 = editor.Edit(uo); if (uo2 == null) { return(null); } string tName = "ANNOTATION_" + uo.Id.ToString(); MetaTable mt = MetaTableCollection.Get(tName); // return new version of metatable return(mt); }
/// <summary> /// SetupForm /// </summary> void SetupForm() { string DefaultLibraryPath = "/Mobius/Visualizations/"; string DefaultCorpIdParm = "CorpId_LIST"; InSetup = true; SpotfireViewProps svp = SpotfireViewProps; string libPath = svp.AnalysisPath; if (Lex.IsUndefined(libPath)) { libPath = DefaultLibraryPath; } LibraryPath.Text = libPath; MetaTable mt = MetaTableCollection.Get(SpotfireLinkModel); if (mt == null) { throw new Exception(SpotfireLinkModel + " table not found"); } mt = mt.Clone(); CriteriaCols.QueryTable = new QueryTable(mt); SetupParameters(); Description.Text = svp.Description; InSetup = false; return; }
/// <summary> /// Edit the Cids criteris /// </summary> /// <returns></returns> bool EditCids() { Query q; QueryTable qt; MetaTable mt; QueryColumn qc; mt = MetaTableCollection.GetWithException(Tso.GetSummarizedMetaTableName()); q = new Query(); qt = new QueryTable(q, mt); qc = qt.KeyQueryColumn; qc.Criteria = Cids.Text; qc.CriteriaDisplay = Cids.Text; if (!CriteriaEditor.GetCompoundIdCriteria(qc)) { return(false); } if (qc.Criteria.StartsWith(" = ")) // make equality look nice { Cids.Text = qc.CriteriaDisplay; } else { Cids.Text = qc.Criteria; } return(true); }
/// <summary> /// Read the list of ids for a compound library /// </summary> /// <param name="libId"></param> /// <returns></returns> public static CidList ReadLibrary( int libId) { if (ServiceFacade.UseRemoteServices) { Mobius.Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = ServiceFacade.InvokeNativeMethod(nativeClient, (int)Services.Native.ServiceCodes.MobiusCidListService, (int)Services.Native.ServiceOpCodes.MobiusCidListService.ReadLibrary, new Services.Native.NativeMethodTransportObject(new object[] { libId })); ((System.ServiceModel.IClientChannel)nativeClient).Close(); if (resultObject == null || resultObject.Value == null) { return(null); } UserObject uo = UserObject.DeserializeBinary((byte[])resultObject.Value); MetaTable mt = MetaTableCollection.Get(MetaTable.PrimaryRootTable); CidList cidList = CidList.Deserialize(uo, mt); return(cidList); } else { return(UAL.CidListDao.ReadLibrary(libId)); } }
/// <summary> /// Parse external format advanced expression into internal form /// </summary> /// <param name="advExprExt"></param> /// <param name="mcList"></param> /// <returns></returns> string ParseAdvancedExpr( string advExprExt, out List <MetaColumn> mcList) { MetaTable mt; MetaColumn mc; string advExpr = advExprExt; // copy external to internal mcList = new List <MetaColumn>(); Lex lex = new Lex(); lex.OpenString(advExprExt); while (true) { string tok = lex.Get(); if (tok == "") { break; } if (Lex.IsQuoted(tok, '"')) { tok = tok.Substring(1, tok.Length - 2).Trim(); // remove quotes int i1 = tok.IndexOf('.'); if (i1 < 0) { throw new Exception("Invalid table.field name: " + tok); } string table = tok.Substring(0, i1); string column = tok.Substring(i1 + 1); mt = MetaTableCollection.Get(table); if (mt == null) { throw new Exception("Unknown table name: " + table); } mc = mt.GetMetaColumnByLabel(column); if (mc == null) { mc = mt.GetMetaColumnByName(column); } if (mc == null) { throw new Exception("Unknown column name: " + column); } string tok2 = mt.Name + "." + mc.Name; // store as internal name advExpr = advExpr.Replace(tok, tok2); if (!mcList.Contains(mc)) { mcList.Add(mc); } } } return(advExpr); // return internal form }
/// <summary> /// Build the Query, QueryManager and DataTable for the matching structure display /// </summary> public void BuildStructureDisplayQuery() { MetaTable mt = MetaTableCollection.Get("QuickSearchRelatedStructures"); if (mt == null) { DebugLog.Message("QuickSearchRelatedStructures MetaTable not found"); RSC.MoleculeGridPageControl.Visible = false; return; } Query q = ToolHelper.InitEmbeddedDataToolQuery(mt); QueryTable qt = q.Tables[0]; q.UserObject.Name = qt.MetaTable.Label; StructureDisplayQuery = q; QueryColumn qc = qt.FirstStructureQueryColumn; if (qc != null) // setup dummy criteria { ParsedStructureCriteria pssc = new ParsedStructureCriteria(); pssc.SearchType = StructureSearchType.FullStructure; // just full structure search for now pssc.Molecule = new MoleculeMx(MoleculeFormat.Smiles, "C"); // placeholder structure pssc.ConvertToQueryColumnCriteria(qc); qc.DisplayFormatString = "Highlight=true;Align=true"; } string title = "Related Structures"; qt.Label = title; DataTableMx dt = q.ResultsDataTable as DataTableMx; Qm = ToolHelper.SetupQueryManager(q, dt); MoleculeGridPageControl mgpc = RSC.MoleculeGridPageControl; MoleculeGridPanel gp = mgpc.MoleculeGridPanel; mgpc.Width = RSC.Width - 3; // be sure we have page control correctly sized mgpc.Height = RSC.Height - mgpc.Top - 3; ToolHelper.SetupGridPanelForDisplay(Qm, mgpc.MoleculeGridPanel, true, true); MoleculeGridControl grid = mgpc.MoleculeGrid; if (grid != null && grid.GV != null) { grid.GV.IndicatorWidth = 40; // narrow indicator a bit } //ToolHelper.DisplayData // build and display empty grid for query with columns scaled to fit the grid // (q, dt, RSC.MoleculeGridPageControl.MoleculeGridPanel, true, true); return; }
/// <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); } }
/// <summary> /// Create an annotation table given its metatable and user object /// </summary> /// <param name="mt"></param> /// <param name="uo"></param> public static void CreateAnnotationTable( MetaTable mt, UserObject uo) { uo.Type = UserObjectType.Annotation; // be sure type is set uo.Content = mt.Serialize(); // serialize the metatable to the user object UserObjectTree.GetValidUserObjectTypeFolder(uo); UserObjectDao.Write(uo); // write the user object MetaTableCollection.UpdateGlobally(mt); // update map with modified metatable return; }
/// <summary> /// Lookup a MetaTable by name throwing any exceptions from underlying factories /// </summary> /// <param name="name"></param> /// <returns>MetaTable or null if not found</returns> /// public MetaTable GetMetaTable( String name) { MetaTable mt; if (RestrictedMetaTables.MetatableIsRestricted(name)) { return(null); } if (RestrictedMetatable.MetatableIsGenerallyRestricted(name)) { return(null); } name = name.Trim().ToUpper(); if (MetaTableCollection.TableMap.ContainsKey(name)) { // see if in collection already mt = MetaTableCollection.TableMap[name]; return(mt); } for (int i1 = 0; i1 < MetaFactories.Count; i1++) { MetaTableFactoryRef mtfr = MetaFactories[i1]; mt = mtfr.MetaTableFactory.GetMetaTable(name); if (mt != null) { NormalizeMetaTable(mt); return(mt); } } // Check to see if this is a summary table that can be created from an unsummarized version of itself if (!Lex.EndsWith(name, MetaTable.SummarySuffix)) { return(null); // see if named as summary table } string name2 = name.Substring(0, name.Length - MetaTable.SummarySuffix.Length); MetaTable mt2 = MetaTableCollection.Get(name2); if (mt2 == null || !mt2.SummarizedExists) { return(null); } mt = mt2.Clone(); AdjustForSummarization(mt, true); return(mt); }
private void SummarizedViewMenuItem_Click(object sender, EventArgs e) { string mtName = FocusedMetaTable.Name + MetaTable.SummarySuffix; // indicate summary table MetaTable mt = MetaTableCollection.Get(mtName); if (mt == null) { MessageBoxMx.ShowError("MetaTable not found: " + mtName); return; } RenderTable(mt, null); }
/// <summary> /// Add a MetaTableItem to the DataTable /// </summary> /// <param name="mtName"></param> void AddMetaTableItemToDataTable( string mtName) { MetaTreeNode mtn = MetaTreeNodeCollection.GetNode(mtName); if (mtn != null && mtn.IsFolderType) { return; // ignore folders } MetaTable mt = MetaTableCollection.Get(mtName); if (mt == null) { MessageBoxMx.ShowError("The selected item is not a recognized data table: " + mtName); return; } string allowedTypes = Qc.MetaColumn.TableMap; if (Lex.IsDefined(allowedTypes)) // see if supplied table is allowed { int ai; string[] sa = allowedTypes.Split(','); for (ai = 0; ai < sa.Length; ai++) { string allowedType = sa[ai]; if (Lex.IsUndefined(allowedType)) { continue; } if (Lex.Contains(mt.Name, allowedType.Trim())) { break; } } if (ai >= sa.Length) { MessageBoxMx.ShowError("The selected data table is not is not of a type that can be added here (" + allowedTypes + ")"); return; } } MetaTableItem i = new MetaTableItem(); i.ExternalName = mt.Label; i.InternalName = mt.Name; AddMetaTableItemToDataTable(i); return; }
/// <summary> /// Select an existing calculated field definition /// </summary> /// <returns></returns> public static MetaTable SelectExisting() { UserObject uo = UserObjectOpenDialog.ShowDialog(UserObjectType.CalcField, "Select Calculated Field"); if (uo == null) { return(null); } string tName = "CALCFIELD_" + uo.Id.ToString(); MetaTable mt = MetaTableCollection.Get(tName); return(mt); }
/// <summary> /// Create a new calculated field /// </summary> /// <returns></returns> public static MetaTable CreateNew() { CalcField cf = new CalcField(); UserObject uo = Edit(cf, null); if (uo == null) { return(null); } string tName = "CALCFIELD_" + uo.Id.ToString(); MetaTable mt = MetaTableCollection.Get(tName); return(mt); }
/// <summary> /// Create a new annotation /// </summary> /// <returns></returns> public static MetaTable CreateNewAnnotationTable() { UserDataEditor editor = new UserDataEditor(); UserObject uo = new UserObject(UserObjectType.Annotation); uo = editor.Edit(uo); if (uo == null) { return(null); } string tName = "ANNOTATION_" + uo.Id.ToString(); MetaTable mt = MetaTableCollection.Get(tName); return(mt); }
/// <summary> /// Read the list of compounds for a library /// </summary> /// <param name="libId"></param> /// <returns></returns> public static CidList ReadLibrary( int libId) { CidList l = new CidList(); DbCommandMx dao = new DbCommandMx(); string sql = @" SELECT l.library_name, l.library_desc_text, s.corp_nbr FROM corp_owner.corp_substance s, corp_owner.corp_library_substance ls, corp_owner.corp_library l WHERE l.lib_id = <libId> and s.cpd_id = ls.cpd_id and l.lib_id = ls.lib_id" ; sql = Lex.Replace(sql, "<libId>", libId.ToString()); dao.Prepare(sql); dao.ExecuteReader(); MetaTable rootMt = MetaTableCollection.Get(MetaTable.PrimaryRootTable); while (dao.Read()) { if (Lex.IsNullOrEmpty(l.UserObject.Name)) { string name = dao.GetString(0); if (Lex.IsNullOrEmpty(name) || Lex.IsInteger(name)) { name = dao.GetString(1); // use desc if no name or just a number } if (Lex.IsNullOrEmpty(name)) { name = "Library " + libId; } l.UserObject.Name = name; } int intCorpId = dao.GetInt(2); string corpId = CompoundId.Normalize(intCorpId, rootMt); l.Add(corpId); } dao.CloseReader(); dao.Dispose(); return(l); }
/// <summary> /// Check that each of the numbers in the list exist in the database /// </summary> /// <param name="list">String form of list as entered by user</param> /// <param name="rootTableName">Root table to check against</param> /// <returns></returns> public static string ValidateList( string listText, string rootTableName) { string cn, extCn, errorMsg; int i1, i2; if (String.IsNullOrEmpty(rootTableName)) { return(null); } MetaTable rootTable = MetaTableCollection.GetWithException(rootTableName); string[] cna = listText.Split(new Char[] { '\n', '\r', ' ' }); int t0 = TimeOfDay.Milliseconds(); for (i1 = 0; i1 < cna.Length; i1++) { if (i1 > 1000 || TimeOfDay.Milliseconds() - t0 > 3000) { return(null); // limit size & time of check } extCn = cna[i1].Trim(); if (extCn == "" || extCn.StartsWith("(")) { continue; } i2 = extCn.IndexOf("("); // strip trailing text in parens if (i2 > 0) { extCn = extCn.Substring(0, i2); } cn = CompoundId.BestMatch(extCn, rootTable); if (cn == "") { cn = extCn; // nothing found, use original text } if (!CompoundIdUtil.Exists(cn, rootTable)) { return(extCn); } } return(null); }
public MetaTable GetMetaTable( string mtName) { MetaTable mt = null; MetaColumn mc, mc2; int methodId; string txt, tok; mtName = mtName.Trim().ToUpper(); string name2 = mtName; string prefix = "ORACLE"; if (mtName.StartsWith(prefix + "_") || mtName.StartsWith(prefix + ".")) { name2 = mtName.Substring(prefix.Length + 1); } string[] sa = name2.Split('.'); if (sa.Length < 2) { return(null); } name2 = sa[0] + "." + sa[1]; mt = MetaTableFactory.GetMetaTableFromDatabaseDictionary(name2); if (mt == null || mt.MetaColumns.Count == 0) { return(null); } mt.Name = mtName; // assign fully qualified name if (sa.Length >= 3) // key col name included { mc = mt.GetMetaColumnByName(sa[2]); if (mc != null) { mc.DataType = MetaColumnType.CompoundId; } } if (sa.Length >= 4) // assign parent if parent table name included { mt.Parent = MetaTableCollection.Get(sa[3]); } return(mt); }
/// <summary> /// Get query to select all data. /// It consists of a single QueryTable with the CID and key table name /// This keeps the initial query sent to the client small which helps /// response time for users not on the same local network as the server. /// </summary> /// <param name="keyMtName"></param> /// <param name="cn"></param> /// <returns></returns> public static Query GetSelectAllDataQuery( string keyMtName, string cn) { MetaTable mt = MetaTableCollection.GetWithException(MetaTable.AllDataQueryTable); Query q = new Query(); QueryTable qt = new QueryTable(mt); q.AddQueryTable(qt); MetaTable keyMt = null; if (Lex.IsDefined(keyMtName)) { keyMt = MetaTableCollection.Get(keyMtName); } if (keyMt != null && keyMt.Root.IsUserDatabaseStructureTable) // if root metatable is user database then normalize based on key { keyMt = keyMt.Root; // be sure we have root cn = CompoundId.Normalize(cn, keyMt); } else { cn = CompoundId.Normalize(cn); keyMt = CompoundId.GetRootMetaTableFromCid(cn, keyMt); keyMt = keyMt.Root; // be sure we have root (may not be structure table) } if (keyMt == null) { throw new Exception("Failed to identify key MetaTable"); } q.KeyCriteria = q.KeyCriteriaDisplay = " = " + cn; QueryColumn qc = qt.GetQueryColumnByNameWithException("root_table"); qc.Criteria = qc.CriteriaDisplay = qc.MetaColumn.Name + " = " + keyMt.Name; return(q); }
/// <summary> /// Do Generic display of a list of structures /// </summary> /// <param name="title"></param> /// <param name="cidLabel"></param> /// <param name="structLabel"></param> /// <param name="structures"></param> public static void DisplayStructures( string title, string cidLabel, string structLabel, List <MoleculeMx> structures, MoleculeGridPanel gridPanel, bool embedDataInQuery) { QueryManager qm = null; MetaTable mt = MetaTableCollection.GetWithException("Generic_Structure_Table"); mt.MetaBrokerType = MetaBrokerType.NoSql; Query q = ToolHelper.InitEmbeddedDataToolQuery(mt); QueryTable qt = q.Tables[0]; qt.Label = title; qt.GetQueryColumnByName("CompoundId").Label = cidLabel; qt.GetQueryColumnByName("Structure").Label = structLabel; DataTableMx dt = q.ResultsDataTable as DataTableMx; for (int mi = 0; mi < structures.Count; mi++) { MoleculeMx cs = structures[mi]; DataRowMx dr = dt.NewRow(); string cid = cs.Id; if (Lex.IsUndefined(cid)) { cid = (mi + 1).ToString(); } dr[qt.Alias + ".CompoundId"] = new CompoundId(cid); dr[qt.Alias + ".Structure"] = cs; dt.Rows.Add(dr); } DisplayData(q, dt, gridPanel, embedDataInQuery); return; }
/// <summary> /// ContentsTreeItemSelected /// </summary> /// <param name="nodeTarget"></param> private void ContentsTreeItemSelected(string nodeTarget) { MetaTreeNode node = MetaTreeNodeCollection.GetNode(nodeTarget); if (node == null || (node.Type & TypeFilter) == 0) { SelectionName.Text = SelectionTarget.Text = ""; return; } else if (node.IsDataTableType) { MetaTable mt = MetaTableCollection.Get(node.Target); if (mt == null) { return; // shouldn't happen } if (mt.SummarizedExists) // Prompt user for summarization-level choice { FocusedMetaTable = mt; Point p = Form.MousePosition; p = ContentsTreeWithSearch.ContentsTreeCtl.PointToClient(p); SummarizationLevelContextMenu.Show(ContentsTreeWithSearch.ContentsTreeCtl, p); return; } } SelectionName.Text = node.Label; SelectionTarget.Text = node.Target; // If item is double clicked then we're done MouseEventArgs ma = ContentsTreeWithSearch.CurrentContentsTreeMouseDownEvent; if (ma != null && ma.Clicks >= 2) { DialogResult = DialogResult.OK; } return; }
/// <summary> /// Get list of Tables that underlie the CalcTable in the form of a prototype Query /// </summary> /// <param name="qt"></param> /// <returns></returns> Query GetUnderlyingTables(QueryTable qt) { QueryTable qt2; MetaTable mt2; string mtName, alias, tok; Query q2 = new Query(); string[] l1 = qt.MetaTable.TableMap.Split(','); foreach (string s in l1) { tok = s.Trim(); if (tok.Contains(" ")) { string[] sa = tok.Split(' '); mtName = sa[0].Trim(); alias = sa[1].Trim(); } else { mtName = tok; alias = tok; } mt2 = MetaTableCollection.Get(mtName); if (mt2 == null) { throw new Exception("Metatable not found: " + mtName); } qt2 = new QueryTable(mt2); qt2.SelectKeyOnly(); qt2.Alias = alias; q2.AddQueryTable(qt2); } return(q2); }
/// <summary> /// Get list list of ResultsViewModels /// </summary> /// <returns></returns> public static List <ResultsViewModel> GetResultsViewModels() { string viewTypeName, viewSubtype, imageName, viewTitle; int imageIdx; if (ResultsViewModels != null) { return(ResultsViewModels); } ResultsViewModels = new List <ResultsViewModel>(); MetaTable mt = MetaTableCollection.Get("AddResultsViewMenu"); if (mt == null) { DebugLog.Message("AddResultsViewMenu MetaTable not found"); return(null); } foreach (MetaColumn mc in mt.MetaColumns) { ResultsViewModel m = new ResultsViewModel(); m.Name = mc.Name; m.Title = mc.Label; m.Description = mc.Description; m.ShowInViewsMenu = (mc.InitialSelection == ColumnSelectionEnum.Selected); Lex.Split(mc.ColumnMap, ",", out viewTypeName, out viewSubtype, out imageName); Enum.TryParse <ResultsViewType>(viewTypeName, true, out m.ViewType); m.ViewSubtype = viewSubtype; m.CustomViewTypeImageName = imageName; ResultsViewModels.Add(m); } return(ResultsViewModels); }
/// <summary> /// Load/reload from specified file /// </summary> public void BuildFromFile(string fileName) { if (ServiceFacade.UseRemoteServices) { MetaTableCollection.Reset(); // reset local collection string serverFile = ServerFile.GetTempFileName(".xml", true); ServerFile.CopyToServer(fileName, serverFile); Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = nativeClient.InvokeNativeMethod( (int)Services.Native.ServiceCodes.MobiusMetaTableService, (int)Services.Native.ServiceOpCodes.MobiusMetaTableService.BuildFromFile, new Mobius.Services.Native.NativeMethodTransportObject(new object[] { serverFile })); ((System.ServiceModel.IClientChannel)nativeClient).Close(); } else // just do local build { Mobius.MetaFactoryNamespace.MetaTableFactory.BuildFromXmlFile(fileName); } }
/// <summary> /// ContentsTreeItemSelected /// </summary> /// <param name="nodeTarget"></param> private void ContentsTreeItemSelected(string nodeTarget) { //MetaTreeNode node = ContentsTreeWithSearch.ContentsTree.GetMetaTreeNodeAt(ContentsTreeWithSearch.ContentsTree.PointToClient(Cursor.Position)); //if (node == null || !node.IsDataTableType) return; string mtName = nodeTarget; MetaTable mt = MetaTableCollection.Get(mtName); if (mt == null) { return; } if (mt.UseSummarizedData || !mt.SummarizedExists) { RenderTable(mt, null); // use table as selected } else // select table based on desired summarization level { if (mt.SummarizedExists && SelectSummarizedDataByDefault) { string mtName2 = mtName += MetaTable.SummarySuffix; MetaTable mt2 = MetaTableCollection.Get(mtName2); if (mt2 != null) { RenderTable(mt2, null); // use table as selected return; } } // Prompt user for summarization-level choice FocusedMetaTable = mt; Point p = Form.MousePosition; p = ContentsTreeWithSearch.ContentsTreeCtl.PointToClient(p); SummarizationLevelContextMenu.Show(ContentsTreeWithSearch.ContentsTreeCtl, p); } }
/// <summary> /// Parse metatable & metacolumn /// </summary> /// <param name="mtName"></param> /// <param name="mt"></param> /// <param name="mcName"></param> /// <param name="mc"></param> static void ParseMetaTableMetaColumn( string mtName, out MetaTable mt, string mcName, out MetaColumn mc) { mt = null; mc = null; mt = MetaTableCollection.Get(mtName); if (mt == null) { throw new Exception("Can't find metatable: " + mtName); } mc = mt.GetMetaColumnByName(mcName); if (mc == null) { throw new Exception("Can't find metacolumn: " + mcName); } return; }
public Query BuildStructureSearchQuery() { MetaTable mt = MetaTableCollection.Get(MetaTable.SmallWorldMetaTableName); if (mt == null) { DebugLog.Message("SmallWorld MetaTable not found"); MoleculeGridPageControl.Visible = false; return(null); } Query q = new Query(); // build single-table query q.SingleStepExecution = true; QueryTable qt = new QueryTable(q, mt); string title = "SmallWorld"; qt.Label = title; q.UserObject.Name = qt.MetaTable.Label; // need? return(q); }