I was thinking a lot around metadata implementation and came up with the following. I have created 3 tables: MetaObject, MetaObjectProperties and MetaObjectRelations. In DHIS2 schema most of MetaObjects (DE, Indicators, DS, DECategoryCombo, DECategory, DEOption) have one one to many relations. So I read each object and placed its property values into MetaObject. After all goes well I put id of MetaObject back to original object’s metaCode persisted field, added to IdentifiableObject inherited by all metadata objects. Instead of objects Id I added its metacode as its reference to other objects.
In listings of each metadata objects’ interface I added add to metadata link, which will add this particular object into MetaObject. After all metaobjects are added into MetaObject table, we can easily rebuit our other objects with their links to other objects. This also should be useful for new installation, once we create XML representation of MetaObject.
Similarly we can use MetaObject for transfering data (import/export) between nodes of the same metaobjects as all have exactly same metacode.
Implementation is here https://code.launchpad.net/~murodlatifov/+junk/dhis2
Interesting idea. Making all your meta objects "weakly typed" like
this creates a lot of simplicity which can be a good thing. FWIW this
has quite a good analogy with sdmx as well where all objects have a
code+codelist+metadata representation. i guess you should have to
manage the validity of your representations elsewhere (ie. things like
what are the required properties of a dataelement, indicator etc)?
In terms of a general, easy to parse xml representation I can see this
approach could have a lot of merit. For serializing (eg to xml) why
are the intermediate metaobject tables necessary? (I can see they
would be useful for sql dump - restore but you are storing everything
twice which seems a shame). Am I right in thinking that mostly what
you have *added* is a new authoritative identifier - the metaCode -
which might be a good thing. Probably there are other "fixed" fields
you could add to metaobject (eg all the ones from identifiable object
plus additional fields refelcting metaobject ownership and version?).
Or do you prefer to keep as weakly typed as possible?
Regarding validation, it would be difficult (if not impossible) to do
entirely with xml schema or relaxng but that is not the end of the
world. You could do a fairly simple schematron schema to validate
these kinds of objects. With schematron you can create the assertions
you would need like : if this metaobject is an orgunit it should have
a property with property="active" and value of true|false etc.
Interesting.
Cheers
Bob
···
On 8 February 2011 04:55, Murod Latifov <mlatifov@gmail.com> wrote:
Hi,
I was thinking a lot around metadata implementation and came up with the
following. I have created 3 tables: MetaObject, MetaObjectProperties and
MetaObjectRelations. In DHIS2 schema most of MetaObjects (DE, Indicators,
DS, DECategoryCombo, DECategory, DEOption) have one one to many relations.
So I read each object and placed its property values into MetaObject. After
all goes well I put id of MetaObject back to original object's metaCode
persisted field, added to IdentifiableObject inherited by all metadata
objects. Instead of objects Id I added its metacode as its reference to
other objects.
In listings of each metadata objects' interface I added add to metadata
link, which will add this particular object into MetaObject. After all
metaobjects are added into MetaObject table, we can easily rebuit our other
objects with their links to other objects. This also should be useful for
new installation, once we create XML representation of MetaObject.
Similarly we can use MetaObject for transfering data (import/export) between
nodes of the same metaobjects as all have exactly same metacode.
Implementation is here https://code.launchpad.net/~murodlatifov/+junk/dhis2