Ejemplo n.º 1
0
    /**
     * The number of results returned by the search query (based on values of input fields).
     * @param userInputFields :: A map containing the users' search input (key => FieldName, value => FieldValue).
     * @param sessionIDs :: The sessions information of each active catalog.
     * @return Number of results returned by the search query.
     */
    int64_t CatalogHelper::getNumberOfSearchResults(
        const std::map<std::string, std::string> &userInputFields,
        const std::vector<std::string> &sessionIDs)
    {
      auto catalogAlgorithm = createCatalogAlgorithm("CatalogSearch");
      // Set the property to only perform a count search.
      catalogAlgorithm->setProperty("CountOnly", true);
      // Set the "search" properties to their related input fields.
      setSearchProperties(catalogAlgorithm, userInputFields);

      auto session = Mantid::API::CatalogManager::Instance().getActiveSessions();
      if (session.size() == sessionIDs.size())
      {
        executeAsynchronously(catalogAlgorithm);
        return catalogAlgorithm->getProperty("NumberOfSearchResults");
      }
      else
      {
        for (unsigned i = 0; i < sessionIDs.size(); ++i)
        {
          catalogAlgorithm->setProperty("Session", sessionIDs.at(i));
          executeAsynchronously(catalogAlgorithm);
        }
        return catalogAlgorithm->getProperty("NumberOfSearchResults");
      }
    }
Ejemplo n.º 2
0
/**
 * Search the archive with the user input terms provided and save them to a
 * workspace ("searchResults").
 * @param userInputFields :: A map containing all users' search fields - (key =>
 * FieldName, value => FieldValue).
 * @param offset :: skip this many rows and start returning rows from this
 * point.
 * @param limit  :: limit the number of rows returned by the query.
 * @param sessionIDs :: The sessions information of each active catalog.
 */
void CatalogHelper::executeSearch(
    const std::map<std::string, std::string> &userInputFields,
    const int &offset, const int &limit,
    const std::vector<std::string> &sessionIDs) {
  auto catalogAlgorithm = createCatalogAlgorithm("CatalogSearch");
  // Set the properties to limit the number of results returned for paging
  // purposes.
  catalogAlgorithm->setProperty("Limit", limit);
  catalogAlgorithm->setProperty("Offset", offset);
  // Set the "search" properties to their related input fields.
  setSearchProperties(catalogAlgorithm, userInputFields);

  auto session = Mantid::API::CatalogManager::Instance().getActiveSessions();
  if (session.size() == sessionIDs.size()) {
    executeAsynchronously(catalogAlgorithm);
  } else {
    for (unsigned i = 0; i < sessionIDs.size(); ++i) {
      catalogAlgorithm->setProperty("Session", sessionIDs.at(i));
      executeAsynchronously(catalogAlgorithm);
    }
  }
}