Skip to content

Commit

Permalink
Updated CatalogListInstrument algor to take sessionID. Refs #9112.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawrainey committed Mar 11, 2014
1 parent 58e10f1 commit 4eee3a0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
Expand Up @@ -12,8 +12,8 @@ namespace MantidQt
{

public:
/// Obtain the list of instruments that are available.
const std::vector<std::string> getInstrumentList();
/// Obtain the list of instruments that are available for the given session information.
const std::vector<std::string> getInstrumentList(const std::vector<std::string> &sessionIDs);
/// Obtain the list of instruments that are available.
const std::vector<std::string> getInvestigationTypeList();
/// Run the search algorithm with the given user input.
Expand Down
30 changes: 25 additions & 5 deletions Code/Mantid/MantidQt/MantidWidgets/src/CatalogHelper.cpp
Expand Up @@ -14,15 +14,35 @@ namespace MantidQt
{

/**
* Obtain the list of instruments from the ICAT Catalog algorithm.
* Obtain a list of instruments for specified catalogs.
* @param sessionIDs :: The sessions information of each active catalog.
* @return A vector containing the list of all instruments available.
*/
const std::vector<std::string> CatalogHelper::getInstrumentList()
const std::vector<std::string> CatalogHelper::getInstrumentList(const std::vector<std::string> &sessionIDs)
{
auto catalogAlgorithm = createCatalogAlgorithm("CatalogListInstruments");
executeAsynchronously(catalogAlgorithm);
// return the vector containing the list of instruments available.
return (catalogAlgorithm->getProperty("InstrumentList"));
auto session = Mantid::API::CatalogManager::Instance().getActiveSessions();

// If ONE or ALL catalogs are selected to search through use no session (empty).
// This will invoke the compositeCatalog instead of specific catalogs for each session.
if (sessionIDs.size() <= 1 || session.size() == sessionIDs.size())
{
executeAsynchronously(catalogAlgorithm);
return catalogAlgorithm->getProperty("InstrumentList");
}

std::vector<std::string> instrumentList;
// Use catalogs for the specified sessions.
for (unsigned i = 0; i < sessionIDs.size(); ++i)
{
catalogAlgorithm->setProperty("Session",sessionIDs.at(i));
executeAsynchronously(catalogAlgorithm);
// Append the result of each search to the instrument list.
std::vector<std::string> result = catalogAlgorithm->getProperty("InstrumentList");
instrumentList.insert(instrumentList.end(),result.begin(),result.end());
}
// Return the vector containing the list of instruments available.
return instrumentList;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion Code/Mantid/MantidQt/MantidWidgets/src/CatalogSearch.cpp
Expand Up @@ -383,7 +383,8 @@ namespace MantidQt
void CatalogSearch::populateInstrumentBox()
{
// Obtain the list of instruments to display in the drop-box.
std::vector<std::string> instrumentList = m_icatHelper->getInstrumentList();
std::vector<std::string> instrumentList = m_icatHelper->getInstrumentList(
m_catalogSelector->getSelectedCatalogSessions());

// This option allows the user to select no instruments (thus searching over them all).
m_icatUiForm.Instrument->insertItem(-1,"");
Expand Down

0 comments on commit 4eee3a0

Please sign in to comment.