Example usage for com.liferay.portal.kernel.search Field VIEW_ACTION_ID

List of usage examples for com.liferay.portal.kernel.search Field VIEW_ACTION_ID

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.search Field VIEW_ACTION_ID.

Prototype

String VIEW_ACTION_ID

To view the source code for com.liferay.portal.kernel.search Field VIEW_ACTION_ID.

Click Source Link

Usage

From source file:com.liferay.calendar.search.CalendarBookingIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(CalendarBooking calendarBooking) throws Exception {

    Document document = getBaseModelDocument(CLASS_NAME, calendarBooking);

    document.addKeyword(Field.CLASS_NAME_ID, _classNameLocalService.getClassNameId(Calendar.class));
    document.addKeyword(Field.CLASS_PK, calendarBooking.getCalendarId());

    Locale defaultLocale = LocaleUtil.getSiteDefault();

    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    String[] descriptionLanguageIds = getLanguageIds(defaultLanguageId, calendarBooking.getDescription());

    for (String descriptionLanguageId : descriptionLanguageIds) {
        String description = calendarBooking.getDescription(descriptionLanguageId);

        document.addText(LocalizationUtil.getLocalizedName(Field.DESCRIPTION, descriptionLanguageId),
                description);/*  ww  w .  j  ava  2 s.  com*/
    }

    document.addKeyword(Field.RELATED_ENTRY, true);

    String[] titleLanguageIds = getLanguageIds(defaultLanguageId, calendarBooking.getTitle());

    for (String titleLanguageId : titleLanguageIds) {
        String title = calendarBooking.getTitle(titleLanguageId);

        document.addText(LocalizationUtil.getLocalizedName(Field.TITLE, titleLanguageId), title);
    }

    document.addKeyword(Field.VIEW_ACTION_ID, CalendarActionKeys.VIEW_BOOKING_DETAILS);

    String calendarBookingId = String.valueOf(calendarBooking.getCalendarBookingId());

    if (calendarBooking.isInTrash()) {
        calendarBookingId = TrashUtil.getOriginalTitle(calendarBookingId);
    }

    document.addKeyword("calendarBookingId", calendarBookingId);

    document.addText("defaultLanguageId", defaultLanguageId);
    document.addNumber("endTime", calendarBooking.getEndTime());
    document.addText("location", calendarBooking.getLocation());
    document.addNumber("startTime", calendarBooking.getStartTime());

    return document;
}