Search in sources :

Example 1 with OrderByComparator

use of com.liferay.portal.kernel.util.OrderByComparator in project liferay-ide by liferay.

the class KBArticleLocalServiceImpl method fetchLatestKBArticleByUrlTitle.

@Override
public KBArticle fetchLatestKBArticleByUrlTitle(long groupId, long kbFolderId, String urlTitle, int status) throws SystemException {
    urlTitle = StringUtil.replaceFirst(urlTitle, StringPool.SLASH, StringPool.BLANK);
    List<KBArticle> kbArticles = null;
    OrderByComparator orderByComparator = new KBArticleVersionComparator();
    if (status == WorkflowConstants.STATUS_ANY) {
        kbArticles = kbArticlePersistence.findByG_KBFI_UT(groupId, kbFolderId, urlTitle, 0, 1, orderByComparator);
    } else {
        kbArticles = kbArticlePersistence.findByG_KBFI_UT_ST(groupId, kbFolderId, urlTitle, status, 0, 1, orderByComparator);
    }
    if (kbArticles.isEmpty()) {
        return null;
    }
    return kbArticles.get(0);
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) KBArticleVersionComparator(com.liferay.knowledgebase.util.comparator.KBArticleVersionComparator) OrderByComparator(com.liferay.portal.kernel.util.OrderByComparator)

Aggregations

KBArticle (com.liferay.knowledgebase.model.KBArticle)1 KBArticleVersionComparator (com.liferay.knowledgebase.util.comparator.KBArticleVersionComparator)1 OrderByComparator (com.liferay.portal.kernel.util.OrderByComparator)1