Пример #1
0
static GncBillTerm*
load_single_billterm (GncSqlBackend* sql_be, GncSqlRow& row,
                      BillTermParentGuidVec& l_billterms_needing_parents)
{
    g_return_val_if_fail (sql_be != NULL, NULL);

    auto guid = gnc_sql_load_guid (sql_be, row);
    auto pBillTerm = gncBillTermLookup (sql_be->book(), guid);
    if (pBillTerm == nullptr)
    {
        pBillTerm = gncBillTermCreate (sql_be->book());
    }
    gnc_sql_load_object (sql_be, row, GNC_ID_BILLTERM, pBillTerm, col_table);

    /* If the billterm doesn't have a parent, it might be because it hasn't been
       loaded yet.  If so, add this billterm to the list of billterms with no
       parent, along with the parent GncGUID so that after they are all loaded,
       the parents can be fixed up. */
    if (gncBillTermGetParent (pBillTerm) == NULL)
    {
        BillTermParentGuid s;

        s.billterm = pBillTerm;
        s.have_guid = false;
        gnc_sql_load_object (sql_be, row, GNC_ID_TAXTABLE, &s,
                             billterm_parent_col_table);
        if (s.have_guid)
            l_billterms_needing_parents.push_back(new BillTermParentGuid(s));

    }

    qof_instance_mark_clean (QOF_INSTANCE (pBillTerm));

    return pBillTerm;
}
Пример #2
0
static void
load_slot (slot_info_t* pInfo, GncSqlRow& row)
{
    slot_info_t* slot_info;

    g_return_if_fail (pInfo != NULL);
    g_return_if_fail (pInfo->be != NULL);
    g_return_if_fail (pInfo->pKvpFrame != NULL);

    slot_info = slot_info_copy (pInfo, NULL);

    gnc_sql_load_object (pInfo->be, row, TABLE_NAME, slot_info, col_table);

    if (slot_info->pList != pInfo->pList)
    {
        if (pInfo->pList != NULL)
        {
            PWARN ("Load slot returned a different list than the original");
        }
        else
        {
            pInfo->pList = slot_info->pList;
        }
    }
    delete slot_info;
}
Пример #3
0
/* ================================================================= */
static  SchedXaction*
load_single_sx (GncSqlBackend* sql_be, GncSqlRow& row)
{
    const GncGUID* guid;
    SchedXaction* pSx;
    GList* schedule;
    GDate start_date;

    g_return_val_if_fail (sql_be != NULL, NULL);

    guid = gnc_sql_load_guid (sql_be, row);
    g_assert (guid != NULL);
    pSx = xaccSchedXactionMalloc (sql_be->book());

    gnc_sx_begin_edit (pSx);
    gnc_sql_load_object (sql_be, row, GNC_SX_ID, pSx, col_table);
    schedule = gnc_sql_recurrence_load_list (sql_be, guid);
    gnc_sx_set_schedule (pSx, schedule);
    gnc_sx_commit_edit (pSx);
    gnc_sql_transaction_load_tx_for_account (sql_be, pSx->template_acct);

    g_object_get (pSx, "start-date", &start_date, NULL);

    return pSx;
}
Пример #4
0
static void
load_slot( slot_info_t *pInfo, GncSqlRow* row )
{
    slot_info_t *slot_info;

    g_return_if_fail( pInfo != NULL );
    g_return_if_fail( pInfo->be != NULL );
    g_return_if_fail( row != NULL );
    g_return_if_fail( pInfo->pKvpFrame != NULL );

    slot_info = slot_info_copy( pInfo, NULL );
    g_string_free( slot_info->path, TRUE );
    slot_info->path = NULL;

    gnc_sql_load_object( pInfo->be, row, TABLE_NAME, slot_info, col_table );

    if ( slot_info->path != NULL )
    {
        (void)g_string_free( slot_info->path, TRUE );
    }
    if ( slot_info->pList != pInfo->pList )
    {
        if (pInfo->pList != NULL)
        {
            PWARN("Load slot returned a different list than the original");
        }
        else
        {
            pInfo->pList = slot_info->pList;
        }
    }
    g_slice_free( slot_info_t, slot_info );
}
Пример #5
0
static void
load_slot_for_list_item( GncSqlBackend* be, GncSqlRow* row, QofCollection* coll )
{
    slot_info_t slot_info = { NULL, NULL, TRUE, NULL, 0, NULL, FRAME, NULL, NULL };
    const GncGUID* guid;
    QofInstance* inst;

    g_return_if_fail( be != NULL );
    g_return_if_fail( row != NULL );
    g_return_if_fail( coll != NULL );

    guid = load_obj_guid( be, row );
    g_assert( guid != NULL );
    inst = qof_collection_lookup_entity( coll, guid );

    slot_info.be = be;
    slot_info.pKvpFrame = qof_instance_get_slots( inst );
    slot_info.context = NONE;

    gnc_sql_load_object( be, row, TABLE_NAME, &slot_info, col_table );

    if ( slot_info.path != NULL )
    {
        (void)g_string_free( slot_info.path, TRUE );
    }
}
Пример #6
0
static void
load_slot_for_book_object( GncSqlBackend* be, GncSqlRow* row, BookLookupFn lookup_fn )
{
    slot_info_t slot_info = { NULL, NULL, TRUE, NULL, 0, NULL, FRAME, NULL, NULL };
    const GncGUID* guid;
    QofInstance* inst;

    g_return_if_fail( be != NULL );
    g_return_if_fail( row != NULL );
    g_return_if_fail( lookup_fn != NULL );

    guid = load_obj_guid( be, row );
    g_return_if_fail( guid != NULL );
    inst = lookup_fn( guid, be->book );
    g_return_if_fail( inst != NULL );

    slot_info.be = be;
    slot_info.pKvpFrame = qof_instance_get_slots( inst );
    slot_info.path = NULL;

    gnc_sql_load_object( be, row, TABLE_NAME, &slot_info, col_table );

    if ( slot_info.path != NULL )
    {
        (void)g_string_free( slot_info.path, TRUE );
    }
}
Пример #7
0
static /*@ null @*/ Transaction*
load_single_tx( GncSqlBackend* be, GncSqlRow* row )
{
    const GncGUID* guid;
    GncGUID tx_guid;
    Transaction* pTx;

    g_return_val_if_fail( be != NULL, NULL );
    g_return_val_if_fail( row != NULL, NULL );

    guid = gnc_sql_load_guid( be, row );
    if ( guid == NULL ) return NULL;
    tx_guid = *guid;

    // Don't overwrite the transaction if it's already been loaded (and possibly modified).
    pTx = xaccTransLookup( &tx_guid, be->book );
    if ( pTx != NULL )
    {
        return NULL;
    }

    pTx = xaccMallocTransaction( be->book );
    xaccTransBeginEdit( pTx );
    gnc_sql_load_object( be, row, GNC_ID_TRANS, pTx, tx_col_table );

    if (pTx != xaccTransLookup( &tx_guid, be->book ))
    {
	PERR("A malformed transaction with id %s was found in the dataset.",
	     guid_to_string(qof_instance_get_guid(pTx)));
	qof_backend_set_error( &be->be, ERR_BACKEND_DATA_CORRUPT);
	pTx = NULL;
    }

    return pTx;
}
Пример #8
0
/*----------------------------------------------------------------*/
static  GncBudget*
load_single_budget (GncSqlBackend* sql_be, GncSqlRow& row)
{
    const GncGUID* guid;
    GncBudget* pBudget = NULL;
    Recurrence* r;

    g_return_val_if_fail (sql_be != NULL, NULL);

    guid = gnc_sql_load_guid (sql_be, row);
    if (guid != NULL)
    {
        pBudget = gnc_budget_lookup (guid, sql_be->book());
    }
    if (pBudget == NULL)
    {
        pBudget = gnc_budget_new (sql_be->book());
    }

    gnc_budget_begin_edit (pBudget);
    gnc_sql_load_object (sql_be, row, GNC_ID_BUDGET, pBudget, col_table);
    load_budget_amounts (sql_be, pBudget);
    r = gnc_sql_recurrence_load (sql_be, gnc_budget_get_guid (pBudget));
    if (r != NULL)
    {
        gnc_budget_set_recurrence (pBudget, r);
        g_free (r);
    }
    gnc_budget_commit_edit (pBudget);

    return pBudget;
}
Пример #9
0
static GncBillTerm*
load_single_billterm (GncSqlBackend* be, GncSqlRow* row,
                      GList** l_billterms_needing_parents)
{
    const GncGUID* guid;
    GncBillTerm* pBillTerm;

    g_return_val_if_fail (be != NULL, NULL);
    g_return_val_if_fail (row != NULL, NULL);

    guid = gnc_sql_load_guid (be, row);
    pBillTerm = gncBillTermLookup (be->book, guid);
    if (pBillTerm == NULL)
    {
        pBillTerm = gncBillTermCreate (be->book);
    }
    gnc_sql_load_object (be, row, GNC_ID_BILLTERM, pBillTerm, col_table);

    /* If the billterm doesn't have a parent, it might be because it hasn't been loaded yet.
       If so, add this billterm to the list of billterms with no parent, along with the parent
       GncGUID so that after they are all loaded, the parents can be fixed up. */
    if (gncBillTermGetParent (pBillTerm) == NULL)
    {
        billterm_parent_guid_struct* s = static_cast<decltype (s)> (
                                             g_malloc (sizeof (billterm_parent_guid_struct)));
        g_assert (s != NULL);

        s->billterm = pBillTerm;
        s->have_guid = FALSE;
        gnc_sql_load_object (be, row, GNC_ID_TAXTABLE, s, billterm_parent_col_table);
        if (s->have_guid)
        {
            *l_billterms_needing_parents = g_list_prepend (*l_billterms_needing_parents,
                                                           s);
        }
        else
        {
            g_free (s);
        }
    }

    qof_instance_mark_clean (QOF_INSTANCE (pBillTerm));

    return pBillTerm;
}
Пример #10
0
static void
load_single_taxtable( GncSqlBackend* be, GncSqlRow* row,
                      GList** l_tt_needing_parents )
{
    const GncGUID* guid;
    GncTaxTable* tt;

    g_return_if_fail( be != NULL );
    g_return_if_fail( row != NULL );

    guid = gnc_sql_load_guid( be, row );
    tt = gncTaxTableLookup( be->book, guid );
    if ( tt == NULL )
    {
        tt = gncTaxTableCreate( be->book );
    }
    gnc_sql_load_object( be, row, GNC_ID_TAXTABLE, tt, tt_col_table );
    gnc_sql_slots_load( be, QOF_INSTANCE(tt) );
    load_taxtable_entries( be, tt );

    /* If the tax table doesn't have a parent, it might be because it hasn't been loaded yet.
       If so, add this tax table to the list of tax tables with no parent, along with the parent
       GncGUID so that after they are all loaded, the parents can be fixed up. */
    if ( gncTaxTableGetParent( tt ) == NULL )
    {
        taxtable_parent_guid_struct* s = static_cast<decltype(s)>(
            g_malloc(sizeof(taxtable_parent_guid_struct)));
        g_assert( s != NULL );

        s->tt = tt;
        s->have_guid = FALSE;
        gnc_sql_load_object( be, row, GNC_ID_TAXTABLE, s, tt_parent_col_table );
        if ( s->have_guid )
        {
            *l_tt_needing_parents = g_list_prepend( *l_tt_needing_parents, s );
        }
        else
        {
            g_free( s );
        }
    }

    qof_instance_mark_clean( QOF_INSTANCE(tt) );
}
Пример #11
0
static  const GncGUID*
load_obj_guid (const GncSqlBackend* sql_be, GncSqlRow& row)
{
    static GncGUID guid;

    g_return_val_if_fail (sql_be != NULL, NULL);

    gnc_sql_load_object (sql_be, row, NULL, &guid, obj_guid_col_table);

    return &guid;
}
Пример #12
0
static void
load_single_ttentry (GncSqlBackend* sql_be, GncSqlRow& row, GncTaxTable* tt)
{
    GncTaxTableEntry* e = gncTaxTableEntryCreate ();

    g_return_if_fail (sql_be != NULL);
    g_return_if_fail (tt != NULL);

    gnc_sql_load_object (sql_be, row, GNC_ID_TAXTABLE, e, ttentries_col_table);
    gncTaxTableAddEntry (tt, e);
}
Пример #13
0
static /*@ dependent @*//*@ null @*/ const GncGUID*
load_obj_guid( const GncSqlBackend* be, GncSqlRow* row )
{
    static GncGUID guid;

    g_return_val_if_fail( be != NULL, NULL );
    g_return_val_if_fail( row != NULL, NULL );

    gnc_sql_load_object( be, row, NULL, &guid, obj_guid_col_table );

    return &guid;
}
Пример #14
0
static  Account*
load_single_account (GncSqlBackend* be, GncSqlRow* row,
                     GList** l_accounts_needing_parents)
{
    const GncGUID* guid;
    Account* pAccount = NULL;

    g_return_val_if_fail (be != NULL, NULL);
    g_return_val_if_fail (row != NULL, NULL);
    g_return_val_if_fail (l_accounts_needing_parents != NULL, NULL);

    guid = gnc_sql_load_guid (be, row);
    if (guid != NULL)
    {
        pAccount = xaccAccountLookup (guid, be->book);
    }
    if (pAccount == NULL)
    {
        pAccount = xaccMallocAccount (be->book);
    }
    xaccAccountBeginEdit (pAccount);
    gnc_sql_load_object (be, row, GNC_ID_ACCOUNT, pAccount, col_table);
    xaccAccountCommitEdit (pAccount);

    /* If we don't have a parent and this isn't the root account, it might be because the parent
       account hasn't been loaded yet.  Remember the account and its parent guid for later. */
    if (gnc_account_get_parent (pAccount) == NULL
        && pAccount != gnc_book_get_root_account (be->book))
    {
        account_parent_guid_struct* s = static_cast<decltype (s)> (
                                            g_malloc (sizeof (account_parent_guid_struct)));
        g_assert (s != NULL);

        s->pAccount = pAccount;
        gnc_sql_load_object (be, row, GNC_ID_ACCOUNT, s, parent_col_table);
        *l_accounts_needing_parents = g_list_prepend (*l_accounts_needing_parents, s);
    }

    return pAccount;
}
static /*@ dependent @*/ gnc_commodity*
load_single_commodity( GncSqlBackend* be, GncSqlRow* row )
{
    QofBook* pBook = be->book;
    gnc_commodity* pCommodity;

    pCommodity = gnc_commodity_new( pBook, NULL, NULL, NULL, NULL, 100 );
    gnc_commodity_begin_edit( pCommodity );
    gnc_sql_load_object( be, row, GNC_ID_COMMODITY, pCommodity, col_table );
    gnc_commodity_commit_edit( pCommodity );

    return pCommodity;
}
Пример #16
0
static void
load_recurrence (GncSqlBackend* sql_be, GncSqlRow& row,  Recurrence* r)
{
    recurrence_info_t recurrence_info;

    g_return_if_fail (sql_be != NULL);
    g_return_if_fail (r != NULL);

    recurrence_info.be = sql_be;
    recurrence_info.pRecurrence = r;

    gnc_sql_load_object (sql_be, row, TABLE_NAME, &recurrence_info, col_table);
}
Пример #17
0
static void
load_single_taxtable (GncSqlBackend* sql_be, GncSqlRow& row,
                      TaxTblParentGuidVec& l_tt_needing_parents)
{
    const GncGUID* guid;
    GncTaxTable* tt;

    g_return_if_fail (sql_be != NULL);

    guid = gnc_sql_load_guid (sql_be, row);
    tt = gncTaxTableLookup (sql_be->book(), guid);
    if (tt == nullptr)
    {
        tt = gncTaxTableCreate (sql_be->book());
    }
    gnc_sql_load_object (sql_be, row, GNC_ID_TAXTABLE, tt, tt_col_table);
    gnc_sql_slots_load (sql_be, QOF_INSTANCE (tt));
    load_taxtable_entries (sql_be, tt);

    /* If the tax table doesn't have a parent, it might be because it hasn't
       been loaded yet.  if so, add this tax table to the list of tax tables
       with no parent, along with the parent GncGUID so that after they are all
       loaded, the parents can be fixed up. */
    if (gncTaxTableGetParent (tt) == NULL)
    {
        TaxTblParentGuid s;

        s.tt = tt;
        s.have_guid = false;
        gnc_sql_load_object (sql_be, row, GNC_ID_TAXTABLE, &s,
                             tt_parent_col_table);
        if (s.have_guid)
            l_tt_needing_parents.push_back(new TaxTblParentGuid(s));

    }

    qof_instance_mark_clean (QOF_INSTANCE (tt));
}
Пример #18
0
static void
load_recurrence( GncSqlBackend* be, GncSqlRow* row, /*@ out @*/ Recurrence* r )
{
    recurrence_info_t recurrence_info;

    g_return_if_fail( be != NULL );
    g_return_if_fail( row != NULL );
    g_return_if_fail( r != NULL );

    recurrence_info.be = be;
    recurrence_info.pRecurrence = r;

    gnc_sql_load_object( be, row, TABLE_NAME, &recurrence_info, col_table );
}
Пример #19
0
static  Account*
load_single_account (GncSqlBackend* sql_be, GncSqlRow& row,
                     ParentGuidVec& l_accounts_needing_parents)
{
    const GncGUID* guid;
    Account* pAccount = NULL;

    g_return_val_if_fail (sql_be != NULL, NULL);

    guid = gnc_sql_load_guid (sql_be, row);
    if (guid != NULL)
    {
        pAccount = xaccAccountLookup (guid, sql_be->book());
    }
    if (pAccount == NULL)
    {
        pAccount = xaccMallocAccount (sql_be->book());
    }
    xaccAccountBeginEdit (pAccount);
    gnc_sql_load_object (sql_be, row, GNC_ID_ACCOUNT, pAccount, col_table);
    xaccAccountCommitEdit (pAccount);

    /* If we don't have a parent and this isn't the root account, it might be
       because the parent account hasn't been loaded yet.  Remember the account
       and its parent guid for later. */
    if (gnc_account_get_parent (pAccount) == NULL
        && pAccount != gnc_book_get_root_account (sql_be->book()))
    {
        auto s = new ParentGuid;

        s->pAccount = pAccount;
        gnc_sql_load_object (sql_be, row, GNC_ID_ACCOUNT, s, parent_col_table);
        l_accounts_needing_parents.push_back(s);
    }

    return pAccount;
}
Пример #20
0
static  GNCLot*
load_single_lot (GncSqlBackend* be, GncSqlRow& row)
{
    GNCLot* lot;

    g_return_val_if_fail (be != NULL, NULL);

    lot = gnc_lot_new (be->book());

    gnc_lot_begin_edit (lot);
    gnc_sql_load_object (be, row, GNC_ID_LOT, lot, col_table);
    gnc_lot_commit_edit (lot);

    return lot;
}
Пример #21
0
G_GNUC_UNUSED static /*@ null @*/ single_acct_balance_t*
load_single_acct_balances( const GncSqlBackend* be, GncSqlRow* row )
{
    single_acct_balance_t* bal = NULL;

    g_return_val_if_fail( be != NULL, NULL );
    g_return_val_if_fail( row != NULL, NULL );

    bal = g_malloc( (gsize)sizeof(single_acct_balance_t) );
    g_assert( bal != NULL );

    bal->be = be;
    gnc_sql_load_object( be, row, NULL, bal, acct_balances_col_table );

    return bal;
}
Пример #22
0
static  GNCPrice*
load_single_price (GncSqlBackend* be, GncSqlRow* row)
{
    GNCPrice* pPrice;

    g_return_val_if_fail (be != NULL, NULL);
    g_return_val_if_fail (row != NULL, NULL);

    pPrice = gnc_price_create (be->book);

    gnc_price_begin_edit (pPrice);
    gnc_sql_load_object (be, row, GNC_ID_PRICE, pPrice, col_table);
    gnc_price_commit_edit (pPrice);

    return pPrice;
}
Пример #23
0
static /*@ null @*/ Split*
load_single_split( GncSqlBackend* be, GncSqlRow* row )
{
    const GncGUID* guid;
    GncGUID split_guid;
    Split* pSplit = NULL;
    gboolean bad_guid = FALSE;

    g_return_val_if_fail( be != NULL, NULL );
    g_return_val_if_fail( row != NULL, NULL );

    guid = gnc_sql_load_guid( be, row );
    if ( guid == NULL ) return NULL;
    if (guid_equal(guid, guid_null()))
    {
	PWARN("Bad GUID, creating new");
	bad_guid = TRUE;
	split_guid = guid_new_return();
    }
    else
    {
	split_guid = *guid;
	pSplit = xaccSplitLookup( &split_guid, be->book );
    }

    if ( pSplit == NULL )
    {
	pSplit = xaccMallocSplit( be->book );
    }

    /* If the split is dirty, don't overwrite it */
    if ( !qof_instance_is_dirty( QOF_INSTANCE(pSplit) ) )
    {
        gnc_sql_load_object( be, row, GNC_ID_SPLIT, pSplit, split_col_table );
    }

    /*# -ifempty */
    if (pSplit != xaccSplitLookup( &split_guid, be->book ))
    {
        gchar guidstr[GUID_ENCODING_LENGTH+1];
        guid_to_string_buff(qof_instance_get_guid(pSplit), guidstr);
        PERR("A malformed split with id %s was found in the dataset.", guidstr);
        qof_backend_set_error( &be->be, ERR_BACKEND_DATA_CORRUPT);
        pSplit = NULL;
    }
    return pSplit;
}
Пример #24
0
static GncVendor*
load_single_vendor (GncSqlBackend* sql_be, GncSqlRow& row)
{
    const GncGUID* guid;
    GncVendor* pVendor;

    g_return_val_if_fail (sql_be != NULL, NULL);

    guid = gnc_sql_load_guid (sql_be, row);
    pVendor = gncVendorLookup (sql_be->book(), guid);
    if (pVendor == NULL)
    {
        pVendor = gncVendorCreate (sql_be->book());
    }
    gnc_sql_load_object (sql_be, row, GNC_ID_VENDOR, pVendor, col_table);
    qof_instance_mark_clean (QOF_INSTANCE (pVendor));

    return pVendor;
}
Пример #25
0
static GncOrder*
load_single_order (GncSqlBackend* be, GncSqlRow& row)
{
    const GncGUID* guid;
    GncOrder* pOrder;

    g_return_val_if_fail (be != NULL, NULL);

    guid = gnc_sql_load_guid (be, row);
    pOrder = gncOrderLookup (be->book(), guid);
    if (pOrder == NULL)
    {
        pOrder = gncOrderCreate (be->book());
    }
    gnc_sql_load_object (be, row, GNC_ID_ORDER, pOrder, col_table);
    qof_instance_mark_clean (QOF_INSTANCE (pOrder));

    return pOrder;
}
Пример #26
0
static GncEmployee*
load_single_employee (GncSqlBackend* sql_be, GncSqlRow& row)
{
    const GncGUID* guid;
    GncEmployee* pEmployee;

    g_return_val_if_fail (sql_be != NULL, NULL);

    guid = gnc_sql_load_guid (sql_be, row);
    pEmployee = gncEmployeeLookup (sql_be->book(), guid);
    if (pEmployee == NULL)
    {
        pEmployee = gncEmployeeCreate (sql_be->book());
    }
    gnc_sql_load_object (sql_be, row, GNC_ID_EMPLOYEE, pEmployee, col_table);
    qof_instance_mark_clean (QOF_INSTANCE (pEmployee));

    return pEmployee;
}
Пример #27
0
static GncInvoice*
load_single_invoice (GncSqlBackend* be, GncSqlRow& row)
{
    const GncGUID* guid;
    GncInvoice* pInvoice;

    g_return_val_if_fail (be != NULL, NULL);

    guid = gnc_sql_load_guid (be, row);
    pInvoice = gncInvoiceLookup (be->book(), guid);
    if (pInvoice == NULL)
    {
        pInvoice = gncInvoiceCreate (be->book());
    }
    gnc_sql_load_object (be, row, GNC_ID_INVOICE, pInvoice, col_table);
    qof_instance_mark_clean (QOF_INSTANCE (pInvoice));

    return pInvoice;
}
Пример #28
0
static GncJob*
load_single_job( GncSqlBackend* be, GncSqlRow* row )
{
    const GncGUID* guid;
    GncJob* pJob;

    g_return_val_if_fail( be != NULL, NULL );
    g_return_val_if_fail( row != NULL, NULL );

    guid = gnc_sql_load_guid( be, row );
    pJob = gncJobLookup( be->book, guid );
    if ( pJob == NULL )
    {
        pJob = gncJobCreate( be->book );
    }
    gnc_sql_load_object( be, row, GNC_ID_JOB, pJob, col_table );
    qof_instance_mark_clean( QOF_INSTANCE(pJob) );

    return pJob;
}
Пример #29
0
static GncCustomer*
load_single_customer( GncSqlBackend* be, GncSqlRow* row )
{
    const GncGUID* guid;
    GncCustomer* pCustomer;

    g_return_val_if_fail( be != NULL, NULL );
    g_return_val_if_fail( row != NULL, NULL );

    guid = gnc_sql_load_guid( be, row );
    pCustomer = gncCustomerLookup( be->book, guid );
    if ( pCustomer == NULL )
    {
        pCustomer = gncCustomerCreate( be->book );
    }
    gnc_sql_load_object( be, row, GNC_ID_CUSTOMER, pCustomer, col_table );
    qof_instance_mark_clean( QOF_INSTANCE(pCustomer) );

    return pCustomer;
}
Пример #30
0
/* ================================================================= */
static void
load_single_book (GncSqlBackend* sql_be, GncSqlRow& row)
{
    QofBook* pBook;

    g_return_if_fail (sql_be != NULL);

    gnc_sql_load_guid (sql_be, row);

    pBook = sql_be->book();
    if (pBook == NULL)
    {
        pBook = qof_book_new ();
    }

    qof_book_begin_edit (pBook);
    gnc_sql_load_object (sql_be, row, GNC_ID_BOOK, pBook, col_table);
    gnc_sql_slots_load (sql_be, QOF_INSTANCE (pBook));
    qof_book_commit_edit (pBook);

    qof_instance_mark_clean (QOF_INSTANCE (pBook));
}