##// END OF EJS Templates
Amda provider update (1)...
Alexandre Leroux -
r412:e1f4801c4363
parent child
Show More
@@ -0,0 +1,16
1 #ifndef SCIQLOP_AMDADEFS_H
2 #define SCIQLOP_AMDADEFS_H
3
4 #include <QString>
5
6 // ////////////// //
7 // AMDA constants //
8 // ////////////// //
9
10 // Relevant keys in JSON file
11 extern const QString AMDA_COMPONENT_KEY;
12 extern const QString AMDA_PRODUCT_KEY;
13 extern const QString AMDA_ROOT_KEY;
14 extern const QString AMDA_XML_ID_KEY;
15
16 #endif // SCIQLOP_AMDADEFS_H
@@ -0,0 +1,6
1 #include "AmdaDefs.h"
2
3 const QString AMDA_COMPONENT_KEY = QStringLiteral("component");
4 const QString AMDA_PRODUCT_KEY = QStringLiteral("parameter");
5 const QString AMDA_ROOT_KEY = QStringLiteral("dataCenter");
6 const QString AMDA_XML_ID_KEY = QStringLiteral("xml:id");
@@ -1,4 +1,5
1 #include "AmdaParser.h"
1 #include "AmdaParser.h"
2 #include "AmdaDefs.h"
2
3
3 #include <DataSource/DataSourceItem.h>
4 #include <DataSource/DataSourceItem.h>
4
5
@@ -11,18 +12,13 Q_LOGGING_CATEGORY(LOG_AmdaParser, "AmdaParser")
11
12
12 namespace {
13 namespace {
13
14
14 // Significant keys of an AMDA's JSON file
15 const auto COMPONENT_KEY = QStringLiteral("component");
16 const auto PRODUCT_KEY = QStringLiteral("parameter");
17 const auto ROOT_KEY = QStringLiteral("dataCenter");
18
19 /// Returns the correct item type according to the key passed in parameter
15 /// Returns the correct item type according to the key passed in parameter
20 DataSourceItemType itemType(const QString &key) noexcept
16 DataSourceItemType itemType(const QString &key) noexcept
21 {
17 {
22 if (key == PRODUCT_KEY) {
18 if (key == AMDA_PRODUCT_KEY) {
23 return DataSourceItemType::PRODUCT;
19 return DataSourceItemType::PRODUCT;
24 }
20 }
25 else if (key == COMPONENT_KEY) {
21 else if (key == AMDA_COMPONENT_KEY) {
26 return DataSourceItemType::COMPONENT;
22 return DataSourceItemType::COMPONENT;
27 }
23 }
28 else {
24 else {
@@ -98,16 +94,16 std::unique_ptr<DataSourceItem> AmdaParser::readJson(const QString &filePath) no
98 }
94 }
99
95
100 auto jsonDocumentObject = jsonDocument.object();
96 auto jsonDocumentObject = jsonDocument.object();
101 if (!jsonDocumentObject.contains(ROOT_KEY)) {
97 if (!jsonDocumentObject.contains(AMDA_ROOT_KEY)) {
102 qCCritical(LOG_AmdaParser())
98 qCCritical(LOG_AmdaParser())
103 << QObject::tr(
99 << QObject::tr(
104 "Can't retrieve data source tree from file %1: the file is malformed (the key "
100 "Can't retrieve data source tree from file %1: the file is malformed (the key "
105 "for the root element was not found (%2))")
101 "for the root element was not found (%2))")
106 .arg(filePath, ROOT_KEY);
102 .arg(filePath, AMDA_ROOT_KEY);
107 return nullptr;
103 return nullptr;
108 }
104 }
109
105
110 auto rootValue = jsonDocumentObject.value(ROOT_KEY);
106 auto rootValue = jsonDocumentObject.value(AMDA_ROOT_KEY);
111 if (!rootValue.isObject()) {
107 if (!rootValue.isObject()) {
112 qCCritical(LOG_AmdaParser())
108 qCCritical(LOG_AmdaParser())
113 << QObject::tr(
109 << QObject::tr(
General Comments 0
You need to be logged in to leave comments. Login now