RE: Re: [Liferay Forums][3. Development]Get list of next Calendar Events v

تم تعديل 461653 منذ 18 سنوات من الدقائق. New Member المشاركات: 9 تاريخ الإنضمام: 7‏/2‏/08 المشاركات الحديثة
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 منذ 18 سنوات من الدقائق. Liferay Legend المشاركات: 1197 تاريخ الإنضمام: 8‏/2‏/05 المشاركات الحديثة
> 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 منذ 17 سنوات من الدقائق. Liferay Master المشاركات: 546 تاريخ الإنضمام: 8‏/8‏/07 المشاركات الحديثة
Hello,


are there any news regarding this topic. Has this item been implemented?
thumbnail
تم تعديل 2739662 منذ 17 سنوات من الدقائق. New Member المشاركات: 4 تاريخ الإنضمام: 7‏/4‏/09 المشاركات الحديثة
Is there any progress with this issue?
thumbnail
تم تعديل 4542354 منذ 16 سنوات من الدقائق. Junior Member المشاركات: 28 تاريخ الإنضمام: 29‏/1‏/10 المشاركات الحديثة
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 منذ 16 سنوات من الدقائق. Junior Member المشاركات: 28 تاريخ الإنضمام: 29‏/1‏/10 المشاركات الحديثة
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 منذ 15 سنوات من الدقائق. New Member المشاركات: 15 تاريخ الإنضمام: 2‏/4‏/10 المشاركات الحديثة
I'm interested emoticon
thumbnail
تم تعديل 4899025 منذ 15 سنوات من الدقائق. Regular Member المشاركات: 239 تاريخ الإنضمام: 27‏/4‏/10 المشاركات الحديثة
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 منذ 14 سنوات من الدقائق. New Member المشاركات: 5 تاريخ الإنضمام: 16‏/9‏/11 المشاركات الحديثة
it sounds good..thnx..:-)
thumbnail
تم تعديل Brett Conoly منذ 14 سنوات من الدقائق. Regular Member المشاركات: 130 تاريخ الإنضمام: 19‏/7‏/07 المشاركات الحديثة
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);
}