Ref T24, preparations to read dbinfo.json for shared files

This will replace http header file timestamps
* read function in info reader has retrieval mode flag, unused parameters removed
* waitForDbInfoObjects/getDbInfoDataReader (added "Db"), there will be a 2nd reader
* CWebReaderFlags::DbInfoDataReader (added "Db")
* removed ps_read, only read (public)
This commit is contained in:
Klaus Basan
2017-04-20 02:26:21 +02:00
parent 65f4d1f9e2
commit 485c95101b
7 changed files with 79 additions and 97 deletions

View File

@@ -269,8 +269,8 @@ namespace BlackCore
{
static const CDbInfoList e;
if (!sApp->hasWebDataServices()) { return e; }
if (!sApp->getWebDataServices()->getInfoDataReader()) { return e; }
return sApp->getWebDataServices()->getInfoDataReader()->getDbInfoObjects();
if (!sApp->getWebDataServices()->getDbInfoDataReader()) { return e; }
return sApp->getWebDataServices()->getDbInfoDataReader()->getDbInfoObjects();
}
bool CDatabaseReader::hasInfoObjects() const

View File

@@ -91,37 +91,17 @@ namespace BlackCore
return sApp->getGlobalSetup().getDbInfoReaderUrl();
}
void CInfoDataReader::read(CEntityFlags::Entity entities, const QDateTime &newerThan)
void CInfoDataReader::read()
{
this->ps_read(entities, CDbFlags::DbReading, newerThan);
}
void CInfoDataReader::ps_read(CEntityFlags::Entity entities, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
{
Q_UNUSED(mode);
CEntityFlags::Entity triggeredRead = CEntityFlags::NoEntity;
CUrl url(getInfoObjectsUrl());
if (entities.testFlag(CEntityFlags::InfoObjectEntity))
const CUrl url(getDbInfoObjectsUrl());
if (!url.isEmpty())
{
if (!url.isEmpty())
{
if (!newerThan.isNull())
{
const QString tss(newerThan.toString(Qt::ISODate));
url.appendQuery(QString(parameterLatestTimestamp() + "=" + tss));
}
sApp->getFromNetwork(url, { this, &CInfoDataReader::ps_parseInfoObjectsData});
triggeredRead |= CEntityFlags::InfoObjectEntity;
}
else
{
CLogMessage(this).error("No URL for %1") << CEntityFlags::flagToString(CEntityFlags::InfoObjectEntity);
}
sApp->getFromNetwork(url, { this, &CInfoDataReader::ps_parseInfoObjectsData});
emit dataRead(CEntityFlags::InfoObjectEntity, CEntityFlags::StartRead, 0);
}
if (triggeredRead != CEntityFlags::NoEntity)
else
{
emit dataRead(triggeredRead, CEntityFlags::StartRead, 0);
CLogMessage(this).error("No URL for %1") << CEntityFlags::flagToString(CEntityFlags::InfoObjectEntity);
}
}
@@ -153,7 +133,7 @@ namespace BlackCore
this->emitAndLogDataRead(CEntityFlags::InfoObjectEntity, n, res);
}
CUrl CInfoDataReader::getInfoObjectsUrl() const
CUrl CInfoDataReader::getDbInfoObjectsUrl() const
{
return getBaseUrl(CDbFlags::DbReading).withAppendedPath("jsondbinfo.php");
}

View File

@@ -46,19 +46,18 @@ namespace BlackCore
bool areAllDataRead() const;
//! URL info objects web service
BlackMisc::Network::CUrl getInfoObjectsUrl() const;
BlackMisc::Network::CUrl getDbInfoObjectsUrl() const;
// cache handling for base class
//! Allow to call directly, special for info objects reader
void read();
// cache handling for base class: no cache handling here in that case
virtual BlackMisc::Network::CEntityFlags::Entity getSupportedEntities() const override;
virtual QDateTime getCacheTimestamp(BlackMisc::Network::CEntityFlags::Entity entity) const override;
virtual int getCacheCount(BlackMisc::Network::CEntityFlags::Entity entity) const override;
virtual void synchronizeCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
virtual void admitCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
public slots:
//! Allow to call CInfoDataReader::ps_read directly, special for info objects
void read(BlackMisc::Network::CEntityFlags::Entity entities = BlackMisc::Network::CEntityFlags::InfoObjectEntity, const QDateTime &newerThan = QDateTime());
protected:
// cache handling for base class
virtual void invalidateCaches(BlackMisc::Network::CEntityFlags::Entity entities) override;
@@ -69,10 +68,6 @@ namespace BlackCore
//! Info objects have been read
void ps_parseInfoObjectsData(QNetworkReply *nwReply);
//! Read / re-read data file
void ps_read(BlackMisc::Network::CEntityFlags::Entity entities = BlackMisc::Network::CEntityFlags::InfoObjectEntity,
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode = BlackMisc::Db::CDbFlags::DbReading, const QDateTime &newerThan = QDateTime());
private:
BlackMisc::Db::CDbInfoList m_infoObjects;
BlackMisc::Network::CUrl m_urlInfoObjects;