Hi,
I am using QueryBuilder to execute a search operation for all the cq:Page under a path. There are two custom date properties that are being set through page properties :displayStartDate and displayEndDate. All the pages for which displayStartDate <= current Date and time and displayEndDate>= current date and time should be the outcome of the search operation. I have gone through the DateRangePredicateEvaluator for this and it looks to be the solution for me. However, I am not able to make out how to use two daterange predicates in the code.
type=cq:Page path=/content/mercer/global/all/en/webcasts/2014 1_daterange.property=@jcr:content/displayStartDate
2_daterange.property=@jcr:content/displayEndDate
and then :
a) How do I set the upperOperation(<=) and lowerOperation(>=).
b) In what format the current date and time should be put in.
c) I also learned that there is a field called TIME_ZONE. Any insight on how to use this is also appreciated.
Thanks in advance,
Ankit
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Ankit,
I'd suggest checking that displayStart and displayEnd are actually Date properties. It sounds like they aren't.
The timeZone property needs to be parseable by TimeZone.getTimeZone(). See http://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#getTimeZone(java.lang.String)
Regards,
Justin
Views
Replies
Total Likes
I am not sure which aem version you are using. You might need to remove @ from property based on aem version due to bug. Answer for a & b below [1].
[1]
type=cq:Page
path=/content/mercer/global/all/en/webcasts/2014
1_daterange.property=@jcr:content/displayStartDate
1_daterange.upperBound=2014-21-02
1_daterange.upperOperation=<=
2_daterange.property=@jcr:content/displayEndDate
2_daterange.lowerBound=2014-21-02
2_daterange.lowerOperation=>=
Hi Sham,
Thanks for your reply. I am using CQ 5.6.1. Another thing that I noticed is if I use:
type=cq:Page property=@jcr:content/cq:template property.value=/apps/mercer/templates/webcasts/webcastsDetailPage 2_property=@jcr:content/displayUpcoming 2_property.value=true path=/content/mercer/global/all/en/webcasts/2014 daterange.property=@jcr:content/displayStart daterange.upperBound=2014-02-19T19:49:51.560-05:00 daterange.upperOperation=<= 1_daterange.property=@jcr:content/displayEnd 1_daterange.lowerBound=2014-02-19T19:49:51.560-05:00 1_daterange.lowerOperation=>= orderby=@jcr:content/cq:lastModified orderby.sort=desc p.limit=-1
I am getting results as expected but when in the orderby when I use a custom date property( instead of cq:lastModified) set through page properties the ordering is somewhat random.
Also, could you please validate if I can use the timeZone like this : daterange.timeZone = EST ?
Thanks
Views
Replies
Total Likes
Hi Ankit,
I'd suggest checking that displayStart and displayEnd are actually Date properties. It sounds like they aren't.
The timeZone property needs to be parseable by TimeZone.getTimeZone(). See http://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#getTimeZone(java.lang.String)
Regards,
Justin
Views
Replies
Total Likes
Views
Likes
Replies