Introduce MyMoneyStorageMgr
AbandonedPublic

Authored by wojnilowicz on Jan 14 2018, 8:30 AM.

Details

Summary

This patch introduces MyMoneyStorageMgr class to avoid needless duplication of virtual methods in IMyMoneyStorage and IMyMoneySerialize and juggling between those two interfaces.

It's a cornerstone for getting rid of MyMoneyObjectContainer as universal cache.

Its code consists in big part from well proven MyMoneySeqAccessMgr and lends its capabilities to MyMoneyDatabaseMgr. Therefore databases now work just like xml file, i.e. read to cache, make all operations on cache and save to the file at the end of program. This brings us speed and unified code path.

MyMoneyDatabaseMgr looked like duplicate code and had a little bit different logic in two places, which shouldn't happen. That's why tests had to be heavily modified and now are probably duplicate of MyMoneySeqAccessMgr test.

If a database should be connected in real-time to KMyMoney then it's not possible at the moment and for sure shouldn't be solved as it was solved before.

Diff Detail

Repository
R261 KMyMoney
Lint
Lint Skipped
Unit
Unit Tests Skipped
wojnilowicz requested review of this revision.Jan 14 2018, 8:30 AM
wojnilowicz created this revision.
wojnilowicz planned changes to this revision.Jan 15 2018, 5:51 PM
wojnilowicz updated this revision to Diff 26769.Feb 8 2018, 3:35 PM
wojnilowicz retitled this revision from Introduce MyMoneyGenericStorage to Introduce MyMoneyStorageMgr.
wojnilowicz edited the summary of this revision. (Show Details)

I got the patch and applied it w/o problems on master. Compiling was only possible with the following patch added, though:

diff --git a/kmymoney/mymoney/storage/tests/mymoneydatabasemgr-test.cpp b/kmymone
index 1e974a72..3b7b2a9b 100644
--- a/kmymoney/mymoney/storage/tests/mymoneydatabasemgr-test.cpp
+++ b/kmymoney/mymoney/storage/tests/mymoneydatabasemgr-test.cpp
@@ -159,7 +159,7 @@ void MyMoneyStorageMgrTest::testBadConnections()
     m_sql.release();
     m_sql = std::make_unique<MyMoneyStorageSql>(m, m_url);
 //    QExplicitlySharedDataPointer <MyMoneyStorageSql> sql = m->connectToDatabas
-    QVERIFY(m_sql);
+    QVERIFY(m_sql != nullptr);
     QEXPECT_FAIL("", "Will fix when correct behaviour in this case is clear.", C
     QVERIFY(m_sql->open(m_url, QIODevice::ReadWrite) != 0);
   } catch (const MyMoneyException &e) {
@@ -215,7 +215,7 @@ void MyMoneyStorageMgrTest::testAttachDb()
         m_sql.release();
         m_sql = std::make_unique<MyMoneyStorageSql>(m, m_url);
 //        QExplicitlySharedDataPointer <MyMoneyStorageSql> sql = m->connectToDat
-        QVERIFY(m_sql);
+        QVERIFY(m_sql != nullptr);
         int openStatus = m_sql->open(m_url, QIODevice::ReadWrite);
         QCOMPARE(openStatus, 0);
         MyMoneyFile::instance()->attachStorage(m);
diff --git a/kmymoney/plugins/gnc/import/gncimporter.cpp b/kmymoney/plugins/gnc/i
index b76998c1..35d32837 100644
--- a/kmymoney/plugins/gnc/import/gncimporter.cpp
+++ b/kmymoney/plugins/gnc/import/gncimporter.cpp
@@ -37,7 +37,7 @@
 #include "viewinterface.h"
 #include "mymoneyfile.h"
 #include "mymoneyexception.h"
-#include "mymoneyseqaccessmgr.h"
+#include "mymoneystoragemgr.h"
 #include "kmymoneyglobalsettings.h"
 
 class MyMoneyStatement;

Then I ran the test set successfully. Now I have to read through the code which will take a bit of time and try it out on my data file. Will get back here once I am through with that.

Then I ran the test set successfully. Now I have to read through the code which will take a bit of time and try it out on my data file. Will get back here once I am through with that.

Sorry, I've committed it wrongly. Please test it and I will apply any changes afterwards.

wojnilowicz abandoned this revision.Feb 18 2018, 2:36 PM