/// <summary> /// Execute SmallWorld search /// </summary> /// <param name="eqp"></param> void ExecuteSmallWorldSearch( ExecuteQueryParms eqp) { if (!SmallWorldDao.IsSmallWorldAvailable()) { throw new UserQueryException("SmallWorld searching is not currently available."); } Query q = eqp.QueryTable.Query; QueryTable qt = eqp.QueryTable; SmallWorldPredefinedParameters swp = Pssc.SmallWorldParameters; string smiles = Pssc.Molecule.GetSmilesString(); swp.Smiles = smiles; //swp.Database = "Corp"; LastSwNonSqlBroker = null; // debug - force new broker if (SwDao == null) // if Dao not allocated then allocate & execute the search { if (LastSwNonSqlBroker != null && LastSwNonSqlBroker.Pssc != null && LastSwNonSqlBroker.Pssc.SmallWorldParameters != null && LastSwNonSqlBroker.Pssc.SmallWorldParameters.Serialize() == swp.Serialize()) { SwDao = LastSwNonSqlBroker.SwDao; // get rows from previous search SwDao.BuildSwToQeColumnMap(SelectList); // reset the column map for this broker instance } else { SwDao = new SmallWorldDao(); SwDao.KeysToExclude = q.KeysToExclude; SwDao.ExecuteSearch(swp); SwDao.BuildSwToQeColumnMap(SelectList); // LastSwNonSqlBroker = this; // remember for future use } } BuildSmallWorldQueryEngineRows(eqp); // build the QE row set (filtered) from the SW rowset return; }
/// <summary> /// Prep non-Oracle query /// </summary> /// <param name="eqp"></param> /// <returns></returns> public override string PrepareQuery( ExecuteQueryParms eqp) { int cti; Eqp = eqp; QueryEngine qe = eqp.Qe; Query q = qe.Query; QueryTable qt = eqp.QueryTable; QueryColumn qc; MetaTable mt = qt.MetaTable; MetaColumn mc = null; StructCriteriaQc = KeyCriteriaQc = null; QueryColumn strQc = qt.FirstStructureQueryColumn; if (strQc != null && Lex.IsDefined(strQc.Criteria)) { StructCriteriaQc = strQc; } else { throw new Exception("Structure criteria not defined"); } Pssc = ParsedStructureCriteria.Parse(StructCriteriaQc); QueryColumn keyQc = qt.KeyQueryColumn; if (keyQc != null && Lex.IsDefined(q.KeyCriteria)) //keyQc.Criteria)) { KeyCriteriaQc = keyQc; } if (StructCriteriaQc == null && KeyCriteriaQc == null && eqp.SearchKeySubset == null) { throw new Exception("NonSqlBroker - No criteria specified"); } SelectList = new List <MetaColumn>(); // list of selected metacolumns foreach (QueryColumn qc2 in qt.QueryColumns) { if (qc2.MetaColumn == null) { continue; // in case metacolumn not defined } if (qc2.IsKey) { qc2.Selected = true; } if (qc2.Selected || qc2.SortOrder != 0) { SelectList.Add(qc2.MetaColumn); } } // Setup for ECFP4 similarity search if (Pssc.SearchType == StructureSearchType.MolSim && Pssc.SimilarityType == SimilaritySearchType.ECFP4) { Ecfp4Dao = null; // reset Dao to initiate new search return(""); } else if (Pssc.SearchType == StructureSearchType.SmallWorld) // SmallWorld search { SwDao = null; // reset Dao to initiate new search return(""); } else if (Pssc.SearchType == StructureSearchType.Related) // Related structure search { RSS = null; // reset to initiate new search return(""); } else if (!MqlUtil.IsCartridgeMetaTable(mt)) // must be non chemical cartridge table (e.g. User structure DB or structure in Annotation table { return(""); // everything looks ok, query criteria stored here, no sql returned } else { throw new Exception("Unsupported NonSqlBroker search for table: " + eqp.QueryTable.MetaTable.Label); } }