[xwiki-devs] checking if a document has an object of a given class
Hi, I'm failing at getting a logical condition that check if given XWiki document has an object of a given class. Please, could you help me with this? Thanks! Ricardo -- Ricardo Rodríguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems
On Sun, Oct 3, 2010 at 12:55 AM, [Ricardo Rodriguez] eBioTIC. <[email protected]> wrote:
Hi,
I'm failing at getting a logical condition that check if given XWiki document has an object of a given class.
simply #if($xwiki.getDocument('Main.MyDoc').getObject('XWiki.MyClass')) ## blabla #end should do it. Regards, Jerome.
Please, could you help me with this?
Thanks!
Ricardo
-- Ricardo Rodríguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi! Jerome Velociter wrote:
simply
#if($xwiki.getDocument('Main.MyDoc').getObject('XWiki.MyClass')) ## blabla #end
should do it.
Did it! Thanks. I was adding all kind of esoteric logical operators at the end of the string... :-( Cheers! Ricardo -- Ricardo Rodríguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems
In HQL in Lucene? or... in java as Jérôme answered. paul Le 3 oct. 2010 à 00:55, [Ricardo Rodriguez] eBioTIC. a écrit :
Hi,
I'm failing at getting a logical condition that check if given XWiki document has an object of a given class.
Please, could you help me with this?
Hi Paul! Paul Libbrecht wrote:
In HQL in Lucene? or... in java as Jérôme answered.
It was Velocity code where I needed to solve this issue. I guess this page point in the right direction for HQL: http://platform.xwiki.org/xwiki/bin/view/DevGuide/QueryGuide As for Lucene I've found this: http://code.xwiki.org/xwiki/bin/view/Applications/SearchApplicationLuceneSea... What I've been trying to get is a modified version of the Last Visited panel that shows more "user friendly" messages as links. I've still to add some if() to check availability of translations for some kind of entries. It reads now like this: ****** #set($rv_maxItems = $!xwiki.getUserPreference("recent_actions_items")) #if($rv_maxItems == "") #set($rv_maxItems = 5) #end #set($recentlyViewed = $xwiki.getRecentActions("view", $rv_maxItems)) #set($header = $msg.get("panels.recentlyVisited.title")) *$header*<br/> #foreach($docname in $recentlyViewed) #set($rdoc = $xwiki.getDocument($docname).getTranslatedDocument()) #if($xwiki.getDocument($docname).getObject('Users.PdrUserClass')) #set($user = "${rdoc.getObject('Users.PdrUserClass').getProperty('Name').getValue()}") #set($cropat = $user.indexOf("#")) #set($user = $user.substring(0,$cropat)) <a href="$rdoc.getURL("view")">$user</a><br/> #else #if($xwiki.getDocument($docname).getObject('Species.SpeciesClass')) #set($species = "${rdoc.getObject('Species.SpeciesClass').getProperty('GalicianName').getValue()}") <a href="$rdoc.getURL("view")">$species</a><br/> #else <a href="$rdoc.getURL("view")">$rdoc.displayTitle</a><br/> #end #end #end ****** I don't know if using Lucene or HQL options could add some advantage to the used method: I've only used the current LastVisited panel code (as per XE 1.3.x) as base for modifications. This solution is only intended to last until we get this wiki migrated to an updated >2.4 XE/XEM environment. Any idea will be welcome! Ricardo -- Ricardo Rodríguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems
participants (3)
-
[Ricardo Rodriguez] eBioTIC. -
Jerome Velociter -
Paul Libbrecht