Skip to content

Commit

Permalink
Merge branch 'feature/7866_icat_cross_platform_archive_download' into…
Browse files Browse the repository at this point in the history
… develop. Refs #7866.

Conflicts:
	Code/Mantid/Framework/ICat/src/CatalogDownloadDataFiles.cpp
  • Loading branch information
jawrainey committed Oct 16, 2013
2 parents 99d86a8 + de367a5 commit 31b13d9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace Mantid
/// get location of data file or download method
int doDownload( ICATPortBindingProxy & icat);
/// True if the extension of the file is ".raw"
bool isDataFile(const std::string& fileName);
bool isBinary(const std::string& fileName);
/// Saves the downloaded file to disc
std::string saveFiletoDisk(std::istream& rs,const std::string &fileName);
/// Saves downloaded file to local disk
Expand Down
34 changes: 16 additions & 18 deletions Code/Mantid/Framework/ICat/src/CatalogDownloadDataFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if the data archive is not accessible, it downloads the files from the data serv
#include "MantidAPI/ICatalog.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/FacilityInfo.h"

#include "MantidKernel/FileDescriptor.h"

#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPRequest.h>
Expand Down Expand Up @@ -57,7 +57,7 @@ namespace Mantid
void CatalogDownloadDataFiles::init()
{
declareProperty(new ArrayProperty<int64_t> ("FileIds"),"List of fileids to download from the data server");
declareProperty(new ArrayProperty<std::string> ("Filenames"),"List of filenames to download from the data server");
declareProperty(new ArrayProperty<std::string> ("FileNames"),"List of filenames to download from the data server");
declareProperty("DownloadPath","", "The path to save the files to download to.");
declareProperty(new ArrayProperty<std::string>("FileLocations",std::vector<std::string>(),
boost::make_shared<NullValidator>(),
Expand Down Expand Up @@ -127,8 +127,8 @@ namespace Mantid
fileLocation = catalogInfo.transformArchivePath(fileLocation);

// Can we open the file (Hence, have access to the archives?)
std::ifstream isisfile(fileLocation.c_str());
if(isisfile)
std::ifstream hasAccessToArchives(fileLocation.c_str());
if(hasAccessToArchives)
{
g_log.information() << "File (" << *fileName << ") located in archives." << std::endl;

Expand Down Expand Up @@ -160,21 +160,19 @@ namespace Mantid
/**
* Checks to see if the file to be downloaded is a datafile.
* @param fileName :: file name
* @returns true if the file is a data file
* @returns true if the file is a data file, otherwise false.
*/
bool CatalogDownloadDataFiles::isDataFile(const std::string & fileName)
bool CatalogDownloadDataFiles::isBinary(const std::string & fileName)
{
std::basic_string <char>::size_type dotIndex;
//const std::basic_string <char>::size_type npos = -1;
//find the position of .in row file
dotIndex = fileName.find_last_of (".");
std::string fextn=fileName.substr(dotIndex+1,fileName.size()-dotIndex);
std::transform(fextn.begin(),fextn.end(),fextn.begin(),tolower);

bool binary;
(!fextn.compare("raw")|| !fextn.compare("nxs")) ? binary = true : binary = false;
return binary;

// If an invalid argument is passed (which is a test), then return false.
try
{
return !FileDescriptor::isAscii(fileName);
}
catch(std::invalid_argument&)
{
return false;
}
}

/**
Expand Down Expand Up @@ -240,7 +238,7 @@ namespace Mantid

std::ios_base::openmode mode;
//if raw/nexus file open it in binary mode else ascii
isDataFile(fileName)? mode = std::ios_base::binary : mode = std::ios_base::out;
isBinary(fileName) ? mode = std::ios_base::binary : mode = std::ios_base::out;
std::ofstream ofs(filepath.c_str(), mode);
if ( ofs.rdstate() & std::ios::failbit )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ namespace MantidQt
//connect(m_uiForm.closeButton,SIGNAL(clicked()),this,SLOT(onClose()));
connect(m_uiForm.advSearchtableWidget,SIGNAL(itemDoubleClicked(QTableWidgetItem* )),
this,SLOT(investigationSelected(QTableWidgetItem* )));
connect(this,SIGNAL(error(const QString&)),parent()->parent(),SLOT(writeErrorToLogWindow(const QString& )));
connect(m_uiForm.startdatetoolButton,SIGNAL(clicked()),this,SLOT(popupCalendar()));
connect(m_uiForm.enddatetoolButton,SIGNAL(clicked()),this,SLOT(popupCalendar()));
connect(m_uiForm.helpButton,SIGNAL(clicked()),this,SLOT(helpButtonClicked()));
Expand Down
10 changes: 7 additions & 3 deletions Code/Mantid/MantidQt/MantidWidgets/src/ICatInvestigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "MantidAPI/Column.h"
#include "MantidAPI/TableRow.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/CatalogInfo.h"
#include "MantidKernel/FacilityInfo.h"

#include <QHeaderView>
#include <QDesktopServices>
Expand Down Expand Up @@ -49,8 +51,6 @@ namespace MantidQt
connect(m_uiForm.downloadButton,SIGNAL(clicked()),this,SLOT(onDownload()));
//load button clicked
connect(m_uiForm.LoadButton,SIGNAL(clicked()),this,SLOT(onLoad()));
/// send error mesages to logwindow
connect(this,SIGNAL(error(const QString&,int) ),parent()->parent(),SLOT(writeErrorToLogWindow(const QString&)));
//execute loadraw asynchronously
connect(this,SIGNAL(loadRawAsynch(const QString&,const QString&)),parent()->parent(),SLOT(executeLoadRawAsynch(const QString&,const QString& )));
//execute loadnexus asynchronously
Expand Down Expand Up @@ -541,7 +541,11 @@ namespace MantidQt
foreach(index, indexes)
{
QTableWidgetItem *item = m_uiForm.invsttableWidget->item(index.row(),1);
QString location = item->text();
Mantid::Kernel::CatalogInfo catalogInfo = Mantid::Kernel::ConfigService::Instance().getFacility().catalogInfo();
std::string loc = item->text().toStdString();
std::string transformedLoc = catalogInfo.transformArchivePath(loc);
QString location = QString::fromStdString(transformedLoc);

loadData(location);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace MantidQt
{
m_uiForm.setupUi(this);

connect(this,SIGNAL(error(const QString&)),parent()->parent(),SLOT(writeErrorToLogWindow(const QString&)));
connect(m_uiForm.myDatatableWidget,SIGNAL(itemDoubleClicked(QTableWidgetItem* )),
this,SLOT(investigationSelected(QTableWidgetItem* )));

Expand Down
1 change: 0 additions & 1 deletion Code/Mantid/MantidQt/MantidWidgets/src/ICatSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ namespace MantidQt
"background-repeat: repeat-y; width: 17px; height:20px;} ";
m_uiForm.Instrument->setStyleSheet(str);

connect(this,SIGNAL(error(const QString&)),parent()->parent(),SLOT(writeErrorToLogWindow(const QString&)));
try
{
populateInstrumentBox();
Expand Down

0 comments on commit 31b13d9

Please sign in to comment.