8 #include <QJsonDocument>
10 #include <QJsonValueRef>
11 #include <QMetaObject>
12 #include <QNetworkReply>
14 #include <QReadLocker>
15 #include <QStringBuilder>
17 #include <QWriteLocker>
33 using namespace swift::misc::db;
34 using namespace swift::misc::network;
50 Q_ASSERT_X(!entities.testFlag(CEntityFlags::DbInfoObjectEntity), Q_FUNC_INFO,
"Read info objects directly");
55 CEntityFlags::Entity allEntities = entities;
56 CEntityFlags::Entity cachedEntities = CEntityFlags::NoEntity;
57 CEntityFlags::Entity dbEntities = CEntityFlags::NoEntity;
58 CEntityFlags::Entity sharedEntities = CEntityFlags::NoEntity;
59 CEntityFlags::Entity currentEntity =
60 CEntityFlags::iterateDbEntities(allEntities);
64 const QString currentEntityName = CEntityFlags::entitiesToString(currentEntity);
68 Q_ASSERT_X(!rm.testFlag(CDbFlags::Unspecified), Q_FUNC_INFO,
"Missing retrieval mode");
69 const QString rmString = CDbFlags::flagToString(rm);
71 CDbFlags::modeToModeFlag(rm & CDbFlags::DbReadingOrShared);
72 const QString rmDbOrSharedFlagString = CDbFlags::flagToString(rmDbOrSharedFlag);
73 const bool rmDbReadingOrShared =
74 (rmDbOrSharedFlag == CDbFlags::DbReading || rmDbOrSharedFlag == CDbFlags::Shared);
75 const int currentEntityCount = this->
getCacheCount(currentEntity);
77 if (rm.testFlag(CDbFlags::Ignore) || rm.testFlag(CDbFlags::Canceled))
81 else if (rm.testFlag(CDbFlags::Cached))
89 Q_ASSERT_X(!
getBaseUrl(rmDbOrSharedFlag).isEmpty(), Q_FUNC_INFO,
"Wrong retrieval mode");
93 const bool changedUrl = this->
hasChangedUrl(currentEntity, oldUrlInfo, newUrlInfo);
96 const qint64 cacheTimestamp = cacheTs.isValid() ? cacheTs.toMSecsSinceEpoch() : -1;
97 const qint64 latestEntityTimestamp =
98 latestEntityTs.isValid() ? latestEntityTs.toMSecsSinceEpoch() : -1;
99 Q_ASSERT_X(latestEntityTimestamp >= 0, Q_FUNC_INFO,
"Missing timestamp");
100 if (!changedUrl && cacheTimestamp >= latestEntityTimestamp && cacheTimestamp >= 0 &&
101 latestEntityTimestamp >= 0)
104 cachedEntities |= currentEntity;
106 << currentEntityName << cacheTs.toString() << cacheTimestamp;
110 Q_ASSERT_X(rmDbReadingOrShared, Q_FUNC_INFO,
"Wrong retrieval mode");
111 if (rmDbOrSharedFlag == CDbFlags::DbReading) { dbEntities |= currentEntity; }
112 else if (rmDbOrSharedFlag == CDbFlags::Shared) { sharedEntities |= currentEntity; }
117 u
"Data location for '%1' changed ('%2'->'%3'), will override cache for reading '%4'")
119 << rmDbOrSharedFlagString;
123 CLogMessage(
this).
info(u
"Cache for '%1' outdated, latest entity (%2, %3), reading '%4'")
124 << currentEntityName << latestEntityTs.toString() << latestEntityTimestamp
125 << rmDbOrSharedFlagString;
131 if (!rmDbReadingOrShared)
133 CLogMessage(
this).
info(u
"No DB or shared reading for '%1', read mode is: '%2'")
134 << currentEntityName << rmString;
138 CLogMessage(
this).
info(u
"No DB info objects for '%1', read mode is: '%2'")
139 << currentEntityName << rmString;
141 if (currentEntityCount > 0)
144 << currentEntityName << currentEntityCount;
150 if (!rmDbReadingOrShared)
153 CLogMessage(
this).
info(u
"Triggered reading cache for '%1', read mode: %2")
154 << currentEntityName << rmString;
159 CLogMessage(
this).
info(u
"No info object for '%1', triggered reading cache, read mode: %2")
160 << currentEntityName << rmString;
163 cachedEntities |= currentEntity;
169 Q_ASSERT_X(rmDbReadingOrShared, Q_FUNC_INFO,
"Wrong retrieval mode");
170 if (rmDbOrSharedFlag == CDbFlags::DbReading) { dbEntities |= currentEntity; }
171 else if (rmDbOrSharedFlag == CDbFlags::Shared) { sharedEntities |= currentEntity; }
173 currentEntity = CEntityFlags::iterateDbEntities(allEntities);
177 if (cachedEntities != CEntityFlags::NoEntity)
183 if (dbEntities != CEntityFlags::NoEntity)
185 CLogMessage(
this).
info(u
"Start reading DB entities: %1") << CEntityFlags::entitiesToString(dbEntities);
190 if (sharedEntities != CEntityFlags::NoEntity)
193 << CEntityFlags::entitiesToString(sharedEntities);
199 const QDateTime &newerThan)
206 bool checkCacheTsUpfront)
208 if (entities == CEntityFlags::NoEntity) {
return CEntityFlags::NoEntity; }
209 if (checkCacheTsUpfront)
212 if (newerHeaderEntities != entities)
214 const CEntityFlags::Entity validInCacheEntities = (entities ^ newerHeaderEntities) & entities;
215 CLogMessage(
this).
info(u
"Reduced '%1' to '%2' before triggering load of shared files (still in cache)")
216 << CEntityFlags::entitiesToString(entities) << CEntityFlags::entitiesToString(newerHeaderEntities);
220 if (validInCacheEntities != CEntityFlags::NoEntity)
222 QPointer<CDatabaseReader> myself(
this);
224 if (!myself) {
return; }
226 emit this->dataRead(validInCacheEntities, CEntityFlags::ReadFinished, 0, {});
229 if (newerHeaderEntities == CEntityFlags::NoEntity) {
return CEntityFlags::NoEntity; }
230 entities = newerHeaderEntities;
239 const QDateTime &newerThan)
241 Q_ASSERT_X(mode == CDbFlags::DbReading || mode == CDbFlags::Shared, Q_FUNC_INFO,
"Wrong mode");
244 if (entities == CEntityFlags::NoEntity) {
return; }
246 QPointer<CDatabaseReader> myself(
this);
249 this->read(entities, mode, newerThan);
256 Q_ASSERT_X(nwReply, Q_FUNC_INFO,
"missing reply");
261 const QString dataFileData = nwReply->readAll();
264 if (dataFileData.isEmpty())
269 else { CDatabaseReader::stringToDatastoreResponse(dataFileData, datastoreResponse); }
271 return datastoreResponse;
279 return headerResponse;
283 QNetworkReply *nwReply)
const
285 Q_ASSERT_X(nwReply, Q_FUNC_INFO,
"Missing reply");
296 if (nwReply->error() == QNetworkReply::NoError)
304 const QString error(nwReply->errorString());
305 const QString url(nwReply->url().toString());
352 Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO,
"need single entity");
359 CEntityFlags::Entity currentEntity = CEntityFlags::iterateDbEntities(myEntities);
360 while (currentEntity != CEntityFlags::NoEntity)
363 currentEntity = CEntityFlags::iterateDbEntities(myEntities);
370 Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO,
"need single entity");
371 static const QDateTime e;
373 if (il.
isEmpty() || entity == CEntityFlags::NoEntity) {
return e; }
378 if (!info.
isValid()) {
return e; }
384 Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO,
"need single entity");
385 static const QDateTime e;
387 if (il.
isEmpty() || entity == CEntityFlags::NoEntity) {
return e; }
390 if (!info.
isValid()) {
return e; }
396 Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO,
"need single entity");
397 static const QDateTime e;
403 Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO,
"need single entity");
405 if (!cacheTs.isValid()) {
return true; }
408 if (!headerTimestamp.isValid()) {
return false; }
409 return headerTimestamp > cacheTs;
414 Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO,
"need single entity");
416 if (!cacheTs.isValid()) {
return true; }
419 if (!sharedInfoTimestamp.isValid()) {
return false; }
420 return sharedInfoTimestamp > cacheTs;
425 entities &= CEntityFlags::AllDbEntitiesNoInfoObjects;
426 CEntityFlags::Entity currentEntity = CEntityFlags::iterateDbEntities(entities);
427 CEntityFlags::Entity newerEntities = CEntityFlags::NoEntity;
428 while (currentEntity != CEntityFlags::NoEntity)
431 currentEntity = CEntityFlags::iterateDbEntities(entities);
433 return newerEntities;
438 entities &= CEntityFlags::AllDbEntitiesNoInfoObjects;
439 CEntityFlags::Entity currentEntity = CEntityFlags::iterateDbEntities(entities);
440 CEntityFlags::Entity newerEntities = CEntityFlags::NoEntity;
441 while (currentEntity != CEntityFlags::NoEntity)
444 currentEntity = CEntityFlags::iterateDbEntities(entities);
446 return newerEntities;
457 if (cachedEntities == CEntityFlags::NoEntity) {
return CEntityFlags::NoEntity; }
458 CEntityFlags::Entity emitted = CEntityFlags::NoEntity;
459 CEntityFlags::Entity cachedEntitiesToEmit = cachedEntities;
460 CEntityFlags::Entity currentCachedEntity = CEntityFlags::iterateDbEntities(cachedEntitiesToEmit);
461 while (currentCachedEntity)
464 if (!onlyIfHasData || c > 0)
466 emit this->
dataRead(currentCachedEntity, CEntityFlags::ReadFinished, c, {});
467 emitted |= currentCachedEntity;
469 currentCachedEntity = CEntityFlags::iterateDbEntities(cachedEntitiesToEmit);
477 Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO,
"Expect single entity");
479 << number << CEntityFlags::entitiesToString(entity) << res.
getUrlString()
482 res.
isRestricted() ? CEntityFlags::ReadFinishedRestricted : CEntityFlags::ReadFinished,
489 << CEntityFlags::entitiesToString(entity);
499 case CDbFlags::SharedInfoOnly:
501 default: qFatal(
"Wrong mode");
break;
508 if (oldUrl.
isEmpty()) {
return true; }
509 Q_ASSERT_X(!currentUrl.
isEmpty(), Q_FUNC_INFO,
"No base URL");
512 const QString current(currentUrl.
getFullUrl(
false));
513 return old != current;
520 QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
531 const QString fileName = nwReplyPtr->url().fileName();
532 const CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(fileName);
535 CLogMessage(
this).
info(u
"Received header for shared file of '%1' from '%2'")
577 if (!ts.isValid()) {
return false; }
578 return ts > threshold;
591 const bool overrideNewerOnly =
true;
598 return s ?
CStatusMessage(
this).
info(u
"Started reading in background from '%1' of entities: '%2'")
600 CStatusMessage(this).error(u
"Starting reading in background from '%1' of entities: '%2' failed")
620 Q_ASSERT_X(nwReply, Q_FUNC_INFO,
"Missing network reply");
621 if (nwReply && nwReply->isFinished())
631 if (!fileInfo.birthTime().isValid()) {
return false; }
632 if (!overrideNewerOnly) {
return true; }
634 const qint64 fileTs = fileInfo.birthTime().toUTC().toMSecsSinceEpoch();
636 if (!cacheDateTime.isValid()) {
return true; }
637 const qint64 cacheTs = cacheDateTime.toUTC().toMSecsSinceEpoch();
638 if (fileTs > cacheTs)
641 << fileInfo.absoluteFilePath() << cacheDateTime.toUTC().toString());
647 << fileInfo.absoluteFilePath() << cacheDateTime.toUTC().toString());
662 const QString fileName = url.fileName();
663 const CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(fileName);
664 if (CEntityFlags::isSingleEntity(entity))
673 Q_ASSERT_X(CEntityFlags::isSingleEntity(entity), Q_FUNC_INFO,
"needs single entity");
676 case CDbFlags::Shared:
return CDbInfo::entityToSharedName(entity);
677 case CDbFlags::SharedInfoOnly:
return CDbInfo::sharedInfoFileName();
679 case CDbFlags::DbReading:
return CDbInfo::entityToServiceName(entity);
685 if (!ts.isValid()) {
return {}; }
686 return ts.toUTC().toString(Qt::ISODate);
691 static const QStringList cats =
699 static const QString p(
"latestTimestamp");
705 if (!ts.isValid())
return {};
721 void CDatabaseReader::stringToDatastoreResponse(
const QString &jsonContent,
722 JsonDatastoreResponse &datastoreResponse)
724 const int status = datastoreResponse.getHttpStatusCode();
725 if (jsonContent.isEmpty())
727 static const QString errorMsg =
"Empty JSON string, status: %1, URL: '%2', load time: %3";
728 datastoreResponse.setMessage(
730 errorMsg.arg(status).arg(datastoreResponse.getUrlString(),
731 datastoreResponse.getLoadTimeStringWithStartedHint())));
736 if (jsonResponse.isEmpty())
738 if (CNetworkUtils::looksLikePhpErrorMessage(jsonContent))
740 static const QString errorMsg =
"Looks like PHP errror, status %1, URL: '%2', msg: %3";
741 const QString phpErrorMessage = CNetworkUtils::removeHtmlPartsFromPhpErrorMessage(jsonContent);
742 datastoreResponse.setMessage(
744 errorMsg.arg(status).arg(datastoreResponse.getUrlString(), phpErrorMessage)));
748 static const QString errorMsg =
"Empty JSON document, URL: '%1', load time: %2";
749 datastoreResponse.setMessage(
751 errorMsg.arg(datastoreResponse.getUrlString(),
752 datastoreResponse.getLoadTimeStringWithStartedHint())));
757 if (jsonResponse.isArray())
760 datastoreResponse.setJsonArray(jsonResponse.array());
761 datastoreResponse.setLastModifiedTimestamp(QDateTime::currentDateTimeUtc());
765 const QJsonObject responseObject(jsonResponse.object());
766 datastoreResponse.setJsonArray(responseObject[
"data"].toArray());
767 const QString ts(responseObject[
"latest"].toString());
768 datastoreResponse.setLastModifiedTimestamp(ts.isEmpty() ? QDateTime::currentDateTimeUtc() :
769 CDatastoreUtility::parseTimestamp(ts));
770 datastoreResponse.setRestricted(responseObject[
"restricted"].toBool());
782 m_arraySize = value.size();
787 static const QString s(
"DB: %1 | restricted: %2 | array: %3 | string size: %4 | content: %5");
788 return s.arg(boolToYesNo(this->isLoadedFromDb()), boolToYesNo(this->isRestricted()))
789 .arg(this->getArraySize())
791 .arg(this->getContentLengthHeader());
796 const QString fn(getUrl().getFileName());
797 return CDbInfo::sharedFileNames().contains(fn, Qt::CaseInsensitive);
802 return QStringLiteral(
"%1ms").arg(getLoadTimeMs());
807 if (m_requestStarted < 0) {
return this->getLoadTimeString(); }
808 const qint64 diff = QDateTime::currentMSecsSinceEpoch() - m_requestStarted;
809 static const QString s(
"%1 load time, started %2ms before now");
810 return s.arg(this->getLoadTimeString()).arg(diff);
815 Q_ASSERT_X(nwReply, Q_FUNC_INFO,
"Need valid reply");
816 this->setUrl(nwReply->url());
817 const QVariant started = nwReply->property(
"started");
818 if (started.isValid() && started.canConvert<qint64>())
820 const qint64 now = QDateTime::currentMSecsSinceEpoch();
821 const qint64
start = started.value<qint64>();
822 this->setLoadTimeMs(now -
start);
823 m_requestStarted =
start;
824 m_responseReceived = now;
827 const QVariant qvStatusCode = nwReply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
828 if (qvStatusCode.isValid() && qvStatusCode.canConvert<
int>()) { m_httpStatusCode = qvStatusCode.toInt(); }
830 const QDateTime lastModified = nwReply->header(QNetworkRequest::LastModifiedHeader).toDateTime();
831 const qulonglong size = nwReply->header(QNetworkRequest::ContentLengthHeader).toULongLong();
832 this->setLastModifiedTimestamp(lastModified);
833 this->setContentLengthHeader(size);
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
data::CGlobalSetup getGlobalSetup() const
Global setup.
bool hasWebDataServices() const
Web data services available?
bool isShuttingDown() const
Is application shutting down?
CWebDataServices * getWebDataServices() const
Get the web data services.
Support for threaded based reading and parsing tasks such as data files via http, or file system and ...
std::atomic_llong m_networkReplyCurrent
current bytes
static const QStringList & getLogCategories()
Log categories.
virtual void networkReplyProgress(int logId, qint64 current, qint64 max, const QUrl &url)
Network request progress.
std::atomic_int m_networkReplyProgress
Progress percentage 0...100.
void threadAssertCheck() const
Make sure everthing runs correctly in own thread.
void logNetworkReplyReceived(QNetworkReply *reply)
Network reply received, mark in m_urlReadLog.
std::atomic_llong m_networkReplyNax
max bytes
bool doWorkCheck() const
Still enabled etc.?
swift::core::db::CInfoDataReader * getDbInfoDataReader() const
DB info data reader.
swift::core::db::CInfoDataReader * getSharedInfoDataReader() const
Shared info data reader.
const swift::misc::network::CUrl & getDbRootDirectoryUrl() const
Root directory of DB.
swift::misc::network::CUrl getSharedDbDataDirectoryUrl()
Get shared DB data directory URL.
Details how to read a certain entity.
swift::misc::db::CDbFlags::DataRetrievalMode getRetrievalMode() const
Supported modes.
Value object encapsulating a list of reader configs.
CDatabaseReaderConfig findFirstOrDefaultForEntity(const swift::misc::network::CEntityFlags::Entity entities) const
Find first one matching given.
Specialized version of threaded reader for DB data.
virtual QDateTime getCacheTimestamp(swift::misc::network::CEntityFlags::Entity entity) const =0
Get cache timestamp.
virtual bool hasChangedUrl(swift::misc::network::CEntityFlags::Entity entity, swift::misc::network::CUrl &oldUrlInfo, swift::misc::network::CUrl &newUrlInfo) const =0
Changed URL, means the cache values have been read from elsewhere.
virtual void admitCaches(swift::misc::network::CEntityFlags::Entity entities)=0
Admit caches for given entities.
QDateTime getLatestSharedFileHeaderTimestamp(swift::misc::network::CEntityFlags::Entity entity) const
Header timestamp (last-modified) for shared file.
void emitAndLogDataRead(swift::misc::network::CEntityFlags::Entity entity, int number, const JsonDatastoreResponse &res)
Emit signal and log when data have been read.
swift::misc::CStatusMessageList initFromLocalResourceFiles(bool inBackground)
Init from local resource file.
swift::misc::network::CEntityFlags::Entity emitReadSignalPerSingleCachedEntity(swift::misc::network::CEntityFlags::Entity cachedEntities, bool onlyIfHasData)
Split into single entity and send dataRead signal.
HeaderResponse transformReplyIntoHeaderResponse(QNetworkReply *nwReply) const
Check if terminated or error, otherwise set header information.
static QString queryLatestTimestamp(const QDateTime &ts)
Latest timestamp query for DB.
QNetworkReply::NetworkError m_1stReplyStatus
Successful connection?
bool isSharedHeaderNewerThanCacheTimestamp(swift::misc::network::CEntityFlags::Entity entity) const
Is the file timestamp newer than cache timestamp?
swift::misc::db::CDbInfoList getSharedInfoObjects() const
Shared info list (latest data timestamps from DB web service)
virtual void cacheHasChanged(swift::misc::network::CEntityFlags::Entity entities)
Cache for given entity has changed.
virtual void networkReplyProgress(int logId, qint64 current, qint64 max, const QUrl &url)
Network request progress.
bool hasSharedInfoObjects() const
Shared info objects available?
swift::misc::CStatusMessage::StatusSeverity m_severityNoWorkingUrl
severity of message if there is no working URL
void sharedFileHeaderRead(swift::misc::network::CEntityFlags::Entity entity, const QString &fileName, bool success)
Header of shared file read.
bool hasReceivedOkReply() const
Has received Ok response from server at least once?
static QString dateTimeToDbLatestTs(const QDateTime &ts)
A newer than value understood by swift DB.
void setReplyStatus(QNetworkReply::NetworkError status, const QString &message="")
Feedback about connection status.
static const QStringList & getLogCategories()
Log categories.
virtual int getCacheCount(swift::misc::network::CEntityFlags::Entity entity) const =0
Cache`s number of entities.
void entityDownloadProgress(swift::misc::network::CEntityFlags::Entity entity, int logId, int progress, qint64 current, qint64 max, const QUrl &url)
Download progress for an entity.
QDateTime getLatestEntityTimestampFromSharedInfoObjects(swift::misc::network::CEntityFlags::Entity entity) const
Obtain latest object timestamp from shared info objects.
QReadWriteLock m_statusLock
Lock.
JsonDatastoreResponse transformReplyIntoDatastoreResponse(QNetworkReply *nwReply) const
Check if terminated or error, otherwise split into array of objects.
bool hasSharedFileHeader(const swift::misc::network::CEntityFlags::Entity entity) const
Header of shared file read (for single entity)?
QDateTime getLatestEntityTimestampFromDbInfoObjects(swift::misc::network::CEntityFlags::Entity entity) const
Obtain latest object timestamp from DB info objects.
void logNoWorkingUrl(swift::misc::network::CEntityFlags::Entity entity)
Log if no working URL exists, using m_noWorkingUrlSeverity.
bool supportsAnyOfEntities(swift::misc::network::CEntityFlags::Entity entities) const
Is any of the given entities supported here by this reader.
QString getSupportedEntitiesAsString() const
Supported entities as string.
void swiftDbDataRead(bool success)
DB have been read.
bool hasDbInfoObjects() const
DB info objects available?
swift::misc::network::CEntityFlags::Entity getEntitesWithNewerHeaderTimestamp(swift::misc::network::CEntityFlags::Entity entities) const
Those entities where the timestamp of the header is newer than the cache timestamp.
swift::misc::network::CEntityFlags::Entity getEntitesWithNewerSharedInfoObject(swift::misc::network::CEntityFlags::Entity entities) const
Those entities where the timestamp of a shared info object is newer than the cache timestamp.
CDatabaseReaderConfig getConfigForEntity(swift::misc::network::CEntityFlags::Entity entity) const
Config for given entity.
QMap< swift::misc::network::CEntityFlags::Entity, HeaderResponse > m_sharedFileResponses
file responses of the shared files
void receivedSharedFileHeader(QNetworkReply *nwReplyPtr)
Received a reply of a header for a shared file.
swift::misc::network::CEntityFlags::Entity maskBySupportedEntities(swift::misc::network::CEntityFlags::Entity entities) const
Mask by supported entities.
swift::misc::network::CEntityFlags::Entity triggerLoadingDirectlyFromSharedFiles(swift::misc::network::CEntityFlags::Entity entities, bool checkCacheTsUpfront)
Start loading from shared files in own thread.
bool hasSharedFileHeaders(const swift::misc::network::CEntityFlags::Entity entities) const
Headers of shared file read (for single entity)?
bool hasReceivedFirstReply() const
Has received 1st reply?
bool overrideCacheFromFile(bool overrideNewerOnly, const QFileInfo &fileInfo, swift::misc::network::CEntityFlags::Entity entity, swift::misc::CStatusMessageList &msgs) const
Override cache from file.
virtual swift::misc::network::CUrl getDbServiceBaseUrl() const =0
Get the service URL, individual for each reader.
static const QString & parameterLatestTimestamp()
Name of latest timestamp.
static const swift::misc::network::CUrl & getDbUrl()
DB base URL.
swift::misc::db::CDbInfoList getDbInfoObjects() const
DB Info list (latest data timestamps from DB web service)
QString m_statusMessage
Returned status message from watchdog.
void startReadFromBackendInBackgroundThread(swift::misc::network::CEntityFlags::Entity entities, swift::misc::db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan=QDateTime())
Start reading in own thread (without config/caching)
virtual bool readFromJsonFilesInBackground(const QString &dir, swift::misc::network::CEntityFlags::Entity whatToRead, bool overrideNewer)=0
Data read from local data.
virtual swift::misc::network::CEntityFlags::Entity getSupportedEntities() const =0
Supported entities by this reader.
swift::misc::network::CUrl getBaseUrl(swift::misc::db::CDbFlags::DataRetrievalModeFlag mode) const
Base URL for mode (either a shared or DB URL)
void dataRead(swift::misc::network::CEntityFlags::Entity entities, swift::misc::network::CEntityFlags::ReadState state, int number, const QUrl &url)
Combined read signal.
virtual swift::misc::CStatusMessageList readFromJsonFiles(const QString &dir, swift::misc::network::CEntityFlags::Entity whatToRead, bool overrideNewer)=0
Data read from local data.
CDatabaseReaderConfigList m_config
DB reder configuration.
bool setHeaderInfoPart(HeaderResponse &headerResponse, QNetworkReply *nwReply) const
Set the header part.
static bool isChangedUrl(const swift::misc::network::CUrl &oldUrl, const swift::misc::network::CUrl ¤tUrl)
Has URL been changed? Means we load from a different server.
static QString fileNameForMode(swift::misc::network::CEntityFlags::Entity entity, swift::misc::db::CDbFlags::DataRetrievalModeFlag mode)
File name for given mode, either php service or shared file name.
CDatabaseReader::JsonDatastoreResponse setStatusAndTransformReplyIntoDatastoreResponse(QNetworkReply *nwReply)
Check if terminated or error, otherwise split into array of objects.
void readInBackgroundThread(swift::misc::network::CEntityFlags::Entity entities, const QDateTime &newerThan)
Start reading in own thread.
bool m_1stReplyReceived
Successful connection? Does not mean data / authorizations are correct.
swift::misc::network::CEntityFlags::Entity triggerLoadingDirectlyFromDb(swift::misc::network::CEntityFlags::Entity entities, const QDateTime &newerThan)
Start loading from DB in own thread.
const QString & getStatusMessage() const
Status message (error message)
void logParseMessage(const QString &entity, int size, int msElapsed, const JsonDatastoreResponse &response) const
Parsing info message.
bool isSharedInfoObjectNewerThanCacheTimestamp(swift::misc::network::CEntityFlags::Entity entity) const
Is the shared info timestamp newer than cache timestamp?
bool hasCacheTimestampNewerThan(swift::misc::network::CEntityFlags::Entity entity, const QDateTime &threshold) const
Has entity a valid and newer timestamp.
void receivedSharedFileHeaderNonClosing(QNetworkReply *nwReplyPtr)
Received a reply of a header for a shared file.
static QJsonDocument databaseJsonToQJsonDocument(const QString &content)
Database JSON from content string, which can be compressed.
swift::misc::db::CDbInfoList getInfoObjects() const
Get info list (either shared or from DB)
void start(QThread::Priority priority=QThread::InheritPriority)
Starts a thread and moves the worker into it.
static const QString & webservice()
Webservice.
static const QString & swiftDbWebservice()
Webservice with swift DB.
Class for emitting a log message.
static void preformatted(const CStatusMessage &statusMessage)
Sends a verbatim, preformatted message to the log.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
void push_back(const T &value)
Appends an element at the end of the sequence.
bool isEmpty() const
Synonym for empty.
Streamable status message, e.g.
constexpr static auto SeverityError
Status severities.
Status messages, e.g. from Core -> GUI.
Locations of important directories for swift files.
static const QString & staticDbFilesDirectory()
Where static DB files are located.
static QString currentThreadInfo()
Info about current thread, for debug messages.
static bool isInThisThread(const QObject *toBeTested)
Is the current thread the object's thread?
bool isAbandoned() const
For the task to check whether it can finish early.
QDateTime getUtcTimestamp() const
Get timestamp.
DataRetrievalModeFlag
Which data to read, requires corresponding readers.
Info about the latest models.
bool isValid() const
Valid?
Value object encapsulating a list of info objects.
CDbInfo findFirstByEntityOrDefault(swift::misc::network::CEntityFlags::Entity entity) const
Find by entity.
QString toQString(bool i18n=false) const
Cast as QString.
What and state of reading from web services.
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
bool isEmpty() const
Empty.
CUrl withAppendedPath(const QString &path) const
Append path.
const QString & getHost() const
Get host.
QString getFullUrl(bool withQuery=true) const
Qualified name.
Core data traits (aka cached values) and classes.
Classes interacting with the swift database (aka "datastore").
Backend services of the swift project, like dealing with the network or the simulators.
Free functions in swift::misc.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...
Response from our database (depending on JSON DB backend generates)
bool isRestricted() const
Incremental data, restricted by query?
QString toQString() const
String info.
void setJsonArray(const QJsonArray &value)
Set the JSON array.
bool isLoadedFromDb() const
Is loaded from database.
void setStringSize(int size)
Set string size.