##// END OF EJS Templates
[WIP] new generic WS plugin and few other fixes...
[WIP] new generic WS plugin and few other fixes Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1352:fb8f470a1906
r1352:fb8f470a1906
Show More
AmdaProvider.cpp
88 lines | 2.8 KiB | text/x-c | CppLexer
Alexandre Leroux
Inits Amda provider
r377 #include "AmdaProvider.h"
Alexandre Leroux
Amda provider update (2)...
r413 #include "AmdaDefs.h"
Alexandre Leroux
Amda provider (3)...
r380 #include "AmdaResultParser.h"
Alexandre Leroux
Uses previous class to set url when retrieving data
r1115 #include "AmdaServer.h"
Alexandre Leroux
Amda provider (3)...
r380
Alexandre Leroux
Uses DateUtils
r488 #include <Common/DateUtils.h>
Alexandre Leroux
Amda provider (1)...
r378 #include <Data/DataProviderParameters.h>
Modify the AmdaProvider to remove from it all network controller...
r388 #include <Network/NetworkController.h>
#include <SqpApplication.h>
#include <Variable/Variable.h>
Alexandre Leroux
Amda provider (1)...
r378
#include <QNetworkAccessManager>
#include <QNetworkReply>
Alexandre Leroux
Amda provider (2)...
r379 #include <QTemporaryFile>
Modify the AmdaProvider to remove from it all network controller...
r388 #include <QThread>
Removed old IDataProvider IF, some small steps toward new VC integration...
r1351 #include <QJsonDocument>
#include <Network/Downloader.h>
Alexandre Leroux
Inits Amda provider
r377
Q_LOGGING_CATEGORY(LOG_AmdaProvider, "AmdaProvider")
Alexandre Leroux
Amda provider (1)...
r378 namespace {
/// URL format for a request on AMDA server. The parameters are as follows:
Alexandre Leroux
Updates AMDA provider to handle different server URLs...
r943 /// - %1: server URL
/// - %2: start date
/// - %3: end date
/// - %4: parameter id
Alexandre Leroux
Changes url
r790 /// AMDA V2: http://amdatest.irap.omp.eu/php/rest/
Alexandre Leroux
Amda provider (1)...
r378 const auto AMDA_URL_FORMAT = QStringLiteral(
Alexandre Leroux
Updates AMDA provider to handle different server URLs...
r943 "http://%1/php/rest/"
"getParameter.php?startTime=%2&stopTime=%3&parameterID=%4&outputFormat=ASCII&"
Alexandre Leroux
Amda provider (1)...
r378 "timeFormat=ISO8601&gzip=0");
Removed old IDataProvider IF, some small steps toward new VC integration...
r1351 const auto AMDA_URL_FORMAT_WITH_TOKEN = QStringLiteral(
"http://%1/php/rest/"
"getParameter.php?startTime=%2&stopTime=%3&parameterID=%4&outputFormat=ASCII&"
"timeFormat=ISO8601&gzip=0&"
"token=%5");
const auto AMDA_TOKEN_URL_FORMAT = QStringLiteral(
"http://%1/php/rest/"
"auth.php");
Alexandre Leroux
Amda provider (1)...
r378 /// Dates format passed in the URL (e.g 2013-09-23T09:00)
Log AMDA get url of the file and the download file
r440 const auto AMDA_TIME_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss");
Alexandre Leroux
Amda provider (1)...
r378
/// Formats a time to a date that can be passed in URL
Change SqpRange for SqpDateTime
r512 QString dateFormat(double sqpRange) noexcept
Alexandre Leroux
Amda provider (1)...
r378 {
Change SqpRange for SqpDateTime
r512 auto dateTime = DateUtils::dateTime(sqpRange);
Alexandre Leroux
Amda provider (1)...
r378 return dateTime.toString(AMDA_TIME_FORMAT);
}
Alexandre Leroux
Reads variable metadata to get the data type...
r566
Alexandre Leroux
Amda provider (1)...
r378 } // namespace
Alexandre Leroux
Amda provider cleaning...
r409 AmdaProvider::AmdaProvider()
Alexandre Leroux
Inits Amda provider
r377 {
Remove connection for progress from NC -> VC to NC -> Provider.
r425
Alexandre Leroux
Inits Amda provider
r377 }
Alexandre Leroux
Generates and registers clone provider
r712 std::shared_ptr<IDataProvider> AmdaProvider::clone() const
{
// No copy is made in the clone
return std::make_shared<AmdaProvider>();
}
Removed old IDataProvider IF, some small steps toward new VC integration...
r1351 IDataSeries* AmdaProvider::getData(const DataProviderParameters &parameters)
Alexandre Leroux
Amda provider (1)...
r378 {
[WIP] new generic WS plugin and few other fixes...
r1352 auto range = parameters.m_Range;
Removed old IDataProvider IF, some small steps toward new VC integration...
r1351 auto metaData = parameters.m_Data;
auto productId = metaData.value(AMDA_XML_ID_KEY).toString();
Alexandre Leroux
Move the AMDA data type to a type accessible from core
r1278 auto productValueType
Removed old IDataProvider IF, some small steps toward new VC integration...
r1351 = DataSeriesTypeUtils::fromString(metaData.value(AMDA_DATA_TYPE_KEY).toString());
auto startDate = dateFormat(range.m_TStart);
auto endDate = dateFormat(range.m_TEnd);
QVariantHash urlProperties{{AMDA_SERVER_KEY, metaData.value(AMDA_SERVER_KEY)}};
auto token_url = QString{AMDA_TOKEN_URL_FORMAT}.arg(AmdaServer::instance().url(urlProperties));
auto response = Downloader::get(token_url);
auto url = QString{AMDA_URL_FORMAT_WITH_TOKEN}.arg(AmdaServer::instance().url(urlProperties),
startDate, endDate, productId, QString(response.data()));
response = Downloader::get(url);
auto test = QJsonDocument::fromJson(response.data());
url = test["dataFileURLs"].toString();
response = Downloader::get(url);
return AmdaResultParser::readTxt(QTextStream{response.data()},productValueType);
Implementation of progression
r750 }