mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-07-30 08:08:15 -05:00
Neil Williams' QOF sync patch.
* This patch updates the QOF merge code to current QOF to bring the HEAD branch into sync. This update also makes qof_book_merge_param_as_string output strings that are compatible with QSF: using false instead of FALSE in string output and using the QSF_XSD_TIME for the datestrings. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10440 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
2005-01-30 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* src/engine/Account.c:
|
||||
This patch fixes: (QofAccessFunc)xaccAccountSetNonStdSCU in
|
||||
src/engine/Account.c - that's a Set routine allocated as a
|
||||
QofAccessFunc - the patch changes it to the appropriate Get
|
||||
routine - the QofSetterFunc is OK.
|
||||
|
||||
Neil Williams' QOF sync patch:
|
||||
* This patch updates the QOF merge code to current QOF to bring
|
||||
the HEAD branch into sync. This update also makes
|
||||
qof_book_merge_param_as_string output strings that are
|
||||
compatible with QSF: using false instead of FALSE in string
|
||||
output and using the QSF_XSD_TIME for the datestrings.
|
||||
|
||||
2005-01-29 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
David Montenegro's patch for bugs #95551, #124367.
|
||||
|
||||
@@ -9,9 +9,10 @@ AM_CFLAGS = \
|
||||
-I${top_srcdir}/src/gnc-module \
|
||||
-I${top_srcdir}/src/core-utils\
|
||||
-I${top_srcdir}/lib/libc\
|
||||
$(GNOME_XML_CFLAGS) \
|
||||
${GNOME_XML_CFLAGS} \
|
||||
${GLIB_CFLAGS}
|
||||
|
||||
|
||||
libgncmod_backend_file_la_SOURCES = \
|
||||
gncmod-backend-file.c \
|
||||
gnc-account-xml-v2.c \
|
||||
|
||||
@@ -67,7 +67,6 @@ AM_CFLAGS = \
|
||||
-I${top_srcdir}/src/engine \
|
||||
-I${top_srcdir}/src/engine/test-core \
|
||||
-I${top_srcdir}/src/backend/file \
|
||||
$(GNOME_XML_CFLAGS) \
|
||||
${GLIB_CFLAGS} \
|
||||
${GUILE_INCS}
|
||||
|
||||
|
||||
@@ -1255,7 +1255,8 @@ xaccAccountSetDescription (Account *acc, const char *str)
|
||||
xaccAccountCommitEdit(acc);
|
||||
}
|
||||
|
||||
void qofAccountSetParent (Account *acc, QofEntity *parent)
|
||||
static void
|
||||
qofAccountSetParent (Account *acc, QofEntity *parent)
|
||||
{
|
||||
AccountGroup *ag;
|
||||
if((!acc)||(!parent)) return;
|
||||
|
||||
@@ -214,19 +214,6 @@ void xaccAccountSetNotes (Account *account, const char *notes);
|
||||
void xaccAccountSetLastNum (Account *account, const char *num);
|
||||
/** Set the account's type */
|
||||
GNCAccountType xaccAccountGetType (Account *account);
|
||||
/** \brief Special function only for qof_book_merge
|
||||
|
||||
qofAccountSetParent uses a specific QofEntity that is
|
||||
set during a qof_book_merge and it refers to the
|
||||
corresponding QofEntity in the target book. This is used
|
||||
to link new accounts into an existing AccountGroup. The
|
||||
parent reference is only changed if no parent exists.
|
||||
|
||||
Care is needed before this function can be used in any
|
||||
other manner.
|
||||
*/
|
||||
void qofAccountSetParent (Account *, QofEntity *);
|
||||
|
||||
|
||||
/** Get the account's name */
|
||||
const char * xaccAccountGetName (Account *account);
|
||||
|
||||
@@ -62,6 +62,8 @@
|
||||
* This is the *private* header for the account structure.
|
||||
* No one outside of the engine should ever include this file.
|
||||
*/
|
||||
|
||||
/** \struct Account */
|
||||
struct account_s
|
||||
{
|
||||
QofInstance inst;
|
||||
|
||||
+7
-1
@@ -78,7 +78,13 @@ void xaccAccountGroupDestroy (AccountGroup *grp);
|
||||
/** Return the book to which this account belongs */
|
||||
QofBook * xaccGroupGetBook (AccountGroup *group);
|
||||
|
||||
/** DOCUMENT ME! */
|
||||
/** Compare two account groups
|
||||
|
||||
warns if one is NULL, if one has no accounts or if the two
|
||||
groups have different numbers of accounts.
|
||||
|
||||
@return TRUE if the two account groups are equal, FALSE otherwise.
|
||||
*/
|
||||
gboolean xaccGroupEqual(AccountGroup *a, AccountGroup *b,
|
||||
gboolean check_guids);
|
||||
|
||||
|
||||
@@ -3253,7 +3253,7 @@ gboolean xaccSplitRegister (void)
|
||||
{
|
||||
static const QofParam params[] = {
|
||||
{ SPLIT_DATE_RECONCILED, QOF_TYPE_DATE,
|
||||
(QofAccessFunc)xaccSplitRetDateReconciledTS, NULL },
|
||||
(QofAccessFunc)xaccSplitRetDateReconciledTS, (QofSetterFunc)xaccSplitSetDateReconciledTS },
|
||||
|
||||
/* d-* are depricated query params, should not be used in new
|
||||
* queries, should be removed from old queries. */
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
/*
|
||||
* @file gnc-filepath-utils.c
|
||||
* @breif file path resolutionutilities
|
||||
* @brief file path resolutionutilities
|
||||
* @author Copyright (c) 1998-2004 Linas Vepstas <linas@linas.org>
|
||||
* @author Copyright (c) 2000 Dave Peticolas
|
||||
*
|
||||
|
||||
@@ -361,9 +361,31 @@ gnc_lot_get_latest_split (GNCLot *lot)
|
||||
|
||||
/* ============================================================= */
|
||||
|
||||
/* change prototype of gnc_lot_register to return a gboolean
|
||||
and set a foreach
|
||||
before enabling the object description. */
|
||||
/*
|
||||
static QofObject gncLotDesc =
|
||||
{
|
||||
interface_version: QOF_OBJECT_VERSION,
|
||||
e_type: GNC_ID_LOT,
|
||||
type_label: "Lot",
|
||||
create: (gpointer)gnc_lot_new,
|
||||
book_begin: NULL,
|
||||
book_end: NULL,
|
||||
is_dirty: NULL,
|
||||
mark_clean: NULL,
|
||||
foreach: NULL,
|
||||
printable: NULL,
|
||||
version_cmp: NULL,
|
||||
};
|
||||
*/
|
||||
|
||||
void gnc_lot_register (void)
|
||||
{
|
||||
static const QofParam params[] = {
|
||||
{ LOT_TITLE, QOF_TYPE_STRING, (QofAccessFunc)gnc_lot_get_title, (QofSetterFunc)gnc_lot_set_title },
|
||||
{ LOT_NOTES, QOF_TYPE_STRING, (QofAccessFunc)gnc_lot_get_notes, (QofSetterFunc)gnc_lot_set_notes },
|
||||
{ QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
|
||||
{ QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)gnc_lot_get_book, NULL },
|
||||
{ LOT_IS_CLOSED, QOF_TYPE_BOOLEAN, (QofAccessFunc)gnc_lot_is_closed, NULL },
|
||||
@@ -372,6 +394,9 @@ void gnc_lot_register (void)
|
||||
};
|
||||
|
||||
qof_class_register (GNC_ID_LOT, NULL, params);
|
||||
|
||||
// return qof_object_register(&gncLotDesc);
|
||||
|
||||
}
|
||||
|
||||
/* ========================== END OF FILE ========================= */
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
#include "gnc-numeric.h"
|
||||
#include "qofbook.h"
|
||||
#include "qofid.h"
|
||||
#include "qofobject.h"
|
||||
|
||||
GNCLot * gnc_lot_new (QofBook *);
|
||||
void gnc_lot_destroy (GNCLot *);
|
||||
@@ -135,7 +136,8 @@ KvpFrame * gnc_lot_get_slots (GNCLot *);
|
||||
|
||||
#define LOT_IS_CLOSED "is-closed?"
|
||||
#define LOT_BALANCE "balance"
|
||||
|
||||
#define LOT_TITLE "lot-title"
|
||||
#define LOT_NOTES "notes"
|
||||
#endif /* GNC_LOT_H */
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
+31
-18
@@ -1,6 +1,6 @@
|
||||
/*********************************************************************
|
||||
* qof_book_merge.c -- api for QoFBook merge with collision handling *
|
||||
* Copyright (C) 2004 Neil Williams <linux@codehelp.co.uk> *
|
||||
* Copyright (C) 2004-2005 Neil Williams <linux@codehelp.co.uk> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@@ -42,6 +42,8 @@ struct qof_book_mergeRuleIterate {
|
||||
*/
|
||||
#define DEFAULT_MERGE_WEIGHT 1
|
||||
#define QOF_STRING_WEIGHT 3
|
||||
#define QOF_DATE_STRING_LENGTH 31
|
||||
#define QOF_UTC_DATE_FORMAT "%Y-%m-%dT%H:%M:%SZ"
|
||||
|
||||
/* ================================================================ */
|
||||
/* API functions. */
|
||||
@@ -75,11 +77,12 @@ qof_book_mergeInit( QofBook *importBook, QofBook *targetBook)
|
||||
while(check != NULL) {
|
||||
currentRule = check->data;
|
||||
if(currentRule->mergeResult == MERGE_INVALID) {
|
||||
qof_book_merge_abort(mergeData);
|
||||
mergeData->abort = TRUE;
|
||||
return(NULL);
|
||||
}
|
||||
check = g_list_next(check);
|
||||
}
|
||||
g_list_free(check);
|
||||
return mergeData;
|
||||
}
|
||||
|
||||
@@ -117,15 +120,26 @@ qof_book_merge_abort (qof_book_mergeData *mergeData)
|
||||
qof_param_as_string(QofParam*, QofEntity*);
|
||||
Useful? Worth transferring to qofclass.c?
|
||||
Need to fix the KVP->string. How?
|
||||
|
||||
The QOF_TYPE_DATE output format from
|
||||
qof_book_merge_param_as_string has been changed to QSF_XSD_TIME,
|
||||
a UTC formatted timestring: 2005-01-01T10:55:23Z
|
||||
If you change QOF_UTC_DATE_FORMAT, change
|
||||
backend/file/qsf-xml.c : qsf_entity_foreach to
|
||||
reformat to QSF_XSD_TIME or the QSF XML will
|
||||
FAIL the schema validation and QSF exports will become invalid.
|
||||
|
||||
The QOF_TYPE_BOOLEAN is lowercase for the same reason.
|
||||
*/
|
||||
char*
|
||||
qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
|
||||
{
|
||||
gchar *param_string;
|
||||
gchar *param_string, param_date[QOF_DATE_STRING_LENGTH];
|
||||
char param_sa[GUID_ENCODING_LENGTH + 1];
|
||||
KvpFrame *param_kvp;
|
||||
QofType paramType;
|
||||
const GUID *param_guid;
|
||||
time_t param_t;
|
||||
gnc_numeric param_numeric, (*numeric_getter) (QofEntity*, QofParam*);
|
||||
Timespec param_ts, (*date_getter) (QofEntity*, QofParam*);
|
||||
double param_double, (*double_getter) (QofEntity*, QofParam*);
|
||||
@@ -143,7 +157,9 @@ qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
|
||||
if(safe_strcmp(paramType, QOF_TYPE_DATE) == 0) {
|
||||
date_getter = (Timespec (*)(QofEntity*, QofParam*))qtparam->param_getfcn;
|
||||
param_ts = date_getter(qtEnt, qtparam);
|
||||
param_string = g_strdup_printf("%llu", param_ts.tv_sec);
|
||||
param_t = timespecToTime_t(param_ts);
|
||||
strftime(param_date, QOF_DATE_STRING_LENGTH, QOF_UTC_DATE_FORMAT, gmtime(¶m_t));
|
||||
param_string = g_strdup(param_date);
|
||||
return param_string;
|
||||
}
|
||||
if((safe_strcmp(paramType, QOF_TYPE_NUMERIC) == 0) ||
|
||||
@@ -180,8 +196,9 @@ qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
|
||||
if(safe_strcmp(paramType, QOF_TYPE_BOOLEAN) == 0){
|
||||
boolean_getter = (gboolean (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
|
||||
param_boolean = boolean_getter(qtEnt, qtparam);
|
||||
if(param_boolean == TRUE) { param_string = g_strdup("TRUE"); }
|
||||
else { param_string = g_strdup("FALSE"); }
|
||||
/* Boolean values need to be lowercase for QSF validation. */
|
||||
if(param_boolean == TRUE) { param_string = g_strdup("true"); }
|
||||
else { param_string = g_strdup("false"); }
|
||||
return param_string;
|
||||
}
|
||||
/* "kvp" */
|
||||
@@ -300,6 +317,7 @@ void qof_book_mergeRuleForeach( qof_book_mergeData *mergeData,
|
||||
g_return_if_fail(mergeResult != MERGE_INVALID);
|
||||
g_return_if_fail(mergeData->abort == FALSE);
|
||||
iter.fcn = cb;
|
||||
iter.data = mergeData;
|
||||
matching_rules = NULL;
|
||||
iter.ruleList = g_list_copy(mergeData->mergeList);
|
||||
while(iter.ruleList!=NULL) {
|
||||
@@ -309,7 +327,6 @@ void qof_book_mergeRuleForeach( qof_book_mergeData *mergeData,
|
||||
}
|
||||
iter.ruleList = g_list_next(iter.ruleList);
|
||||
}
|
||||
iter.data = mergeData;
|
||||
iter.remainder = g_list_length(matching_rules);
|
||||
g_list_foreach (matching_rules, qof_book_mergeRuleCB, &iter);
|
||||
g_list_free(matching_rules);
|
||||
@@ -579,9 +596,14 @@ qof_book_merge_match_orphans(qof_book_mergeData *mergeData)
|
||||
rule = orphans->data;
|
||||
g_return_if_fail(rule != NULL);
|
||||
difference = g_slist_length(mergeData->mergeObjectParams);
|
||||
if(rule->targetEnt == NULL) {
|
||||
rule->mergeResult = MERGE_NEW;
|
||||
rule->difference = 0;
|
||||
mergeData->mergeList = g_list_prepend(mergeData->mergeList,rule);
|
||||
orphans = g_slist_next(orphans);
|
||||
continue;
|
||||
}
|
||||
mergeData->currentRule = rule;
|
||||
while(targets != NULL) {
|
||||
mergeData->currentRule->targetEnt = targets->data;
|
||||
g_return_if_fail(qof_book_mergeCompare(mergeData) != -1);
|
||||
if(difference > mergeData->currentRule->difference) {
|
||||
best_matchEnt = currentRule->targetEnt;
|
||||
@@ -590,15 +612,6 @@ qof_book_merge_match_orphans(qof_book_mergeData *mergeData)
|
||||
mergeData->mergeList = g_list_prepend(mergeData->mergeList,rule);
|
||||
qof_book_merge_orphan_check(difference, rule, mergeData);
|
||||
}
|
||||
targets = g_slist_next(targets);
|
||||
}
|
||||
if(rule->targetEnt == NULL) {
|
||||
rule->mergeResult = MERGE_NEW;
|
||||
rule->difference = 0;
|
||||
mergeData->mergeList = g_list_prepend(mergeData->mergeList,rule);
|
||||
orphans = g_slist_next(orphans);
|
||||
continue;
|
||||
}
|
||||
orphans = g_slist_next(orphans);
|
||||
}
|
||||
g_slist_free(mergeData->orphan_list);
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
|
||||
/** Type of Paramters (String, Date, Numeric, GUID, etc.) */
|
||||
typedef const char * QofType;
|
||||
|
||||
/** Type of QofParam */
|
||||
typedef struct _QofParam QofParam;
|
||||
|
||||
/** The QofAccessFunc defines an arbitrary function pointer
|
||||
|
||||
@@ -182,11 +182,15 @@
|
||||
static QofQueryPredData * \
|
||||
SUBRNAME (xmlNodePtr root) \
|
||||
{ \
|
||||
xmlNodePtr xp = root->xmlChildrenNode; \
|
||||
QofQueryPredData *pred; \
|
||||
xmlNodePtr xp; \
|
||||
xmlNodePtr node; \
|
||||
QofQueryCompare how; \
|
||||
CTYPE val; \
|
||||
xp = root->xmlChildrenNode; \
|
||||
\
|
||||
QofQueryCompare how = QOF_COMPARE_EQUAL; \
|
||||
CTYPE val = 0; \
|
||||
how = QOF_COMPARE_EQUAL; \
|
||||
val = 0; \
|
||||
\
|
||||
for (node=xp; node; node = node->next) \
|
||||
{ \
|
||||
@@ -197,7 +201,6 @@ SUBRNAME (xmlNodePtr root) \
|
||||
{} \
|
||||
} \
|
||||
\
|
||||
QofQueryPredData *pred; \
|
||||
pred = PRED (how, val); \
|
||||
return pred; \
|
||||
}
|
||||
@@ -245,12 +248,17 @@ static void wrap_new_timespec(KvpValue **v, Timespec value) {
|
||||
static QofQueryPredData *
|
||||
qof_query_pred_kvp_from_xml (xmlNodePtr root)
|
||||
{
|
||||
xmlNodePtr xp = root->xmlChildrenNode;
|
||||
QofQueryCompare how;
|
||||
GSList *path;
|
||||
KvpValue *value;
|
||||
QofQueryPredData *pred;
|
||||
xmlNodePtr xp;
|
||||
xmlNodePtr node;
|
||||
|
||||
QofQueryCompare how = QOF_COMPARE_EQUAL;
|
||||
GSList *path = NULL;
|
||||
KvpValue *value = NULL;
|
||||
how = QOF_COMPARE_EQUAL;
|
||||
xp = root->xmlChildrenNode;
|
||||
path = NULL;
|
||||
value = NULL;
|
||||
|
||||
for (node=xp; node; node = node->next)
|
||||
{
|
||||
@@ -271,7 +279,6 @@ qof_query_pred_kvp_from_xml (xmlNodePtr root)
|
||||
GET_DATE(&value, wrap_new_timespec, "qofquery:date");
|
||||
}
|
||||
|
||||
QofQueryPredData *pred;
|
||||
pred = qof_query_kvp_predicate (how, path, value);
|
||||
g_slist_free (path);
|
||||
return pred;
|
||||
@@ -282,12 +289,18 @@ qof_query_pred_kvp_from_xml (xmlNodePtr root)
|
||||
static QofQueryPredData *
|
||||
qof_query_pred_guid_from_xml (xmlNodePtr root)
|
||||
{
|
||||
xmlNodePtr xp = root->xmlChildrenNode;
|
||||
GList *guid_list, *n;
|
||||
const char *str;
|
||||
GUID *guid;
|
||||
gboolean decode;
|
||||
QofQueryPredData *pred;
|
||||
QofGuidMatch sm;
|
||||
xmlNodePtr xp;
|
||||
xmlNodePtr node;
|
||||
GList *guid_list = NULL;
|
||||
|
||||
QofGuidMatch sm = QOF_GUID_MATCH_ANY;
|
||||
guid_list = NULL;
|
||||
|
||||
sm = QOF_GUID_MATCH_ANY;
|
||||
xp = root->xmlChildrenNode;
|
||||
for (node=xp; node; node = node->next)
|
||||
{
|
||||
if (node->type != XML_ELEMENT_NODE) continue;
|
||||
@@ -298,9 +311,9 @@ qof_query_pred_guid_from_xml (xmlNodePtr root)
|
||||
|
||||
if (0 == strcmp ("qofquery:guid", node->name))
|
||||
{
|
||||
const char *str = GET_TEXT (node);
|
||||
GUID *guid = guid_malloc ();
|
||||
gboolean decode = string_to_guid (str, guid);
|
||||
str = GET_TEXT (node);
|
||||
guid = guid_malloc ();
|
||||
decode = string_to_guid (str, guid);
|
||||
if (decode)
|
||||
{
|
||||
guid_list = g_list_append (guid_list, guid);
|
||||
@@ -313,11 +326,9 @@ qof_query_pred_guid_from_xml (xmlNodePtr root)
|
||||
}
|
||||
}
|
||||
|
||||
QofQueryPredData *pred;
|
||||
pred = qof_query_guid_predicate (sm, guid_list);
|
||||
|
||||
/* The predicate made a copy of everything, so free our stuff */
|
||||
GList *n;
|
||||
for (n=guid_list; n; n=n->next)
|
||||
{
|
||||
guid_free (n->data);
|
||||
@@ -331,11 +342,15 @@ qof_query_pred_guid_from_xml (xmlNodePtr root)
|
||||
static QofQueryPredData *
|
||||
qof_query_pred_char_from_xml (xmlNodePtr root)
|
||||
{
|
||||
xmlNodePtr xp = root->xmlChildrenNode;
|
||||
QofQueryPredData *pred;
|
||||
QofCharMatch sm;
|
||||
const char * char_list;
|
||||
xmlNodePtr xp;
|
||||
xmlNodePtr node;
|
||||
|
||||
QofCharMatch sm = QOF_CHAR_MATCH_ANY;
|
||||
const char * char_list = NULL;
|
||||
char_list = NULL;
|
||||
xp = root->xmlChildrenNode;
|
||||
sm = QOF_CHAR_MATCH_ANY;
|
||||
|
||||
for (node=xp; node; node = node->next)
|
||||
{
|
||||
@@ -348,7 +363,6 @@ qof_query_pred_char_from_xml (xmlNodePtr root)
|
||||
{}
|
||||
}
|
||||
|
||||
QofQueryPredData *pred;
|
||||
pred = qof_query_char_predicate (sm, char_list);
|
||||
return pred;
|
||||
}
|
||||
@@ -358,12 +372,16 @@ qof_query_pred_char_from_xml (xmlNodePtr root)
|
||||
static QofQueryPredData *
|
||||
qof_query_pred_numeric_from_xml (xmlNodePtr root)
|
||||
{
|
||||
xmlNodePtr xp = root->xmlChildrenNode;
|
||||
QofQueryPredData *pred;
|
||||
xmlNodePtr node;
|
||||
|
||||
QofQueryCompare how = QOF_COMPARE_EQUAL;
|
||||
QofNumericMatch sm = QOF_NUMERIC_MATCH_ANY;
|
||||
QofQueryCompare how;
|
||||
QofNumericMatch sm;
|
||||
gnc_numeric num;
|
||||
xmlNodePtr xp;
|
||||
|
||||
xp = root->xmlChildrenNode;
|
||||
how = QOF_COMPARE_EQUAL;
|
||||
sm = QOF_NUMERIC_MATCH_ANY;
|
||||
|
||||
for (node=xp; node; node = node->next)
|
||||
{
|
||||
@@ -376,7 +394,6 @@ qof_query_pred_numeric_from_xml (xmlNodePtr root)
|
||||
{}
|
||||
}
|
||||
|
||||
QofQueryPredData *pred;
|
||||
pred = qof_query_numeric_predicate (how, sm, num);
|
||||
return pred;
|
||||
}
|
||||
@@ -386,12 +403,18 @@ qof_query_pred_numeric_from_xml (xmlNodePtr root)
|
||||
static QofQueryPredData *
|
||||
qof_query_pred_date_from_xml (xmlNodePtr root)
|
||||
{
|
||||
xmlNodePtr xp = root->xmlChildrenNode;
|
||||
xmlNodePtr xp;
|
||||
xmlNodePtr node;
|
||||
QofQueryCompare how;
|
||||
QofDateMatch sm;
|
||||
Timespec date;
|
||||
QofQueryPredData *pred;
|
||||
|
||||
xp = root->xmlChildrenNode;
|
||||
|
||||
QofQueryCompare how = QOF_COMPARE_EQUAL;
|
||||
QofDateMatch sm = QOF_DATE_MATCH_ROUNDED;
|
||||
Timespec date = {0,0};
|
||||
how = QOF_COMPARE_EQUAL;
|
||||
sm = QOF_DATE_MATCH_ROUNDED;
|
||||
date = (Timespec){0,0};
|
||||
|
||||
for (node=xp; node; node = node->next)
|
||||
{
|
||||
@@ -404,7 +427,6 @@ qof_query_pred_date_from_xml (xmlNodePtr root)
|
||||
{}
|
||||
}
|
||||
|
||||
QofQueryPredData *pred;
|
||||
pred = qof_query_date_predicate (how, sm, date);
|
||||
return pred;
|
||||
}
|
||||
@@ -414,13 +436,19 @@ qof_query_pred_date_from_xml (xmlNodePtr root)
|
||||
static QofQueryPredData *
|
||||
qof_query_pred_string_from_xml (xmlNodePtr root)
|
||||
{
|
||||
xmlNodePtr xp = root->xmlChildrenNode;
|
||||
QofQueryPredData *pred;
|
||||
xmlNodePtr xp;
|
||||
xmlNodePtr node;
|
||||
|
||||
QofQueryCompare how = QOF_COMPARE_EQUAL;
|
||||
QofStringMatch sm = QOF_STRING_MATCH_CASEINSENSITIVE;
|
||||
gboolean is_regex = FALSE;
|
||||
const char *pstr = NULL;
|
||||
QofQueryCompare how;
|
||||
QofStringMatch sm;
|
||||
gboolean is_regex;
|
||||
const char *pstr;
|
||||
|
||||
xp = root->xmlChildrenNode;
|
||||
how = QOF_COMPARE_EQUAL;
|
||||
sm = QOF_STRING_MATCH_CASEINSENSITIVE;
|
||||
is_regex = FALSE;
|
||||
pstr = NULL;
|
||||
|
||||
for (node=xp; node; node = node->next)
|
||||
{
|
||||
@@ -433,8 +461,6 @@ qof_query_pred_string_from_xml (xmlNodePtr root)
|
||||
STRING_MATCH, NORMAL, CASEINSENSITIVE);
|
||||
{}
|
||||
}
|
||||
|
||||
QofQueryPredData *pred;
|
||||
pred = qof_query_string_predicate (how, pstr, sm , is_regex);
|
||||
return pred;
|
||||
}
|
||||
@@ -444,9 +470,12 @@ qof_query_pred_string_from_xml (xmlNodePtr root)
|
||||
static GSList *
|
||||
qof_query_param_path_from_xml (xmlNodePtr root)
|
||||
{
|
||||
xmlNodePtr pterms = root->xmlChildrenNode;
|
||||
GSList *plist = NULL;
|
||||
xmlNodePtr pterms;
|
||||
GSList *plist;
|
||||
xmlNodePtr node;
|
||||
|
||||
pterms = root->xmlChildrenNode;
|
||||
plist = NULL;
|
||||
for (node=pterms; node; node = node->next)
|
||||
{
|
||||
if (node->type != XML_ELEMENT_NODE) continue;
|
||||
@@ -466,18 +495,23 @@ static void
|
||||
qof_query_term_from_xml (QofQuery *q, xmlNodePtr root)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
xmlNodePtr term = root->xmlChildrenNode;
|
||||
QofQueryPredData *pred = NULL;
|
||||
GSList *path = NULL;
|
||||
|
||||
xmlNodePtr term;
|
||||
QofQueryPredData *pred;
|
||||
GSList *path;
|
||||
QofQuery *qt;
|
||||
QofQuery *qinv;
|
||||
|
||||
pred = NULL;
|
||||
path = NULL;
|
||||
term = root->xmlChildrenNode;
|
||||
for (node=term; node; node = node->next)
|
||||
{
|
||||
if (node->type != XML_ELEMENT_NODE) continue;
|
||||
if (0 == strcmp (node->name, "qofquery:invert"))
|
||||
{
|
||||
QofQuery *qt = qof_query_create();
|
||||
qt = qof_query_create();
|
||||
qof_query_term_from_xml (qt, node);
|
||||
QofQuery *qinv = qof_query_invert (qt);
|
||||
qinv = qof_query_invert (qt);
|
||||
qof_query_merge_in_place (q, qinv, QOF_QUERY_AND);
|
||||
qof_query_destroy (qinv);
|
||||
qof_query_destroy (qt);
|
||||
@@ -553,8 +587,10 @@ qof_query_term_from_xml (QofQuery *q, xmlNodePtr root)
|
||||
static void
|
||||
qof_query_and_terms_from_xml (QofQuery *q, xmlNodePtr root)
|
||||
{
|
||||
xmlNodePtr andterms = root->xmlChildrenNode;
|
||||
xmlNodePtr andterms;
|
||||
xmlNodePtr node;
|
||||
|
||||
andterms = root->xmlChildrenNode;
|
||||
for (node=andterms; node; node = node->next)
|
||||
{
|
||||
if (node->type != XML_ELEMENT_NODE) continue;
|
||||
@@ -571,16 +607,18 @@ qof_query_and_terms_from_xml (QofQuery *q, xmlNodePtr root)
|
||||
static void
|
||||
qof_query_or_terms_from_xml (QofQuery *q, xmlNodePtr root)
|
||||
{
|
||||
xmlNodePtr andterms = root->xmlChildrenNode;
|
||||
xmlNodePtr andterms;
|
||||
xmlNodePtr node;
|
||||
QofQuery *qand;
|
||||
|
||||
andterms = root->xmlChildrenNode;
|
||||
for (node=andterms; node; node = node->next)
|
||||
{
|
||||
if (node->type != XML_ELEMENT_NODE) continue;
|
||||
|
||||
if (0 == strcmp (node->name, "qofquery:and-terms"))
|
||||
{
|
||||
QofQuery *qand = qof_query_create ();
|
||||
qand = qof_query_create ();
|
||||
qof_query_and_terms_from_xml (qand, node);
|
||||
qof_query_merge_in_place (q, qand, QOF_QUERY_OR);
|
||||
qof_query_destroy (qand);
|
||||
@@ -594,10 +632,13 @@ QofQuery *
|
||||
qof_query_from_xml (xmlNodePtr root)
|
||||
{
|
||||
QofQuery *q;
|
||||
xmlChar *version;
|
||||
xmlNodePtr qpart;
|
||||
xmlNodePtr node;
|
||||
|
||||
if (!root) return NULL;
|
||||
|
||||
xmlChar * version = xmlGetProp(root, "version");
|
||||
version = xmlGetProp(root, "version");
|
||||
if (!root->name || strcmp ("qof:qofquery", root->name))
|
||||
{
|
||||
// XXX something is wrong. warn ...
|
||||
@@ -606,8 +647,7 @@ qof_query_from_xml (xmlNodePtr root)
|
||||
|
||||
q = qof_query_create ();
|
||||
|
||||
xmlNodePtr qpart = root->xmlChildrenNode;
|
||||
xmlNodePtr node;
|
||||
qpart = root->xmlChildrenNode;
|
||||
for (node=qpart; node; node = node->next)
|
||||
{
|
||||
if (node->type != XML_ELEMENT_NODE) continue;
|
||||
@@ -643,6 +683,7 @@ int main (int argc, char * argv[])
|
||||
{
|
||||
QofQuery *q, *qnew;
|
||||
QofSqlQuery *sq;
|
||||
xmlNodePtr topnode;
|
||||
|
||||
guid_init();
|
||||
qof_query_init();
|
||||
|
||||
+116
-74
@@ -208,18 +208,30 @@ qof_kvp_value_to_xml (KvpValue *kval, xmlNodePtr topnode)
|
||||
static xmlNodePtr
|
||||
qof_query_pred_data_to_xml (QofQueryPredData *pd)
|
||||
{
|
||||
GList *n;
|
||||
GSList *ns;
|
||||
xmlNodePtr topnode;
|
||||
query_guid_t pdata_g;
|
||||
query_string_t pdata_s;
|
||||
query_numeric_t pdata_n;
|
||||
query_kvp_t pdata_k;
|
||||
query_date_t pdata_d;
|
||||
query_int64_t pdata_i64;
|
||||
query_int32_t pdata_i32;
|
||||
query_double_t pdata_db;
|
||||
query_boolean_t pdata_bool;
|
||||
query_char_t pdata_c;
|
||||
|
||||
if (!safe_strcmp (pd->type_name, QOF_TYPE_GUID))
|
||||
{
|
||||
xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-guid");
|
||||
topnode = xmlNewNode (NULL, "qofquery:pred-guid");
|
||||
/* GUID Predicate doesn't do a PUT_HOW */
|
||||
|
||||
GList *n;
|
||||
query_guid_t pdata = (query_guid_t) pd;
|
||||
PUT_MATCH5("qofquery:guid-match", pdata->options,
|
||||
pdata_g = (query_guid_t) pd;
|
||||
PUT_MATCH5("qofquery:guid-match", pdata_g->options,
|
||||
GUID_MATCH, ANY, ALL, NONE, NULL, LIST_ANY);
|
||||
|
||||
for (n = pdata->guids; n; n = n->next)
|
||||
for (n = pdata_g->guids; n; n = n->next)
|
||||
{
|
||||
PUT_GUID ("qofquery:guid", n->data);
|
||||
}
|
||||
@@ -227,105 +239,103 @@ qof_query_pred_data_to_xml (QofQueryPredData *pd)
|
||||
}
|
||||
if (!safe_strcmp (pd->type_name, QOF_TYPE_STRING))
|
||||
{
|
||||
xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-string");
|
||||
topnode = xmlNewNode (NULL, "qofquery:pred-string");
|
||||
PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
|
||||
|
||||
query_string_t pdata = (query_string_t) pd;
|
||||
PUT_MATCH2("qofquery:string-match", pdata->options,
|
||||
pdata_s = (query_string_t) pd;
|
||||
PUT_MATCH2("qofquery:string-match", pdata_s->options,
|
||||
STRING_MATCH, NORMAL, CASEINSENSITIVE);
|
||||
PUT_BOOL ("qofquery:is-regex", pdata->is_regex);
|
||||
PUT_STR ("qofquery:string", pdata->matchstring);
|
||||
PUT_BOOL ("qofquery:is-regex", pdata_s->is_regex);
|
||||
PUT_STR ("qofquery:string", pdata_s->matchstring);
|
||||
return topnode;
|
||||
}
|
||||
if (!safe_strcmp (pd->type_name, QOF_TYPE_NUMERIC))
|
||||
{
|
||||
xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-numeric");
|
||||
topnode = xmlNewNode (NULL, "qofquery:pred-numeric");
|
||||
PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
|
||||
|
||||
query_numeric_t pdata = (query_numeric_t) pd;
|
||||
PUT_MATCH3("qofquery:numeric-match", pdata->options,
|
||||
pdata_n = (query_numeric_t) pd;
|
||||
PUT_MATCH3("qofquery:numeric-match", pdata_n->options,
|
||||
NUMERIC_MATCH, DEBIT, CREDIT, ANY);
|
||||
|
||||
PUT_NUMERIC ("qofquery:numeric", pdata->amount);
|
||||
PUT_NUMERIC ("qofquery:numeric", pdata_n->amount);
|
||||
return topnode;
|
||||
}
|
||||
if (!safe_strcmp (pd->type_name, QOF_TYPE_KVP))
|
||||
{
|
||||
xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-kvp");
|
||||
topnode = xmlNewNode (NULL, "qofquery:pred-kvp");
|
||||
PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
|
||||
|
||||
query_kvp_t pdata = (query_kvp_t) pd;
|
||||
|
||||
GSList *n;
|
||||
for (n=pdata->path; n; n=n->next)
|
||||
pdata_k = (query_kvp_t) pd;
|
||||
for (ns=pdata_k->path; ns; ns=ns->next)
|
||||
{
|
||||
PUT_STR ("qofquery:kvp-path", n->data);
|
||||
PUT_STR ("qofquery:kvp-path", ns->data);
|
||||
}
|
||||
qof_kvp_value_to_xml (pdata->value, topnode);
|
||||
qof_kvp_value_to_xml (pdata_k->value, topnode);
|
||||
return topnode;
|
||||
}
|
||||
if (!safe_strcmp (pd->type_name, QOF_TYPE_DATE))
|
||||
{
|
||||
xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-date");
|
||||
topnode = xmlNewNode (NULL, "qofquery:pred-date");
|
||||
PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
|
||||
|
||||
query_date_t pdata = (query_date_t) pd;
|
||||
pdata_d = (query_date_t) pd;
|
||||
|
||||
PUT_MATCH2("qofquery:date-match", pdata->options,
|
||||
PUT_MATCH2("qofquery:date-match", pdata_d->options,
|
||||
DATE_MATCH, NORMAL, ROUNDED);
|
||||
|
||||
PUT_DATE ("qofquery:date", pdata->date);
|
||||
PUT_DATE ("qofquery:date", pdata_d->date);
|
||||
return topnode;
|
||||
}
|
||||
if (!safe_strcmp (pd->type_name, QOF_TYPE_INT64))
|
||||
{
|
||||
xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-int64");
|
||||
topnode = xmlNewNode (NULL, "qofquery:pred-int64");
|
||||
PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
|
||||
|
||||
query_int64_t pdata = (query_int64_t) pd;
|
||||
PUT_INT64 ("qofquery:int64", pdata->val);
|
||||
pdata_i64 = (query_int64_t) pd;
|
||||
PUT_INT64 ("qofquery:int64", pdata_i64->val);
|
||||
return topnode;
|
||||
}
|
||||
if (!safe_strcmp (pd->type_name, QOF_TYPE_INT32))
|
||||
{
|
||||
xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-int32");
|
||||
topnode = xmlNewNode (NULL, "qofquery:pred-int32");
|
||||
PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
|
||||
|
||||
query_int32_t pdata = (query_int32_t) pd;
|
||||
pdata_i32 = (query_int32_t) pd;
|
||||
|
||||
PUT_INT32 ("qofquery:int32", pdata->val);
|
||||
PUT_INT32 ("qofquery:int32", pdata_i32->val);
|
||||
return topnode;
|
||||
}
|
||||
if (!safe_strcmp (pd->type_name, QOF_TYPE_DOUBLE))
|
||||
{
|
||||
xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-double");
|
||||
topnode = xmlNewNode (NULL, "qofquery:pred-double");
|
||||
PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
|
||||
|
||||
query_double_t pdata = (query_double_t) pd;
|
||||
pdata_db = (query_double_t) pd;
|
||||
|
||||
PUT_DBL ("qofquery:double", pdata->val);
|
||||
PUT_DBL ("qofquery:double", pdata_db->val);
|
||||
return topnode;
|
||||
}
|
||||
if (!safe_strcmp (pd->type_name, QOF_TYPE_BOOLEAN))
|
||||
{
|
||||
xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-boolean");
|
||||
topnode = xmlNewNode (NULL, "qofquery:pred-boolean");
|
||||
PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
|
||||
|
||||
query_boolean_t pdata = (query_boolean_t) pd;
|
||||
pdata_bool = (query_boolean_t) pd;
|
||||
|
||||
PUT_BOOL ("qofquery:boolean", pdata->val);
|
||||
PUT_BOOL ("qofquery:boolean", pdata_bool->val);
|
||||
return topnode;
|
||||
}
|
||||
if (!safe_strcmp (pd->type_name, QOF_TYPE_CHAR))
|
||||
{
|
||||
xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-char");
|
||||
topnode = xmlNewNode (NULL, "qofquery:pred-char");
|
||||
/* There is no PUT_HOW for char-match */
|
||||
query_char_t pdata = (query_char_t) pd;
|
||||
pdata_c = (query_char_t) pd;
|
||||
|
||||
PUT_MATCH2("qofquery:char-match", pdata->options,
|
||||
PUT_MATCH2("qofquery:char-match", pdata_c->options,
|
||||
CHAR_MATCH, ANY, NONE);
|
||||
|
||||
PUT_STR ("qofquery:char-list", pdata->char_list);
|
||||
PUT_STR ("qofquery:char-list", pdata_c->char_list);
|
||||
return topnode;
|
||||
}
|
||||
return NULL;
|
||||
@@ -336,11 +346,15 @@ qof_query_pred_data_to_xml (QofQueryPredData *pd)
|
||||
static xmlNodePtr
|
||||
qof_query_param_path_to_xml (GSList *param_path)
|
||||
{
|
||||
xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:param-path");
|
||||
GSList *n = param_path;
|
||||
xmlNodePtr topnode;
|
||||
GSList *n;
|
||||
QofIdTypeConst path;
|
||||
|
||||
n = param_path;
|
||||
topnode = xmlNewNode (NULL, "qofquery:param-path");
|
||||
for ( ; n; n=n->next)
|
||||
{
|
||||
QofIdTypeConst path = n->data;
|
||||
path = n->data;
|
||||
if (!path) continue;
|
||||
PUT_STR ("qofquery:param", path);
|
||||
}
|
||||
@@ -353,13 +367,17 @@ static xmlNodePtr
|
||||
qof_query_one_term_to_xml (QofQueryTerm *qt)
|
||||
{
|
||||
xmlNodePtr node;
|
||||
xmlNodePtr term = xmlNewNode (NULL, "qofquery:term");
|
||||
xmlNodePtr term;
|
||||
xmlNodePtr topnode;
|
||||
gboolean invert;
|
||||
GSList *path;
|
||||
QofQueryPredData *pd;
|
||||
|
||||
gboolean invert = qof_query_term_is_inverted (qt);
|
||||
GSList *path = qof_query_term_get_param_path (qt);
|
||||
QofQueryPredData *pd = qof_query_term_get_pred_data (qt);
|
||||
|
||||
xmlNodePtr topnode = term;
|
||||
invert = qof_query_term_is_inverted (qt);
|
||||
term = xmlNewNode (NULL, "qofquery:term");
|
||||
topnode = term;
|
||||
path = qof_query_term_get_param_path (qt);
|
||||
pd = qof_query_term_get_pred_data (qt);
|
||||
if (invert)
|
||||
{
|
||||
/* inverter becomes new top mode */
|
||||
@@ -381,14 +399,19 @@ qof_query_one_term_to_xml (QofQueryTerm *qt)
|
||||
static xmlNodePtr
|
||||
qof_query_and_terms_to_xml (GList *and_terms)
|
||||
{
|
||||
xmlNodePtr terms = xmlNewNode (NULL, "qofquery:and-terms");
|
||||
GList *n = and_terms;
|
||||
xmlNodePtr terms;
|
||||
GList *n;
|
||||
QofQueryTerm *qt;
|
||||
xmlNodePtr t;
|
||||
|
||||
terms = xmlNewNode (NULL, "qofquery:and-terms");
|
||||
n = and_terms;
|
||||
for ( ; n; n=n->next)
|
||||
{
|
||||
QofQueryTerm *qt = n->data;
|
||||
qt = n->data;
|
||||
if (!qt) continue;
|
||||
|
||||
xmlNodePtr t = qof_query_one_term_to_xml (n->data);
|
||||
t = qof_query_one_term_to_xml (n->data);
|
||||
if (t) xmlAddChild (terms, t);
|
||||
}
|
||||
return terms;
|
||||
@@ -399,15 +422,18 @@ qof_query_and_terms_to_xml (GList *and_terms)
|
||||
static xmlNodePtr
|
||||
qof_query_terms_to_xml (QofQuery *q)
|
||||
{
|
||||
xmlNodePtr terms = NULL;
|
||||
GList *n = qof_query_get_terms (q);
|
||||
xmlNodePtr terms;
|
||||
GList *n;
|
||||
xmlNodePtr andt;
|
||||
|
||||
terms = NULL;
|
||||
n = qof_query_get_terms (q);
|
||||
if (!n) return NULL;
|
||||
terms = xmlNewNode (NULL, "qofquery:or-terms");
|
||||
|
||||
for ( ; n; n=n->next)
|
||||
{
|
||||
xmlNodePtr andt = qof_query_and_terms_to_xml (n->data);
|
||||
andt = qof_query_and_terms_to_xml (n->data);
|
||||
if (andt) xmlAddChild (terms, andt);
|
||||
}
|
||||
return terms;
|
||||
@@ -419,31 +445,39 @@ static xmlNodePtr
|
||||
qof_query_sorts_to_xml (QofQuery *q)
|
||||
{
|
||||
QofQuerySort *s[3];
|
||||
xmlNodePtr sortlist;
|
||||
GSList *plist;
|
||||
xmlNodePtr sort;
|
||||
xmlNodePtr topnode;
|
||||
gboolean increasing;
|
||||
gint opt;
|
||||
xmlNodePtr pl;
|
||||
int i;
|
||||
|
||||
qof_query_get_sorts (q, &s[0], &s[1], &s[2]);
|
||||
|
||||
if (NULL == s[0]) return NULL;
|
||||
|
||||
xmlNodePtr sortlist = xmlNewNode (NULL, "qofquery:sort-list");
|
||||
int i;
|
||||
sortlist = xmlNewNode (NULL, "qofquery:sort-list");
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
if (NULL == s[i]) continue;
|
||||
|
||||
GSList *plist = qof_query_sort_get_param_path (s[i]);
|
||||
plist = qof_query_sort_get_param_path (s[i]);
|
||||
if (!plist) continue;
|
||||
|
||||
xmlNodePtr sort = xmlNewNode (NULL, "qofquery:sort");
|
||||
sort = xmlNewNode (NULL, "qofquery:sort");
|
||||
xmlAddChild (sortlist, sort);
|
||||
|
||||
xmlNodePtr topnode = sort;
|
||||
topnode = sort;
|
||||
|
||||
gboolean increasing = qof_query_sort_get_increasing (s[i]);
|
||||
increasing = qof_query_sort_get_increasing (s[i]);
|
||||
PUT_STR ("qofquery:order", increasing ? "DESCENDING" : "ASCENDING");
|
||||
|
||||
gint opt = qof_query_sort_get_sort_options (s[i]);
|
||||
opt = qof_query_sort_get_sort_options (s[i]);
|
||||
PUT_INT32 ("qofquery:options", opt);
|
||||
|
||||
xmlNodePtr pl = qof_query_param_path_to_xml (plist);
|
||||
pl = qof_query_param_path_to_xml (plist);
|
||||
if (pl) xmlAddChild (sort, pl);
|
||||
}
|
||||
|
||||
@@ -455,16 +489,21 @@ qof_query_sorts_to_xml (QofQuery *q)
|
||||
static void
|
||||
do_qof_query_to_xml (QofQuery *q, xmlNodePtr topnode)
|
||||
{
|
||||
QofIdType search_for = qof_query_get_search_for (q);
|
||||
QofIdType search_for;
|
||||
xmlNodePtr terms;
|
||||
xmlNodePtr sorts;
|
||||
gint max_results;
|
||||
|
||||
search_for = qof_query_get_search_for (q);
|
||||
PUT_STR ("qofquery:search-for", search_for);
|
||||
|
||||
xmlNodePtr terms = qof_query_terms_to_xml(q);
|
||||
terms = qof_query_terms_to_xml(q);
|
||||
if (terms) xmlAddChild (topnode, terms);
|
||||
|
||||
xmlNodePtr sorts = qof_query_sorts_to_xml (q);
|
||||
sorts = qof_query_sorts_to_xml (q);
|
||||
if (sorts) xmlAddChild (topnode, sorts);
|
||||
|
||||
gint max_results = qof_query_get_max_results (q);
|
||||
max_results = qof_query_get_max_results (q);
|
||||
PUT_INT32 ("qofquery:max-results", max_results);
|
||||
}
|
||||
|
||||
@@ -499,6 +538,11 @@ int main (int argc, char * argv[])
|
||||
{
|
||||
QofQuery *q;
|
||||
QofSqlQuery *sq;
|
||||
xmlDocPtr doc;
|
||||
xmlNodePtr topnode;
|
||||
xmlChar *xbuf;
|
||||
int bufsz;
|
||||
xmlOutputBufferPtr xbuf;
|
||||
|
||||
qof_query_init();
|
||||
qof_object_initialize ();
|
||||
@@ -523,12 +567,10 @@ int main (int argc, char * argv[])
|
||||
|
||||
qof_query_print (q);
|
||||
|
||||
xmlDocPtr doc = doc = xmlNewDoc("1.0");
|
||||
xmlNodePtr topnode = qof_query_to_xml (q);
|
||||
doc = doc = xmlNewDoc("1.0");
|
||||
topnode = qof_query_to_xml (q);
|
||||
xmlDocSetRootElement(doc,topnode);
|
||||
|
||||
xmlChar *xbuf;
|
||||
int bufsz;
|
||||
xmlDocDumpFormatMemory (doc, &xbuf, &bufsz, 1);
|
||||
|
||||
printf ("%s\n", xbuf);
|
||||
@@ -538,7 +580,7 @@ int main (int argc, char * argv[])
|
||||
#if 0
|
||||
printf ("duude\n");
|
||||
// xmlOutputBufferPtr xbuf = xmlAllocOutputBuffer (enc);
|
||||
xmlOutputBufferPtr xbuf = xmlOutputBufferCreateFile (stdout, NULL);
|
||||
xbuf = xmlOutputBufferCreateFile (stdout, NULL);
|
||||
printf ("duude\n");
|
||||
|
||||
xbuf = xmlOutputBufferCreateFd (1, NULL);
|
||||
|
||||
@@ -32,18 +32,20 @@
|
||||
#include "qofbook.h"
|
||||
#include "qofsession.h"
|
||||
|
||||
/** \struct QofSession
|
||||
*/
|
||||
struct _QofSession
|
||||
{
|
||||
/* A book holds pointers to the various types of datasets used
|
||||
/** A book holds pointers to the various types of datasets used
|
||||
* by GnuCash. A session may have open multiple books. */
|
||||
GList *books;
|
||||
|
||||
/* The requested book id, in the form or a URI, such as
|
||||
/** The requested book id, in the form or a URI, such as
|
||||
* file:/some/where, or sql:server.host.com:555
|
||||
*/
|
||||
char *book_id;
|
||||
|
||||
/* If any book subroutine failed, this records the failure reason
|
||||
/** If any book subroutine failed, this records the failure reason
|
||||
* (file not found, etc).
|
||||
* This is a 'stack' that is one deep. (Should be deeper ??)
|
||||
* FIXME: Each backend has its own error stack. The session
|
||||
@@ -54,7 +56,7 @@ struct _QofSession
|
||||
char *error_message;
|
||||
|
||||
/* ---------------------------------------------------- */
|
||||
/* Pointer to the backend that is actually used to move data
|
||||
/** Pointer to the backend that is actually used to move data
|
||||
* between the persistant store and the local engine. */
|
||||
QofBackend *backend;
|
||||
};
|
||||
@@ -68,4 +70,3 @@ void qof_session_push_error (QofSession *session, QofBackendError err,
|
||||
QofBackend* gncBackendInit_file(const char *book_id, void *data);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -345,6 +345,7 @@ qof_session_load_backend(QofSession * session, char * backend_name)
|
||||
static void
|
||||
load_backend_library (const char * libso, const char * loadfn)
|
||||
{
|
||||
void (*initfn) (void);
|
||||
void *dl_hand = dlopen (libso, RTLD_LAZY);
|
||||
if (NULL == dl_hand)
|
||||
{
|
||||
@@ -352,7 +353,7 @@ load_backend_library (const char * libso, const char * loadfn)
|
||||
PERR("Can't load %s backend, %s\n", libso, err_str);
|
||||
return;
|
||||
}
|
||||
void (*initfn) (void) = dlsym (dl_hand, loadfn);
|
||||
initfn = dlsym (dl_hand, loadfn);
|
||||
if (initfn)
|
||||
{
|
||||
(*initfn)();
|
||||
@@ -368,6 +369,7 @@ static void
|
||||
qof_session_load_backend(QofSession * session, char * access_method)
|
||||
{
|
||||
GSList *p;
|
||||
GList *node;
|
||||
ENTER (" ");
|
||||
|
||||
/* If the provider list is null, try to register the 'well-known'
|
||||
@@ -390,7 +392,6 @@ qof_session_load_backend(QofSession * session, char * access_method)
|
||||
session->backend = (*(prov->backend_new))();
|
||||
|
||||
/* Tell the books about the backend that they'll be using. */
|
||||
GList *node;
|
||||
for (node=session->books; node; node=node->next)
|
||||
{
|
||||
QofBook *book = node->data;
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
|
||||
/* PROTOTYPES ******************************************************/
|
||||
|
||||
/** QofSession definition */
|
||||
typedef struct _QofSession QofSession;
|
||||
|
||||
QofSession * qof_session_new (void);
|
||||
|
||||
+54
-37
@@ -129,12 +129,13 @@ get_table_and_param (char * str, char **tab, char **param)
|
||||
static inline char *
|
||||
dequote_string (char *str)
|
||||
{
|
||||
size_t len;
|
||||
/* strip out quotation marks ... */
|
||||
if (('\'' == str[0]) ||
|
||||
('\"' == str[0]))
|
||||
{
|
||||
str ++;
|
||||
size_t len = strlen(str);
|
||||
len = strlen(str);
|
||||
str[len-1] = 0;
|
||||
}
|
||||
return str;
|
||||
@@ -145,7 +146,20 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
{
|
||||
char tmpbuff[128];
|
||||
GSList *param_list;
|
||||
GList *guid_list;
|
||||
QofQueryPredData *pred_data = NULL;
|
||||
sql_field_item *sparam, *svalue;
|
||||
char * qparam_name, *qvalue_name, *table_name, *param_name;
|
||||
char *sep, *path,*str,*p;
|
||||
QofQuery *qq;
|
||||
KvpValue *kv, *kval;
|
||||
KvpValueType kvt;
|
||||
QofQueryCompare qop;
|
||||
time_t exact;
|
||||
int rc, len;
|
||||
Timespec ts;
|
||||
QofType param_type;
|
||||
QofGuidMatch gm;
|
||||
|
||||
if (NULL == cond)
|
||||
{
|
||||
@@ -161,14 +175,14 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
PWARN("missing left paramter");
|
||||
return NULL;
|
||||
}
|
||||
sql_field_item * sparam = cond->d.pair.left->item;
|
||||
sparam = cond->d.pair.left->item;
|
||||
if (SQL_name != sparam->type)
|
||||
{
|
||||
PWARN("we support only paramter names at this time (parsed %d)",
|
||||
sparam->type);
|
||||
return NULL;
|
||||
}
|
||||
char * qparam_name = sparam->d.name->data;
|
||||
qparam_name = sparam->d.name->data;
|
||||
if (NULL == qparam_name)
|
||||
{
|
||||
PWARN ("missing paramter name");
|
||||
@@ -183,13 +197,13 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
PWARN ("missing right paramter");
|
||||
return NULL;
|
||||
}
|
||||
sql_field_item * svalue = cond->d.pair.right->item;
|
||||
svalue = cond->d.pair.right->item;
|
||||
if (SQL_name != svalue->type)
|
||||
{
|
||||
PWARN("we support only simple values (parsed as %d)", svalue->type);
|
||||
return NULL;
|
||||
}
|
||||
char * qvalue_name = svalue->d.name->data;
|
||||
qvalue_name = svalue->d.name->data;
|
||||
if (NULL == qvalue_name)
|
||||
{
|
||||
PWARN("missing value");
|
||||
@@ -207,11 +221,11 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
PWARN ("missing kvp frame");
|
||||
return NULL;
|
||||
}
|
||||
KvpValue *kv = kvp_frame_get_value (query->kvp_join, qvalue_name+5);
|
||||
kv = kvp_frame_get_value (query->kvp_join, qvalue_name+5);
|
||||
/* If there's no value, its not an error;
|
||||
* we just don't do this predicate */
|
||||
if (!kv) return NULL;
|
||||
KvpValueType kvt = kvp_value_get_type (kv);
|
||||
kvt = kvp_value_get_type (kv);
|
||||
|
||||
tmpbuff[0] = 0x0;
|
||||
qvalue_name = tmpbuff;
|
||||
@@ -251,7 +265,6 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
param_list = qof_query_build_param_list (qparam_name, NULL);
|
||||
|
||||
/* Get the where-term comparison operator */
|
||||
QofQueryCompare qop;
|
||||
switch (cond->op)
|
||||
{
|
||||
case SQL_eq: qop = QOF_COMPARE_EQUAL; break;
|
||||
@@ -270,8 +283,6 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
/* OK, need to know the type of the thing being matched
|
||||
* in order to build the correct predicate. Get the type
|
||||
* from the object parameters. */
|
||||
char *table_name;
|
||||
char *param_name;
|
||||
get_table_and_param (qparam_name, &table_name, ¶m_name);
|
||||
if (NULL == table_name)
|
||||
{
|
||||
@@ -290,7 +301,7 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QofType param_type = qof_class_get_parameter_type (table_name, param_name);
|
||||
param_type = qof_class_get_parameter_type (table_name, param_name);
|
||||
if (!param_type)
|
||||
{
|
||||
PWARN ("The parameter \'%s\' on object \'%s\' is not known",
|
||||
@@ -339,14 +350,12 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
/* work around highly bogus locale setting */
|
||||
qof_date_format_set(QOF_DATE_FORMAT_US);
|
||||
|
||||
time_t exact;
|
||||
int rc = qof_scan_date_secs (qvalue_name, &exact);
|
||||
rc= qof_scan_date_secs (qvalue_name, &exact);
|
||||
if (0 == rc)
|
||||
{
|
||||
PWARN ("unable to parse date: %s", qvalue_name);
|
||||
return NULL;
|
||||
}
|
||||
Timespec ts;
|
||||
ts.tv_sec = exact;
|
||||
ts.tv_nsec = 0;
|
||||
pred_data = qof_query_date_predicate (qop, QOF_DATE_MATCH_DAY, ts);
|
||||
@@ -377,9 +386,9 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
// XXX less, than greater than don't make sense,
|
||||
// should check for those bad conditions
|
||||
|
||||
QofGuidMatch gm = QOF_GUID_MATCH_ANY;
|
||||
gm = QOF_GUID_MATCH_ANY;
|
||||
if (QOF_COMPARE_NEQ == qop) gm = QOF_GUID_MATCH_NONE;
|
||||
GList *guid_list = g_list_append (NULL, &guid);
|
||||
guid_list = g_list_append (NULL, &guid);
|
||||
pred_data = qof_query_guid_predicate (gm, guid_list);
|
||||
|
||||
g_list_free (guid_list);
|
||||
@@ -389,12 +398,11 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
/* We are expecting an encoded value that looks like
|
||||
* /some/path/string:value
|
||||
*/
|
||||
char *sep = strchr (qvalue_name, ':');
|
||||
sep = strchr (qvalue_name, ':');
|
||||
if (!sep) return NULL;
|
||||
*sep = 0;
|
||||
char * path = qvalue_name;
|
||||
char * str = sep +1;
|
||||
char * p;
|
||||
path = qvalue_name;
|
||||
str = sep +1;
|
||||
/* If str has only digits, we know its a plain number.
|
||||
* If its numbers and a decimal point, assume a float
|
||||
* If its numbers and a slash, assume numeric
|
||||
@@ -402,8 +410,8 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
* If it looks like an iso date ...
|
||||
* else assume its a string.
|
||||
*/
|
||||
KvpValue *kval = NULL;
|
||||
int len = strlen (str);
|
||||
kval = NULL;
|
||||
len = strlen (str);
|
||||
if ((32 == len) && (32 == strspn (str, "0123456789abcdef")))
|
||||
{
|
||||
GUID guid;
|
||||
@@ -455,7 +463,7 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QofQuery *qq = qof_query_create();
|
||||
qq = qof_query_create();
|
||||
qof_query_add_term (qq, param_list, pred_data, QOF_QUERY_FIRST_TERM);
|
||||
return qq;
|
||||
}
|
||||
@@ -465,6 +473,9 @@ handle_single_condition (QofSqlQuery *query, sql_condition * cond)
|
||||
static QofQuery *
|
||||
handle_where (QofSqlQuery *query, sql_where *swear)
|
||||
{
|
||||
QofQueryOp qop;
|
||||
QofQuery * qq;
|
||||
|
||||
switch (swear->type)
|
||||
{
|
||||
case SQL_pair:
|
||||
@@ -473,7 +484,6 @@ handle_where (QofSqlQuery *query, sql_where *swear)
|
||||
QofQuery *qright = handle_where (query, swear->d.pair.right);
|
||||
if (NULL == qleft) return qright;
|
||||
if (NULL == qright) return qleft;
|
||||
QofQueryOp qop;
|
||||
switch (swear->d.pair.op)
|
||||
{
|
||||
case SQL_and: qop = QOF_QUERY_AND; break;
|
||||
@@ -484,7 +494,7 @@ handle_where (QofSqlQuery *query, sql_where *swear)
|
||||
qof_query_destroy (qright);
|
||||
return NULL;
|
||||
}
|
||||
QofQuery * qq = qof_query_merge (qleft, qright, qop);
|
||||
qq = qof_query_merge (qleft, qright, qop);
|
||||
qof_query_destroy (qleft);
|
||||
qof_query_destroy (qright);
|
||||
return qq;
|
||||
@@ -511,11 +521,14 @@ handle_where (QofSqlQuery *query, sql_where *swear)
|
||||
static void
|
||||
handle_sort_order (QofSqlQuery *query, GList *sorder_list)
|
||||
{
|
||||
if (!sorder_list) return;
|
||||
|
||||
GSList *qsp[3];
|
||||
GList *n;
|
||||
gboolean direction[3];
|
||||
int i;
|
||||
sql_order_field *sorder;
|
||||
char * qparam_name;
|
||||
|
||||
if (!sorder_list) return;
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
@@ -524,14 +537,14 @@ handle_sort_order (QofSqlQuery *query, GList *sorder_list)
|
||||
|
||||
if (sorder_list)
|
||||
{
|
||||
sql_order_field *sorder = sorder_list->data;
|
||||
sorder = sorder_list->data;
|
||||
|
||||
/* Set the sort direction */
|
||||
if (SQL_asc == sorder->order_type) direction[i] = TRUE;
|
||||
|
||||
/* Find the paramter name */
|
||||
char * qparam_name = NULL;
|
||||
GList *n = sorder->name;
|
||||
qparam_name = NULL;
|
||||
n = sorder->name;
|
||||
if (n)
|
||||
{
|
||||
qparam_name = n->data;
|
||||
@@ -559,6 +572,10 @@ handle_sort_order (QofSqlQuery *query, GList *sorder_list)
|
||||
void
|
||||
qof_sql_query_parse (QofSqlQuery *query, const char *str)
|
||||
{
|
||||
GList *tables;
|
||||
sql_select_statement *sss;
|
||||
sql_where *swear;
|
||||
|
||||
if (!query) return;
|
||||
|
||||
/* Delete old query, if any */
|
||||
@@ -590,14 +607,14 @@ qof_sql_query_parse (QofSqlQuery *query, const char *str)
|
||||
* user wrote "SELECT * FROM tableA, tableB WHERE ..."
|
||||
* then we don't have a single unique table-name.
|
||||
*/
|
||||
GList *tables = sql_statement_get_tables (query->parse_result);
|
||||
tables = sql_statement_get_tables (query->parse_result);
|
||||
if (1 == g_list_length (tables))
|
||||
{
|
||||
query->single_global_tablename = tables->data;
|
||||
}
|
||||
|
||||
sql_select_statement *sss = query->parse_result->statement;
|
||||
sql_where * swear = sss->where;
|
||||
sss = query->parse_result->statement;
|
||||
swear = sss->where;
|
||||
if (swear)
|
||||
{
|
||||
/* Walk over the where terms, turn them into QOF predicates */
|
||||
@@ -625,7 +642,7 @@ qof_sql_query_parse (QofSqlQuery *query, const char *str)
|
||||
GList *
|
||||
qof_sql_query_run (QofSqlQuery *query, const char *str)
|
||||
{
|
||||
GList *node;
|
||||
GList *node, *results;
|
||||
|
||||
if (!query) return NULL;
|
||||
|
||||
@@ -635,7 +652,7 @@ qof_sql_query_run (QofSqlQuery *query, const char *str)
|
||||
qof_query_set_book (query->qof_query, query->book);
|
||||
|
||||
// qof_query_print (query->qof_query);
|
||||
GList *results = qof_query_run (query->qof_query);
|
||||
results = qof_query_run (query->qof_query);
|
||||
|
||||
return results;
|
||||
}
|
||||
@@ -643,7 +660,7 @@ qof_sql_query_run (QofSqlQuery *query, const char *str)
|
||||
GList *
|
||||
qof_sql_query_rerun (QofSqlQuery *query)
|
||||
{
|
||||
GList *node;
|
||||
GList *node, *results;
|
||||
|
||||
if (!query) return NULL;
|
||||
|
||||
@@ -652,7 +669,7 @@ qof_sql_query_rerun (QofSqlQuery *query)
|
||||
qof_query_set_book (query->qof_query, query->book);
|
||||
|
||||
// qof_query_print (query->qof_query);
|
||||
GList *results = qof_query_run (query->qof_query);
|
||||
results = qof_query_run (query->qof_query);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ LDADD = \
|
||||
../libgw-kvp.la \
|
||||
../test-core/libgncmod-test-engine.la \
|
||||
${GLIB_LIBS} \
|
||||
-lltdl \
|
||||
-lglib
|
||||
-lltdl
|
||||
|
||||
# these tests are ordered kind more or less in the order
|
||||
# that they should be executed, with more basic tests coming first.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*********************************************************************
|
||||
* test-book-merge.c -- test implementation api for QoFBook merge *
|
||||
* Copyright (C) 2004 Neil Williams <linux@codehelp.co.uk> *
|
||||
* Copyright (C) 2004-2005 Neil Williams <linux@codehelp.co.uk> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@@ -213,7 +213,7 @@ obj_setAmount(myobj *g, gnc_numeric h)
|
||||
gnc_numeric
|
||||
obj_getAmount(myobj *g)
|
||||
{
|
||||
if(!g) return double_to_gnc_numeric(0,0,GNC_HOW_DENOM_EXACT);
|
||||
if(!g) return gnc_numeric_zero();
|
||||
return g->Amount;
|
||||
}
|
||||
|
||||
@@ -413,6 +413,7 @@ test_rule_loop (qof_book_mergeData *mergeData, qof_book_mergeRule *rule, guint r
|
||||
importstring = NULL;
|
||||
targetstring = NULL;
|
||||
skip_target = FALSE;
|
||||
mergeData->currentRule = rule;
|
||||
do_test ((rule != NULL), "loop:#1 Rule is NULL");
|
||||
do_test (remainder > 0, "loop:#2 remainder error.");
|
||||
do_test ((safe_strcmp(NULL, rule->mergeLabel) != 0), "loop:#3 object label\n");
|
||||
@@ -449,11 +450,11 @@ test_rule_loop (qof_book_mergeData *mergeData, qof_book_mergeRule *rule, guint r
|
||||
/* do NOT use as_string for calculations or set_fcn */
|
||||
importstring = qof_book_merge_param_as_string(eachParam, rule->importEnt);
|
||||
do_test ((importstring != NULL), "loop:#16 import param_as_string is null");
|
||||
// printf("importstring %s\t%s Type\n", importstring, eachParam->param_type);
|
||||
/* printf("importstring %s\t%s Type\n", importstring, eachParam->param_type);*/
|
||||
if(!skip_target) {
|
||||
targetstring = qof_book_merge_param_as_string(eachParam, rule->targetEnt);
|
||||
do_test ((targetstring != NULL), "loop:#17 target param_as_string is null");
|
||||
// printf("targetstring %s\t%s Type\n", targetstring, eachParam->param_type);
|
||||
/* printf("targetstring %s\t%s Type\n", targetstring, eachParam->param_type);*/
|
||||
}
|
||||
/* add your own code for user involvement here. */
|
||||
/* either store the importstring and targetstring values and display separately,
|
||||
|
||||
@@ -53,7 +53,6 @@ QofBook *targetBook = NULL;
|
||||
gchar *buffer = "";
|
||||
|
||||
void collision_rule_loop ( qof_book_mergeData*, qof_book_mergeRule*, guint );
|
||||
void progress_rule_loop ( qof_book_mergeData*, qof_book_mergeRule*, guint );
|
||||
|
||||
static GtkWidget*
|
||||
merge_get_widget (const char *name)
|
||||
@@ -226,11 +225,6 @@ on_qof_book_merge_prepare (GnomeDruidPage *gnomedruidpage,
|
||||
g_return_if_fail(targetBook != NULL);
|
||||
mergeData = qof_book_mergeInit(mergeBook, targetBook);
|
||||
g_return_if_fail(mergeData != NULL);
|
||||
qof_book_mergeRuleForeach(mergeData, progress_rule_loop, MERGE_NEW);
|
||||
qof_book_mergeRuleForeach(mergeData, progress_rule_loop, MERGE_ABSOLUTE);
|
||||
qof_book_mergeRuleForeach(mergeData, progress_rule_loop, MERGE_DUPLICATE);
|
||||
qof_book_mergeRuleForeach(mergeData, progress_rule_loop, MERGE_UPDATE);
|
||||
gtk_label_set_text(progress, buffer);
|
||||
qof_book_mergeRuleForeach(mergeData, collision_rule_loop, MERGE_REPORT);
|
||||
gnc_resume_gui_refresh ();
|
||||
}
|
||||
@@ -279,76 +273,6 @@ gnc_create_merge_druid ( void )
|
||||
return dialog;
|
||||
}
|
||||
|
||||
void progress_rule_loop(qof_book_mergeData *mergeData, qof_book_mergeRule *rule, guint remainder)
|
||||
{
|
||||
GtkLabel *progress;
|
||||
|
||||
g_return_if_fail(mergeData != NULL);
|
||||
progress = GTK_LABEL(merge_get_widget("ResultsBox"));
|
||||
buffer = "";
|
||||
g_return_if_fail(rule != NULL);
|
||||
if(rule->mergeResult == MERGE_NEW) {
|
||||
if (remainder == 1) {
|
||||
buffer = g_strconcat(buffer,
|
||||
g_strdup_printf("%i %s tagged as NEW.\n", remainder, rule->mergeLabel), NULL);
|
||||
gtk_label_set_text (progress, buffer);
|
||||
}
|
||||
else {
|
||||
buffer = g_strconcat(buffer,
|
||||
g_strdup_printf("%i entities of type %s are tagged as NEW.\n",
|
||||
remainder, rule->mergeLabel), NULL);
|
||||
gtk_label_set_text (progress, buffer);
|
||||
}
|
||||
gtk_widget_show(GTK_WIDGET(progress));
|
||||
return;
|
||||
}
|
||||
if(rule->mergeResult == MERGE_ABSOLUTE) {
|
||||
if (remainder == 1) {
|
||||
buffer = g_strconcat(buffer,
|
||||
g_strdup_printf("%i %s tagged as an absolute GUID match.\n",
|
||||
remainder, rule->mergeLabel), NULL);
|
||||
gtk_label_set_text (progress, buffer);
|
||||
}
|
||||
else {
|
||||
buffer = g_strconcat(buffer,
|
||||
g_strdup_printf("%i entities of type %s tagged as an absolute GUID match.\n",
|
||||
remainder, rule->mergeLabel), NULL);
|
||||
gtk_label_set_text (progress, buffer);
|
||||
}
|
||||
gtk_widget_show(GTK_WIDGET(progress));
|
||||
return;
|
||||
}
|
||||
if(rule->mergeResult == MERGE_DUPLICATE) {
|
||||
if (remainder == 1) {
|
||||
buffer = g_strconcat(buffer, g_strdup_printf("%i %s tagged as a duplicate.\n",
|
||||
remainder, rule->mergeLabel), NULL);
|
||||
gtk_label_set_text (progress, buffer);
|
||||
}
|
||||
else {
|
||||
buffer = g_strconcat(buffer, g_strdup_printf("%i entities of type %s tagged as a duplicate.\n",
|
||||
remainder, rule->mergeLabel), NULL);
|
||||
gtk_label_set_text (progress, buffer);
|
||||
}
|
||||
gtk_widget_show(GTK_WIDGET(progress));
|
||||
return;
|
||||
}
|
||||
if(rule->mergeResult == MERGE_UPDATE) {
|
||||
if (remainder == 1) {
|
||||
buffer = g_strconcat(buffer, g_strdup_printf("%i %s tagged as to be updated.\n",
|
||||
remainder, rule->mergeLabel), NULL);
|
||||
gtk_label_set_text (progress, buffer);
|
||||
}
|
||||
else {
|
||||
buffer = g_strconcat(buffer, g_strdup_printf("%i entities of type %s tagged as to be updated.\n",
|
||||
remainder, rule->mergeLabel), NULL);
|
||||
gtk_label_set_text (progress, buffer);
|
||||
}
|
||||
gtk_widget_show(GTK_WIDGET(progress));
|
||||
return;
|
||||
}
|
||||
g_free(buffer);
|
||||
}
|
||||
|
||||
void collision_rule_loop(qof_book_mergeData *mergeData, qof_book_mergeRule *rule, guint remainder)
|
||||
{
|
||||
GSList *user_reports;
|
||||
|
||||
Reference in New Issue
Block a user