Skip to content

Commit

Permalink
Make ICAT3 helper class a member variable. Refs #8230.
Browse files Browse the repository at this point in the history
- This allows the helper class member variables to be shared across the catalog methods.
  • Loading branch information
jawrainey committed Nov 21, 2013
1 parent eb84922 commit 75f4f75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "MantidAPI/ICatalog.h"
#include "MantidICat/CatalogSearchParam.h"
#include "MantidICat/ICat3/ICat3ErrorHandling.h"
#include "MantidICat/ICat3/ICat3Helper.h"

namespace Mantid
{
Expand Down Expand Up @@ -67,6 +68,10 @@ namespace Mantid
virtual void keepAlive();
/// keep alive in minutes
virtual int keepAliveinminutes();

private:
/// The helper class that accesses ICAT functionality.
CICatHelper* m_helper;
};

}
Expand Down
42 changes: 16 additions & 26 deletions Code/Mantid/Framework/ICat/src/ICat3/ICat3Catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "MantidAPI/CatalogFactory.h"
#include "MantidICat/Session.h"
#include "MantidAPI/Progress.h"
#include "MantidICat/ICat3/ICat3Helper.h"
#include "MantidAPI/AnalysisDataService.h"

namespace Mantid
{
Expand All @@ -12,7 +12,7 @@ namespace Mantid
DECLARE_CATALOG(ICat3Catalog)

/// constructor
ICat3Catalog::ICat3Catalog()
ICat3Catalog::ICat3Catalog() : m_helper(new CICatHelper())
{
}
/// destructor
Expand All @@ -26,15 +26,12 @@ namespace Mantid
*/
void ICat3Catalog::login(const std::string& username,const std::string& password,const std::string& url)
{
CICatHelper helper;
helper.doLogin(username,password,url);
m_helper->doLogin(username,password,url);
}
/// This method disconnects the client application from ICat3 based catalog services
void ICat3Catalog::logout()
{

CICatHelper helper;
helper.doLogout();
m_helper->doLogout();
Session::Instance().setSessionId("");//clearing the session id saved to Mantid after log out
}

Expand All @@ -43,8 +40,7 @@ namespace Mantid
*/
void ICat3Catalog::myData(Mantid::API::ITableWorkspace_sptr& mydataws_sptr)
{
CICatHelper helper;
helper.doMyDataSearch(mydataws_sptr);
m_helper->doMyDataSearch(mydataws_sptr);
}

/*This method returns the datasets associated to the given investigationid .
Expand All @@ -53,9 +49,8 @@ namespace Mantid
*/
void ICat3Catalog::getDataSets(const long long& investigationId,Mantid::API::ITableWorkspace_sptr& datasetsws_sptr)
{
CICatHelper helper;
//search datasets for a given investigation id using ICat api.
helper.doDataSetsSearch(investigationId,
m_helper->doDataSetsSearch(investigationId,
ICat3::ns1__investigationInclude__DATASETS_USCOREAND_USCOREDATASET_USCOREPARAMETERS_USCOREONLY,datasetsws_sptr);
}

Expand All @@ -65,26 +60,23 @@ namespace Mantid
*/
void ICat3Catalog::getDataFiles(const long long& investigationId,Mantid::API::ITableWorkspace_sptr& datafilesws_sptr)
{
CICatHelper helperobj;
helperobj.getDataFiles(investigationId,ICat3::ns1__investigationInclude__DATASETS_USCOREAND_USCOREDATAFILES,datafilesws_sptr);
m_helper->getDataFiles(investigationId,ICat3::ns1__investigationInclude__DATASETS_USCOREAND_USCOREDATAFILES,datafilesws_sptr);
}

/**This method returns the list of instruments
*@param instruments :: instruments list
*/
void ICat3Catalog::listInstruments(std::vector<std::string>& instruments)
{
CICatHelper helper;
helper.listInstruments(instruments);
m_helper->listInstruments(instruments);
}

/**This method returns the list of investigationtypes
*@param invstTypes :: investigation types list
*/
void ICat3Catalog::listInvestigationTypes(std::vector<std::string>& invstTypes)
{
CICatHelper helper;
helper.listInvestigationTypes(invstTypes);
m_helper->listInvestigationTypes(invstTypes);
}

/**This method method gets the file location strings from isis archive
Expand All @@ -93,8 +85,7 @@ namespace Mantid
*/
void ICat3Catalog::getFileLocation(const long long & fileid,std::string & filelocation)
{
CICatHelper helper;
helper.getlocationString(fileid,filelocation);
m_helper->getlocationString(fileid,filelocation);
}

/**This method method gets the url for downloading the file from isis server
Expand All @@ -103,8 +94,7 @@ namespace Mantid
*/
void ICat3Catalog::getDownloadURL(const long long & fileid,std::string& url)
{
CICatHelper helper;
helper.getdownloadURL(fileid,url);
m_helper->getdownloadURL(fileid,url);
}

/**This method method does the search for investigations
Expand All @@ -116,18 +106,18 @@ namespace Mantid
void ICat3Catalog::search(const CatalogSearchParam& inputs, Mantid::API::ITableWorkspace_sptr& ws_sptr,
const int &offset, const int &limit)
{
UNUSED_ARG(offset);
UNUSED_ARG(limit);
CICatHelper helper;
helper.doAdvancedSearch(inputs,ws_sptr);
m_helper->doAdvancedSearch(inputs,ws_sptr, offset, limit);
}

/**
* Modifies the search query to obtain the number
* of investigations to be returned by the catalog.
* @return The number of investigations returned by the search performed.
*/
int64_t ICat3Catalog::getNumberOfSearchResults() { return -1; }
int64_t ICat3Catalog::getNumberOfSearchResults()
{
return m_helper->getNumberOfSearchResults();
}

/// keep alive
void ICat3Catalog::keepAlive()
Expand Down

0 comments on commit 75f4f75

Please sign in to comment.