@@ -31,8 +31,9 IF(BUILD_PLUGINS) | |||
|
31 | 31 | # Available values are: |
|
32 | 32 | # - "default": default AMDA server |
|
33 | 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 | 35 | # Any other value will lead to the use of the default server |
|
35 |
ADD_DEFINITIONS(-DSCIQLOP_AMDA_SERVER="d |
|
|
36 | ADD_DEFINITIONS(-DSCIQLOP_AMDA_SERVER="hybrid") | |
|
36 | 37 | |
|
37 | 38 | set(sciqlop-amda_DIR "${CMAKE_SOURCE_DIR}/plugins/amda/cmake") |
|
38 | 39 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-amda_DIR}") |
@@ -26,8 +26,9 endif | |||
|
26 | 26 | # Available values are: |
|
27 | 27 | # - "default": default AMDA server |
|
28 | 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 | 30 | # Any other value will lead to the use of the default server |
|
30 |
add_project_arguments('-DSCIQLOP_AMDA_SERVER="d |
|
|
31 | add_project_arguments('-DSCIQLOP_AMDA_SERVER="hybrid"', language : 'cpp') | |
|
31 | 32 | |
|
32 | 33 | subdir('core') |
|
33 | 34 | subdir('gui') |
@@ -26,8 +26,10 public: | |||
|
26 | 26 | |
|
27 | 27 | /// @return the name of the server |
|
28 | 28 | virtual QString name() const = 0; |
|
29 | ||
|
30 | /// @param properties used to generate url | |
|
29 | 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 | 35 | #endif // SCIQLOP_AMDASERVER_H |
@@ -180,8 +180,9 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
180 | 180 | auto startDate = dateFormat(dateTime.m_TStart); |
|
181 | 181 | auto endDate = dateFormat(dateTime.m_TEnd); |
|
182 | 182 | |
|
183 | auto url = QUrl{ | |
|
184 |
|
|
|
183 | QVariantHash urlProperties{{AMDA_SERVER_KEY, data.value(AMDA_SERVER_KEY)}}; | |
|
184 | auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(AmdaServer::instance().url(urlProperties), | |
|
185 | startDate, endDate, productId)}; | |
|
185 | 186 | qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url; |
|
186 | 187 | auto tempFile = std::make_shared<QTemporaryFile>(); |
|
187 | 188 |
@@ -1,21 +1,51 | |||
|
1 | 1 | #include "AmdaServer.h" |
|
2 | 2 | |
|
3 | #include "AmdaDefs.h" | |
|
4 | ||
|
3 | 5 | Q_LOGGING_CATEGORY(LOG_AmdaServer, "AmdaServer") |
|
4 | 6 | |
|
5 | 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 | 15 | /// Default AMDA server |
|
8 | 16 | struct AmdaDefaultServer : public AmdaServer { |
|
9 | 17 | public: |
|
10 | 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 | 26 | /// Alternative AMDA server (tests) |
|
15 | 27 | struct AmdaTestServer : public AmdaServer { |
|
16 | 28 | public: |
|
17 | 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 | 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 | 55 | if (server == QString{"amdatest"}) { |
|
26 | 56 | return std::make_unique<AmdaTestServer>(); |
|
27 | 57 | } |
|
58 | else if (server == QString{"hybrid"}) { | |
|
59 | return std::make_unique<AmdaHybridServer>(); | |
|
60 | } | |
|
28 | 61 | else { |
|
29 | 62 | if (server != QString{"default"}) { |
|
30 | 63 | qCWarning(LOG_AmdaServer()) |
General Comments 0
You need to be logged in to leave comments.
Login now