Commit 6694eabb authored by Volker Krause's avatar Volker Krause
Browse files

Adapt network configuration type field to the transport API format

parent 3d7c1917
Pipeline #48202 passed with stage
in 21 seconds
......@@ -43,7 +43,7 @@ private Q_SLOTS:
const auto top = doc.object();
QVERIFY(!top.isEmpty());
QVERIFY(!top.value(QLatin1String("type")).toString().isEmpty());
QVERIFY(!top.value(QLatin1String("type")).toObject().isEmpty());
const auto tz = top.value(QLatin1String("timezone")).toString();
if (!tz.isEmpty()) {
......
......@@ -41,7 +41,7 @@ public:
~HafasMgateBackend();
void init() override;
static inline constexpr const char* type() { return "hafas_mgate"; }
static inline constexpr const char* type() { return "hafasMgate"; }
Capabilities capabilities() const override;
bool needsLocationQuery(const Location &loc, AbstractBackend::QueryType type) const override;
bool queryJourney(const JourneyRequest &request, JourneyReply *reply, QNetworkAccessManager *nam) const override;
......
......@@ -21,7 +21,7 @@ public:
~HafasQueryBackend();
void init() override;
static inline constexpr const char* type() { return "hafas_query"; }
static inline constexpr const char* type() { return "hafasQuery"; }
Capabilities capabilities() const override;
bool needsLocationQuery(const Location &loc, QueryType type) const override;
bool queryLocation(const LocationRequest &request, LocationReply *reply, QNetworkAccessManager *nam) const override;
......
......@@ -34,7 +34,7 @@ public:
OpenTripPlannerGraphQLBackend();
~OpenTripPlannerGraphQLBackend();
static inline constexpr const char* type() { return "otp_graphql"; }
static inline constexpr const char* type() { return "otpGraphQl"; }
Capabilities capabilities() const override;
bool needsLocationQuery(const Location &loc, AbstractBackend::QueryType type) const override;
bool queryJourney(const JourneyRequest &req, JourneyReply *reply, QNetworkAccessManager *nam) const override;
......
......@@ -21,7 +21,7 @@ public:
OpenTripPlannerRestBackend();
~OpenTripPlannerRestBackend();
static inline constexpr const char* type() { return "otp_rest"; }
static inline constexpr const char* type() { return "otpRest"; }
Capabilities capabilities() const override;
bool needsLocationQuery(const Location &loc, AbstractBackend::QueryType type) const override;
bool queryJourney(const JourneyRequest &req, JourneyReply *reply, QNetworkAccessManager *nam) const override;
......
......@@ -66,9 +66,9 @@ public:
void loadNetworks();
std::unique_ptr<AbstractBackend> loadNetwork(const QJsonObject &obj);
template <typename Backend, typename Backend2, typename ...Backends>
static std::unique_ptr<AbstractBackend> loadNetwork(const QString &backendType, const QJsonObject &obj);
static std::unique_ptr<AbstractBackend> loadNetwork(const QJsonObject &backendType, const QJsonObject &obj);
template <typename Backend> std::unique_ptr<AbstractBackend>
static loadNetwork(const QString &backendType, const QJsonObject &obj);
static loadNetwork(const QJsonObject &backendType, const QJsonObject &obj);
template <typename T>
static std::unique_ptr<AbstractBackend> loadNetwork(const QJsonObject &obj);
......@@ -180,33 +180,34 @@ void ManagerPrivate::loadNetworks()
std::unique_ptr<AbstractBackend> ManagerPrivate::loadNetwork(const QJsonObject &obj)
{
const auto type = obj.value(QLatin1String("type")).toString();
const auto type = obj.value(QLatin1String("type")).toObject();
// backends need to be topologically sorted according to their preference/priority here
return loadNetwork<
NavitiaBackend,
OpenTripPlannerGraphQLBackend,
OpenTripPlannerRestBackend,
DeutscheBahnBackend,
HafasMgateBackend,
HafasQueryBackend,
EfaBackend,
DeutscheBahnBackend,
GBFSBackend,
AccessibilityCloudBackend
>(type, obj);
}
template <typename Backend, typename Backend2, typename ...Backends>
std::unique_ptr<AbstractBackend> ManagerPrivate::loadNetwork(const QString &backendType, const QJsonObject &obj)
std::unique_ptr<AbstractBackend> ManagerPrivate::loadNetwork(const QJsonObject &backendType, const QJsonObject &obj)
{
if (backendType == QLatin1String(Backend::type())) {
if (backendType.value(QLatin1String(Backend::type())).toBool()) {
return loadNetwork<Backend>(obj);
}
return loadNetwork<Backend2, Backends...>(backendType, obj);
}
template <typename Backend>
std::unique_ptr<AbstractBackend> ManagerPrivate::loadNetwork(const QString &backendType, const QJsonObject &obj)
std::unique_ptr<AbstractBackend> ManagerPrivate::loadNetwork(const QJsonObject &backendType, const QJsonObject &obj)
{
if (backendType == QLatin1String(Backend::type())) {
if (backendType.value(QLatin1String(Backend::type())).toBool()) {
return ManagerPrivate::loadNetwork<Backend>(obj);
}
qCWarning(Log) << "Unknown backend type:" << backendType;
......
......@@ -109,5 +109,7 @@
"en",
"de"
],
"type": "hafas_mgate"
"type": {
"hafasMgate": true
}
}
......@@ -80,5 +80,7 @@
"de"
],
"timezone": "Europe/Vienna",
"type": "efa"
"type": {
"efa": true
}
}
......@@ -108,5 +108,7 @@
"en",
"de"
],
"type": "hafas_mgate"
"type": {
"hafasMgate": true
}
}
......@@ -109,5 +109,7 @@
"en",
"de"
],
"type": "hafas_mgate"
"type": {
"hafasMgate": true
}
}
......@@ -81,5 +81,7 @@
"de"
],
"timezone": "Europe/Vienna",
"type": "efa"
"type": {
"efa": true
}
}
......@@ -107,5 +107,7 @@
"en",
"de"
],
"type": "hafas_mgate"
"type": {
"hafasMgate": true
}
}
......@@ -110,5 +110,7 @@
"de"
],
"timezone": "Europe/Vienna",
"type": "hafas_mgate"
"type": {
"hafasMgate": true
}
}
......@@ -125,5 +125,7 @@
"en",
"de"
],
"type": "hafas_mgate"
"type": {
"hafasMgate": true
}
}
......@@ -74,5 +74,7 @@
"endpoint": "https://transportnsw.info/web/"
},
"timezone": "Australia/Sydney",
"type": "efa"
"type": {
"efa": true
}
}
......@@ -104,5 +104,7 @@
"fr",
"nl"
],
"type": "hafas_mgate"
"type": {
"hafasMgate": true
}
}
......@@ -107,5 +107,7 @@
],
"standardLocationIdentifierType": "uic"
},
"type": "hafas_query"
"type": {
"hafasQuery": true
}
}
......@@ -101,5 +101,7 @@
"en",
"de"
],
"type": "hafas_mgate"
"type": {
"hafasMgate": true
}
}
......@@ -100,5 +100,7 @@
"en",
"de"
],
"type": "hafas_mgate"
"type": {
"hafasMgate": true
}
}
......@@ -78,5 +78,7 @@
"de"
],
"timezone": "Europe/Berlin",
"type": "efa"
"type": {
"efa": true
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment