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