another quick answer ;)

On Fri, Oct 2, 2009 at 7:49 PM, Niels Mayer <nielsma...@gmail.com> wrote:

> On Thu, Oct 1, 2009 at 10:37 AM, Pascal Voitot <
> pascal.voitot....@gmail.com>
>  wrote:
>
> > A quick answer from a user who uses classes quite intensively...
> > you can create links to other class instances (or objects) in your class
> by
> > using the "Database List" property type for example. It is very powerful
> > when you want to create a field of a class where values are stored in
> > another class and created dynamically. [...]
>
>
> Thanks for helping me better understand this feature of Xwiki.
>
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/DataModel mentions:
>
>   - Database List
>   - Database Tree List
>
> but the only explanation I'm finding quickly is
>
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/DsXWikiDatabaseListClasses
>  and
> http://dev.xwiki.org/xwiki/bin/view/Drafts/DatabaseListProperties .
>
> Are there any examples, tutorials or documentation, or just pointers to
> source-code using this technique?
>
>
I don't know any samples or tutorials... I discovered by experience :)



> Questions: Is there an overall performance penalty with adding database
> list
> fields that doesn't occur with a regular type such as a string or static
> list? Does the associated database query only happen when the databaselist
> properties are .get()'d explicitly? Also, most of the document properties
> allow "setting". I assume databaselist and databasetreelist are "read only"
> and are not quite analogous to the list-type property, where you could
> set/edit one or more selections, and then retrieve them back again. Or are
> these just like other document properties (e.g. list) where values can be
> get/set, the databaselist just determines the set of permissible values
> dymamically, presents them when the property is edited, and validates
> against them when the property is set.
>
>
Naturally this is not a Java-like list... this database list is just a list
of values where possible values are retrieved from fields of objects of
another XWikiClass... and these values shall be string values as far as I
can remember... it is simply a list of options dynamically built from DB...
I also remember that the value of the field is stored directly in the parent
object property. This means the parent object doesn't store the id of the
link object but the value of a field of the link object.
So naturally there is a performance penalty when you retrieve the possible
values from the instances of the link XWikiClass. But this is much more
dynamic than a static list...

But if you link your database list with a field of a XWikiClass that is
managed as a primary key (unique value), using a simple XWiki request, you
can retrieve the linked object itself quite easily and it behaves as if you
had a link between 2 objects. You do manually the work hibernate could do
for you and it might not be as performant as hibernate could do but in many
cases this is more than enough and so easy to use in XWiki...


> BTW, in looking up info on this, I found these helpful:
> http://markmail.org/message/dhkrfddcli6fne7m
> http://lists.xwiki.org/pipermail/users/2007-November/009471.html
>
> Sergiu's explanation was the most helpful:
> http://osdir.com/ml/web.wiki.xwiki.user/2008-02/msg00135.html
> (I'll reproduce here to save you from the advertising on osdir.com)
> -----------------------
> horbjørn Konstantinovitz wrote:
>
> > > Hi,
>
> >
>
> > I am currently developing a program documentation system based on xwiki.
>
> > I am able to create pages which describes programs. For each program
>
> > which has to be described I programatically creates a page and populate
>
> > a object with static program information. But I need to document which
>
> > database files the program uses, with links to the relevant database
>
> > file descriptions (a list). For that I want to use a database list
>
> > class. I also want to show a call graph. for that I want to use a
>
> > database tree class. But I am not able to find any documentation on
>
> > these class properties. Can anyone give an example of use for each of
>
> > these two properties or give pointers to relevant examples.
>
> >
>
> >
>
> > The article http://www.theserverside.com/tt/articles/article.tss?l=XWiki
>
> > on the server side were a very good introduction! But it didn't treat
>
> > the property Custom Display. Are there any documentation on this
> property?
>
> >
>
> > Cheers
>
> >
>
> > /Thorbjørn Konstantinovitz
>
> >
>
>
> > First, a bit of introduction on DBList and DBTreeList.
>
>
> > StaticList properties, when edited, allow the user to select one of the
>
> predefined values (or more, if the property has "multiple select" =
>
> true). DBList does something similar, allows the user to select one or
>
> more values from a list of values, but the list is not predefined, it is
>
> populated with values from the database.
>
>
> > DBTreeList does the same as DBList, but also induces a pseudo-hierarchy
>
> in the option list, displaying the options as a tree.
>
>
> > DBList and DBTreeList properties work in two ways.
>
>
> > One is with an hql query, which allows complete flexibility on what you
>
> want to select. For DBList you select one or two columns. The first
>
> column is the list of possible values that get into the option list. The
>
> second (optional) column allows to separate the actual value that gets
>
> stored in the database, and the values that are displayed to the user.
>
> This allows, for example, to store XWiki.JohnDoe in the database, but to
>
> display "Doe, John" in the interface. If only one column is selected,
>
> the value displayed is the same as the value used internally.
>
>
> > DBTreeList queries must select 3 columns. The first two are the same as
>
> for DBList, while the 3rd column defines the child<->parent relations.
>
> Selected rows that have null or an empty string on the third column will
>
> be considered the roots of the tree. Rows that have a value "X" on the
>
> third column will be inserted as child nodes of the node with value "X"
>
> (the first column).
>
>
> >
> > The second way to define the option lists is by using the fields: XWiki
>
> Class Name, Id Field Name, Value Field Name and Parent Field Name. Using
>
> those fields, the XWiki platform constructs the following hql queries:
>
>
> > select idprop.value, valueprop.value, parentprop.value from
>
> XWikiDocument doc, BaseObject obj, StringProperty idprop, StringProperty
>
> valueprop, StringProperty parentprop.value where obj.name = doc.name and
>
> obj.className = "value entered in Class name" and idprop.id.id = obj.id
>
> and idprop.id.name = "value entered in Id Field Name" and
>
> valueprop.id.id = obj.id and valueprop.id.name = "value entered in Value
>
> Field Name" and parentprop.id.id = obj.id and parentprop.id.name =
>
> "value entered in Parent Field Name"
>
>
> > So, it selects from objects of a given type (XWiki Class) 3 properties
>
> (of storage type String, read bellow what this means). As a special
>
> case, you can use "doc.<some doc property>" or "obj.<some object
>
> property>" instead of property names, and the query is adapted
>
> accordingly. In the case of DBList, only 2 columns are selected, as the
>
> Parent property is not used/defined.
>
>
> > String storage type means:
>
> - either a property of type String
>
> - or a property of type StaticList, DBList or DBTreeList with
>
> multipleSelect = false
>
>
> > If you want to use the DBTreeList, you must model your data so that they
>
> will allow these kind of queries.
>
>
> > --
>
> Sergiu Dumitriu
>
> http://purl.org/net/sergiu/
>
> <
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/DsXWikiDatabaseListClasses
> >
> Niels
> http://nielsmayer.com
> _______________________________________________
> devs mailing list
> devs@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/devs
>
_______________________________________________
devs mailing list
devs@xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to