Xwql query of all child pages of current document with class property filtering

Hi All,
I’m getting ready to deploy an XWiki install and I’m quite impressed with the capabilities. I’ve created numerous classes and such and am liking many of the features, but I’m a bit stuck on this one.

I have a class that is to hold software release information (i.e. release date, is it a GA or limited release, notes, instructions, etc.). This class is functioning fine, but I have created a second class to build a list display of all releases (a basic livetable marco filtered to the current document space, no big deal there). But it also needs to list the “current release”. I started with livetable, sorting the releases by release date desc, limiting pages to 1 and 1 result per page, etc… and started running into issues on 10.7, along with not wanting to restyle the livetable.

So now I’m just wanting to build the table manually and use xwql to query child documents of the current page to get the result that I’m looking for.

Currently I have this:

{{velocity}}
#set($xwql = "from doc.object(XWiki.ReleaseClass) as release where doc.fullName <> 'XWiki.ReleaseTemplate' and release.LimitedRelease = 0 and release.ReleaseDate <= :date order by release.ReleaseDate desc")
#set($results = $services.query.xwql($xwql).bindValue('date', $datetool.getSystemDate()).setLimit(1).execute())

(% class="box" %)
(((
|=Release Version|=Release Date
#foreach ($item in $results)
  #set($release = $xwiki.getDocument($item))
  |[[$release.display("doc.title")>>${item}]]|$release.display("ReleaseDate")|
#end
)))
{{/velocity}}

and this does everything I’m looking for EXCEPT limit the search to child pages (we have several products and only want documents under the current document)

I’ve looked at the query module and changing the above to this does not throw errors, but it does not return ANY results:

{{velocity}}
#set($xwql = "from doc.object(XWiki.ReleaseClass) as release where doc.space like :space and doc.fullName <> 'XWiki.ReleaseTemplate' and release.LimitedRelease = 0 and release.ReleaseDate <= :date order by release.ReleaseDate desc")
#set($results = $services.query.xwql($xwql).bindValue('date', $datetool.getSystemDate()).bindValue('space').literal("${doc.space}.").anyChars().setLimit(1).execute())

(% class="box" %)
(((
|=Release Version|=Release Date
#foreach ($item in $results)
  #set($release = $xwiki.getDocument($item))
  |[[$release.display("doc.title")>>${item}]]|$release.display("ReleaseDate")|
#end
)))
{{/velocity}}

if I hard code the space it’ll work but as I need this to be reusable without the need for code tweaks every time. it’s much easier for me to tell people to create a blank page and add the “ReleaseHomeClass” object and save than to store a bunch of code and educate a whole team on how to modify the code.

I’ve tried a few other things but something’s clearly not clicking correctly in my head so hopefully someone can help.

Thanks

Hi @ryanp

Took me a while to notice it but I think yo’ure just missing the call to query()in ....anyChars().query().execute().

BTW and in case you’re interested, there’s a Release app at https://extensions.xwiki.org/xwiki/bin/view/Extension/Release%20Application

thanks for the reply,
I had tried adding the .query and it threw errors, complaining about extra dots or something.
I’ve been hammering away at it and I think this is working, though I haven’t had a chance to test it thoroughly:

#set ($query = $services.query.xwql("from doc.object(XWiki.ReleaseClass) as release where release.LimitedRelease = 0 and release.ReleaseDate <= :date and doc.space like :space escape '!' order by release.ReleaseDate desc"))
#set ($spaceReferenceString = ${doc.space})
#set ($spaceLike = $spaceReferenceString.replaceAll('([%_!])', '!$1').concat('.%'))
#set ($query = $query.bindValue('space', $spaceLike))
#set ($query = $query.bindValue('date', $datetool.getSystemDate()))
#set($results = $query.setLimit(1).execute())
(% class="box" %)
(((
|=Release Version|=Release Date
#foreach ($item in $results)
  #set($release = $xwiki.getDocument($item))
  |[[$release.display("doc.title")>>${item}]]|$release.display("ReleaseDate")|
#end
)))

I tried many of the pre-built extentions for various things (release management, QA, Ideas, etc) and while many of them have really cool features, they either didn’t suit our needs or when modifying them we were getting inconsistent behavior (i.e. any time I’d edit the ideas app voting would break, although it was simply removing the cost and assignee fields and adding some more properties, QA was very web focused and we primarily develop desktop apps)

Yes that’s the “old”/manual way to do it and it should work too. That’s why we added the “literal API”, to avoid doing this complex thing of replacing chars & specifying the escape char :wink: