##// END OF EJS Templates
Adds "hybrid" server mode...
Alexandre Leroux -
r1118:7dc72cc510ff
parent child
Show More
@@ -31,8 +31,9 IF(BUILD_PLUGINS)
31 # Available values are:
31 # Available values are:
32 # - "default": default AMDA server
32 # - "default": default AMDA server
33 # - "amdatest": AMDA test server
33 # - "amdatest": AMDA test server
34 # - "hybrid": use both the default server and the test server (the server used is relative to each product, according to its "server" property in the JSON file)
34 # Any other value will lead to the use of the default server
35 # Any other value will lead to the use of the default server
35 ADD_DEFINITIONS(-DSCIQLOP_AMDA_SERVER="default")
36 ADD_DEFINITIONS(-DSCIQLOP_AMDA_SERVER="hybrid")
36
37
37 set(sciqlop-amda_DIR "${CMAKE_SOURCE_DIR}/plugins/amda/cmake")
38 set(sciqlop-amda_DIR "${CMAKE_SOURCE_DIR}/plugins/amda/cmake")
38 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-amda_DIR}")
39 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-amda_DIR}")
@@ -26,8 +26,9 endif
26 # Available values are:
26 # Available values are:
27 # - "default": default AMDA server
27 # - "default": default AMDA server
28 # - "amdatest": AMDA test server
28 # - "amdatest": AMDA test server
29 # - "hybrid": use both the default server and the test server (the server used is relative to each product, according to its "server" property in the JSON file)
29 # Any other value will lead to the use of the default server
30 # Any other value will lead to the use of the default server
30 add_project_arguments('-DSCIQLOP_AMDA_SERVER="default"', language : 'cpp')
31 add_project_arguments('-DSCIQLOP_AMDA_SERVER="hybrid"', language : 'cpp')
31
32
32 subdir('core')
33 subdir('core')
33 subdir('gui')
34 subdir('gui')
@@ -26,8 +26,10 public:
26
26
27 /// @return the name of the server
27 /// @return the name of the server
28 virtual QString name() const = 0;
28 virtual QString name() const = 0;
29
30 /// @param properties used to generate url
29 /// @return the url of the server (used to retrieve data)
31 /// @return the url of the server (used to retrieve data)
30 virtual QString url() const = 0;
32 virtual QString url(const QVariantHash &properties = {}) const = 0;
31 };
33 };
32
34
33 #endif // SCIQLOP_AMDASERVER_H
35 #endif // SCIQLOP_AMDASERVER_H
@@ -180,8 +180,9 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
180 auto startDate = dateFormat(dateTime.m_TStart);
180 auto startDate = dateFormat(dateTime.m_TStart);
181 auto endDate = dateFormat(dateTime.m_TEnd);
181 auto endDate = dateFormat(dateTime.m_TEnd);
182
182
183 auto url = QUrl{
183 QVariantHash urlProperties{{AMDA_SERVER_KEY, data.value(AMDA_SERVER_KEY)}};
184 QString{AMDA_URL_FORMAT}.arg(AmdaServer::instance().url(), startDate, endDate, productId)};
184 auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(AmdaServer::instance().url(urlProperties),
185 startDate, endDate, productId)};
185 qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url;
186 qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url;
186 auto tempFile = std::make_shared<QTemporaryFile>();
187 auto tempFile = std::make_shared<QTemporaryFile>();
187
188
@@ -1,21 +1,51
1 #include "AmdaServer.h"
1 #include "AmdaServer.h"
2
2
3 #include "AmdaDefs.h"
4
3 Q_LOGGING_CATEGORY(LOG_AmdaServer, "AmdaServer")
5 Q_LOGGING_CATEGORY(LOG_AmdaServer, "AmdaServer")
4
6
5 namespace {
7 namespace {
6
8
9 /// URL of the default AMDA server
10 const auto AMDA_DEFAULT_SERVER_URL = QStringLiteral("amda.irap.omp.eu");
11
12 /// URL of the AMDA test server
13 const auto AMDA_TEST_SERVER_URL = QStringLiteral("amdatest.irap.omp.eu");
14
7 /// Default AMDA server
15 /// Default AMDA server
8 struct AmdaDefaultServer : public AmdaServer {
16 struct AmdaDefaultServer : public AmdaServer {
9 public:
17 public:
10 QString name() const override { return QStringLiteral("AMDA (default)"); }
18 QString name() const override { return QStringLiteral("AMDA (default)"); }
11 QString url() const override { return QStringLiteral("amda.irap.omp.eu"); }
19 QString url(const QVariantHash &properties) const override
20 {
21 Q_UNUSED(properties);
22 return AMDA_DEFAULT_SERVER_URL;
23 }
12 };
24 };
13
25
14 /// Alternative AMDA server (tests)
26 /// Alternative AMDA server (tests)
15 struct AmdaTestServer : public AmdaServer {
27 struct AmdaTestServer : public AmdaServer {
16 public:
28 public:
17 QString name() const override { return QStringLiteral("AMDA (test)"); }
29 QString name() const override { return QStringLiteral("AMDA (test)"); }
18 QString url() const override { return QStringLiteral("amdatest.irap.omp.eu"); }
30 QString url(const QVariantHash &properties) const override
31 {
32 Q_UNUSED(properties);
33 return AMDA_TEST_SERVER_URL;
34 }
35 };
36
37 /// Hybrid AMDA server: use both of default and test server.
38 /// The server used is relative to each product for which to retrieve url, according to its "server"
39 /// property
40 struct AmdaHybridServer : public AmdaServer {
41 public:
42 QString name() const override { return QStringLiteral("AMDA (hybrid)"); }
43 QString url(const QVariantHash &properties) const override
44 {
45 // Reads "server" property to determine which server url to use
46 auto server = properties.value(AMDA_SERVER_KEY).toString();
47 return server == QString{"amdatest"} ? AMDA_TEST_SERVER_URL : AMDA_DEFAULT_SERVER_URL;
48 }
19 };
49 };
20
50
21 /// @return an AMDA server instance created from the name of the server passed in parameter. If the
51 /// @return an AMDA server instance created from the name of the server passed in parameter. If the
@@ -25,6 +55,9 std::unique_ptr<AmdaServer> createInstance(const QString &server)
25 if (server == QString{"amdatest"}) {
55 if (server == QString{"amdatest"}) {
26 return std::make_unique<AmdaTestServer>();
56 return std::make_unique<AmdaTestServer>();
27 }
57 }
58 else if (server == QString{"hybrid"}) {
59 return std::make_unique<AmdaHybridServer>();
60 }
28 else {
61 else {
29 if (server != QString{"default"}) {
62 if (server != QString{"default"}) {
30 qCWarning(LOG_AmdaServer())
63 qCWarning(LOG_AmdaServer())
General Comments 0
You need to be logged in to leave comments. Login now