[Kde-pim] the kde-pim database internal structure.
Andras Mantia
amantia at kde.org
Thu Nov 1 08:05:35 GMT 2012
Michaƫl Parchet wrote:
> Hello,
>
> In my project, I must add some table like bills and insurances for
> example. The contact have several group like customers, doctors insurance.
> Every calendar event must bill. (It's a billing and manage physiotherapy
> project).
>
> So how to customize the akonadi database for my project if it's possible ?
You approach the problem from a wrong way. Akonadi doesn't care what data
goes it. All it cares about is to define "collections" and "items". A
collection can be a group (doctors), a folder (email folder), whatever. An
item can be an entry, like vcard for a person, a mail, or such. Each item
can have data associated with it. For akonadi this data is just an array of
bytes. It is up to you to define the meaning of the data.
To convert e.g the data from your own Doctor or Customer class to a
bytearray, you need to provide serializer plugins that converts from your
class to bytearray and back. See kdepim-runtime/plugins for existing
plugins.
You can find information about them also in the link I provided ( PIM item
serializer). Once you have a serializer plugin for a certain mimetype, you
can store an item in Akonadi like described in
http://api.kde.org/4.x-api/kdepimlibs-
apidocs/akonadi/html/classAkonadi_1_1ItemCreateJob.html
(use a your own mimetype and your own class in setMimeType and setPayload).
Fetching an item is described here
http://api.kde.org/4.x-api/kdepimlibs-
apidocs/akonadi/html/classAkonadi_1_1ItemFetchJob.html
Getting the payload stored in the item is:
http://api.kde.org/4.x-api/kdepimlibs-
apidocs/akonadi/html/classAkonadi_1_1Item.html#a036bca6746aa1f0035586023b54c6fca
Assuming you stored a class named Doctor in akonadi,
Doctor doctor = item.payload<Doctor>();
or to be more safe
if (item.hasPayload<Doctor>()) {
Doctor doctor = item.payload<Doctor>()
...
}
As you can see in normal case you don't need to know how Akonadi stores the
data and where it does. It actually just caches it, you need to have a
Resource (http://api.kde.org/4.x-api/kdepimlibs-
apidocs/akonadi/html/index.html#libakonadi_resource) that stores the data in
the final location (in a file, on a remote server, etc.)
Akonadi is NOT the final place of your data. It is a *cache* and a common
interface towards different kind of data.
Andras
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/
More information about the kde-pim
mailing list