39 #include "gnc-sql-connection.hpp" 40 #include "gnc-sql-backend.hpp" 41 #include "gnc-sql-object-backend.hpp" 42 #include "gnc-sql-column-table-entry.hpp" 46 #define _GNC_MOD_NAME GNC_ID_JOB 48 G_GNUC_UNUSED
static QofLogModule log_module =
G_LOG_DOMAIN;
50 #define TABLE_NAME "jobs" 51 #define TABLE_VERSION 1 53 #define MAX_ID_LEN 2048 54 #define MAX_NAME_LEN 2048 55 #define MAX_REFERENCE_LEN 2048 57 static EntryVec col_table
59 gnc_sql_make_table_entry<CT_GUID>(
"guid", 0, COL_NNUL | COL_PKEY,
"guid"),
60 gnc_sql_make_table_entry<CT_STRING>(
"id", MAX_ID_LEN, COL_NNUL,
62 gnc_sql_make_table_entry<CT_STRING>(
"name", MAX_NAME_LEN, COL_NNUL,
"name"),
63 gnc_sql_make_table_entry<CT_STRING>(
"reference", MAX_REFERENCE_LEN,
64 COL_NNUL, JOB_REFERENCE,
true),
65 gnc_sql_make_table_entry<CT_BOOLEAN>(
"active", 0, COL_NNUL,
68 gnc_sql_make_table_entry<CT_OWNERREF>(
"owner", 0, 0,
73 GncSqlJobBackend::GncSqlJobBackend() :
75 TABLE_NAME, col_table) {}
83 g_return_val_if_fail (sql_be != NULL, NULL);
85 guid = gnc_sql_load_guid (sql_be, row);
86 pJob = gncJobLookup (sql_be->book(), guid);
89 pJob = gncJobCreate (sql_be->book());
91 gnc_sql_load_object (sql_be, row, GNC_ID_JOB, pJob, col_table);
92 qof_instance_mark_clean (QOF_INSTANCE (pJob));
99 gnc_job_lookup (
const GncGUID *guid,
const QofBook *book)
107 g_return_if_fail (sql_be != NULL);
109 std::string sql(
"SELECT * FROM " TABLE_NAME);
110 auto stmt = sql_be->create_statement_from_sql(sql);
113 for (
auto row : *result)
114 load_single_job (sql_be, row);
116 std::string pkey(col_table[0]->name());
117 sql =
"SELECT DISTINCT ";
118 sql += pkey +
" FROM " TABLE_NAME;
120 (BookLookupFn)gnc_job_lookup);
125 job_should_be_saved (GncJob* job)
129 g_return_val_if_fail (job != NULL, FALSE);
132 id = gncJobGetID (job);
133 if (
id == NULL || *
id ==
'\0')
142 write_single_job (
QofInstance* term_p, gpointer data_p)
146 g_return_if_fail (term_p != NULL);
147 g_return_if_fail (GNC_IS_JOB (term_p));
148 g_return_if_fail (data_p != NULL);
150 if (s->is_ok && job_should_be_saved (GNC_JOB (term_p)))
159 g_return_val_if_fail (sql_be != NULL, FALSE);
bool write(GncSqlBackend *) override
Write all objects of m_type_name to the database.
GncSqlResultPtr execute_select_statement(const GncSqlStatementPtr &stmt) const noexcept
Executes an SQL SELECT statement and returns the result rows.
void gnc_sql_slots_load_for_sql_subquery(GncSqlBackend *sql_be, const std::string subquery, BookLookupFn lookup_fn)
gnc_sql_slots_load_for_sql_subquery - Loads slots for all objects whose guid is supplied by a subquer...
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
load and save accounts data to SQL
#define QOF_BOOK_RETURN_ENTITY(book, guid, e_type, c_type)
Encapsulates all the information about a dataset manipulated by QOF.
void load_all(GncSqlBackend *) override
Load all objects of m_type in the database into memory.
void(* QofSetterFunc)(gpointer, gpointer)
The QofSetterFunc defines an function pointer for parameter setters.
Row of SQL Query results.
load and save job data to SQL
void qof_object_foreach(QofIdTypeConst type_name, QofBook *book, QofInstanceForeachCB cb, gpointer user_data)
Invoke the callback 'cb' on every instance ov a particular object type.
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
The QofAccessFunc defines an arbitrary function pointer for access functions.
Encapsulates per-class table schema with functions to load, create a table, commit a changed front-en...
Data-passing struct for callbacks to qof_object_foreach() used in GncSqlObjectBackend::write().
The type used to store guids in C.
Main SQL backend structure.