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

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

Introduction

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

Prototype

public static String getSortableFieldName(String name) 

Source Link

Usage

From source file:com.liferay.asset.internal.util.AssetHelperImpl.java

License:Open Source License

private String _getOrderByCol(String sortField, String fieldType, int sortType, Locale locale) {

    if (sortField.startsWith(DDMStructureManager.STRUCTURE_INDEXER_FIELD_PREFIX)) {

        StringBundler sb = new StringBundler(5);

        sb.append(sortField);//from w w  w.j a  va  2  s. co m
        sb.append(StringPool.UNDERLINE);
        sb.append(LocaleUtil.toLanguageId(locale));
        sb.append(StringPool.UNDERLINE);

        String suffix = "String";

        if (!fieldType.equals("ddm-date") && ((sortType == Sort.DOUBLE_TYPE) || (sortType == Sort.FLOAT_TYPE)
                || (sortType == Sort.INT_TYPE) || (sortType == Sort.LONG_TYPE))) {

            suffix = "Number";
        }

        sb.append(suffix);

        sortField = Field.getSortableFieldName(sb.toString());
    } else if (sortField.equals("modifiedDate")) {
        sortField = Field.MODIFIED_DATE;
    } else if (sortField.equals("title")) {
        sortField = Field.getSortableFieldName("localized_title_".concat(LocaleUtil.toLanguageId(locale)));
    }

    return sortField;
}