Search in sources :

Example 6 with KBArticle

use of com.liferay.knowledgebase.model.KBArticle in project liferay-ide by liferay.

the class AdminPortlet method render.

@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
    try {
        int status = WorkflowConstants.STATUS_ANY;
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status);
        KBArticle kbArticle = null;
        long kbArticleClassNameId = PortalUtil.getClassNameId(KBArticleConstants.getClassName());
        long resourceClassNameId = ParamUtil.getLong(renderRequest, "resourceClassNameId", kbArticleClassNameId);
        long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey");
        if ((resourcePrimKey > 0) && (resourceClassNameId == kbArticleClassNameId)) {
            kbArticle = KBArticleServiceUtil.getLatestKBArticle(resourcePrimKey, status);
        }
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_ARTICLE, kbArticle);
        KBTemplate kbTemplate = null;
        long kbTemplateId = ParamUtil.getLong(renderRequest, "kbTemplateId");
        if (kbTemplateId > 0) {
            kbTemplate = KBTemplateServiceUtil.getKBTemplate(kbTemplateId);
        }
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_TEMPLATE, kbTemplate);
    } catch (Exception e) {
        if (e instanceof NoSuchArticleException || e instanceof NoSuchTemplateException || e instanceof PrincipalException) {
            SessionErrors.add(renderRequest, e.getClass());
        } else {
            throw new PortletException(e);
        }
    }
    super.render(renderRequest, renderResponse);
}
Also used : NoSuchTemplateException(com.liferay.knowledgebase.NoSuchTemplateException) KBArticle(com.liferay.knowledgebase.model.KBArticle) PortletException(javax.portlet.PortletException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) KBTemplate(com.liferay.knowledgebase.model.KBTemplate) NoSuchTemplateException(com.liferay.knowledgebase.NoSuchTemplateException) KBTemplateContentException(com.liferay.knowledgebase.KBTemplateContentException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) NoSuchSubscriptionException(com.liferay.portal.NoSuchSubscriptionException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) IOException(java.io.IOException) WindowStateException(javax.portlet.WindowStateException) NoSuchCommentException(com.liferay.knowledgebase.NoSuchCommentException) KBTemplateTitleException(com.liferay.knowledgebase.KBTemplateTitleException) KBArticleImportException(com.liferay.knowledgebase.KBArticleImportException) PortletException(javax.portlet.PortletException)

Example 7 with KBArticle

use of com.liferay.knowledgebase.model.KBArticle in project liferay-ide by liferay.

the class AdminActivityInterpreter method getEntryTitle.

@Override
protected String getEntryTitle(SocialActivity activity, ServiceContext serviceContext) throws Exception {
    String title = StringPool.BLANK;
    String className = activity.getClassName();
    if (className.equals(KBArticle.class.getName())) {
        KBArticle kbArticle = KBArticleLocalServiceUtil.getLatestKBArticle(activity.getClassPK(), WorkflowConstants.STATUS_APPROVED);
        title = kbArticle.getTitle();
    } else if (className.equals(KBComment.class.getName())) {
        KBComment kbComment = KBCommentLocalServiceUtil.getKBComment(activity.getClassPK());
        String kbCommentClassName = kbComment.getClassName();
        if (kbCommentClassName.equals(KBArticle.class.getName())) {
            KBArticle kbArticle = KBArticleLocalServiceUtil.getLatestKBArticle(kbComment.getClassPK(), WorkflowConstants.STATUS_APPROVED);
            title = kbArticle.getTitle();
        } else if (kbCommentClassName.equals(KBTemplate.class.getName())) {
            KBTemplate kbTemplate = KBTemplateLocalServiceUtil.getKBTemplate(kbComment.getClassPK());
            title = kbTemplate.getTitle();
        }
    } else if (className.equals(KBTemplate.class.getName())) {
        KBTemplate kbTemplate = KBTemplateLocalServiceUtil.getKBTemplate(activity.getClassPK());
        title = kbTemplate.getTitle();
    }
    return getJSONValue(activity.getExtraData(), "title", title);
}
Also used : KBComment(com.liferay.knowledgebase.model.KBComment) KBArticle(com.liferay.knowledgebase.model.KBArticle) KBTemplate(com.liferay.knowledgebase.model.KBTemplate)

Example 8 with KBArticle

use of com.liferay.knowledgebase.model.KBArticle in project liferay-ide by liferay.

the class KBArticleTitleComparator method compare.

@Override
public int compare(Object obj1, Object obj2) {
    KBArticle kbArticle1 = (KBArticle) obj1;
    KBArticle kbArticle2 = (KBArticle) obj2;
    int value = StringUtil.toLowerCase(kbArticle1.getTitle()).compareTo(StringUtil.toLowerCase(kbArticle2.getTitle()));
    if (_ascending) {
        return value;
    } else {
        return -value;
    }
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle)

Example 9 with KBArticle

use of com.liferay.knowledgebase.model.KBArticle in project liferay-ide by liferay.

the class KBArticleUserNameComparator method compare.

@Override
public int compare(Object obj1, Object obj2) {
    KBArticle kbArticle1 = (KBArticle) obj1;
    KBArticle kbArticle2 = (KBArticle) obj2;
    int value = StringUtil.toLowerCase(kbArticle1.getUserName()).compareTo(StringUtil.toLowerCase(kbArticle2.getUserName()));
    if (_ascending) {
        return value;
    } else {
        return -value;
    }
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle)

Example 10 with KBArticle

use of com.liferay.knowledgebase.model.KBArticle in project liferay-ide by liferay.

the class KBArticleViewCountComparator method compare.

@Override
public int compare(Object obj1, Object obj2) {
    KBArticle kbArticle1 = (KBArticle) obj1;
    KBArticle kbArticle2 = (KBArticle) obj2;
    int value = 0;
    if (kbArticle1.getViewCount() < kbArticle2.getViewCount()) {
        value = -1;
    } else if (kbArticle1.getViewCount() > kbArticle2.getViewCount()) {
        value = 1;
    }
    if (_ascending) {
        return value;
    } else {
        return -value;
    }
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle)

Aggregations

KBArticle (com.liferay.knowledgebase.model.KBArticle)306 NoSuchArticleException (com.liferay.knowledgebase.NoSuchArticleException)185 StringBundler (com.liferay.portal.kernel.util.StringBundler)177 SystemException (com.liferay.portal.kernel.exception.SystemException)125 Session (com.liferay.portal.kernel.dao.orm.Session)119 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)117 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)116 ArrayList (java.util.ArrayList)82 List (java.util.List)77 Query (com.liferay.portal.kernel.dao.orm.Query)75 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)73 KBArticleImpl (com.liferay.knowledgebase.model.impl.KBArticleImpl)47 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)29 KBFolder (com.liferay.knowledgebase.model.KBFolder)8 NoSuchCommentException (com.liferay.knowledgebase.NoSuchCommentException)5 NoSuchSubscriptionException (com.liferay.portal.NoSuchSubscriptionException)5 PortalException (com.liferay.portal.kernel.exception.PortalException)5 PrincipalException (com.liferay.portal.security.auth.PrincipalException)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)4