Example usage for com.liferay.portal.kernel.bean BeanLocator getNames

List of usage examples for com.liferay.portal.kernel.bean BeanLocator getNames

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.bean BeanLocator getNames.

Prototype

public String[] getNames();

Source Link

Usage

From source file:au.com.permeance.liferay.portlet.controller.SamplePortletController.java

License:Open Source License

@RenderMapping
public String handleViewPage(final RenderRequest request, final ModelMap model) throws SystemException {
    _log.info("In View");

    BeanLocator bl = PortletBeanLocatorUtil.getBeanLocator("calendar-portlet");

    FluentReflectionInvokation calendarSvc = FluentReflection.within(bl)
            .on("com.liferay.calendar.service.CalendarLocalService");
    FluentReflectionInvokation bookingsSvc = FluentReflection.within(bl)
            .on("com.liferay.calendar.service.CalendarBookingLocalService");
    Object result = calendarSvc.invoke("getCalendarsCount");

    List<?> calendars = (List<?>) calendarSvc.invoke("getCalendars", 0, 100);

    Map<Object, Object> calIdToBookings = new HashMap<Object, Object>();

    for (Object cal : calendars) {
        FluentReflectionInvokation calendar = FluentReflection.on(cal);
        Object calendarId = calendar.invoke("getCalendarId");

        List<BookingVO> bookingVos = new LinkedList<SamplePortletController.BookingVO>();
        List<?> bookings = (List<?>) bookingsSvc.invoke("getCalendarBookings", calendarId);
        for (Object bookingObj : bookings) {
            FluentReflectionInvokation booking = FluentReflection.on(bookingObj);
            String title = (String) booking.invoke("getTitle", "en-US");
            long startDate = (Long) booking.invoke("getStartTime");
            long endDate = (Long) booking.invoke("getEndTime");

            BookingVO vo = new BookingVO();
            vo.title = title;//www.ja  v a2 s.c om
            vo.start = new Date(startDate);
            vo.end = new Date(endDate);

            bookingVos.add(vo);
        }

        calIdToBookings.put(calendarId, bookingVos);
    }

    String[] names;
    if (bl != null) {

        names = bl.getNames();
    } else {
        names = new String[] { "not found" };
    }

    model.put("calendarsCount", result);
    model.put("calendars", calendars);
    model.put("beanNames", names);
    model.put("bookings", calIdToBookings);

    return "view";
}