Merge the sql parsers of the business objects into the main sql module.

Also, completely remove the business-core/sql module because it is
no longer needed. The tests of this module have been moved into
backend/dbi because they depend on sql+dbi, but not more than that.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19364 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2010-07-14 19:39:19 +00:00
parent 0f17917433
commit 2f39208e7d
41 changed files with 92 additions and 363 deletions

View File

@ -1485,8 +1485,6 @@ AC_CONFIG_FILES(po/Makefile.in
src/test-core/Makefile
src/business/Makefile
src/business/business-core/Makefile
src/business/business-core/sql/Makefile
src/business/business-core/sql/test/Makefile
src/business/business-core/test/Makefile
src/business/business-utils/Makefile
src/business/dialog-tax-table/Makefile

View File

@ -93,7 +93,6 @@ ADD_SUBDIRECTORY (app-utils)
IF (WITH_SQL)
ADD_SUBDIRECTORY (backend/dbi)
ADD_SUBDIRECTORY (backend/sql)
ADD_SUBDIRECTORY (business/business-core/sql)
ENDIF (WITH_SQL)
ADD_SUBDIRECTORY (gnc)

View File

@ -6,6 +6,10 @@ libgncmod_test_dbi_la_SOURCES = \
test-dbi-stuff.c
libgncmod_test_dbi_la_LDFLAGS = -module
test_dbi_business_SOURCES = \
test-dbi-business.c \
test-dbi-business-stuff.c
test_dbi_basic_SOURCES = \
test-dbi-basic.c
@ -15,6 +19,7 @@ test_dbi_SOURCES = \
TESTS = \
test-dbi-basic \
test-dbi \
test-dbi-business \
test-load-backend
GNC_TEST_DEPS = \
@ -38,6 +43,7 @@ TESTS_ENVIRONMENT = \
check_PROGRAMS = \
test-dbi-basic \
test-dbi \
test-dbi-business \
test-load-backend
EXTRA_DIST = \
@ -50,6 +56,7 @@ LDADD = ${top_builddir}/src/test-core/libtest-core.la \
${top_builddir}/src/core-utils/libgnc-core-utils.la \
${top_builddir}/src/libqof/qof/libgnc-qof.la \
${top_builddir}/src/backend/dbi/test/libgncmod-test-dbi.la \
${top_builddir}/src/backend/sql/libgnc-backend-sql.la \
${top_builddir}/lib/libc/libc-missing.la
AM_CFLAGS = \
@ -61,6 +68,7 @@ AM_CFLAGS = \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/engine/test-core \
-I${top_srcdir}/src/libqof/qof \
-I${top_srcdir}/src/backend/sql \
-DTEST_MYSQL_URL=\"${TEST_MYSQL_URL}\" \
-DTEST_PGSQL_URL=\"${TEST_PGSQL_URL}\" \
${GLIB_CFLAGS} \

View File

@ -18,29 +18,51 @@ INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/engine)
SET (libgnc_backend_sql_SOURCES
gnc-backend-sql.c
gnc-account-sql.c
gnc-address-sql.c
gnc-bill-term-sql.c
gnc-book-sql.c
gnc-budget-sql.c
gnc-commodity-sql.c
gnc-customer-sql.c
gnc-employee-sql.c
gnc-entry-sql.c
gnc-invoice-sql.c
gnc-job-sql.c
gnc-lots-sql.c
gnc-order-sql.c
gnc-owner-sql.c
gnc-price-sql.c
gnc-recurrence-sql.c
gnc-schedxaction-sql.c
gnc-slots-sql.c
gnc-tax-table-sql.c
gnc-transaction-sql.c
gnc-vendor-sql.c
escape.c
)
SET (libgnc_backend_sql_HEADERS
gnc-account-sql.h
gnc-address-sql.h
gnc-backend-sql.h
gnc-bill-term-sql.h
gnc-book-sql.h
gnc-budget-sql.h
gnc-commodity-sql.h
gnc-customer-sql.h
gnc-employee-sql.h
gnc-entry-sql.h
gnc-invoice-sql.h
gnc-job-sql.h
gnc-lots-sql.h
gnc-order-sql.h
gnc-owner-sql.h
gnc-price-sql.h
gnc-recurrence-sql.h
gnc-schedxaction-sql.h
gnc-slots-sql.h
gnc-tax-table-sql.h
gnc-transaction-sql.h
gnc-vendor-sql.h
escape.h
)

View File

@ -21,29 +21,51 @@ AM_CFLAGS = \
libgnc_backend_sql_la_SOURCES = \
gnc-backend-sql.c \
gnc-account-sql.c \
gnc-address-sql.c \
gnc-bill-term-sql.c \
gnc-book-sql.c \
gnc-budget-sql.c \
gnc-commodity-sql.c \
gnc-customer-sql.c \
gnc-employee-sql.c \
gnc-entry-sql.c \
gnc-invoice-sql.c \
gnc-job-sql.c \
gnc-lots-sql.c \
gnc-order-sql.c \
gnc-owner-sql.c \
gnc-price-sql.c \
gnc-recurrence-sql.c \
gnc-schedxaction-sql.c \
gnc-slots-sql.c \
gnc-tax-table-sql.c \
gnc-transaction-sql.c \
gnc-vendor-sql.c \
escape.c
noinst_HEADERS = \
gnc-account-sql.h \
gnc-address-sql.h \
gnc-backend-sql.h \
gnc-bill-term-sql.h \
gnc-book-sql.h \
gnc-budget-sql.h \
gnc-commodity-sql.h \
gnc-customer-sql.h \
gnc-employee-sql.h \
gnc-entry-sql.h \
gnc-invoice-sql.h \
gnc-job-sql.h \
gnc-lots-sql.h \
gnc-order-sql.h \
gnc-owner-sql.h \
gnc-price-sql.h \
gnc-recurrence-sql.h \
gnc-schedxaction-sql.h \
gnc-slots-sql.h \
gnc-tax-table-sql.h \
gnc-transaction-sql.h \
gnc-vendor-sql.h \
escape.h
libgnc_backend_sql_la_LIBADD = \

View File

@ -59,6 +59,18 @@
#include "gnc-slots-sql.h"
#include "gnc-transaction-sql.h"
#include "gnc-address-sql.h"
#include "gnc-bill-term-sql.h"
#include "gnc-customer-sql.h"
#include "gnc-employee-sql.h"
#include "gnc-entry-sql.h"
#include "gnc-invoice-sql.h"
#include "gnc-job-sql.h"
#include "gnc-order-sql.h"
#include "gnc-owner-sql.h"
#include "gnc-tax-table-sql.h"
#include "gnc-vendor-sql.h"
#if defined( S_SPLINT_S )
#include "splint-defs.h"
#endif
@ -1024,6 +1036,29 @@ gnc_sql_run_query( QofBackend* pBEnd, gpointer pQuery )
}
/* ================================================================= */
/* Order in which business objects need to be loaded */
static const gchar* business_fixed_load_order[] =
{ GNC_ID_BILLTERM, GNC_ID_TAXTABLE, NULL };
static void
business_core_sql_init(void)
{
/* Initialize our pointers into the backend subsystem */
gnc_address_sql_initialize();
gnc_billterm_sql_initialize();
gnc_customer_sql_initialize();
gnc_employee_sql_initialize();
gnc_entry_sql_initialize();
gnc_invoice_sql_initialize();
gnc_job_sql_initialize();
gnc_order_sql_initialize();
gnc_owner_sql_initialize();
gnc_taxtable_sql_initialize();
gnc_vendor_sql_initialize();
gnc_sql_set_load_order( business_fixed_load_order );
}
static void
gnc_sql_init_object_handlers( void )
{
@ -1037,6 +1072,9 @@ gnc_sql_init_object_handlers( void )
gnc_sql_init_recurrence_handler();
gnc_sql_init_schedxaction_handler();
gnc_sql_init_lot_handler();
/* And the business objects */
business_core_sql_init();
}
/* ================================================================= */

View File

@ -1,18 +1,6 @@
SUBDIRS = .
test_column_types_SOURCES = \
${top_srcdir}/src/backend/sql/gnc-backend-sql.c \
${top_srcdir}/src/backend/sql/gnc-account-sql.c \
${top_srcdir}/src/backend/sql/gnc-book-sql.c \
${top_srcdir}/src/backend/sql/gnc-budget-sql.c \
${top_srcdir}/src/backend/sql/gnc-commodity-sql.c \
${top_srcdir}/src/backend/sql/gnc-lots-sql.c \
${top_srcdir}/src/backend/sql/gnc-price-sql.c \
${top_srcdir}/src/backend/sql/gnc-recurrence-sql.c \
${top_srcdir}/src/backend/sql/gnc-schedxaction-sql.c \
${top_srcdir}/src/backend/sql/gnc-slots-sql.c \
${top_srcdir}/src/backend/sql/gnc-transaction-sql.c \
${top_srcdir}/src/backend/sql/escape.c \
test-column-types.c
TESTS = \
@ -39,6 +27,7 @@ check_PROGRAMS = \
LDADD = ${top_builddir}/src/test-core/libtest-core.la \
${top_builddir}/src/gnc-module/libgnc-module.la \
${top_builddir}/src/backend/sql/libgnc-backend-sql.la \
${top_builddir}/src/engine/libgncmod-engine.la \
${top_builddir}/src/engine/test-core/libgncmod-test-engine.la \
${top_builddir}/src/core-utils/libgnc-core-utils.la \

View File

@ -1,4 +1,4 @@
SUBDIRS = . sql test
SUBDIRS = . test
pkglib_LTLIBRARIES = libgncmod-business-core.la

View File

@ -1,54 +0,0 @@
# CMakeLists.txt for src/backend/dbi
ADD_DEFINITIONS (-DG_LOG_DOMAIN=\"gnc.backend.sql\")
INCLUDE_DIRECTORIES (${GCONF2_INCLUDE_DIRS})
INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
INCLUDE_DIRECTORIES (${GUILE_INCLUDE_DIRS})
INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/lib/libc) # for gnc-ui.h
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/libqof/qof)
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module)
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/engine)
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/business/business-core)
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/backend/sql)
SET (libgnc_business_backend_sql_SOURCES
gncmod-business-backend-sql.c
gnc-address-sql.c
gnc-bill-term-sql.c
gnc-customer-sql.c
gnc-employee-sql.c
gnc-entry-sql.c
gnc-invoice-sql.c
gnc-job-sql.c
gnc-order-sql.c
gnc-owner-sql.c
gnc-tax-table-sql.c
gnc-vendor-sql.c
)
SET (libgnc_business_backend_sql_HEADERS
gncmod-business-backend-sql.h
gnc-address-sql.h
gnc-bill-term-sql.h
gnc-customer-sql.h
gnc-employee-sql.h
gnc-entry-sql.h
gnc-invoice-sql.h
gnc-job-sql.h
gnc-order-sql.h
gnc-owner-sql.h
gnc-tax-table-sql.h
gnc-vendor-sql.h
)
# Add dependency on config.h
SET_SOURCE_FILES_PROPERTIES (${libgnc_business_backend_sql_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
ADD_LIBRARY (gnc-business-backend-sql
${libgnc_business_backend_sql_SOURCES}
${libgnc_business_backend_sql_HEADERS}
)

View File

@ -1,55 +0,0 @@
SUBDIRS = . test
pkglib_LTLIBRARIES = libgncmod-business-backend-sql.la
AM_CFLAGS = \
-I${top_srcdir}/src \
-I${top_srcdir}/src/backend \
-I${top_srcdir}/src/backend/sql \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/gnc-module \
-I${top_srcdir}/src/business/business-core \
-I${top_srcdir}/src/libqof/qof \
${GLIB_CFLAGS} \
${LIBGDA_CFLAGS}
libgncmod_business_backend_sql_la_SOURCES = \
gncmod-business-backend-sql.c \
gnc-address-sql.c \
gnc-bill-term-sql.c \
gnc-customer-sql.c \
gnc-employee-sql.c \
gnc-entry-sql.c \
gnc-invoice-sql.c \
gnc-job-sql.c \
gnc-order-sql.c \
gnc-owner-sql.c \
gnc-tax-table-sql.c \
gnc-vendor-sql.c
noinst_HEADERS = \
gncmod-business-backend-sql.h \
gnc-address-sql.h \
gnc-bill-term-sql.h \
gnc-customer-sql.h \
gnc-employee-sql.h \
gnc-entry-sql.h \
gnc-invoice-sql.h \
gnc-job-sql.h \
gnc-order-sql.h \
gnc-owner-sql.h \
gnc-tax-table-sql.h \
gnc-vendor-sql.h
libgncmod_business_backend_sql_la_LDFLAGS = -module -avoid-version
libgncmod_business_backend_sql_la_LIBADD = \
${top_builddir}/src/business/business-core/libgncmod-business-core.la \
${top_builddir}/src/backend/sql/libgnc-backend-sql.la \
${top_builddir}/src/engine/libgncmod-engine.la \
${top_builddir}/src/gnc-module/libgnc-module.la \
${top_builddir}/src/libqof/qof/libgnc-qof.la \
${GLIB_LIBS} \
${LIBGDA_LIBS}
INCLUDES = -DG_LOG_DOMAIN=\"gnc.backend.sql\"

View File

@ -1,137 +0,0 @@
/*********************************************************************
* gncmod-business-backend-sql.c
* module definition/initialization for the sql backend module
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, contact:
*
* Free Software Foundation Voice: +1-617-542-5942
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
* Boston, MA 02110-1301, USA gnu@gnu.org
*
*********************************************************************/
/** @file gncmod-business-backend-sql.c
* @brief load and save address data to SQL
* @author Copyright (c) 2007-2008 Phil Longstaff <plongstaff@rogers.com>
*
* This file implements the top-level QofBackend API for saving/
* restoring data to/from an SQL database
*/
#include "config.h"
#include <gmodule.h>
#include "gnc-module.h"
#include "gnc-module-api.h"
#include "gnc-engine.h"
#include "gnc-backend-sql.h"
#include "gnc-address-sql.h"
#include "gnc-bill-term-sql.h"
#include "gnc-customer-sql.h"
#include "gnc-employee-sql.h"
#include "gnc-entry-sql.h"
#include "gnc-invoice-sql.h"
#include "gnc-job-sql.h"
#include "gnc-order-sql.h"
#include "gnc-owner-sql.h"
#include "gnc-tax-table-sql.h"
#include "gnc-vendor-sql.h"
#include "gncmod-business-backend-sql.h"
GNC_MODULE_API_DECL(libgncmod_business_backend_sql)
/* version of the gnc module system interface we require */
int libgncmod_business_backend_sql_gnc_module_system_interface = 0;
/* module versioning uses libtool semantics. */
int libgncmod_business_backend_sql_gnc_module_current = 0;
int libgncmod_business_backend_sql_gnc_module_revision = 0;
int libgncmod_business_backend_sql_gnc_module_age = 0;
static GNCModule bus_core;
gchar *
libgncmod_business_backend_sql_gnc_module_path(void)
{
return g_strdup( "gnucash/business-core-sql" );
}
gchar *
libgncmod_business_backend_sql_gnc_module_description(void)
{
return g_strdup( "The SQL backend for GnuCash business objects" );
}
/* Order in which business objects need to be loaded */
static const gchar* fixed_load_order[] =
{ GNC_ID_BILLTERM, GNC_ID_TAXTABLE, NULL };
void
gnc_module_init_business_core_sql_init(void)
{
/* Initialize our pointers into the backend subsystem */
gnc_address_sql_initialize();
gnc_billterm_sql_initialize();
gnc_customer_sql_initialize();
gnc_employee_sql_initialize();
gnc_entry_sql_initialize();
gnc_invoice_sql_initialize();
gnc_job_sql_initialize();
gnc_order_sql_initialize();
gnc_owner_sql_initialize();
gnc_taxtable_sql_initialize();
gnc_vendor_sql_initialize();
gnc_sql_set_load_order( fixed_load_order );
}
int
libgncmod_business_backend_sql_gnc_module_init(int refcount)
{
if (!gnc_engine_is_initialized())
{
return FALSE;
}
bus_core = gnc_module_load( "gnucash/business-core", 0 );
if ( !bus_core ) return FALSE;
if ( refcount == 0 )
{
gnc_module_init_business_core_sql_init();
}
return TRUE;
}
int
libgncmod_business_backend_sql_gnc_module_end(int refcount)
{
int unload = TRUE;
if ( bus_core )
{
unload = gnc_module_unload( bus_core );
}
if ( refcount == 0 )
{
bus_core = NULL;
}
return unload;
}

View File

@ -1,32 +0,0 @@
/*********************************************************************
* gncmod-business-backend-sql.h
* module definition/initialization for the sql backend module
*
* Copyright (c) 2010 Christian Stimming <stimming@tuhh.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, contact:
*
* Free Software Foundation Voice: +1-617-542-5942
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
* Boston, MA 02110-1301, USA gnu@gnu.org
*
*********************************************************************/
#ifndef GNCMOD_BUSINESS_BACKEND_SQL_H
#define GNCMOD_BUSINESS_BACKEND_SQL_H
void
gnc_module_init_business_core_sql_init(void);
#endif

View File

@ -1,65 +0,0 @@
SUBDIRS = .
test_dbi_business_SOURCES = \
test-dbi-business.c \
test-dbi-business-stuff.c
TESTS = \
test-dbi-business
GNC_TEST_DEPS = \
--gnc-module-dir ${top_builddir}/src/engine \
--guile-load-dir ${top_builddir}/src/engine \
--library-dir ${top_builddir}/lib/libqof/qof \
--library-dir ${top_builddir}/src/core-utils \
--library-dir ${top_builddir}/src/gnc-module \
--library-dir ${top_builddir}/src/engine \
--library-dir ${top_builddir}/src/backend/sql
if CUSTOM_GNC_DBD_DIR
gnc_dbd_dir_override="GNC_DBD_DIR=@GNC_DBD_DIR@"
endif
TESTS_ENVIRONMENT = \
GNC_ACCOUNT_PATH=${top_srcdir}/accounts/C \
SRCDIR=${srcdir} \
${gnc_dbd_dir_override} \
$(shell ${top_srcdir}/src/gnc-test-env --no-exports ${GNC_TEST_DEPS})
check_PROGRAMS = \
test-dbi-business
LDADD = ${top_builddir}/src/test-core/libtest-core.la \
${top_builddir}/src/gnc-module/libgnc-module.la \
${top_builddir}/src/engine/libgncmod-engine.la \
${top_builddir}/src/engine/test-core/libgncmod-test-engine.la \
${top_builddir}/src/core-utils/libgnc-core-utils.la \
${top_builddir}/src/libqof/qof/libgnc-qof.la \
${top_builddir}/src/backend/dbi/test/libgncmod-test-dbi.la \
${top_builddir}/src/backend/sql/libgnc-backend-sql.la \
${top_builddir}/src/business/business-core/libgncmod-business-core.la \
${top_builddir}/src/business/business-core/sql/libgncmod-business-backend-sql.la \
${top_builddir}/lib/libc/libc-missing.la
AM_CFLAGS = \
-I${top_srcdir}/lib/libc \
-I${top_srcdir}/src \
-I${top_srcdir}/src/core-utils \
-I${top_srcdir}/src/test-core \
-I${top_srcdir}/src/engine \
-I${top_srcdir}/src/engine/test-core \
-I${top_srcdir}/src/libqof/qof \
-I${top_srcdir}/src/backend/dbi/test \
-I${top_srcdir}/src/backend/sql \
-I${top_srcdir}/src/business/business-core \
-I${top_srcdir}/src/business/business-core/sql \
-DTEST_MYSQL_URL=\"${TEST_MYSQL_URL}\" \
-DTEST_PGSQL_URL=\"${TEST_PGSQL_URL}\" \
${GLIB_CFLAGS} \
${GUILE_INCS} \
${GCONF_CFLAGS}
EXTRA_DIST = \
test-dbi-business-stuff.h
INCLUDES = -DG_LOG_DOMAIN=\"gnc.business.sql\"

View File

@ -5,7 +5,6 @@
(gnc:module-load "gnucash/business-core" 0)
(gnc:module-load "gnucash/business-utils" 0)
(gnc:module-load "gnucash/gnome-search" 0)
(gnc:module-load "gnucash/business-core-sql" 0)
(gnc:module-load "gnucash/dialog-tax-table" 0)
(gnc:module-load "gnucash/report/report-gnome" 0)

View File

@ -98,7 +98,6 @@ ADD_EXECUTABLE (cutecash
TARGET_LINK_LIBRARIES (cutecash gnc-backend-xml)
TARGET_LINK_LIBRARIES (cutecash app-utils calculation)
IF (WITH_SQL)
TARGET_LINK_LIBRARIES (cutecash gnc-business-backend-sql)
TARGET_LINK_LIBRARIES (cutecash gnc-backend-dbi gnc-backend-sql)
TARGET_LINK_LIBRARIES (cutecash ${LIBDBI_LIBRARY})
ENDIF (WITH_SQL)

View File

@ -40,7 +40,6 @@
#include "engine/gnc-engine.h"
#include "backend/xml/gnc-backend-xml.h"
#include "backend/dbi/gnc-backend-dbi.h"
#include "sql/gncmod-business-backend-sql.h"
#include "Transaction.h"
#include "Split.h"
#include "Account.h"
@ -186,5 +185,4 @@ gnc_engine_init_static(0, no_args);
gnc_module_init_backend_xml();
gnc_module_init_backend_dbi();
gnc_module_init_business_core_sql_init();
%}