Re: [Liferay Forums][3. Development]Get list of next Calendar Events via Li

461653, modified 18 Years ago. New Member Posts: 9 Join Date: 2/7/08 Recent Posts
Hi

I'm developing a small Portlet that is supposed to show me the next upcoming Events. The Events are normal CalEvents created with the liferay Calendar Portlet.

So what I want to do is retrieve the events via the API (CalEventLocalServiceUtil.getEvents()). But I find the API is not very efficient. You seem to can only get the events for one day at a time. So if I want to look ahead 3 years into the future a would have 1095 API Calls and hence 1095 DB calls. Is there a more efficient way to do this?

I'm thinking something where I can provide the groupID, start- and end-date and I get all Events in a list.

There also is the API:

CalEventLocalServiceUtil.getEvents(groupId, type, begin, end);


But I would need something like this not type specific. Also the begin and end parameters are int and I could't figure out what they are really doing.
thumbnail
10527, modified 18 Years ago. Liferay Legend Posts: 1197 Join Date: 2/8/05 Recent Posts
> There also is the API:
>
>
CalEventLocalServiceUtil.getEvents(groupId, type, begin, end);

>
> But I would need something like this not type specific. Also the begin and end parameters are int and I could't figure out what they are really doing.


The body of
CalEventLocalServiceUtil.getEvents(groupId, type, begin,
end);

is:
	public List<calevent> getEvents(
			long groupId, String type, int begin, int end)
		throws SystemException {

		if (Validator.isNull(type)) {
			return calEventPersistence.findByGroupId(groupId, begin, end);
		}
		else {
			return calEventPersistence.findByG_T(groupId, type, begin, end);
		}
	}
</calevent>


So, using

CalEventLocalServiceUtil.getEvents(10023, null, 0, 1000);

works fine. Problem is still that you can't specify a time interval.
I'll see if we can add this in as it really sounds reasonable.
thumbnail
34461, modified 17 Years ago. Liferay Master Posts: 546 Join Date: 8/8/07 Recent Posts
Hello,


are there any news regarding this topic. Has this item been implemented?
thumbnail
2739662, modified 17 Years ago. New Member Posts: 4 Join Date: 4/7/09 Recent Posts
Is there any progress with this issue?
thumbnail
4542354, modified 16 Years ago. Junior Member Posts: 28 Join Date: 1/29/10 Recent Posts
Hello, I got pretty far with an 'events' web-content-display velocity based portlet (see picture/attachment; btw - is velocity a good idea for that? no portlet building skills) but also stuck at the point of needing to only see events from today forward. I thought those begin, end were dates so it was looking like a piece of cake. The type set to null retrieves all values (as Ray stated), begin/end of -1 gets everything as well.

Plan B: looks like that service can be called with a date as the second parm. Date type "cal" - anyone know how to get/set that via velocity?
thumbnail
4542354, modified 16 Years ago. Junior Member Posts: 28 Join Date: 1/29/10 Recent Posts
Ok, figured out how to get a 'calendar' data type. I'm a boy-genius emoticon
#set ($realcal = $dateTool.getCalendar())

If interest, I'll publish the working velocity when it gets that far. Gotta figure every website needs one of these right? Is it me or does our Liferay 'community' seem to need a breath of life?
4816710, modified 15 Years ago. New Member Posts: 15 Join Date: 4/2/10 Recent Posts
I'm interested emoticon
thumbnail
4899025, modified 15 Years ago. Regular Member Posts: 239 Join Date: 4/27/10 Recent Posts
Go to event_iterator.jspf

1. Copy the selCal value to a new tempCalender Object

2. start a for loop initialized with 0, its max limit 'n' can be ur wish.

3. replace CalEventLocalServiceUtil.getEvents's Date object parameter with our new tempCalender Object.

--------
exixting code

--------

4. atlast increment tempCalender's Date field, repeat the loop


This ll display events from selectedDate/currentDate to selectedDate/currentDate + n days.
GAURAV RASTOGI, modified 14 Years ago. New Member Posts: 5 Join Date: 9/16/11 Recent Posts
it sounds good..thnx..:-)
thumbnail
Brett Conoly, modified 14 Years ago. Regular Member Posts: 130 Join Date: 7/19/07 Recent Posts
You can try something similar to this right now:

@SuppressWarnings({ "unchecked", "rawtypes" })
private List<CalEvent> getEvents(ClientDataRequest portletRequest, RetrieveEventsAction action) throws SystemException {
ThemeDisplay themeDisplay = (ThemeDisplay) requestProvider.getPortletRequest().getAttribute(WebKeys.THEME_DISPLAY);
Long groupId = themeDisplay.getScopeGroupId();

DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(CalEvent.class);
Conjunction primaryCriteria = RestrictionsFactoryUtil.conjunction();
primaryCriteria.add(PropertyFactoryUtil.forName("startDate").between(action.getStartDate(), action.getEndDate()));
primaryCriteria.add(PropertyFactoryUtil.forName("groupId").eq(groupId));
dynamicQuery.add(primaryCriteria);

return (List) CalEventLocalServiceUtil.dynamicQuery(dynamicQuery);
}