use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.
the class KBTemplateStagedModelDataHandler method doImportStagedModel.
@Override
protected void doImportStagedModel(PortletDataContext portletDataContext, KBTemplate kbTemplate) throws Exception {
long userId = portletDataContext.getUserId(kbTemplate.getUserUuid());
ServiceContext serviceContext = portletDataContext.createServiceContext(kbTemplate);
KBTemplate importedKBTemplate = null;
if (portletDataContext.isDataStrategyMirror()) {
KBTemplate existingKBTemplate = KBTemplateUtil.fetchByUUID_G(kbTemplate.getUuid(), portletDataContext.getScopeGroupId());
if (existingKBTemplate == null) {
serviceContext.setUuid(kbTemplate.getUuid());
importedKBTemplate = KBTemplateLocalServiceUtil.addKBTemplate(userId, kbTemplate.getTitle(), kbTemplate.getContent(), serviceContext);
} else {
importedKBTemplate = KBTemplateLocalServiceUtil.updateKBTemplate(existingKBTemplate.getKbTemplateId(), kbTemplate.getTitle(), kbTemplate.getContent(), serviceContext);
}
} else {
importedKBTemplate = KBTemplateLocalServiceUtil.addKBTemplate(userId, kbTemplate.getTitle(), kbTemplate.getContent(), serviceContext);
}
portletDataContext.importClassedModel(kbTemplate, importedKBTemplate);
}
use of com.liferay.knowledgebase.model.KBTemplate 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.KBTemplate 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.KBTemplate in project liferay-ide by liferay.
the class KBTemplateCreateDateComparator method compare.
@Override
public int compare(Object obj1, Object obj2) {
KBTemplate kbTemplate1 = (KBTemplate) obj1;
KBTemplate kbTemplate2 = (KBTemplate) obj2;
int value = DateUtil.compareTo(kbTemplate1.getCreateDate(), kbTemplate2.getCreateDate());
if (_ascending) {
return value;
} else {
return -value;
}
}
use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.
the class KBTemplateTitleComparator method compare.
@Override
public int compare(Object obj1, Object obj2) {
KBTemplate kbTemplate1 = (KBTemplate) obj1;
KBTemplate kbTemplate2 = (KBTemplate) obj2;
int value = StringUtil.toLowerCase(kbTemplate1.getTitle()).compareTo(StringUtil.toLowerCase(kbTemplate2.getTitle()));
if (_ascending) {
return value;
} else {
return -value;
}
}
Aggregations