mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
refs #751, improved model writing to DB
* a pending request can be aborted when taking too long * success / directWrite flags in signals
This commit is contained in:
committed by
Roland Winklmeier
parent
ced9f5294e
commit
23ccb35ed8
@@ -77,9 +77,11 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
bool CDatastoreUtility::parseSwiftPublishResponse(const QString &jsonResponse, CAircraftModelList &publishedModels, CAircraftModelList &skippedModels, CStatusMessageList &messages)
|
||||
bool CDatastoreUtility::parseSwiftPublishResponse(const QString &jsonResponse, CAircraftModelList &publishedModels, CAircraftModelList &skippedModels, CStatusMessageList &messages, bool &directWrite)
|
||||
{
|
||||
static const CLogCategoryList cats({ CLogCategory::swiftDbWebservice()});
|
||||
directWrite = false;
|
||||
|
||||
if (jsonResponse.isEmpty())
|
||||
{
|
||||
messages.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "Empty JSON data"));
|
||||
@@ -88,7 +90,7 @@ namespace BlackMisc
|
||||
|
||||
QJsonDocument jsonDoc(QJsonDocument::fromJson(jsonResponse.toUtf8()));
|
||||
|
||||
// array of messages
|
||||
// array of messages only
|
||||
if (jsonDoc.isArray())
|
||||
{
|
||||
CStatusMessageList msgs(CStatusMessageList::fromDatabaseJson(jsonDoc.array()));
|
||||
@@ -106,7 +108,7 @@ namespace BlackMisc
|
||||
|
||||
// fully blown object
|
||||
QJsonObject json(jsonDoc.object());
|
||||
bool data = false;
|
||||
bool hasData = false;
|
||||
if (json.contains("msgs"))
|
||||
{
|
||||
QJsonValue msgJson(json.take("msgs"));
|
||||
@@ -114,10 +116,17 @@ namespace BlackMisc
|
||||
if (!msgs.isEmpty())
|
||||
{
|
||||
messages.push_back(msgs);
|
||||
data = true;
|
||||
hasData = true;
|
||||
}
|
||||
}
|
||||
|
||||
// direct write means models written, otherwise CRs
|
||||
if (json.contains("directWrite"))
|
||||
{
|
||||
QJsonValue dw(json.take("directWrite"));
|
||||
directWrite = dw.toBool(false);
|
||||
}
|
||||
|
||||
if (json.contains("publishedModels"))
|
||||
{
|
||||
QJsonValue publishedJson(json.take("publishedModels"));
|
||||
@@ -125,7 +134,7 @@ namespace BlackMisc
|
||||
if (!published.isEmpty())
|
||||
{
|
||||
publishedModels.push_back(published);
|
||||
data = true;
|
||||
hasData = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,16 +145,16 @@ namespace BlackMisc
|
||||
if (!skipped.isEmpty())
|
||||
{
|
||||
skippedModels.push_back(skipped);
|
||||
data = true;
|
||||
hasData = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!data)
|
||||
if (!hasData)
|
||||
{
|
||||
messages.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "Received response, but no JSON data"));
|
||||
}
|
||||
|
||||
return data;
|
||||
return hasData;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user