Skip to content

Commit

Permalink
Updated wiki of catalog algorithms. Refs #8900.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawrainey committed Feb 12, 2014
1 parent e4ceb01 commit 5a7f802
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 68 deletions.
Expand Up @@ -10,40 +10,39 @@ namespace Mantid
{
namespace ICat
{
/** CatalogDownloadDataFiles class is responsible for GetDataFile algorithms.
This algorithm gets the location string for a given file from ISIS archive file using ICat API.
If the file is not able to open from isis archive,it will call another ICat api to get the URL for the file.
Then uses POCO http methods to download over internet.
/**
CatalogDownloadDataFiles is responsible for downloading datafiles from a catalog.
Required Properties:
<UL>
<LI> Filenames - List of files to download </LI>
<LI> InputWorkspace - The name of the workspace whioch stored the last investigation search results </LI>
<LI> FileLocations - List of files with location which is downloaded </LI>
</UL>
Required Properties:
@author Sofia Antony, ISIS Rutherford Appleton Laboratory
@date 07/07/2010
Copyright &copy; 2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
<UL>
<LI> Filenames - List of files to download </LI>
<LI> InputWorkspace - The name of the workspace whioch stored the last investigation search results </LI>
<LI> FileLocations - List of files with location which is downloaded </LI>
</UL>
This file is part of Mantid.
@author Sofia Antony, ISIS Rutherford Appleton Laboratory
@date 07/07/2010
Copyright &copy; 2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This file is part of Mantid.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport CatalogDownloadDataFiles : public API::Algorithm
{
public:
Expand Down
11 changes: 6 additions & 5 deletions Code/Mantid/Framework/ICat/inc/MantidICat/CatalogGetDataFiles.h
Expand Up @@ -9,13 +9,14 @@ namespace Mantid
{
namespace ICat
{
/**CatalogGetDataFiles is a class responsible for GetInvestigation algorithm.
This algorithm does the basic search and returns the investigations record
/**
CatalogGetDataFiles obtains a list of datafiles and related information for an investigation.
Required Properties:
<UL>
<LI> InvestigationId - The id of the investigation to display</LI>
<LI> InputWorkspace - Input workspace which saved last search</LI>
<LI> OutputWorkspace - The putput workspace to store </LI>
<LI> InvestigationId - The id of the investigation to use for searching.</LI>
<LI> OutputWorkspace - The workspace to store the datafile information.</LI>
</UL>
@author Sofia Antony, ISIS Rutherford Appleton Laboratory
Expand Down
Expand Up @@ -14,10 +14,11 @@ namespace Mantid
This algorithm obtains the datasets for a given investigation record using the related ID.
Required Properties:
<UL>
<LI> InvestigationId - The id of the investigation to display</LI>
<LI> InputWorkspace - Input workspace which saved last search</LI>
<LI> OutputWorkspace - The putput workspace to store </LI>
<LI> InvestigationId - The id of the investigation to display</LI>
<LI> InputWorkspace - Input workspace which saved last search</LI>
<LI> OutputWorkspace - The putput workspace to store </LI>
</UL>
@author Sofia Antony, ISIS Rutherford Appleton Laboratory
Expand Down
Expand Up @@ -11,7 +11,7 @@ namespace Mantid
namespace ICat
{
/**
This algorithm obtains a list of instruments used from the catalog service.
This algorithm obtains a list of instruments types from the catalog.
@author Sofia Antony, STFC Rutherford Appleton Laboratory
@date 09/07/2010
Expand Down
Expand Up @@ -10,7 +10,7 @@ namespace Mantid
{

/**
This algorithm is responsible for obtaining a list of investigation types from the catalog.
This algorithm obtains a list of investigation types from the catalog.
@author Sofia Antony, STFC Rutherford Appleton Laboratory
@date 12/08/2010
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/ICat/inc/MantidICat/CatalogLogout.h
Expand Up @@ -8,7 +8,7 @@ namespace Mantid
namespace ICat
{

/** This class is responsible for disconnecting from the ICat DB .This class written as a Mantid algorithm.
/** This class is responsible for logging the user out of the catalog.
@author Sofia Antony, STFC Rutherford Appleton Laboratory
@date 23/07/2010
Expand Down
Expand Up @@ -9,8 +9,8 @@ namespace Mantid
namespace ICat
{

/** CatalogMyDataSearch is a class responsible for searching investigations of the logged in user.
* This algorithm does Icat search and returns the investigations record
/**
This algorithm obtains all of the information for the investigations the logged in user is an investigator of.
Required Properties:
<UL>
Expand Down
8 changes: 8 additions & 0 deletions Code/Mantid/Framework/ICat/inc/MantidICat/CatalogPublish.h
Expand Up @@ -11,6 +11,14 @@ namespace Mantid
/**
CatalogPublish is responsible for publishing user data to the data archive.
Required Properties:
<UL>
<LI> InvestigationNumber - The number/id of the investigation in the archives to publish the data to.</LI>
<LI> FileName - The path to the datafile to publish to the archives.</LI>
<LI> InputWorkspace - The name of the workspace to publish to the archives.</LI>
</UL>
@author Jay Rainey, ISIS Rutherford Appleton Laboratory
@date 06/12/2013
Copyright &copy; 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Expand Down
39 changes: 11 additions & 28 deletions Code/Mantid/Framework/ICat/src/CatalogDownloadDataFiles.cpp
Expand Up @@ -134,38 +134,26 @@ namespace Mantid
{
std::string extension = Poco::Path(fileName).getExtension();
std::transform(extension.begin(),extension.end(),extension.begin(),tolower);

if (extension.compare("raw") == 0 || extension.compare("nxs") == 0)
{
return true;
}
else
{
return false;
}
return (extension.compare("raw") == 0 || extension.compare("nxs") == 0);
}

/**
* Downloads file over Internet using Poco HTTPClientSession
* @param URL- URL of the file to down load
* @param fileName :: file name
* @return Full path of where file is saved to
* Downloads datafiles from the archives, and saves to the users save default directory.
* @param URL :: The URL of the file to download.
* @param fileName :: The name of the file to save to disk.
* @return The full path to the saved file.
*/
std::string CatalogDownloadDataFiles::doDownloadandSavetoLocalDrive(const std::string& URL,const std::string& fileName)
{
std::string retVal_FullPath;
std::string pathToDownloadedDatafile;

clock_t start;
//use HTTP Get method to download the data file from the server to local disk

try
{
Poco::URI uri(URL);

std::string path(uri.getPathAndQuery());
if (path.empty())
{
throw std::runtime_error("URL string is empty,ICat interface can not download the file"+fileName);
}
start=clock();

Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> certificateHandler = new Poco::Net::AcceptCertificateHandler(true);
Expand Down Expand Up @@ -198,7 +186,7 @@ namespace Mantid
}

// Save the file to local disk if no errors occurred on the IDS.
retVal_FullPath = saveFiletoDisk(responseStream,fileName);
pathToDownloadedDatafile = saveFiletoDisk(responseStream,fileName);

clock_t end=clock();
float diff = float(end - start)/CLOCKS_PER_SEC;
Expand All @@ -215,12 +203,12 @@ namespace Mantid
// However, the port the user used to download the file will be left open.
catch(Poco::Exception&) {}

return retVal_FullPath;
return pathToDownloadedDatafile;
}

/**
* Saves the input stream to a file
* @param rs :: input stream
* @param rs :: The response stream from the server, which contains the file's content.
* @param fileName :: name of the output file
* @return Full path of where file is saved to
*/
Expand All @@ -230,11 +218,7 @@ namespace Mantid
std::ios_base::openmode mode = isDataFile(fileName) ? std::ios_base::binary : std::ios_base::out;

std::ofstream ofs(filepath.c_str(), mode);
if ( ofs.rdstate() & std::ios::failbit )
{
throw Mantid::Kernel::Exception::FileError("Error on creating File",fileName);
}

if ( ofs.rdstate() & std::ios::failbit ) throw Exception::FileError("Error on creating File",fileName);
//copy the input stream to a file.
Poco::StreamCopier::copyStream(rs, ofs);

Expand All @@ -254,7 +238,6 @@ namespace Mantid
std::string CatalogDownloadDataFiles::testDownload(const std::string& URL,const std::string& fileName)
{
return doDownloadandSavetoLocalDrive(URL,fileName);

}

}
Expand Down

0 comments on commit 5a7f802

Please sign in to comment.