@@ -17,14 +17,21 Q_LOGGING_CATEGORY(LOG_AmdaProvider, "AmdaProvider") | |||
|
17 | 17 | |
|
18 | 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 | 26 | /// URL format for a request on AMDA server. The parameters are as follows: |
|
21 |
/// - %1: s |
|
|
22 |
/// - %2: |
|
|
23 |
/// - %3: |
|
|
27 | /// - %1: server URL | |
|
28 | /// - %2: start date | |
|
29 | /// - %3: end date | |
|
30 | /// - %4: parameter id | |
|
24 | 31 | /// AMDA V2: http://amdatest.irap.omp.eu/php/rest/ |
|
25 | 32 | const auto AMDA_URL_FORMAT = QStringLiteral( |
|
26 |
"http:// |
|
|
27 |
"getParameter.php?startTime=% |
|
|
33 | "http://%1/php/rest/" | |
|
34 | "getParameter.php?startTime=%2&stopTime=%3¶meterID=%4&outputFormat=ASCII&" | |
|
28 | 35 | "timeFormat=ISO8601&gzip=0"); |
|
29 | 36 | |
|
30 | 37 | /// Dates format passed in the URL (e.g 2013-09-23T09:00) |
@@ -37,6 +44,18 QString dateFormat(double sqpRange) noexcept | |||
|
37 | 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 | 59 | AmdaResultParser::ValueType valueType(const QString &valueType) |
|
41 | 60 | { |
|
42 | 61 | if (valueType == QStringLiteral("scalar")) { |
@@ -168,6 +187,9 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
168 | 187 | // scalar, vector... |
|
169 | 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 | 194 | // Creates URL // |
|
173 | 195 | // /////////// // |
@@ -175,7 +197,8 void AmdaProvider::retrieveData(QUuid token, const SqpRange &dateTime, const QVa | |||
|
175 | 197 | auto startDate = dateFormat(dateTime.m_TStart); |
|
176 | 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 | 202 | qCInfo(LOG_AmdaProvider()) << tr("TORM AmdaProvider::retrieveData url:") << url; |
|
180 | 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 | 240 | // Don't do anything if the reply was abort |
|
218 | 241 | if (reply->error() == QNetworkReply::NoError) { |
|
219 |
|
|
|
220 | auto downloadFileUrl = QUrl{QString{reply->readAll()}}; | |
|
242 | auto downloadFileUrl = QUrl{QString{reply->readAll()}.trimmed()}; | |
|
221 | 243 | |
|
222 | 244 | qCInfo(LOG_AmdaProvider()) |
|
223 | 245 | << tr("TORM AmdaProvider::retrieveData downloadFileUrl:") << downloadFileUrl; |
General Comments 0
You need to be logged in to leave comments.
Login now