Пример #1
0
        /// <summary>
        /// Add cid criteria to the derived query to get set of compounds desired
        /// </summary>
        /// <param name="q"></param>
        /// <param name="cidList"></param>

        void ModifyQueryForCidSearch(
            Query q,
            List <string> cidList)
        {
            QueryTable  qt    = q.Tables[0];
            QueryColumn keyQc = qt.KeyQueryColumn;

            ParsedSingleCriteria psc = new ParsedSingleCriteria();

            psc.QueryColumn = keyQc;

            if (cidList.Count == 1)
            {
                psc.Op    = "=";
                psc.Value = cidList[0];
            }

            else
            {
                psc.Op        = "in";
                psc.ValueList = cidList;
            }

            MqlUtil.ConvertParsedSingleCriteriaToQueryColumnCriteria(psc, keyQc, false);
            keyQc.CopyCriteriaToQueryKeyCritera(q);
            return;
        }
Пример #2
0
/// <summary>
/// Build the query that is executed to retrieve the summarized target data and optional structure data
/// </summary>
/// <returns></returns>

        void BuildQuery(string title)
        {
            int qid = SS.I.ServicesIniFile.ReadInt("SpillTheBeansToolModelQuery", -1);

            if (qid < 0)
            {
                throw new Exception("SpillTheBeansToolModelQuery not defined");
            }

            Query q = QbUtil.ReadQuery(qid);

            if (q == null)
            {
                throw new Exception("Failed to read SpillTheBeansToolModelQuery: " + qid);
            }

            AssertMx.IsDefined(KeyQc?.Criteria, "KeyQc.Criteria");

            ParsedSingleCriteria psc = MqlUtil.ParseSingleCriteria(KeyQc?.Criteria);             // parse key criteria

            KeyQc.CopyCriteriaToQueryKeyCritera(q);
            Query = q;             // save for later use

            return;
        }
Пример #3
0
        /// <summary>
        /// Invoke the editor
        /// </summary>
        /// <param name="qc">QueryColumn to edit</param>
        /// <returns></returns>

        public static bool Edit(
            QueryColumn qc)
        {
            AssertMx.IsNotNull(qc, "qc");

            if (Instance == null)
            {
                Instance = new CriteriaCompoundId();
            }

            new JupyterGuiConverter().ConvertFormOrUserControl(Instance);

            if (qc.IsKey)             // if key col be sure qc is in sync with Query.KeyCriteria
            {
                qc.CopyCriteriaFromQueryKeyCriteria();
            }

            if (qc.Criteria.Trim().StartsWith("=") && qc.MetaColumn != null)
            {
                qc.Criteria = qc.MetaColumnName + " " + qc.Criteria;
            }

            Instance.Qc = qc;
            Instance.Setup(qc);

            DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm);

            if (dr == DialogResult.OK)
            {
                if (qc.IsKey)                 // if key col then update Query.KeyCriteria
                {
                    qc.CopyCriteriaToQueryKeyCritera();
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
/// Edit criteria for a query column
/// </summary>
/// <param name="qc"></param>
/// <returns>True if criteria has been successfully edited</returns>

        public static bool EditCriteria(
            QueryColumn qc)
        {
            MetaColumn mc    = qc.MetaColumn;
            Query      Query = qc.QueryTable.Query;
            bool       sameQ = Query == QueriesControl.Instance.CurrentQuery;       // debug

            if (Lex.Contains(qc.MetaColumn.ColumnMap, ToolUtil.ToolParametersColumnMapValue))
            {
                DialogResult dr = ToolHelper.InvokeToolCriteriaEditor(qc);
                return(dr == DialogResult.OK);
            }

            try
            {
                if (!mc.IsSearchable)
                {
                    MessageBoxMx.ShowError("The " + qc.ActiveLabel + " data item is not currently searchable.");
                    return(false);
                }

                if (mc.IsKey)                              // edit key criteria
                {
                    qc.CopyCriteriaFromQueryKeyCriteria(); // be sure qc is in sync with Query.KeyCriteria
                    if (!CriteriaCompoundId.Edit(qc))
                    {
                        return(false);
                    }

                    qc.CopyCriteriaToQueryKeyCritera();                     // update Query.KeyCriteria
                    return(true);
                }

                switch (mc.DataType)
                {
                // Compound Number criteria

                case MetaColumnType.CompoundId:

                    if (!CriteriaCompoundId.Edit(qc))
                    {
                        return(false);
                    }
                    else
                    {
                        break;
                    }

                // Structure criteria

                case MetaColumnType.Structure:
                    if (!CriteriaStructure.Edit(qc))
                    {
                        return(false);
                    }
                    break;

                // Mol. formula criteria

                case MetaColumnType.MolFormula:
                    if (!CriteriaMolFormula.Edit(qc))
                    {
                        return(false);
                    }
                    break;


                // General criteria

                case MetaColumnType.Integer:
                case MetaColumnType.Number:
                case MetaColumnType.QualifiedNo:
                case MetaColumnType.String:
                case MetaColumnType.Date:
                case MetaColumnType.DictionaryId:

                    if (!CriteriaDialog.Edit(qc))
                    {
                        return(false);
                    }
                    else
                    {
                        break;
                    }

                default:
                    MessageBoxMx.ShowError("The " + qc.ActiveLabel + " data item is not currently searchable.");
                    return(false);
                }

                return(true);
            }

            catch (Exception ex)
            {
                string msg = "Unexpected error editing criteria: \r\n\r\n" +
                             DebugLog.FormatExceptionMessage(ex);
                ServicesLog.Message(msg);
                MessageBoxMx.ShowError(msg);
                return(false);
            }
        }