Example usage for com.liferay.portal.kernel.search Document addNumber

List of usage examples for com.liferay.portal.kernel.search Document addNumber

Introduction

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

Prototype

public void addNumber(String name, String[] values);

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);/*from   w w  w . j a v a 2s. c o m*/
    }

    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;
}

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

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    CalendarBooking calendarBooking = (CalendarBooking) obj;

    Document document = getBaseModelDocument(PORTLET_ID, calendarBooking);

    Locale defaultLocale = LocaleUtil.getSiteDefault();

    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    String descriptionDefaultLanguageId = LocalizationUtil
            .getDefaultLanguageId(calendarBooking.getDescription());

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

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

        if (descriptionLanguageId.equals(descriptionDefaultLanguageId)) {
            document.addText(Field.DESCRIPTION, description);
        }/*from w w w .  jav  a2 s.  com*/

        document.addText(Field.DESCRIPTION.concat(StringPool.UNDERLINE).concat(descriptionLanguageId),
                description);
    }

    String titleDefaultLanguageId = LocalizationUtil.getDefaultLanguageId(calendarBooking.getTitle());

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

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

        if (titleLanguageId.equals(titleDefaultLanguageId)) {
            document.addText(Field.TITLE, title);
        }

        document.addText(Field.TITLE.concat(StringPool.UNDERLINE).concat(titleLanguageId), title);
    }

    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;
}

From source file:com.liferay.exportimport.search.ExportImportConfigurationIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(ExportImportConfiguration exportImportConfiguration) throws Exception {

    Document document = getBaseModelDocument(CLASS_NAME, exportImportConfiguration);

    document.addText(Field.DESCRIPTION, exportImportConfiguration.getDescription());
    document.addText(Field.NAME, exportImportConfiguration.getName());
    document.addKeyword(Field.TYPE, exportImportConfiguration.getType());
    document.addNumber("exportImportConfigurationId",
            exportImportConfiguration.getExportImportConfigurationId());

    Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap();

    populateDates(document, settingsMap);
    populateLayoutIds(document, settingsMap);
    populateLocale(document, settingsMap);
    populateParameterMap(document, settingsMap);
    populateSiteInformation(document, settingsMap);
    populateTimeZone(document, settingsMap);

    document.addKeyword(_PREFIX_SETTING + Field.USER_ID, MapUtil.getLong(settingsMap, "userId"));

    return document;
}

From source file:org.opencps.dossiermgt.search.DossierFileIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    // TODO Auto-generated method stub
    DossierFile dossierFile = (DossierFile) obj;

    Document document = getBaseModelDocument(PORTLET_ID, dossierFile);

    if (dossierFile.getDisplayName() != null && !Validator.isBlank(dossierFile.getDisplayName())) {
        Field field = new Field(DossierFileDisplayTerms.DISPLAY_NAME,
                dossierFile.getDisplayName().toLowerCase().split("\\s+"));
        field.setBoost(5);/*from w  w  w .  j  av  a 2  s . co  m*/
        document.add(field);
    }

    if (dossierFile.getModifiedDate() != null) {
        document.addDate(Field.MODIFIED_DATE, dossierFile.getModifiedDate());
    }
    if (dossierFile.getFormData() != null && !Validator.isBlank(dossierFile.getFormData())) {
        document.addText(DossierFileDisplayTerms.FORM_DATA,
                dossierFile.getFormData().toLowerCase().split("\\s+"));
    }
    if (dossierFile.getDossierFileNo() != null && !Validator.isBlank(dossierFile.getDossierFileNo())) {
        document.addText(DossierFileDisplayTerms.DOSSIER_FILE_NO, dossierFile.getDossierFileNo());
    }
    document.addNumber(DossierFileDisplayTerms.DOSSIER_FILE_ID, dossierFile.getDossierFileId());
    document.addKeyword(Field.GROUP_ID, getSiteGroupId(dossierFile.getGroupId()));
    document.addKeyword(Field.SCOPE_GROUP_ID, dossierFile.getGroupId());

    return document;
}

From source file:org.opencps.dossiermgt.search.DossierIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    // TODO Auto-generated method stub
    Dossier dossier = (Dossier) obj;/*from  w ww . j a  v a  2 s  . com*/

    Document document = getBaseModelDocument(PORTLET_ID, dossier);

    if (dossier.getReceptionNo() != null && !Validator.isBlank(dossier.getReceptionNo())) {
        Field field = new Field(DossierDisplayTerms.RECEPTION_NO, dossier.getReceptionNo());
        field.setBoost(5);
        document.add(field);
    }
    if (dossier.getModifiedDate() != null) {
        document.addDate(Field.MODIFIED_DATE, dossier.getModifiedDate());
    }
    if (dossier.getCityName() != null && !Validator.isBlank(dossier.getCityName())) {
        document.addText(DossierDisplayTerms.CITY_NAME, dossier.getCityName().toLowerCase().split("\\s+"));
    }
    if (dossier.getExternalRefNo() != null && !Validator.isBlank(dossier.getExternalRefNo())) {
        document.addText(DossierDisplayTerms.EXTERNALREF_NO, dossier.getExternalRefNo());
    }
    if (dossier.getExternalRefUrl() != null && !Validator.isBlank(dossier.getExternalRefUrl())) {
        document.addText(DossierDisplayTerms.EXTERNALREF_URL, dossier.getExternalRefUrl());
    }
    if (dossier.getGovAgencyName() != null && !Validator.isBlank(dossier.getGovAgencyName())) {
        document.addText(DossierDisplayTerms.GOVAGENCY_NAME,
                dossier.getGovAgencyName().toLowerCase().split("\\s+"));
    }
    if (dossier.getSubjectName() != null && !Validator.isBlank(dossier.getSubjectName())) {
        document.addText(DossierDisplayTerms.SUBJECT_NAME,
                dossier.getSubjectName().toLowerCase().split("\\s+"));
    }
    if (dossier.getAddress() != null && !Validator.isBlank(dossier.getAddress())) {
        document.addText(DossierDisplayTerms.ADDRESS, dossier.getAddress().toLowerCase().split("\\s+"));
    }
    if (dossier.getCityCode() != null && !Validator.isBlank(dossier.getCityCode())) {
        document.addText(DossierDisplayTerms.CITY_CODE, dossier.getCityCode());
    }
    if (dossier.getDistrictCode() != null && !Validator.isBlank(dossier.getDistrictCode())) {
        document.addText(DossierDisplayTerms.DISTRICT_CODE, dossier.getDistrictCode());
    }
    if (dossier.getDistrictName() != null && !Validator.isBlank(dossier.getDistrictName())) {
        document.addText(DossierDisplayTerms.DISTRICT_NAME,
                dossier.getDistrictName().toLowerCase().split("\\s+"));
    }
    if (dossier.getWardCode() != null && !Validator.isBlank(dossier.getWardCode())) {
        document.addText(DossierDisplayTerms.WARD_CODE, dossier.getWardCode());
    }
    if (dossier.getWardName() != null && !Validator.isBlank(dossier.getWardName())) {
        document.addText(DossierDisplayTerms.WARD_NAME, dossier.getWardName().toLowerCase().split("\\s+"));
    }
    if (dossier.getContactName() != null && !Validator.isBlank(dossier.getContactName())) {
        document.addText(DossierDisplayTerms.CONTACT_NAME,
                dossier.getContactName().toLowerCase().split("\\s+"));
    }
    if (dossier.getContactTelNo() != null && !Validator.isBlank(dossier.getContactTelNo())) {
        document.addText(DossierDisplayTerms.CONTACT_TEL_NO, dossier.getContactTelNo());
    }
    if (dossier.getContactEmail() != null && !Validator.isBlank(dossier.getContactEmail())) {
        document.addText(DossierDisplayTerms.CONTACT_EMAIL, dossier.getContactEmail());
    }
    if (dossier.getNote() != null && !Validator.isBlank(dossier.getNote())) {
        document.addText(DossierDisplayTerms.NOTE, dossier.getNote().toLowerCase().split("\\s+"));
    }
    document.addNumber(DossierDisplayTerms.DOSSIER_ID, dossier.getDossierId());

    document.addKeyword(Field.GROUP_ID, getSiteGroupId(dossier.getGroupId()));
    document.addKeyword(Field.SCOPE_GROUP_ID, dossier.getGroupId());

    return document;
}