On Wed, Feb 22, 2012 at 1:06 AM,
<ricardo.julio.rodriguez.fernan...@sergas.es> wrote:
> Hi! Thanks for your detailed answer. Please, see below...
> --
> Ricardo Rodríguez
> Research Management and Promotion Technician
> Health Research Institute of Santiago de Compostela (IDIS)
> http://www.idisantiago.es
> ________________________________________
> From: users-boun...@xwiki.org [users-boun...@xwiki.org] On Behalf Of Marius 
> Dumitru Florea [mariusdumitru.flo...@xwiki.com]
> Sent: 20 February 2012 09:03
> To: XWiki Users
> Subject: Re: [xwiki-users] understanding Livetable Macro (XE 2.4.30451)
>
> Hi Ricardo,
>
> On Sun, Feb 19, 2012 at 12:25 PM,
> <ricardo.julio.rodriguez.fernan...@sergas.es> wrote:
>> Hi all!
>>
>> First of all, please, allow me to thank again all XWiki Team for this great 
>> framework! It could be it happens that on Sunday I'm prone to purple prose, 
>> but I do think I'll feel the same tomorrow morning! :-)
>>
>> Now, some doubts here...
>>
>> I'm not able to understand how filtering does work in Livetable Macro. For 
>> instance, I get a JSON file including a number of results following a 
>> modified getgroupmembers.vm. Here the line of getgroupmembers getting 
>> members column
>>
>>    "member"   : "$mdoc.getTranslatedDocument().title #if($hasAdmin || 
>> $isAdvancedUser) (#if($wikiname != 'local')$wikiname:#end$m)#end",
>>
>> and one of the items in the JSON file...
>>
>>                    {
>>    "fullname"     : "XWiki.XWikiIDISC04",
>>    "prettyname"   : "XWikiIDISC04 (XWiki.XWikiIDISC04)",
>>    "wikiname"     : "local",
>>    "memberurl"    : "/bin/XWiki/XWikiIDISC04",
>>    "docurl"       : "/bin/XWiki/XWikiIDISArealNeurology",
>>    "grayed"       : "false",
>>    "doc_viewable" : "true",
>>    "doc_hasadmin" : "${xwiki.hasAccessLevel('admin', $context.user, $doc)}",
>>    "member"   : "Neurobiology   (XWiki.XWikiIDISC04)",
>>    "member_url" : "/bin/XWiki/XWikiIDISC04",
>>    "doc_delete_url" : 
>> "/bin/XWiki/XWikiIDISArealNeurology?xpage=deletegroupmember&fullname=XWiki.XWikiIDISC04&ajax=true"
>>   }
>>
>> The Livetable Macro instance showing group membership reads...
>>
>> #set($columnOptions = {
>>  "member" : {'link': 'auto', 'type': 'text', 'displayName': 'Research 
>> groups'},
>>
>
>> But if I use strings content in $mdoc.getTranslatedDocument().title, I get 
>> no results in the filtered database. only strings in $m (showing the 
>> fullname of the document) work fine. You could check this behaviour on your 
>> own here...
>>
>> http://atrium_km.idisantiago.es/bin/XWiki/XWikiIDISArealNeurology
>>>
>>> With Firebug (or any other browser tool that catches XmlHttpRequests)
>>> you can see that when you filter the live table (e.g. type 'logy') a
>>> request like this is made:
>>>
>>> http://atrium_km.idisantiago.es/bin/XWiki/XWikiIDISArealNeurology?xpage=getgroupmembers&offset=1&limit=15&reqNo=5&member=logy&sort=member&dir=asc
>>>
>>> Notice 'member=logy' which specifies the filter. Now if you search
>>> getgroupmembers.vm for '$request.member' (that's how request
>>> parameters are accessed) you'll see why group members are filtered by
>>> their document name and not by their document title.
>>>
>
> Thanks for the explanation. Are these lines the ones concerned in this task?
>
> #set($rm = $xwiki.rightsmanager)
> #if($request.member && !$request.member.trim().equals(''))

>  #set($countm = $rm.getAllMatchedMembersNamesForGroup($doc.fullName, 
> $request.member, 0, 0, $order).size())
>  #set($members = $rm.getAllMatchedMembersNamesForGroup($doc.fullName, 
> $request.member, $limit, $off, $order))

I replaced these two lines with:

----------8<----------
## Statement to filter group members by their translated title.
#set($statement = "FROM BaseObject as groupObject, StringProperty as
memberField, XWikiDocument as memberDoc WHERE groupObject.name =
:groupName and groupObject.className = 'XWiki.XWikiGroups' and
groupObject.id = memberField.id.id and memberDoc.fullName =
memberField.value and (memberDoc.language = :language or
(memberDoc.language = '' and memberDoc.defaultLanguage = :language))
and lower(memberDoc.title) like :titleFilter")
## Determine the member count.
#set($countStatement = "SELECT count(memberField.value) $statement")
#set($query = $services.query.hql($countStatement))
#set($query = $query.bindValue('groupName', $doc.fullName))
#set($query = $query.bindValue('language', $context.language))
#set($query = $query.bindValue('titleFilter',
"%$!request.member.toLowerCase()%"))
#set($countm = $query.execute().get(0))
## Retrieve a subset of the filtered members.
#set($selectStatement = "SELECT memberField.value $statement ORDER BY
memberDoc.title $order")
#set($query = 
$services.query.hql($selectStatement).setLimit($limit).setOffset($off))
#set($query = $query.bindValue('groupName', $doc.fullName))
#set($query = $query.bindValue('language', $context.language))
#set($query = $query.bindValue('titleFilter',
"%$!request.member.toLowerCase()%"))
#set($members = $query.execute())
---------->8----------

and it worked for me on a 4.0 snapshot. I'll let you adapt it for your
older version of XWiki Enterprise.

Hope this helps,
Marius

> #else
>  #set($countm  = $rm.countAllMembersNamesForGroup($doc.fullName))
>  #set($members = $rm.getAllMatchedMembersNamesForGroup($doc.fullName, 
> $util.null, $limit, $off, $order))
> #end
>
> $doc.fullName clearly appears as a parameter passed to 
> getAllMatchedMembersNameForGroup method.
>
>>> You can find the rights manager source code here
>>> https://github.com/xwiki/xwiki-platform/tree/master/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/plugin/rightsmanager
>>> . Unfortunately it doesn't have a method to retrieve group member
>>> matched by their document title so you'll have to write this code by
>>> yourself (either directly in getgroupmembers.vm or in a script service
>>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents#HFromwikipages
>>> )
>
> I'm afraid I'm not a developer myself! It is not easy for me to understand 
> that source code. But, even not been a Java person, is not possible to pass 
> other fields to the method to get the Livetable filtered? Please, why?
>
> I've also found this...
>
> http://www.xwiki.org/xwiki/bin/view/FAQ/Why+is+it+not+possible+to+filter+on+doc+title+in+a+Livetable#History
>
> I can understand this, but I would like to find/be able to implement a 
> solution here (XWiki Enterprise 2.4.30451) because:
>
> 1. Livetables created showing group members are a really useful tool here. 
> XWiki groups are rather convenient to organize users and groups and assign 
> them rights on the set of documents of their concern.
> 2. Document title is a really, at least until now!, useful piece of 
> information that allow us, for instance, to store different translations of 
> the name of a group and recover them using getTranslatedDocument().
> 3. read-only SQL access to xwikidoc.XWD_TITLE and, for instance, XWD_PARENT 
> offers us a quite useful source of information to tabulate information on 
> users and groups. It is simple to create new documents with a given structure 
> in their names to easily filter contents by type of document.
>
> Livetable filtering is an impressive tool. I would like to enable our users 
> to use filtering by name in documents like this...
>
> http://atrium_km.idisantiago.es/bin/XWiki/XWikiIDISAreaEndocrinology?language=en
>
> All pages have title: we have edited it in the three available languages.
>
> Must I go through the creation of a new component to get it? Is there any 
> simpler way of achieving this? Any workaround to be used until I'm able to 
> understand how does work the whole thing and to write that component?
>
> Thank you for your help,
>
> Ricardo
>
>>>
>>> Hope this helps,
>>> Marius
>
>>
>>
>> Please, why? How could I use $mdoc.getTranslatedDocument().title to filter 
>> the list?
>>
>> Thank you for your help!!!
>>
>> --
>> Ricardo Rodríguez
>> Research Management and Promotion Technician
>> Health Research Institute of Santiago de Compostela (IDIS)
>> http://www.idisantiago.es
>>
>> Nota: A información contida nesta mensaxe e os seus posibles documentos 
>> adxuntos é privada e confidencial e está dirixida únicamente ó seu 
>> destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, 
>> por favor elimínea. A distribución ou copia desta mensaxe non está 
>> autorizada.
>>
>> Nota: La información contenida en este mensaje y sus posibles documentos 
>> adjuntos es privada y confidencial y está dirigida únicamente a su 
>> destinatario/a. Si usted no es el/la destinatario/a original de este 
>> mensaje, por favor elimínelo. La distribución o copia de este mensaje no 
>> está autorizada.
>>
>> See more languages: http://www.sergas.es/aviso_confidencialidad.htm
>> _______________________________________________
>> users mailing list
>> users@xwiki.org
>> http://lists.xwiki.org/mailman/listinfo/users
> _______________________________________________
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
> Nota: A información contida nesta mensaxe e os seus posibles documentos 
> adxuntos é privada e confidencial e está dirixida únicamente ó seu 
> destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, 
> por favor elimínea. A distribución ou copia desta mensaxe non está autorizada.
>
> Nota: La información contenida en este mensaje y sus posibles documentos 
> adjuntos es privada y confidencial y está dirigida únicamente a su 
> destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
> por favor elimínelo. La distribución o copia de este mensaje no está 
> autorizada.
>
> See more languages: http://www.sergas.es/aviso_confidencialidad.htm
> _______________________________________________
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to