##// END OF EJS Templates
Initial Pybind11 binding experiment working....
Initial Pybind11 binding experiment working. Can open an amda formatted file from Python and get few attributes from ScalarSeries. Loading module from python works. Embedding python interpreter also works. Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1316:8af4c223fdc1
r1339:98271eda8c6e
Show More
CatalogueController.cpp
574 lines | 19.2 KiB | text/x-c | CppLexer
/ core / src / Catalogue / CatalogueController.cpp
correction of merge
r1059 #include <Catalogue/CatalogueController.h>
#include <Variable/Variable.h>
#include <CatalogueDao.h>
Add retrieve events impl
r1125 #include <ComparaisonPredicate.h>
#include <CompoundPredicate.h>
#include <DBCatalogue.h>
#include <DBEvent.h>
Add Catalogue methods
r1159 #include <DBEventProduct.h>
Add retrieve events impl
r1125 #include <DBTag.h>
#include <IRequestPredicate.h>
Drop of events on a catalogue
r1230 #include <QDataStream>
correction of merge
r1059 #include <QMutex>
#include <QThread>
#include <QDir>
#include <QStandardPaths>
Q_LOGGING_CATEGORY(LOG_CatalogueController, "CatalogueController")
Fix the loading of the default database
r1126 namespace {
Add retrieve events impl
r1125
Addd save methods. Fix bug with work repository suffix handling
r1224 static QString REPOSITORY_WORK_SUFFIX = QString{"_work"};
static QString REPOSITORY_TRASH_SUFFIX = QString{"_trash"};
Add retrieve events impl
r1125 }
mperrinel
Add Catalogue methods
r1298 /**
* Possible types of an repository
*/
Add catalogue handling
r1302 enum class DBType { SYNC, WORK, TRASH };
correction of merge
r1059 class CatalogueController::CatalogueControllerPrivate {
Add Catalogue methods
r1159
correction of merge
r1059 public:
Add Catalogue methods
r1159 explicit CatalogueControllerPrivate(CatalogueController *parent) : m_Q{parent} {}
correction of merge
r1059 CatalogueDao m_CatalogueDao;
Add retrieve events impl
r1125
Add Catalogue methods
r1159 QStringList m_RepositoryList;
CatalogueController *m_Q;
Add catalogue handling
r1302 QSet<QString> m_KeysWithChanges;
store events with changes in the catalogue controller
r1237
QString eventUniqueKey(const std::shared_ptr<DBEvent> &event) const;
Add catalogue handling
r1302 QString catalogueUniqueKey(const std::shared_ptr<DBCatalogue> &catalogue) const;
store events with changes in the catalogue controller
r1237
Add Catalogue methods
r1159 void copyDBtoDB(const QString &dbFrom, const QString &dbTo);
QString toWorkRepository(QString repository);
QString toSyncRepository(QString repository);
Addd save methods. Fix bug with work repository suffix handling
r1224 void savAllDB();
void saveEvent(std::shared_ptr<DBEvent> event, bool persist = true);
void saveCatalogue(std::shared_ptr<DBCatalogue> catalogue, bool persist = true);
mperrinel
Add Catalogue methods
r1298
Add catalogue handling
r1302 std::shared_ptr<IRequestPredicate> createFinder(const QUuid &uniqId, const QString &repository,
DBType type);
correction of merge
r1059 };
CatalogueController::CatalogueController(QObject *parent)
Add Catalogue methods
r1159 : impl{spimpl::make_unique_impl<CatalogueControllerPrivate>(this)}
correction of merge
r1059 {
qCDebug(LOG_CatalogueController()) << tr("CatalogueController construction")
<< QThread::currentThread();
}
CatalogueController::~CatalogueController()
{
qCDebug(LOG_CatalogueController()) << tr("CatalogueController destruction")
<< QThread::currentThread();
}
Add Catalogue methods
r1159 QStringList CatalogueController::getRepositories() const
{
return impl->m_RepositoryList;
}
Add retrieve events impl
r1125 void CatalogueController::addDB(const QString &dbPath)
{
QDir dbDir(dbPath);
if (dbDir.exists()) {
auto dirName = dbDir.dirName();
if (std::find(impl->m_RepositoryList.cbegin(), impl->m_RepositoryList.cend(), dirName)
!= impl->m_RepositoryList.cend()) {
qCCritical(LOG_CatalogueController())
<< tr("Impossible to addDB that is already loaded");
}
if (!impl->m_CatalogueDao.addDB(dbPath, dirName)) {
qCCritical(LOG_CatalogueController())
<< tr("Impossible to addDB %1 from %2 ").arg(dirName, dbPath);
}
Fix the loading of the default database
r1126 else {
Add Catalogue methods
r1159 impl->m_RepositoryList << dirName;
impl->copyDBtoDB(dirName, impl->toWorkRepository(dirName));
Add retrieve events impl
r1125 }
}
else {
qCCritical(LOG_CatalogueController()) << tr("Impossible to addDB that not exists: ")
<< dbPath;
}
}
void CatalogueController::saveDB(const QString &destinationPath, const QString &repository)
{
if (!impl->m_CatalogueDao.saveDB(destinationPath, repository)) {
qCCritical(LOG_CatalogueController())
<< tr("Impossible to saveDB %1 from %2 ").arg(repository, destinationPath);
}
}
std::list<std::shared_ptr<DBEvent> >
CatalogueController::retrieveEvents(const QString &repository) const
{
Add Catalogue methods
r1159 QString dbDireName = repository.isEmpty() ? REPOSITORY_DEFAULT : repository;
Add retrieve events impl
r1125 auto eventsShared = std::list<std::shared_ptr<DBEvent> >{};
Add Catalogue methods
r1159 auto events = impl->m_CatalogueDao.getEvents(impl->toWorkRepository(dbDireName));
Add retrieve events impl
r1125 for (auto event : events) {
eventsShared.push_back(std::make_shared<DBEvent>(event));
}
return eventsShared;
}
std::list<std::shared_ptr<DBEvent> > CatalogueController::retrieveAllEvents() const
{
auto eventsShared = std::list<std::shared_ptr<DBEvent> >{};
for (auto repository : impl->m_RepositoryList) {
eventsShared.splice(eventsShared.end(), retrieveEvents(repository));
}
return eventsShared;
}
CatalogueController: add few basic methods + commit the one not yet implemented
r1128 std::list<std::shared_ptr<DBEvent> >
Adaptation to the shared pointers of catalogue controller
r1143 CatalogueController::retrieveEventsFromCatalogue(std::shared_ptr<DBCatalogue> catalogue) const
CatalogueController: add few basic methods + commit the one not yet implemented
r1128 {
auto eventsShared = std::list<std::shared_ptr<DBEvent> >{};
auto events = impl->m_CatalogueDao.getCatalogueEvents(*catalogue);
for (auto event : events) {
eventsShared.push_back(std::make_shared<DBEvent>(event));
}
return eventsShared;
}
Add Catalogue methods
r1159 void CatalogueController::updateEvent(std::shared_ptr<DBEvent> event)
{
Addd save methods. Fix bug with work repository suffix handling
r1224 event->setRepository(impl->toWorkRepository(event->getRepository()));
Add Catalogue methods
r1159
store events with changes in the catalogue controller
r1237 auto uniqueId = impl->eventUniqueKey(event);
Add catalogue handling
r1302 impl->m_KeysWithChanges.insert(uniqueId);
store events with changes in the catalogue controller
r1237
Add Catalogue methods
r1159 impl->m_CatalogueDao.updateEvent(*event);
}
Add missing methods
r1227 void CatalogueController::updateEventProduct(std::shared_ptr<DBEventProduct> eventProduct)
{
impl->m_CatalogueDao.updateEventProduct(*eventProduct);
}
Add Catalogue methods
r1159 void CatalogueController::removeEvent(std::shared_ptr<DBEvent> event)
{
// Remove it from both repository and repository_work
event->setRepository(impl->toWorkRepository(event->getRepository()));
impl->m_CatalogueDao.removeEvent(*event);
event->setRepository(impl->toSyncRepository(event->getRepository()));
impl->m_CatalogueDao.removeEvent(*event);
connect remove event button
r1241 impl->savAllDB();
Add Catalogue methods
r1159 }
void CatalogueController::addEvent(std::shared_ptr<DBEvent> event)
{
Adaptation to last version of catalogue controller
r1164 event->setRepository(impl->toWorkRepository(event->getRepository()));
Add Catalogue methods
r1159
Update addEvent method to handle correctly DBEventProduct creation
r1223 auto eventTemp = *event;
impl->m_CatalogueDao.addEvent(eventTemp);
Add Catalogue methods
r1159
// Call update is necessary at the creation of add Event if it has some tags or some event
// products
if (!event->getEventProducts().empty() || !event->getTags().empty()) {
Update addEvent method to handle correctly DBEventProduct creation
r1223
auto eventProductsTemp = eventTemp.getEventProducts();
auto eventProductTempUpdated = std::list<DBEventProduct>{};
for (auto eventProductTemp : eventProductsTemp) {
eventProductTemp.setEvent(eventTemp);
eventProductTempUpdated.push_back(eventProductTemp);
}
eventTemp.setEventProducts(eventProductTempUpdated);
impl->m_CatalogueDao.updateEvent(eventTemp);
Add Catalogue methods
r1159 }
Discard an added event remove it now.
r1260
Rebase fix CatalogueCatalogue
r1301 auto workPred = impl->createFinder(event->getUniqId(), event->getRepository(), DBType::WORK);
Discard an added event remove it now.
r1300
Discard an added event remove it now.
r1260 auto workEvent = impl->m_CatalogueDao.getEvent(workPred);
*event = workEvent;
Rebase fix CatalogueCatalogue
r1301
auto uniqueId = impl->eventUniqueKey(event);
Add catalogue handling
r1302 impl->m_KeysWithChanges.insert(uniqueId);
Add Catalogue methods
r1159 }
void CatalogueController::saveEvent(std::shared_ptr<DBEvent> event)
{
Addd save methods. Fix bug with work repository suffix handling
r1224 impl->saveEvent(event, true);
Add catalogue handling
r1302 impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
store events with changes in the catalogue controller
r1237 }
Discard an added event remove it now.
r1260 void CatalogueController::discardEvent(std::shared_ptr<DBEvent> event, bool &removed)
Add discard method for event
r1243 {
mperrinel
Add Catalogue methods
r1298 auto syncPred = impl->createFinder(event->getUniqId(), event->getRepository(), DBType::SYNC);
auto workPred = impl->createFinder(event->getUniqId(), event->getRepository(), DBType::WORK);
Fix bug in discard method to handle repository
r1244
auto syncEvent = impl->m_CatalogueDao.getEvent(syncPred);
Discard an added event remove it now.
r1260 if (!syncEvent.getUniqId().isNull()) {
removed = false;
impl->m_CatalogueDao.copyEvent(syncEvent, impl->toWorkRepository(event->getRepository()),
true);
auto workEvent = impl->m_CatalogueDao.getEvent(workPred);
*event = workEvent;
Add catalogue handling
r1302 impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
Discard an added event remove it now.
r1260 }
else {
removed = true;
// Since the element wasn't in sync repository. Discard it means remove it
event->setRepository(impl->toWorkRepository(event->getRepository()));
impl->m_CatalogueDao.removeEvent(*event);
}
Add discard method for event
r1243 }
store events with changes in the catalogue controller
r1237 bool CatalogueController::eventHasChanges(std::shared_ptr<DBEvent> event) const
{
Add catalogue handling
r1302 return impl->m_KeysWithChanges.contains(impl->eventUniqueKey(event));
Add Catalogue methods
r1159 }
CatalogueController: add few basic methods + commit the one not yet implemented
r1128 std::list<std::shared_ptr<DBCatalogue> >
Add Catalogue methods
r1159 CatalogueController::retrieveCatalogues(const QString &repository) const
CatalogueController: add few basic methods + commit the one not yet implemented
r1128 {
Add Catalogue methods
r1159 QString dbDireName = repository.isEmpty() ? REPOSITORY_DEFAULT : repository;
CatalogueController: add few basic methods + commit the one not yet implemented
r1128 auto cataloguesShared = std::list<std::shared_ptr<DBCatalogue> >{};
Add Catalogue methods
r1159 auto catalogues = impl->m_CatalogueDao.getCatalogues(impl->toWorkRepository(dbDireName));
CatalogueController: add few basic methods + commit the one not yet implemented
r1128 for (auto catalogue : catalogues) {
cataloguesShared.push_back(std::make_shared<DBCatalogue>(catalogue));
}
return cataloguesShared;
}
mperrinel
Add Catalogue methods
r1298 void CatalogueController::addCatalogue(std::shared_ptr<DBCatalogue> catalogue)
{
catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
auto catalogueTemp = *catalogue;
impl->m_CatalogueDao.addCatalogue(catalogueTemp);
Add catalogue handling
r1302 auto workPred
= impl->createFinder(catalogue->getUniqId(), catalogue->getRepository(), DBType::WORK);
mperrinel
Add Catalogue methods
r1298
auto workCatalogue = impl->m_CatalogueDao.getCatalogue(workPred);
*catalogue = workCatalogue;
Add catalogue handling
r1302 auto uniqueId = impl->catalogueUniqueKey(catalogue);
impl->m_KeysWithChanges.insert(uniqueId);
mperrinel
Add Catalogue methods
r1298 }
Add Catalogue methods
r1159 void CatalogueController::updateCatalogue(std::shared_ptr<DBCatalogue> catalogue)
{
Addd save methods. Fix bug with work repository suffix handling
r1224 catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
Add Catalogue methods
r1159
Add catalogue handling
r1302 auto uniqueId = impl->catalogueUniqueKey(catalogue);
impl->m_KeysWithChanges.insert(uniqueId);
mperrinel
Add Catalogue methods
r1298
Add Catalogue methods
r1159 impl->m_CatalogueDao.updateCatalogue(*catalogue);
}
void CatalogueController::removeCatalogue(std::shared_ptr<DBCatalogue> catalogue)
{
// Remove it from both repository and repository_work
catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
impl->m_CatalogueDao.removeCatalogue(*catalogue);
catalogue->setRepository(impl->toSyncRepository(catalogue->getRepository()));
impl->m_CatalogueDao.removeCatalogue(*catalogue);
mperrinel
Add Catalogue methods
r1298 impl->savAllDB();
Add Catalogue methods
r1159 }
void CatalogueController::saveCatalogue(std::shared_ptr<DBCatalogue> catalogue)
{
Addd save methods. Fix bug with work repository suffix handling
r1224 impl->saveCatalogue(catalogue, true);
Add catalogue handling
r1302 impl->m_KeysWithChanges.remove(impl->catalogueUniqueKey(catalogue));
Save a statical catalogue now remove events save gui button
r1316
// remove key of events of the catalogue
if (catalogue->getType() == CatalogueType::STATIC) {
auto events = this->retrieveEventsFromCatalogue(catalogue);
for (auto event : events) {
impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
}
}
Add catalogue handling
r1302 }
void CatalogueController::discardCatalogue(std::shared_ptr<DBCatalogue> catalogue, bool &removed)
{
auto syncPred
= impl->createFinder(catalogue->getUniqId(), catalogue->getRepository(), DBType::SYNC);
auto workPred
= impl->createFinder(catalogue->getUniqId(), catalogue->getRepository(), DBType::WORK);
auto syncCatalogue = impl->m_CatalogueDao.getCatalogue(syncPred);
if (!syncCatalogue.getUniqId().isNull()) {
removed = false;
impl->m_CatalogueDao.copyCatalogue(
syncCatalogue, impl->toWorkRepository(catalogue->getRepository()), true);
auto workCatalogue = impl->m_CatalogueDao.getCatalogue(workPred);
*catalogue = workCatalogue;
impl->m_KeysWithChanges.remove(impl->catalogueUniqueKey(catalogue));
}
else {
removed = true;
// Since the element wasn't in sync repository. Discard it means remove it
catalogue->setRepository(impl->toWorkRepository(catalogue->getRepository()));
impl->m_CatalogueDao.removeCatalogue(*catalogue);
}
Add Catalogue methods
r1159 }
void CatalogueController::saveAll()
{
for (auto repository : impl->m_RepositoryList) {
// Save Event
auto events = this->retrieveEvents(repository);
for (auto event : events) {
Addd save methods. Fix bug with work repository suffix handling
r1224 impl->saveEvent(event, false);
Add Catalogue methods
r1159 }
// Save Catalogue
auto catalogues = this->retrieveCatalogues(repository);
for (auto catalogue : catalogues) {
Addd save methods. Fix bug with work repository suffix handling
r1224 impl->saveCatalogue(catalogue, false);
Add Catalogue methods
r1159 }
}
Addd save methods. Fix bug with work repository suffix handling
r1224
impl->savAllDB();
Add catalogue handling
r1302 impl->m_KeysWithChanges.clear();
Add Catalogue methods
r1159 }
Check unsaved data on close
r1239 bool CatalogueController::hasChanges() const
{
Add catalogue handling
r1302 return !impl->m_KeysWithChanges.isEmpty();
Check unsaved data on close
r1239 }
Drop of events on a catalogue
r1230 QByteArray
CatalogueController::mimeDataForEvents(const QVector<std::shared_ptr<DBEvent> > &events) const
{
auto encodedData = QByteArray{};
QMap<QString, QVariantList> idsPerRepository;
for (auto event : events) {
idsPerRepository[event->getRepository()] << event->getUniqId();
}
QDataStream stream{&encodedData, QIODevice::WriteOnly};
stream << idsPerRepository;
return encodedData;
}
QVector<std::shared_ptr<DBEvent> >
CatalogueController::eventsForMimeData(const QByteArray &mimeData) const
{
auto events = QVector<std::shared_ptr<DBEvent> >{};
QDataStream stream{mimeData};
QMap<QString, QVariantList> idsPerRepository;
stream >> idsPerRepository;
for (auto it = idsPerRepository.cbegin(); it != idsPerRepository.cend(); ++it) {
auto repository = it.key();
auto allRepositoryEvent = retrieveEvents(repository);
for (auto uuid : it.value()) {
for (auto repositoryEvent : allRepositoryEvent) {
if (uuid.toUuid() == repositoryEvent->getUniqId()) {
events << repositoryEvent;
}
}
}
}
return events;
}
Move event in catalogue with Drag&Drop
r1308 QByteArray CatalogueController::mimeDataForCatalogues(
const QVector<std::shared_ptr<DBCatalogue> > &catalogues) const
{
auto encodedData = QByteArray{};
QMap<QString, QVariantList> idsPerRepository;
for (auto catalogue : catalogues) {
idsPerRepository[catalogue->getRepository()] << catalogue->getUniqId();
}
QDataStream stream{&encodedData, QIODevice::WriteOnly};
stream << idsPerRepository;
return encodedData;
}
QVector<std::shared_ptr<DBCatalogue> >
CatalogueController::cataloguesForMimeData(const QByteArray &mimeData) const
{
auto catalogues = QVector<std::shared_ptr<DBCatalogue> >{};
QDataStream stream{mimeData};
QMap<QString, QVariantList> idsPerRepository;
stream >> idsPerRepository;
for (auto it = idsPerRepository.cbegin(); it != idsPerRepository.cend(); ++it) {
auto repository = it.key();
auto allRepositoryCatalogues = retrieveCatalogues(repository);
for (auto uuid : it.value()) {
for (auto repositoryCatalogues : allRepositoryCatalogues) {
if (uuid.toUuid() == repositoryCatalogues->getUniqId()) {
catalogues << repositoryCatalogues;
}
}
}
}
return catalogues;
}
correction of merge
r1059 void CatalogueController::initialize()
{
Add discard method for event
r1243 qCDebug(LOG_CatalogueController()) << tr("CatalogueController init")
<< QThread::currentThread();
Fix merge problem
r1242
correction of merge
r1059 impl->m_CatalogueDao.initialize();
Fix the loading of the default database
r1126 auto defaultRepositoryLocation
= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QDir defaultRepositoryLocationDir;
if (defaultRepositoryLocationDir.mkpath(defaultRepositoryLocation)) {
defaultRepositoryLocationDir.cd(defaultRepositoryLocation);
auto defaultRepository = defaultRepositoryLocationDir.absoluteFilePath(REPOSITORY_DEFAULT);
Add fix for default repository init
r1256
Add Catalogue methods
r1159 qCInfo(LOG_CatalogueController()) << tr("Persistant data loading from: ")
<< defaultRepository;
Add fix for default repository init
r1256
QDir dbDir(defaultRepository);
impl->m_RepositoryList << REPOSITORY_DEFAULT;
if (dbDir.exists()) {
auto dirName = dbDir.dirName();
if (impl->m_CatalogueDao.addDB(defaultRepository, dirName)) {
impl->copyDBtoDB(dirName, impl->toWorkRepository(dirName));
}
}
else {
qCInfo(LOG_CatalogueController()) << tr("Initialisation of Default repository detected")
<< defaultRepository;
}
Add retrieve events impl
r1125 }
Fix the loading of the default database
r1126 else {
qCWarning(LOG_CatalogueController())
<< tr("Cannot load the persistent default repository from ")
<< defaultRepositoryLocation;
}
qCDebug(LOG_CatalogueController()) << tr("CatalogueController init END");
correction of merge
r1059 }
store events with changes in the catalogue controller
r1237 QString CatalogueController::CatalogueControllerPrivate::eventUniqueKey(
const std::shared_ptr<DBEvent> &event) const
{
return event->getUniqId().toString().append(event->getRepository());
}
Add catalogue handling
r1302 QString CatalogueController::CatalogueControllerPrivate::catalogueUniqueKey(
const std::shared_ptr<DBCatalogue> &catalogue) const
{
return catalogue->getUniqId().toString().append(catalogue->getRepository());
}
Add Catalogue methods
r1159 void CatalogueController::CatalogueControllerPrivate::copyDBtoDB(const QString &dbFrom,
const QString &dbTo)
{
Add saveEvent action
r1225 // auto cataloguesShared = std::list<std::shared_ptr<DBCatalogue> >{};
Adaptation to last version of catalogue controller
r1164 auto catalogues = m_CatalogueDao.getCatalogues(dbFrom);
Add saveEvent action
r1225 auto events = m_CatalogueDao.getEvents(dbFrom);
Add Catalogue methods
r1159 for (auto catalogue : catalogues) {
Add saveEvent action
r1225 m_CatalogueDao.copyCatalogue(catalogue, dbTo, true);
Add Catalogue methods
r1159 }
for (auto event : events) {
Add saveEvent action
r1225 m_CatalogueDao.copyEvent(event, dbTo, true);
Add Catalogue methods
r1159 }
}
QString CatalogueController::CatalogueControllerPrivate::toWorkRepository(QString repository)
{
auto syncRepository = toSyncRepository(repository);
Addd save methods. Fix bug with work repository suffix handling
r1224 return QString("%1%2").arg(syncRepository, REPOSITORY_WORK_SUFFIX);
Add Catalogue methods
r1159 }
QString CatalogueController::CatalogueControllerPrivate::toSyncRepository(QString repository)
{
auto syncRepository = repository;
if (repository.endsWith(REPOSITORY_WORK_SUFFIX)) {
syncRepository.remove(REPOSITORY_WORK_SUFFIX);
}
else if (repository.endsWith(REPOSITORY_TRASH_SUFFIX)) {
syncRepository.remove(REPOSITORY_TRASH_SUFFIX);
}
return syncRepository;
}
Addd save methods. Fix bug with work repository suffix handling
r1224
void CatalogueController::CatalogueControllerPrivate::savAllDB()
{
for (auto repository : m_RepositoryList) {
auto defaultRepositoryLocation
= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
m_CatalogueDao.saveDB(defaultRepositoryLocation, repository);
}
}
void CatalogueController::CatalogueControllerPrivate::saveEvent(std::shared_ptr<DBEvent> event,
bool persist)
{
Add saveEvent action
r1225 m_CatalogueDao.copyEvent(*event, toSyncRepository(event->getRepository()), true);
Addd save methods. Fix bug with work repository suffix handling
r1224 if (persist) {
savAllDB();
}
}
void CatalogueController::CatalogueControllerPrivate::saveCatalogue(
std::shared_ptr<DBCatalogue> catalogue, bool persist)
{
Add saveEvent action
r1225 m_CatalogueDao.copyCatalogue(*catalogue, toSyncRepository(catalogue->getRepository()), true);
Addd save methods. Fix bug with work repository suffix handling
r1224 if (persist) {
savAllDB();
}
}
mperrinel
Add Catalogue methods
r1298
Add catalogue handling
r1302 std::shared_ptr<IRequestPredicate> CatalogueController::CatalogueControllerPrivate::createFinder(
const QUuid &uniqId, const QString &repository, DBType type)
mperrinel
Add Catalogue methods
r1298 {
// update catalogue parameter
Add catalogue handling
r1302 auto uniqIdPredicate = std::make_shared<ComparaisonPredicate>(QString{"uniqId"}, uniqId,
ComparaisonOperation::EQUALEQUAL);
mperrinel
Add Catalogue methods
r1298
auto repositoryType = repository;
switch (type) {
Add catalogue handling
r1302 case DBType::SYNC:
repositoryType = toSyncRepository(repositoryType);
break;
case DBType::WORK:
repositoryType = toWorkRepository(repositoryType);
break;
case DBType::TRASH:
default:
break;
mperrinel
Add Catalogue methods
r1298 }
auto repositoryPredicate = std::make_shared<ComparaisonPredicate>(
Add catalogue handling
r1302 QString{"repository"}, repositoryType, ComparaisonOperation::EQUALEQUAL);
mperrinel
Add Catalogue methods
r1298
auto finderPred = std::make_shared<CompoundPredicate>(CompoundOperation::AND);
finderPred->AddRequestPredicate(uniqIdPredicate);
finderPred->AddRequestPredicate(repositoryPredicate);
return finderPred;
}