refs #748, fixed airport JSON bugs and removed workaround

* removed workaround in web data services
* removed convertFromDatabaseJson functions, not needed
* changed to use the correct static fromDatabaseJson functions
* fixed prefixes
* load correct Country object by loading it as nested object
* key and timestamp was missing in CAirport tuple metadata
This commit is contained in:
Klaus Basan
2016-10-18 04:35:24 +02:00
parent 34d74904ff
commit b8d323226f
8 changed files with 39 additions and 73 deletions

View File

@@ -21,7 +21,7 @@ namespace BlackCore
{
namespace Db
{
CAirportDataReader::CAirportDataReader(QObject* parent, const CDatabaseReaderConfigList &config) :
CAirportDataReader::CAirportDataReader(QObject *parent, const CDatabaseReaderConfigList &config) :
CDatabaseReader(parent, config, QStringLiteral("CAirportDataReader"))
{
// void
@@ -65,7 +65,7 @@ namespace BlackCore
void CAirportDataReader::ps_parseAirportData(QNetworkReply *nwReply)
{
CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply);
const CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply);
if (res.hasErrorMessage())
{
CLogMessage::preformatted(res.lastWarningOrAbove());
@@ -74,29 +74,26 @@ namespace BlackCore
}
CAirportList airports;
if (res.isRestricted())
{
airports = this->getAirports();
CAirportList updates;
updates.convertFromDatabaseJson(res);
CAirportList updates(CAirportList::fromDatabaseJson(res));
airports.replaceOrAddObjectsByKey(updates);
}
else
{
airports.convertFromDatabaseJson(res);
airports = CAirportList::fromDatabaseJson(res);
}
int size = airports.size();
qint64 timestamp = lastModifiedMsSinceEpoch(nwReply);
if (size > 0 && timestamp < 0)
const int size = airports.size();
qint64 latestTimestamp = airports.latestTimestampMsecsSinceEpoch();
if (size > 0 && latestTimestamp < 0)
{
CLogMessage(this).error("No timestamp in airport list, setting to last modified value");
timestamp = lastModifiedMsSinceEpoch(nwReply);
latestTimestamp = lastModifiedMsSinceEpoch(nwReply);
}
m_airportCache.set(airports, timestamp);
m_airportCache.set(airports, latestTimestamp);
emit dataRead(CEntityFlags::AirportEntity, CEntityFlags::ReadFinished, airports.size());
}

View File

@@ -45,11 +45,11 @@ namespace BlackCore
//! \copydoc BlackCore::Db::CDatabaseReader::getCacheTimestamp()
QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entities) const override;
//! \copydoc BlackCore::Db::CDatabaseReader:;getCacheCount()
//! \copydoc BlackCore::Db::CDatabaseReader::getCacheCount()
int getCacheCount(BlackMisc::Network::CEntityFlags::Entity entity) const override;
protected:
//! \copydoc BlackCore::Db::CDatabaseReader::syncronizeCaches()
//! \copydoc BlackCore::Db::CDatabaseReader::synchronizeCaches()
void synchronizeCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
//! \copydoc BlackCore::Db::CDatabaseReader::invalidateCaches()

View File

@@ -756,9 +756,8 @@ namespace BlackCore
CLogMessage(cats).info("Read data %1 entries: %2 state: %3") << CEntityFlags::flagToString(entity) << number << CEntityFlags::flagToString(state);
}
//! \todo adjust value when airports are ready
this->m_swiftDbEntitiesRead |= entity;
if (((static_cast<int>(this->m_swiftDbEntitiesRead)) & static_cast<int>(CEntityFlags::AllDbEntitiesNoInfoObjectsNoAirports)) > 0)
if (((static_cast<int>(this->m_swiftDbEntitiesRead)) & static_cast<int>(CEntityFlags::AllDbEntities)) > 0)
{
emit allSwiftDbDataRead();
}