Skip to content
Snippets Groups Projects
Commit 4a18ac07 authored by Gigg, Martyn Anthony's avatar Gigg, Martyn Anthony
Browse files

Revert changes to Load that have broken the LoadTest system test

This reverts the changes to Load from commits
  - 67348e40
  - cf334a95

We need a better way for a specific loader to request that it will handle
all files that Load has found.
Refs #10061
parent 069c533e
No related branches found
No related tags found
No related merge requests found
...@@ -101,8 +101,6 @@ namespace Mantid ...@@ -101,8 +101,6 @@ namespace Mantid
API::IAlgorithm_sptr m_loader; API::IAlgorithm_sptr m_loader;
/// The name of the property that will be passed the property from our Filename /// The name of the property that will be passed the property from our Filename
std::string m_filenamePropName; std::string m_filenamePropName;
/// Indicate whether a collection of files should be loaded into a single workspace.
bool m_loadMultipleAsOne;
/// Mutex for temporary fix for #5963 /// Mutex for temporary fix for #5963
static Poco::Mutex m_mutex; static Poco::Mutex m_mutex;
}; };
......
...@@ -170,24 +170,12 @@ namespace Mantid ...@@ -170,24 +170,12 @@ namespace Mantid
// ... store it's name and version and check that all other files have loaders with the same name and version. // ... store it's name and version and check that all other files have loaders with the same name and version.
std::string name = loader->name(); std::string name = loader->name();
int version = loader->version(); int version = loader->version();
std::string ext = fileNames[0].substr(fileNames[0].find_last_of("."));
for(size_t i = 1; i < fileNames.size(); ++i) for(size_t i = 1; i < fileNames.size(); ++i)
{ {
// If it's loading into a single file, perform a cursory check on file extensions only. loader = getFileLoader(fileNames[i]);
if(dynamic_cast<MultipleFileProperty*>(loader->getPointerToProperty("Filename")) != NULL)
{ if( name != loader->name() || version != loader->version() )
if( fileNames[i].substr(fileNames[i].find_last_of(".")) != ext) throw std::runtime_error("Cannot load multiple files when more than one Loader is needed.");
{
throw std::runtime_error("Cannot load multiple files when more than one Loader is needed.");
}
}
else
{
loader = getFileLoader(fileNames[i]);
if( name != loader->name() || version != loader->version() )
throw std::runtime_error("Cannot load multiple files when more than one Loader is needed.");
}
} }
} }
...@@ -237,18 +225,11 @@ namespace Mantid ...@@ -237,18 +225,11 @@ namespace Mantid
const auto & props = loader->getProperties(); const auto & props = loader->getProperties();
for(auto it = props.begin(); it != props.end(); ++it) for(auto it = props.begin(); it != props.end(); ++it)
{ {
auto *fp = dynamic_cast<API::MultipleFileProperty*>(*it); if(auto *fp = dynamic_cast<API::FileProperty*>(*it))
auto *fp2 = dynamic_cast<API::FileProperty*>(*it);
if(fp)
{ {
m_filenamePropName = fp->name(); m_filenamePropName = fp->name();
break; break;
} }
if(fp2)
{
m_filenamePropName = fp2->name();
break;
}
} }
if(m_filenamePropName.empty()) if(m_filenamePropName.empty())
{ {
...@@ -315,7 +296,6 @@ namespace Mantid ...@@ -315,7 +296,6 @@ namespace Mantid
exts.push_back(".h5"); exts.push_back(".h5");
exts.push_back(".hd5"); exts.push_back(".hd5");
exts.push_back(".sqw"); exts.push_back(".sqw");
exts.push_back(".fits");
declareProperty(new MultipleFileProperty("Filename", exts), declareProperty(new MultipleFileProperty("Filename", exts),
"The name of the file(s) to read, including the full or relative " "The name of the file(s) to read, including the full or relative "
...@@ -343,15 +323,11 @@ namespace Mantid ...@@ -343,15 +323,11 @@ namespace Mantid
* Executes the algorithm. * Executes the algorithm.
*/ */
void Load::exec() void Load::exec()
{ {
std::vector<std::vector<std::string> > fileNames = getProperty("Filename"); std::vector<std::vector<std::string> > fileNames = getProperty("Filename");
// Test for loading as a single file if(isSingleFile(fileNames))
IAlgorithm_sptr loader = getFileLoader(fileNames[0][0]); {
m_loadMultipleAsOne = dynamic_cast<MultipleFileProperty*>(loader->getPointerToProperty("Filename")) != NULL;
if(isSingleFile(fileNames) || m_loadMultipleAsOne)
{
// This is essentially just the same code that was called before multiple files were supported. // This is essentially just the same code that was called before multiple files were supported.
loadSingleFile(); loadSingleFile();
} }
...@@ -363,7 +339,7 @@ namespace Mantid ...@@ -363,7 +339,7 @@ namespace Mantid
} }
void Load::loadSingleFile() void Load::loadSingleFile()
{ {
std::string loaderName = getPropertyValue("LoaderName"); std::string loaderName = getPropertyValue("LoaderName");
if( loaderName.empty() ) if( loaderName.empty() )
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment