##// END OF EJS Templates
Updates AMDA provider to handle different server URLs...
Alexandre Leroux -
r943:a2f640a8dec0
parent child
Show More
@@ -17,14 +17,21 Q_LOGGING_CATEGORY(LOG_AmdaProvider, "AmdaProvider")
17
17
18 namespace {
18 namespace {
19
19
20 /// URL of the default AMDA server
21 const auto AMDA_SERVER_URL = QStringLiteral("amda.irap.omp.eu");
22
23 /// URL of the AMDA test server
24 const auto AMDA_TEST_SERVER_URL = QStringLiteral("amdatest.irap.omp.eu");
25
20 /// URL format for a request on AMDA server. The parameters are as follows:
26 /// URL format for a request on AMDA server. The parameters are as follows:
21 /// - %1: start date
27 /// - %1: server URL
22 /// - %2: end date
28 /// - %2: start date
23 /// - %3: parameter id
29 /// - %3: end date
30 /// - %4: parameter id
24 /// AMDA V2: http://amdatest.irap.omp.eu/php/rest/
31 /// AMDA V2: http://amdatest.irap.omp.eu/php/rest/
25 const auto AMDA_URL_FORMAT = QStringLiteral(
32 const auto AMDA_URL_FORMAT = QStringLiteral(
26 "http://amda.irap.omp.eu/php/rest/"
33 "http://%1/php/rest/"
27 "getParameter.php?startTime=%1&stopTime=%2&parameterID=%3&outputFormat=ASCII&"
34 "getParameter.php?startTime=%2&stopTime=%3&parameterID=%4&outputFormat=ASCII&"
28 "timeFormat=ISO8601&gzip=0");
35 "timeFormat=ISO8601&gzip=0");
29
36
30 /// Dates format passed in the URL (e.g 2013-09-23T09:00)
37 /// Dates format passed in the URL (e.g 2013-09-23T09:00)
@@ -37,6 +44,18 QString dateFormat(double sqpRange) noexcept
37 return dateTime.toString(AMDA_TIME_FORMAT);
44 return dateTime.toString(AMDA_TIME_FORMAT);
38 }
45 }
39
46
47 /// Returns the URL of the AMDA server queried for requests, depending on the type of server passed
48 /// as a parameter
49 QString serverURL(const QString &server)
50 {
51 if (server == QString{"amdatest"}) {
52 return AMDA_TEST_SERVER_URL;
53 }
54 else {
55 return AMDA_SERVER_URL;
56 }
57 }
58
40 AmdaResultParser::ValueType valueType(const QString &valueType)
59 AmdaResultParser::ValueType valueType(const QString &valueType)
41 {
60 {
42 if (valueType == QStringLiteral("scalar")) {
61 if (valueType == QStringLiteral("scalar")) {
@@ -168,6 +187,9 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
168 // scalar, vector...
187 // scalar, vector...
169 auto productValueType = valueType(data.value(AMDA_DATA_TYPE_KEY).toString());
188 auto productValueType = valueType(data.value(AMDA_DATA_TYPE_KEY).toString());
170
189
190 // Gets the server being queried to retrieve the product. It's then used to set the server URL
191 auto productServer = data.value(AMDA_SERVER_KEY).toString();
192
171 // /////////// //
193 // /////////// //
172 // Creates URL //
194 // Creates URL //
173 // /////////// //
195 // /////////// //
@@ -175,7 +197,8 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
175 auto startDate = dateFormat(dateTime.m_TStart);
197 auto startDate = dateFormat(dateTime.m_TStart);
176 auto endDate = dateFormat(dateTime.m_TEnd);
198 auto endDate = dateFormat(dateTime.m_TEnd);
177
199
178 auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(startDate, endDate, productId)};
200 auto url = QUrl{
201 QString{AMDA_URL_FORMAT}.arg(serverURL(productServer), startDate, endDate, productId)};
179 qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url;
202 qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url;
180 auto tempFile = std::make_shared<QTemporaryFile>();
203 auto tempFile = std::make_shared<QTemporaryFile>();
181
204
@@ -216,8 +239,7 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa
216
239
217 // Don't do anything if the reply was abort
240 // Don't do anything if the reply was abort
218 if (reply->error() == QNetworkReply::NoError) {
241 if (reply->error() == QNetworkReply::NoError) {
219 // AMDA v2: auto downloadFileUrl = QUrl{QString{reply->readAll()}.trimmed()};
242 auto downloadFileUrl = QUrl{QString{reply->readAll()}.trimmed()};
220 auto downloadFileUrl = QUrl{QString{reply->readAll()}};
221
243
222 qCInfo(LOG_AmdaProvider())
244 qCInfo(LOG_AmdaProvider())
223 << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl;
245 << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl;
General Comments 0
You need to be logged in to leave comments. Login now