Tjaart van Wijck wrote:
a) A class definition is essentially a special type of
wiki page that
defines the class structure (i.e. properties).
Yes, but here "special" means just that it contains a class definition,
as otherwise nothing makes it "special". Any document can host a class,
just add property definitions to it.
b) No more than 1 class definition can be contained in
this special type of
page.
Yes. In the future this _might_ not be true, but there are no plans in
that direction.
c) Objects are instances of these classes and must be
associate with a page.
(Can a single object be associated with more than 1 page?)
Yes. One object resides in only one page, so you cannot associate it
with more than one page directly. You can, however, define another class
with a DBList property listing the existing objects, and you can then
attach that type of "linking" object to other pages.
d) Multiple objects can be associated with a wiki
page.
Yes, from the same or different classes.
e) An HQL query iterates through the wiki pages,
through each object in each
page and each property in each object
Only if you write the query in this manner. Basically HQL is not
something XWiki invented, it is the standard Hibernate Query Language,
which is an object retrieval QL. So it behaves like any query language,
with the SELECT, FROM and WHERE sub-clauses. But you are right, meaning
that you can use in the FROM part documents, objects and properties, and
you can link them using "obj.name = doc.fullName" and "prop.id.id =
obj.id". You can use more than one property/object/document in the query
(I once got to write queries with something around 30 properties in the
same query, which I later had to split into 2 queries as mysql has a
limit on the number of JOINs you can have).
d) An HQL query specifying page/document constraints
returns a Java List of
documents
No, unless you use $xwiki.search("select doc from..."). The standard
$xwiki.searchDocuments returns a java list of document names. You then
have to use $xwiki.getDocument($item) or $xwiki.wrapDocs($results) to
get Document API objects (which are different from the internal
XWikiDocument objects)
e) An HQL query specifying object constraints returns
a Java List of objects
(does not seem to be the case from the above code?!)
Yes, if you're using $xwiki.search("select obj from BaseObject obj...").
Still, this is the internal com.xpn.xwiki.objects.BaseObject class, and
not the API usually accessed from scripts, which is
com.xpn.xwiki.api.Object. This is why your script does not _seem_ to
work, as you're using API methods on the privileged object.
f) An HQL query specifying property constraints
returns a Java List of
properties
Yes, if you're using $xwiki.search("select prop from StringProperty
prop...") (replace with other property type).
--
Sergiu Dumitriu
http://purl.org/net/sergiu/