YATiSh
Yet Another TIme SHeet
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
yatishDBmysql Class Reference

Interacts with yatish tables in a MySQL/MariaDB database. More...

#include <yatishDBmysql.h>

Collaboration diagram for yatishDBmysql:
Collaboration graph
[legend]

Public Member Functions

 yatishDBmysql ()
 Mainly connects to the MySQL database specified in yatish.auth More...
 
 ~yatishDBmysql ()
 
bool IsOk ()
 
int Commit ()
 Updates slaveDB with records of masterDB where the sync field is not 'S'. More...
 
int Upload ()
 Uploads masterDB into slaveDB. More...
 
int Download ()
 Downloads slaveDB into masterDB. More...
 

Private Member Functions

bool NewTables ()
 Creates the yatish tables. More...
 
bool EmptySlaveTables ()
 Empties all yatish tables in slaveDB. More...
 
bool EmptyMasterTables ()
 Empties all yatish tables in masterDB. More...
 
bool OutdateMasterTables ()
 Sets the sync field to 'I' in all records of all yatish tables in masterDB. More...
 
bool Delete ()
 Takes care of DELETEs in yatish tables. More...
 
bool Insert ()
 Takes care of INSERTs in yatish tables with a single name column. More...
 
bool InsertProject ()
 Takes care of INSERTs in yatish_project. More...
 
bool InsertActivity ()
 Takes care of INSERTs in yatish_activity. More...
 
bool InsertTimeslot ()
 Takes care of INSERTs in yatish_timeslot. More...
 
bool Update ()
 Takes care of UPDATEs in yatish tables with a single name column. More...
 
bool UpdateProject ()
 Takes care of UPDATEs in yatish_project. More...
 
bool UpdateActivity ()
 Takes care of UPDATEs in yatish_activity. More...
 
bool UpdateTimeslot ()
 Takes care of UPDATEs in yatish_timeslot. More...
 
bool DownloadNames ()
 Downloads yatish tables with a single name column. More...
 
bool DownloadProject ()
 Downloads yatish_project. More...
 
bool DownloadActivity ()
 Downloads yatish_activity. More...
 
bool DownloadTimeslot ()
 Download yatish_timeslot. More...
 

Private Attributes

int errorCode
 

Static Private Attributes

static wxDatabase * slaveDB = nullptr
 

Additional Inherited Members

- Static Public Attributes inherited from yatishDB
static const char * tableName []
 Must be defined in the same order as enum tableID. More...
 
- Protected Member Functions inherited from yatishDB
wxDatabase * GetDatabase (const wxString &)
 Sets up a (configuration) flux using its argument then calls wxDatabase::GetDatabase(). More...
 
bool TablesOk (wxDatabase *)
 Returns false if any of the yatish table is missings. More...
 
- Static Protected Attributes inherited from yatishDB
static wxDatabase * masterDB = nullptr
 

Detailed Description

Interacts with yatish tables in a MySQL/MariaDB database.

See also
yatishDBsqlite

Definition at line 18 of file yatishDBmysql.h.

Constructor & Destructor Documentation

◆ yatishDBmysql()

yatishDBmysql::yatishDBmysql ( )

Mainly connects to the MySQL database specified in yatish.auth

(initializing private member slaveDB).

Definition at line 26 of file yatishDBmysql.cpp.

◆ ~yatishDBmysql()

yatishDBmysql::~yatishDBmysql ( )

Definition at line 115 of file yatishDBmysql.cpp.

Member Function Documentation

◆ Commit()

int yatishDBmysql::Commit ( )

Updates slaveDB with records of masterDB where the sync field is not 'S'.

Also sets the (local) sync field to 'S' when (remote) data were updated with no error.

Returns
wxDatabase error code if something went wrong (otherwise 0)

Definition at line 126 of file yatishDBmysql.cpp.

◆ Delete()

bool yatishDBmysql::Delete ( )
private

Takes care of DELETEs in yatish tables.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong
Note
We rely on the fact that the id of a record is the same in both RDBMS (cf. Insert()).

Definition at line 219 of file yatishDBmysql.cpp.

◆ Download()

int yatishDBmysql::Download ( )

Downloads slaveDB into masterDB.

Warning
Former data in masterDB (if any) are erased.
Returns
wxDatabase error code if something went wrong (otherwise 0)

Definition at line 150 of file yatishDBmysql.cpp.

◆ DownloadActivity()

bool yatishDBmysql::DownloadActivity ( )
private

Downloads yatish_activity.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 456 of file yatishDBmysql.cpp.

◆ DownloadNames()

bool yatishDBmysql::DownloadNames ( )
private

Downloads yatish tables with a single name column.

The id is also copied (we do not use local AUTO_INCREMENT). The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong
Note
This function assumes tableName was defined with "simple" tables first.
See also
DownloadProject() DownloadActivity() DownloadTimeslot()

Definition at line 282 of file yatishDBmysql.cpp.

◆ DownloadProject()

bool yatishDBmysql::DownloadProject ( )
private

Downloads yatish_project.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 371 of file yatishDBmysql.cpp.

◆ DownloadTimeslot()

bool yatishDBmysql::DownloadTimeslot ( )
private

Download yatish_timeslot.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 551 of file yatishDBmysql.cpp.

◆ EmptyMasterTables()

bool yatishDBmysql::EmptyMasterTables ( )
private

Empties all yatish tables in masterDB.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 180 of file yatishDBmysql.cpp.

◆ EmptySlaveTables()

bool yatishDBmysql::EmptySlaveTables ( )
private

Empties all yatish tables in slaveDB.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 161 of file yatishDBmysql.cpp.

◆ Insert()

bool yatishDBmysql::Insert ( )
private

Takes care of INSERTs in yatish tables with a single name column.

The id is also copied (we do not use remote AUTO_INCREMENT). The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong
Note
This function assumes tableName was defined with "simple" tables first.
See also
InsertProject() InsertActivity() InsertTimeslot()

Definition at line 250 of file yatishDBmysql.cpp.

◆ InsertActivity()

bool yatishDBmysql::InsertActivity ( )
private

Takes care of INSERTs in yatish_activity.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 427 of file yatishDBmysql.cpp.

◆ InsertProject()

bool yatishDBmysql::InsertProject ( )
private

Takes care of INSERTs in yatish_project.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 343 of file yatishDBmysql.cpp.

◆ InsertTimeslot()

bool yatishDBmysql::InsertTimeslot ( )
private

Takes care of INSERTs in yatish_timeslot.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 514 of file yatishDBmysql.cpp.

◆ IsOk()

bool yatishDBmysql::IsOk ( )
inline

Definition at line 22 of file yatishDBmysql.h.

◆ NewTables()

bool yatishDBmysql::NewTables ( )
private

Creates the yatish tables.

Warning
If any of the tables was already there, it is emptied.
Returns
false if something went wrong

Definition at line 49 of file yatishDBmysql.cpp.

◆ OutdateMasterTables()

bool yatishDBmysql::OutdateMasterTables ( )
private

Sets the sync field to 'I' in all records of all yatish tables in masterDB.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 199 of file yatishDBmysql.cpp.

◆ Update()

bool yatishDBmysql::Update ( )
private

Takes care of UPDATEs in yatish tables with a single name column.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong
Note
This function assumes tableName was defined with "simple" tables first.
We rely on the fact that the id of a record is the same in both RDBMS (cf. Insert()).
See also
UpdateProject() UpdateActivity() UpdateTimeslot()

Definition at line 314 of file yatishDBmysql.cpp.

◆ UpdateActivity()

bool yatishDBmysql::UpdateActivity ( )
private

Takes care of UPDATEs in yatish_activity.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 485 of file yatishDBmysql.cpp.

◆ UpdateProject()

bool yatishDBmysql::UpdateProject ( )
private

Takes care of UPDATEs in yatish_project.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 399 of file yatishDBmysql.cpp.

◆ UpdateTimeslot()

bool yatishDBmysql::UpdateTimeslot ( )
private

Takes care of UPDATEs in yatish_timeslot.

The error code from the wxDatabase library (if any) is stored in errorCode (private member).

Returns
false if something went wrong

Definition at line 580 of file yatishDBmysql.cpp.

◆ Upload()

int yatishDBmysql::Upload ( )

Uploads masterDB into slaveDB.

Warning
Former data in slaveDB (if any) are erased.
Returns
wxDatabase error code if something went wrong (otherwise 0)

Definition at line 138 of file yatishDBmysql.cpp.

Member Data Documentation

◆ errorCode

int yatishDBmysql::errorCode
private

Definition at line 28 of file yatishDBmysql.h.

◆ slaveDB

wxDatabase * yatishDBmysql::slaveDB = nullptr
staticprivate

Definition at line 27 of file yatishDBmysql.h.


The documentation for this class was generated from the following files: