Skip to content

Commit

Permalink
Use catalogHelper and remove ICAT4 specific methods. Refs #9186.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawrainey committed Apr 2, 2014
1 parent 6b814e3 commit 17000d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 51 deletions.
Expand Up @@ -77,8 +77,6 @@ namespace Mantid
void saveInvestigations(std::vector<ICat4::xsd__anyType*> response, API::ITableWorkspace_sptr& outputws);
// Creates a search query string based on inputs provided by the user.
std::string buildSearchQuery(const CatalogSearchParam& inputs);
// Saves "DataFiles" result to output workspace.
void saveDataFiles(std::vector<ICat4::xsd__anyType*> response, API::ITableWorkspace_sptr& outputws);
// Saves "DataSets" information to the output workspace.
void saveDataSets(std::vector<ICat4::xsd__anyType*> response, API::ITableWorkspace_sptr& outputws);
// Convert a file size to human readable file format.
Expand Down
52 changes: 3 additions & 49 deletions Code/Mantid/Framework/ICat/src/ICat4/ICat4Catalog.cpp
Expand Up @@ -550,62 +550,16 @@ namespace Mantid

if (result == 0)
{
saveDataFiles(response.return_, outputws);
ns1__datafile* datafile;
auto datafiles = m_catalogHelper.castContainerType(response.return_,datafile);
m_catalogHelper.saveDataFiles(datafiles,outputws);
}
else
{
m_catalogHelper.throwErrorMessage(icat);
}
}

/**
* Saves result from "getDataFiles" to workspace.
* @param response :: result response from the catalog.
* @param outputws :: shared pointer to datasets
*/
void ICat4Catalog::saveDataFiles(std::vector<xsd__anyType*> response, API::ITableWorkspace_sptr& outputws)
{
if (outputws->getColumnNames().empty())
{
// Add rows headers to the output workspace.
outputws->addColumn("str","Name");
outputws->addColumn("str","Location");
outputws->addColumn("str","Create Time");
outputws->addColumn("long64","Id");
outputws->addColumn("long64","File size(bytes)");
outputws->addColumn("str","File size");
outputws->addColumn("str","Description");
}

std::vector<xsd__anyType*>::const_iterator iter;
for(iter = response.begin(); iter != response.end(); ++iter)
{
ns1__datafile * datafile = dynamic_cast<ns1__datafile*>(*iter);
if (datafile)
{
API::TableRow table = outputws->appendRow();
// Now add the relevant investigation data to the table.
savetoTableWorkspace(datafile->name, table);
savetoTableWorkspace(datafile->location, table);

std::string createDate = formatDateTime(*datafile->createTime, "%Y-%m-%d %H:%M:%S");
savetoTableWorkspace(&createDate, table);

savetoTableWorkspace(datafile->id, table);
savetoTableWorkspace(datafile->fileSize, table);

std::string fileSize = bytesToString(*datafile->fileSize);
savetoTableWorkspace(&fileSize, table);

if (datafile->description) savetoTableWorkspace(datafile->description, table);
}
else
{
throw std::runtime_error("ICat4Catalog::saveDataFiles expected a datafile. Please contact the Mantid development team.");
}
}
}

/**
* Returns the list of instruments.
* @param instruments :: instruments list
Expand Down

0 comments on commit 17000d9

Please sign in to comment.