Hello, I have problems making a query to retrieve from the database all the objects that are from a certain class (e.g "TryClass") and of a certain type as well (e.g "StaticListClass"). Can anyone give me a hint please? Thank you very much. Evelina Slatineanu
Hi, Please someone correct me if I'm wrong. I think xwiki objects cannot be instance of types (such as "StaticListClass"), but only of xwiki classes. the types (String, StaticList, etc.) are only intended to be classes properties. There is a privileged API to make queries that can return objects or properties : $xwiki.search($wheresql). Privileged means the velocity script running it needs to be saved by someone with the "programming" right allowed. It can then retrieve your objects this way : #set($myobjects=$xwiki.search("select obj from BaseObject as obj where obj.className='MySpace.MyClass'")) Have fun, Jerome On 6/6/07, [email protected] <[email protected]> wrote:
Hello,
I have problems making a query to retrieve from the database all the objects that are from a certain class (e.g "TryClass") and of a certain type as well (e.g "StaticListClass"). Can anyone give me a hint please?
Thank you very much.
Evelina Slatineanu
-- You receive this message as a subscriber of the [email protected] list. To unsubscribe: mailto: [email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
You can retrieve the document names that have an object of class MySpace.MyClass with the following query (the one provided by Jerome needs priviledge access to the API). #set($docnamelist=$xwiki.searchDocuments(", BaseObject as obj where doc.fullName=obj.name and obj.className='MySpace.MyClass'")) Ludovic Jerome Velociter a écrit :
Hi,
Please someone correct me if I'm wrong.
I think xwiki objects cannot be instance of types (such as "StaticListClass"), but only of xwiki classes. the types (String, StaticList, etc.) are only intended to be classes properties.
There is a privileged API to make queries that can return objects or properties : $xwiki.search($wheresql). Privileged means the velocity script running it needs to be saved by someone with the "programming" right allowed.
It can then retrieve your objects this way :
#set($myobjects=$xwiki.search("select obj from BaseObject as obj where obj.className='MySpace.MyClass'"))
Have fun, Jerome
On 6/6/07, *[email protected] <mailto:[email protected]>* <[email protected] <mailto:[email protected]>> wrote:
Hello,
I have problems making a query to retrieve from the database all the objects that are from a certain class (e.g "TryClass") and of a certain type as well (e.g "StaticListClass"). Can anyone give me a hint please?
Thank you very much.
Evelina Slatineanu
-- You receive this message as a subscriber of the [email protected] <mailto:[email protected]> mailing list. To unsubscribe: mailto: [email protected] <mailto:[email protected]> For general help: mailto: [email protected] <mailto:[email protected]>?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
------------------------------------------------------------------------
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
-- Ludovic Dubost Blog: http://www.ludovic.org/blog/ XWiki: http://www.xwiki.com Skype: ldubost GTalk: ldubost AIM: nvludo Yahoo: ludovic
On 6/6/07, [email protected] <[email protected]> wrote:
Hello,
I have problems making a query to retrieve from the database all the objects that are from a certain class (e.g "TryClass") and of a certain type as well (e.g "StaticListClass"). Can anyone give me a hint please?
Thank you very much.
Evelina Slatineanu
Hi, You should look in the hibernate mapping file to find out what are the terms you can use inside hql. There are 3 types of string properties: StringProperty, StringListProperty, DBStringListProperty. StringProperties are easy to retrieve, since they contain just one value per object. The query is something like: select distinct prop.value from BaseObject as obj, StringProperty as prop where obj.className='${xclass}' and obj.id=prop.id.id and prop.id.name='${xprop}' You should be able to pass the xclass and xprop parameters from the java displayEdit method to the javascript making the AJAX call, and from there to the velocity script returning the suggested items. The query indeed requires programming rights, so it should go to a special document in the XWiki space, something like XWiki.Suggest StringListProperties are a bit more difficult, since you retrieve the list of values as one string. The query is: select distinct prop.textValue from BaseObject as obj, StringListProperty as prop where obj.className='${xlass}' and obj.id=prop.id.id and prop.id.name='${xprop}' You will then need to split each result using the separators specified in the definition for that property. DBStringListProperties are easy to retrieve, though the query is a bit more difficult to find out when you don't know it already: select distinct list from BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.className='${xclass}' and obj.id=prop.id.id and prop.id.name='${xprop}' This returns all the existing values, one per row. Now, you need to decide which type of property you have. The type of property used is not given by the type of property class you put in the class, but by the settings for multiSelect and relationalStorage, like this: if relationalStorage is true, then use DBStringListProperty, even for StaticListClass else, if multiSelect is true, use StringListProperty else use StringProperty, even for DBStringListClass So, when making the query, you need to do something like: if (isRelationalStorage() { make DBStringListProperty query } else if (isMultiSelect()) { make StringListProperty query } else { make StringProperty query } You should write this pseudocode in velocity. The object on which to call the is*() methods is the property definition, retrieved like: $xwiki.getDocument(${xclass}).getxWikiClass().get(${xprop}).isRelationalStorage() The problem is that these methods are not in the API, but they should be added (hint: you can make a JIRA issue and a patch for this). Meanwhile, you can use: $xwiki.getDocument(${xclass}).getxWikiClass().get(${xprop}).getPropertyClass().isRelationalStorage() which requires programming rights. Sergiu -- http://purl.org/net/sergiu
Wow, Sergiu, you should win a "Best Answers Award" for the replays you give on this list. Thank you very much. You always make things clear to me! Thanks again. Evelina
participants (4)
-
evelyne24@gmail.com -
Jerome Velociter -
Ludovic Dubost -
Sergiu Dumitriu