Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/8445_icat_refactor_algor…
Browse files Browse the repository at this point in the history
…ithms'
  • Loading branch information
Samuel Jackson committed Nov 18, 2013
2 parents 13a0e21 + e7ad498 commit c992036
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 102 deletions.
11 changes: 3 additions & 8 deletions Code/Mantid/Framework/ICat/src/CatalogGetDataFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,10 @@ namespace Mantid
//execute the algorithm
void CatalogGetDataFiles::exec()
{
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();

int64_t investigationId = getProperty("InvestigationId");

API::ITableWorkspace_sptr ws_sptr = API::WorkspaceFactory::Instance().createTable("TableWorkspace");

catalog->getDataFiles(investigationId,ws_sptr);

setProperty("OutputWorkspace",ws_sptr);
auto workspace = API::WorkspaceFactory::Instance().createTable("TableWorkspace");
CatalogAlgorithmHelper().createCatalog()->getDataFiles(investigationId,workspace);
setProperty("OutputWorkspace",workspace);
}

}
Expand Down
7 changes: 3 additions & 4 deletions Code/Mantid/Framework/ICat/src/CatalogGetDataSets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ namespace Mantid
/// exec methods
void CatalogGetDataSets::exec()
{
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();
API::ITableWorkspace_sptr ws_sptr = API::WorkspaceFactory::Instance().createTable("TableWorkspace");
auto workspace = API::WorkspaceFactory::Instance().createTable("TableWorkspace");
int64_t investigationId = getProperty("InvestigationId");
catalog->getDataSets(investigationId,ws_sptr);
setProperty("OutputWorkspace",ws_sptr);
CatalogAlgorithmHelper().createCatalog()->getDataSets(investigationId,workspace);
setProperty("OutputWorkspace",workspace);
}

}
Expand Down
12 changes: 1 addition & 11 deletions Code/Mantid/Framework/ICat/src/CatalogListInstruments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,8 @@ namespace Mantid
/// exec method
void CatalogListInstruments::exec()
{
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();

std::vector<std::string> intruments;
try
{
catalog->listInstruments(intruments);
}
catch(std::runtime_error&)
{
setProperty("IsValid",false);
throw std::runtime_error("Please login to the information catalog using the login dialog provided.");
}
CatalogAlgorithmHelper().createCatalog()->listInstruments(intruments);
setProperty("InstrumentList",intruments);
}

Expand Down
12 changes: 1 addition & 11 deletions Code/Mantid/Framework/ICat/src/CatalogListInvestigationTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,8 @@ namespace Mantid
/// exec method
void CatalogListInvestigationTypes::exec()
{
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();

std::vector<std::string> investTypes;
try
{
catalog->listInvestigationTypes(investTypes);
}
catch(std::runtime_error&)
{
setProperty("IsValid",false);
throw std::runtime_error("Please login to the information catalog using the login dialog provided.");
}
CatalogAlgorithmHelper().createCatalog()->listInvestigationTypes(investTypes);
setProperty("InvestigationTypes",investTypes);
}

Expand Down
7 changes: 1 addition & 6 deletions Code/Mantid/Framework/ICat/src/CatalogLogin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,12 @@ namespace Mantid
/// execute the algorithm
void CatalogLogin::exec()
{
// Create and use the catalog the user has specified in Facilities.xml
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();

std::string username = getProperty("Username");
std::string password = getProperty("Password");

g_log.notice() << "Attempting to verify user credentials against " <<
Mantid::Kernel::ConfigService::Instance().getFacility().catalogInfo().catalogName() << std::endl;
progress(0.5, "Verifying user credentials...");

catalog->login(username,password,"");
CatalogAlgorithmHelper().createCatalog()->login(username, password, "");
}

}
Expand Down
3 changes: 1 addition & 2 deletions Code/Mantid/Framework/ICat/src/CatalogLogout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ namespace Mantid
/// execute the algorithm
void CatalogLogout::exec()
{
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();
catalog->logout();
CatalogAlgorithmHelper().createCatalog()->logout();
}
}
}
14 changes: 2 additions & 12 deletions Code/Mantid/Framework/ICat/src/CatalogMyDataSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,8 @@ namespace Mantid
void CatalogMyDataSearch::exec()
{
// Create and use the catalog the user has specified in Facilities.xml
ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();

API::ITableWorkspace_sptr outputws = WorkspaceFactory::Instance().createTable("TableWorkspace");
try
{
catalog->myData(outputws);
}
catch(std::runtime_error&)
{
setProperty("IsValid",false);
throw std::runtime_error("Please login to the information catalog using the login dialog provided.");
}
auto outputws = WorkspaceFactory::Instance().createTable("TableWorkspace");
CatalogAlgorithmHelper().createCatalog()->myData(outputws);
setProperty("OutputWorkspace",outputws);
}
}
Expand Down
6 changes: 2 additions & 4 deletions Code/Mantid/Framework/ICat/src/CatalogSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,14 @@ namespace Mantid
/// Execution method.
void CatalogSearch::exec()
{
// Create and use the catalog the user has specified in Facilities.xml
ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();
// Obtains the inputs from the search interface.
CatalogSearchParam params;
// Get the user input search terms to search for.
getInputProperties(params);
// Create output workspace.
ITableWorkspace_sptr workspace = WorkspaceFactory::Instance().createTable("TableWorkspace");
auto workspace = WorkspaceFactory::Instance().createTable("TableWorkspace");
// Search for investigations in the archives.
catalog->search(params,workspace);
CatalogAlgorithmHelper().createCatalog()->search(params,workspace);
// Search for investigations with user specific search inputs.
setProperty("OutputWorkspace",workspace);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ namespace MantidQt
const std::vector<std::string> downloadDataFiles(const std::vector<std::pair<int64_t, std::string>> &userSelectedFiles, const std::string &downloadPath);
/// Validate each input field against the related algorithm property.
const std::map<std::string, std::string> validateProperties(const std::map<std::string, std::string> &inputFields);
/// Using a property (isValid) in the list instruments algorithm verify if the session is valid.
bool validSession();
/// Open the login dialog if user not logged in.
void openLoginDialog(QWidget* window);
/// Creates a time_t value from an input date ("23/06/2003") for comparison.
time_t getTimevalue(const std::string& inputDate);

Expand Down
35 changes: 0 additions & 35 deletions Code/Mantid/MantidQt/MantidWidgets/src/CatalogHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,41 +146,6 @@ namespace MantidQt
return errors;
}


/**
* Using the list instruments algorithm verify if the session is valid.
* @return True if session is valid, otherwise false.
*/
bool CatalogHelper::validSession()
{
auto catalogAlgorithm = createCatalogAlgorithm("CatalogListInstruments");

executeAsynchronously(catalogAlgorithm);

if (catalogAlgorithm->getProperty("IsValid"))
{
return true;
}
return false;
}

/**
* Open the login dialog if user not logged in.
* @param window :: The window to open the dialog box in.
*/
void CatalogHelper::openLoginDialog(QWidget* window)
{
auto catalogAlgorithm = createCatalogAlgorithm("CatalogLogin");

MantidQt::API::InterfaceManager interfaceManager;
auto *loginDialog = interfaceManager.createDialog(catalogAlgorithm.get(), window);

if(loginDialog->exec() == QDialog::Accepted)
{
executeAsynchronously(catalogAlgorithm);
}
}

/**
* Creates a time_t value from an input date ("23/06/2003") for comparison.
* @param inputDate :: string containing the date.
Expand Down
5 changes: 0 additions & 5 deletions Code/Mantid/MantidQt/MantidWidgets/src/CatalogSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ namespace MantidQt
*/
CatalogSearch::CatalogSearch(QWidget* parent) : QWidget(parent)
{
if (!m_icatHelper->validSession())
{
m_icatHelper->openLoginDialog(parent);
}

initLayout();
// Load saved settings from store.
loadSettings();
Expand Down

0 comments on commit c992036

Please sign in to comment.