New Hacker

Derek Atkins warlord at MIT.EDU
Thu Sep 1 20:40:47 EDT 2005


Quoting Mike B <songofmike at yahoo.com>:

>
>
> --- Josh Sled <jsled at asynchronous.org> wrote:
>
>> Account data is primarily organized in the engine's
>> data objects, which
>> are located in src/engine/.  The business module
>> is
>> nicely
>> compartmentalized into src/business/, and it's
>> "engine"-equivalent is in
>> src/business/business-core/.
>
> What I'm confused about is how to load/store these
> data objects.  We can call this OR mapping or
> serialization.  I was under the impression that the
> backend storage could change into an actual relational
> layer.

Begin_edit/Commit_Edit is first, and then the qof_session_save() is the 
second. The former are used in online storage systems (e.g. SQL), the 
latter for
serialized storage (e.g. XML).

>> What database schema?  What SQL queries?  What OR
>> mapping layer?
>> GnuCash doesn't have these things, in the same way
>> other systems do.
>
> Right, so as far as I can tell I need to interface
> with the storage system by using the Query objects.
> It seems like you can build queries of different
> types, and that you build parameters and predicates
> for them.  I haven't seen any documentation about how
> this really works, and I'm unclear about how to build
> hese parameters and predicates (or even what is
> possible to build).  It's difficult to follow the code
> through several layers of indirection in order to
> discover these things, so I'm asking here.  Again, an
> example would really help me.  A simple one would be
> getting a list of business customers.

Look in src/business/business-gnome/dialog-customer.c -- at the end of 
the file
is sets up the Search Dialog parameter lists for how to search for 
customers. If you want a list of ALL customers you could build a query 
that's effectively:

  select * from customers where name matches-regex '.'

The parameters are just what you would think they are, starting with the
QueryFor object.  So when you QueryFor Customer, all parameters are based on a
Customer.  When you QueryFor Invoice, all parameters are based on an 
invoice. So, for example, when searching for an invoice you can search 
for:

  <invoice>->Owner->Name matches "Company"

The parameter list for this predicate would be Owner, Name, <NULL>.  Because
<invoice>->Owner->Name is a string, you need a String predicate to match
against this parameter.

It's all quite logical when you stop reading the code and think of the
architecture.  There should even be some rudimentary docs in the source 
tree on
this, and even in Doxygen.

> Thanks,
>
> - mike

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available



More information about the gnucash-devel mailing list