Example usage for com.liferay.portal.kernel.search Sort LONG_TYPE

List of usage examples for com.liferay.portal.kernel.search Sort LONG_TYPE

Introduction

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

Prototype

int LONG_TYPE

To view the source code for com.liferay.portal.kernel.search Sort LONG_TYPE.

Click Source Link

Usage

From source file:com.liferay.asset.browser.web.internal.display.context.AssetBrowserDisplayContext.java

License:Open Source License

public AssetBrowserSearch getAssetBrowserSearch() throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    AssetBrowserSearch assetBrowserSearch = new AssetBrowserSearch(_renderRequest, getPortletURL());

    if (Validator.isNull(getKeywords())) {
        if (Validator.isNotNull(getAddButtonURL())) {
            assetBrowserSearch//from  w  ww  .ja v a 2 s  . c o  m
                    .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
        }
    } else {
        assetBrowserSearch.setSearch(true);
    }

    AssetRendererFactory assetRendererFactory = getAssetRendererFactory();

    int total = getTotal();

    assetBrowserSearch.setTotal(total);

    if (AssetBrowserWebConfigurationValues.SEARCH_WITH_DATABASE) {
        List<AssetEntry> assetEntries = AssetEntryLocalServiceUtil.getEntries(getFilterGroupIds(),
                new long[] { assetRendererFactory.getClassNameId() }, getKeywords(), getKeywords(),
                getKeywords(), getKeywords(), getListable(), false, false, assetBrowserSearch.getStart(),
                assetBrowserSearch.getEnd(), "modifiedDate", StringPool.BLANK, getOrderByType(),
                StringPool.BLANK);

        assetBrowserSearch.setResults(assetEntries);
    } else {
        Sort sort = null;

        boolean orderByAsc = false;

        if (Objects.equals(getOrderByType(), "asc")) {
            orderByAsc = true;
        }

        if (Objects.equals(getOrderByCol(), "modified-date")) {
            sort = new Sort(Field.MODIFIED_DATE, Sort.LONG_TYPE, orderByAsc);
        } else if (Objects.equals(getOrderByCol(), "title")) {
            String sortFieldName = DocumentImpl
                    .getSortableFieldName("localized_title_".concat(themeDisplay.getLanguageId()));

            sort = new Sort(sortFieldName, Sort.STRING_TYPE, orderByAsc);
        }

        Hits hits = AssetEntryLocalServiceUtil.search(themeDisplay.getCompanyId(), getFilterGroupIds(),
                themeDisplay.getUserId(), assetRendererFactory.getClassName(), getSubtypeSelectionId(),
                getKeywords(), isShowNonindexable(), getStatuses(), assetBrowserSearch.getStart(),
                assetBrowserSearch.getEnd(), sort);

        List<AssetEntry> assetEntries = _assetHelper.getAssetEntries(hits);

        assetBrowserSearch.setResults(assetEntries);
    }

    return assetBrowserSearch;
}

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public SearchContainer getCategoriesSearchContainer() throws PortalException {

    if (_categoriesSearchContainer != null) {
        return _categoriesSearchContainer;
    }/*from   w w  w  .  ja  va2  s  . c  o m*/

    SearchContainer categoriesSearchContainer = new SearchContainer(_renderRequest, getIteratorURL(), null,
            "there-are-no-categories");

    if (Validator.isNull(getKeywords())) {
        if (isShowCategoriesAddButton()) {
            categoriesSearchContainer
                    .setEmptyResultsMessageCssClass("there-are-no-categories.-you-can-add-a-category-by-"
                            + "clicking-the-plus-button-on-the-bottom-right-corner");
            categoriesSearchContainer
                    .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
        }
    } else {
        categoriesSearchContainer.setSearch(true);
    }

    categoriesSearchContainer.setOrderByCol(getOrderByCol());

    boolean orderByAsc = false;

    String orderByType = getOrderByType();

    if (orderByType.equals("asc")) {
        orderByAsc = true;
    }

    OrderByComparator<AssetCategory> orderByComparator = new AssetCategoryCreateDateComparator(orderByAsc);

    categoriesSearchContainer.setOrderByComparator(orderByComparator);

    categoriesSearchContainer.setOrderByType(orderByType);

    EmptyOnClickRowChecker emptyOnClickRowChecker = new EmptyOnClickRowChecker(_renderResponse);

    StringBundler sb = new StringBundler(7);

    sb.append("^(?!.*");
    sb.append(_renderResponse.getNamespace());
    sb.append("redirect).*(/vocabulary/");
    sb.append(getVocabularyId());
    sb.append("/category/");
    sb.append(getCategoryId());
    sb.append(")");

    emptyOnClickRowChecker.setRememberCheckBoxStateURLRegex(sb.toString());

    categoriesSearchContainer.setRowChecker(emptyOnClickRowChecker);

    List<AssetCategory> categories = null;
    int categoriesCount = 0;

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    long scopeGroupId = themeDisplay.getScopeGroupId();

    if (Validator.isNotNull(getKeywords())) {
        AssetCategoryDisplay assetCategoryDisplay = null;

        Sort sort = null;

        if (isFlattenedNavigationAllowed()) {
            sort = new Sort("leftCategoryId", Sort.INT_TYPE, orderByAsc);
        } else {
            sort = new Sort("createDate", Sort.LONG_TYPE, orderByAsc);
        }

        assetCategoryDisplay = AssetCategoryServiceUtil.searchCategoriesDisplay(new long[] { scopeGroupId },
                getKeywords(), new long[] { getVocabularyId() }, new long[0],
                categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(), sort);

        categoriesCount = assetCategoryDisplay.getTotal();

        categoriesSearchContainer.setTotal(categoriesCount);

        categories = assetCategoryDisplay.getCategories();
    } else if (isFlattenedNavigationAllowed()) {
        AssetCategory category = getCategory();

        if (Validator.isNull(category)) {
            categoriesCount = AssetCategoryServiceUtil
                    .getVocabularyCategoriesCount(themeDisplay.getScopeGroupId(), getVocabularyId());

            categories = AssetCategoryServiceUtil.getVocabularyCategories(getVocabularyId(),
                    categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(),
                    new AssetCategoryLeftCategoryIdComparator(orderByAsc));
        } else {
            categoriesCount = AssetCategoryServiceUtil.getVocabularyCategoriesCount(
                    themeDisplay.getScopeGroupId(), category.getCategoryId(), getVocabularyId());

            categories = AssetCategoryServiceUtil.getVocabularyCategories(category.getCategoryId(),
                    getVocabularyId(), categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(),
                    new AssetCategoryLeftCategoryIdComparator(orderByAsc));
        }

        categoriesSearchContainer.setTotal(categoriesCount);
    } else {
        categoriesCount = AssetCategoryServiceUtil.getVocabularyCategoriesCount(scopeGroupId, getCategoryId(),
                getVocabularyId());

        categoriesSearchContainer.setTotal(categoriesCount);

        categories = AssetCategoryServiceUtil.getVocabularyCategories(scopeGroupId, getCategoryId(),
                getVocabularyId(), categoriesSearchContainer.getStart(), categoriesSearchContainer.getEnd(),
                categoriesSearchContainer.getOrderByComparator());
    }

    categoriesSearchContainer.setResults(categories);

    _categoriesSearchContainer = categoriesSearchContainer;

    return _categoriesSearchContainer;
}

From source file:com.liferay.asset.categories.admin.web.internal.display.context.AssetCategoriesDisplayContext.java

License:Open Source License

public SearchContainer getVocabulariesSearchContainer() throws PortalException {

    if (_vocabulariesSearchContainer != null) {
        return _vocabulariesSearchContainer;
    }/*from   ww  w. j ava2  s . c  o m*/

    SearchContainer vocabulariesSearchContainer = new SearchContainer(_renderRequest,
            _renderResponse.createRenderURL(), null, "there-are-no-vocabularies");

    String keywords = getKeywords();

    if (Validator.isNull(keywords)) {
        if (isShowVocabulariesAddButton()) {
            vocabulariesSearchContainer
                    .setEmptyResultsMessage("there-are-no-vocabularies.-you-can-add-a-vocabulary-by-"
                            + "clicking-the-plus-button-on-the-bottom-right-corner");
            vocabulariesSearchContainer
                    .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
        }
    } else {
        vocabulariesSearchContainer.setSearch(true);
    }

    vocabulariesSearchContainer.setOrderByCol(getOrderByCol());

    String orderByType = getOrderByType();

    boolean orderByAsc = false;

    if (orderByType.equals("asc")) {
        orderByAsc = true;
    }

    OrderByComparator<AssetVocabulary> orderByComparator = new AssetVocabularyCreateDateComparator(orderByAsc);

    vocabulariesSearchContainer.setOrderByComparator(orderByComparator);

    vocabulariesSearchContainer.setOrderByType(orderByType);

    EmptyOnClickRowChecker emptyOnClickRowChecker = new EmptyOnClickRowChecker(_renderResponse);

    StringBundler sb = new StringBundler(5);

    sb.append("^(?!.*");
    sb.append(_renderResponse.getNamespace());
    sb.append("redirect).*(/vocabulary/");
    sb.append(getVocabularyId());
    sb.append(")");

    emptyOnClickRowChecker.setRememberCheckBoxStateURLRegex(sb.toString());

    vocabulariesSearchContainer.setRowChecker(emptyOnClickRowChecker);

    List<AssetVocabulary> vocabularies = null;
    int vocabulariesCount = 0;

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    long scopeGroupId = themeDisplay.getScopeGroupId();

    if (Validator.isNotNull(keywords)) {
        Sort sort = new Sort("createDate", Sort.LONG_TYPE, orderByAsc);

        AssetVocabularyDisplay assetVocabularyDisplay = AssetVocabularyServiceUtil.searchVocabulariesDisplay(
                scopeGroupId, keywords, true, vocabulariesSearchContainer.getStart(),
                vocabulariesSearchContainer.getEnd(), sort);

        vocabulariesCount = assetVocabularyDisplay.getTotal();

        vocabulariesSearchContainer.setTotal(vocabulariesCount);

        vocabularies = assetVocabularyDisplay.getVocabularies();
    } else {
        vocabulariesCount = AssetVocabularyServiceUtil.getGroupVocabulariesCount(scopeGroupId);

        vocabulariesSearchContainer.setTotal(vocabulariesCount);

        vocabularies = AssetVocabularyServiceUtil.getGroupVocabularies(scopeGroupId, true,
                vocabulariesSearchContainer.getStart(), vocabulariesSearchContainer.getEnd(),
                vocabulariesSearchContainer.getOrderByComparator());

        if (vocabulariesCount == 0) {
            vocabulariesCount = AssetVocabularyServiceUtil.getGroupVocabulariesCount(scopeGroupId);

            vocabulariesSearchContainer.setTotal(vocabulariesCount);
        }
    }

    vocabulariesSearchContainer.setResults(vocabularies);

    _vocabulariesSearchContainer = vocabulariesSearchContainer;

    return _vocabulariesSearchContainer;
}

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  ww  .ja  va2 s .c  o 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;
}

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

License:Open Source License

private int _getSortType(String fieldType) {
    int sortType = Sort.STRING_TYPE;

    if (fieldType.equals(Field.CREATE_DATE) || fieldType.equals(Field.EXPIRATION_DATE)
            || fieldType.equals(Field.PUBLISH_DATE) || fieldType.equals("ddm-date")
            || fieldType.equals("modifiedDate")) {

        sortType = Sort.LONG_TYPE;
    } else if (fieldType.equals(Field.PRIORITY) || fieldType.equals("ddm-decimal")
            || fieldType.equals("ddm-number")) {

        sortType = Sort.DOUBLE_TYPE;//  w ww .  j  av a 2  s  .  c o  m
    } else if (fieldType.equals("ddm-integer")) {
        sortType = Sort.INT_TYPE;
    }

    return sortType;
}

From source file:com.liferay.journal.web.internal.display.context.JournalDisplayContext.java

License:Open Source License

public SearchContainer getSearchContainer(boolean showVersions) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    SearchContainer articleSearchContainer = new SearchContainer(_liferayPortletRequest, getPortletURL(), null,
            null);//from   w  w w .jav a 2  s .  co  m

    if (!isSearch()) {
        articleSearchContainer
                .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn");
    } else {
        articleSearchContainer.setSearch(true);
    }

    OrderByComparator<JournalArticle> orderByComparator = JournalPortletUtil
            .getArticleOrderByComparator(getOrderByCol(), getOrderByType());

    articleSearchContainer.setOrderByCol(getOrderByCol());
    articleSearchContainer.setOrderByComparator(orderByComparator);
    articleSearchContainer.setOrderByType(getOrderByType());

    EntriesChecker entriesChecker = new EntriesChecker(_liferayPortletRequest, _liferayPortletResponse);

    entriesChecker.setCssClass("entry-selector");
    entriesChecker.setRememberCheckBoxStateURLRegex(
            "^(?!.*" + _liferayPortletResponse.getNamespace() + "redirect).*(folderId=" + getFolderId() + ")");

    articleSearchContainer.setRowChecker(entriesChecker);

    EntriesMover entriesMover = new EntriesMover(themeDisplay.getScopeGroupId());

    articleSearchContainer.setRowMover(entriesMover);

    if (isNavigationMine() || isNavigationRecent()) {
        boolean includeOwner = true;

        if (isNavigationMine()) {
            includeOwner = false;
        }

        if (isNavigationRecent()) {
            articleSearchContainer.setOrderByCol("create-date");
            articleSearchContainer.setOrderByType(getOrderByType());
        }

        int total = JournalArticleServiceUtil.getGroupArticlesCount(themeDisplay.getScopeGroupId(),
                themeDisplay.getUserId(), getFolderId(), getStatus(), includeOwner);

        articleSearchContainer.setTotal(total);

        List results = JournalArticleServiceUtil.getGroupArticles(themeDisplay.getScopeGroupId(),
                themeDisplay.getUserId(), getFolderId(), getStatus(), includeOwner,
                articleSearchContainer.getStart(), articleSearchContainer.getEnd(),
                articleSearchContainer.getOrderByComparator());

        articleSearchContainer.setResults(results);
    } else if (Validator.isNotNull(getDDMStructureKey())) {
        int total = JournalArticleServiceUtil.getArticlesCountByStructureId(themeDisplay.getScopeGroupId(),
                getDDMStructureKey(), getStatus());

        articleSearchContainer.setTotal(total);

        List results = JournalArticleServiceUtil.getArticlesByStructureId(themeDisplay.getScopeGroupId(),
                getDDMStructureKey(), getStatus(), articleSearchContainer.getStart(),
                articleSearchContainer.getEnd(), articleSearchContainer.getOrderByComparator());

        articleSearchContainer.setResults(results);
    } else if (Validator.isNotNull(getDDMTemplateKey())) {
        List<Long> folderIds = new ArrayList<>(1);

        if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

            folderIds.add(getFolderId());
        }

        int total = JournalArticleServiceUtil.searchCount(themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(), null);

        articleSearchContainer.setTotal(total);

        List results = JournalArticleServiceUtil.search(themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(), null,
                articleSearchContainer.getStart(), articleSearchContainer.getEnd(),
                articleSearchContainer.getOrderByComparator());

        articleSearchContainer.setResults(results);
    } else if (isSearch()) {
        List<Long> folderIds = new ArrayList<>(1);

        if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

            folderIds.add(getFolderId());
        }

        JournalWebConfiguration journalWebConfiguration = (JournalWebConfiguration) _request
                .getAttribute(JournalWebConfiguration.class.getName());

        if (journalWebConfiguration.journalArticlesSearchWithIndex()) {
            boolean orderByAsc = false;

            if (Objects.equals(getOrderByType(), "asc")) {
                orderByAsc = true;
            }

            Sort sort = null;

            if (Objects.equals(getOrderByCol(), "display-date")) {
                sort = new Sort("displayDate", Sort.LONG_TYPE, orderByAsc);
            } else if (Objects.equals(getOrderByCol(), "id")) {
                sort = new Sort(DocumentImpl.getSortableFieldName(Field.ARTICLE_ID), Sort.STRING_TYPE,
                        !orderByAsc);
            } else if (Objects.equals(getOrderByCol(), "modified-date")) {
                sort = new Sort(Field.MODIFIED_DATE, Sort.LONG_TYPE, orderByAsc);
            } else if (Objects.equals(getOrderByCol(), "title")) {
                sort = new Sort("title", Sort.STRING_TYPE, !orderByAsc);
            }

            LinkedHashMap<String, Object> params = new LinkedHashMap<>();

            params.put("expandoAttributes", getKeywords());

            Indexer indexer = JournalSearcher.getInstance();

            SearchContext searchContext = buildSearchContext(themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                    getDDMStructureKey(), getDDMTemplateKey(), getKeywords(), params,
                    articleSearchContainer.getStart(), articleSearchContainer.getEnd(), sort, showVersions);

            Hits hits = indexer.search(searchContext);

            int total = hits.getLength();

            articleSearchContainer.setTotal(total);

            List results = new ArrayList<>();

            Document[] documents = hits.getDocs();

            for (int i = 0; i < documents.length; i++) {
                Document document = documents[i];

                JournalArticle article = null;
                JournalFolder folder = null;

                String className = document.get(Field.ENTRY_CLASS_NAME);
                long classPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

                if (className.equals(JournalArticle.class.getName())) {
                    if (!showVersions) {
                        article = JournalArticleLocalServiceUtil.fetchLatestArticle(classPK,
                                WorkflowConstants.STATUS_ANY, false);
                    } else {
                        String articleId = document.get(Field.ARTICLE_ID);
                        long groupId = GetterUtil.getLong(document.get(Field.GROUP_ID));
                        double version = GetterUtil.getDouble(document.get(Field.VERSION));

                        article = JournalArticleLocalServiceUtil.fetchArticle(groupId, articleId, version);
                    }

                    results.add(article);
                } else if (className.equals(JournalFolder.class.getName())) {
                    folder = JournalFolderLocalServiceUtil.getFolder(classPK);

                    results.add(folder);
                }
            }

            articleSearchContainer.setResults(results);
        } else {
            int total = JournalArticleServiceUtil.searchCount(themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                    getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(),
                    null);

            articleSearchContainer.setTotal(total);

            List results = JournalArticleServiceUtil.search(themeDisplay.getCompanyId(),
                    themeDisplay.getScopeGroupId(), folderIds, JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                    getKeywords(), -1.0, getDDMStructureKey(), getDDMTemplateKey(), null, null, getStatus(),
                    null, articleSearchContainer.getStart(), articleSearchContainer.getEnd(),
                    articleSearchContainer.getOrderByComparator());

            articleSearchContainer.setResults(results);
        }
    } else {
        int total = JournalFolderServiceUtil.getFoldersAndArticlesCount(themeDisplay.getScopeGroupId(), 0,
                getFolderId(), getStatus());

        articleSearchContainer.setTotal(total);

        OrderByComparator<Object> folderOrderByComparator = null;

        boolean orderByAsc = false;

        if (Objects.equals(getOrderByType(), "asc")) {
            orderByAsc = true;
        }

        if (Objects.equals(getOrderByCol(), "display-date")) {
            folderOrderByComparator = new FolderArticleDisplayDateComparator(orderByAsc);
        } else if (Objects.equals(getOrderByCol(), "id")) {
            folderOrderByComparator = new FolderArticleArticleIdComparator(orderByAsc);
        } else if (Objects.equals(getOrderByCol(), "modified-date")) {
            folderOrderByComparator = new FolderArticleModifiedDateComparator(orderByAsc);
        } else if (Objects.equals(getOrderByCol(), "title")) {
            folderOrderByComparator = new FolderArticleTitleComparator(orderByAsc);
        }

        List results = JournalFolderServiceUtil.getFoldersAndArticles(themeDisplay.getScopeGroupId(), 0,
                getFolderId(), getStatus(), themeDisplay.getLocale(), articleSearchContainer.getStart(),
                articleSearchContainer.getEnd(), folderOrderByComparator);

        articleSearchContainer.setResults(results);
    }

    return articleSearchContainer;
}

From source file:com.liferay.knowledgebase.util.KnowledgeBaseUtil.java

License:Open Source License

public static Sort[] getKBArticleSorts(String orderByCol, String orderByType) {

    if (Validator.isNull(orderByCol) || Validator.isNull(orderByType)) {
        return SortFactoryUtil.getDefaultSorts();
    }//from  www  . j av a2 s  .  c  o  m

    boolean reverse = true;

    if (orderByType.equals("asc")) {
        reverse = false;
    }

    if (orderByCol.equals("create-date")) {
        String fieldName = Field.CREATE_DATE;

        return new Sort[] { SortFactoryUtil.create(fieldName, Sort.LONG_TYPE, reverse),
                SortFactoryUtil.create(null, Sort.SCORE_TYPE, false) };
    } else if (orderByCol.equals("modified-date")) {
        String fieldName = Field.MODIFIED_DATE;

        return new Sort[] { SortFactoryUtil.create(fieldName, Sort.LONG_TYPE, reverse),
                SortFactoryUtil.create(null, Sort.SCORE_TYPE, false) };
    } else if (orderByCol.equals("score")) {
        String fieldName = null;

        return new Sort[] { SortFactoryUtil.create(fieldName, Sort.SCORE_TYPE, !reverse),
                SortFactoryUtil.create(Field.MODIFIED_DATE, Sort.LONG_TYPE, true) };
    } else if (orderByCol.equals("title")) {
        String fieldName = "titleKeyword";

        return new Sort[] { SortFactoryUtil.create(fieldName, Sort.STRING_TYPE, reverse),
                SortFactoryUtil.create(null, Sort.SCORE_TYPE, false) };
    } else if (orderByCol.equals("user-name")) {
        String fieldName = Field.USER_NAME;

        return new Sort[] { SortFactoryUtil.create(fieldName, Sort.STRING_TYPE, reverse),
                SortFactoryUtil.create(null, Sort.SCORE_TYPE, false) };
    }

    return SortFactoryUtil.getDefaultSorts();
}

From source file:org.fit.portlet.service.service.impl.InserFitxaPersonalLocalServiceImpl.java

License:Open Source License

private int getType(String orderByColumn) {

    if (orderByColumn.equalsIgnoreCase(Field.CLASS_PK)) {

        return Sort.LONG_TYPE;

    }/*from  w w  w . j  a  va 2s. c  om*/

    return Sort.STRING_TYPE;
}