-
Notifications
You must be signed in to change notification settings - Fork 122
/
QueryRemoteFile2.cpp
56 lines (42 loc) · 1.93 KB
/
QueryRemoteFile2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "MantidAPI/RemoteJobManagerFactory.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/FacilityInfo.h"
#include "MantidKernel/ListValidator.h"
#include "MantidKernel/MandatoryValidator.h"
#include "MantidRemoteAlgorithms/QueryRemoteFile2.h"
namespace Mantid {
namespace RemoteAlgorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(QueryRemoteFile2)
using namespace Mantid::Kernel;
using namespace Mantid::API;
// A reference to the logger is provided by the base class, it is called g_log.
void QueryRemoteFile2::init() {
// Unlike most algorithms, this one doesn't deal with workspaces....
auto requireValue = boost::make_shared<MandatoryValidator<std::string>>();
// Compute Resources
std::vector<std::string> computes = Mantid::Kernel::ConfigService::Instance()
.getFacility()
.computeResources();
declareProperty("ComputeResource", "",
boost::make_shared<StringListValidator>(computes),
"The name of the remote computer to query", Direction::Input);
// The transaction ID comes from the StartRemoteTransaction algortithm
declareProperty("TransactionID", "", requireValue,
"The ID of the transaction who's files we want to list",
Direction::Input);
declareProperty(
make_unique<ArrayProperty<std::string>>("FileNames", Direction::Output),
"The names of all the files that were found");
}
void QueryRemoteFile2::exec() {
Mantid::API::IRemoteJobManager_sptr jm =
Mantid::API::RemoteJobManagerFactory::Instance().create(
getPropertyValue("ComputeResource"));
std::string tid = getPropertyValue("TransactionID");
std::vector<std::string> names = jm->queryRemoteFile(tid);
setProperty("FileNames", names);
}
} // end namespace RemoteAlgorithms
} // end namespace Mantid