use of com.liferay.knowledgebase.model.KBComment in project liferay-ide by liferay.
the class KBCommentLocalServiceImpl method updateStatus.
public KBComment updateStatus(long kbCommentId, int status, ServiceContext serviceContext) throws PortalException, SystemException {
KBComment kbComment = kbCommentPersistence.findByPrimaryKey(kbCommentId);
kbComment.setStatus(status);
kbCommentPersistence.update(kbComment);
notifySubscribers(kbComment, serviceContext);
return kbComment;
}
use of com.liferay.knowledgebase.model.KBComment in project liferay-ide by liferay.
the class KBCommentLocalServiceImpl method addKBComment.
@Override
public KBComment addKBComment(long userId, long classNameId, long classPK, String content, int userRating, ServiceContext serviceContext) throws PortalException, SystemException {
// KB comment
User user = userPersistence.findByPrimaryKey(userId);
long groupId = serviceContext.getScopeGroupId();
Date now = new Date();
validate(content);
long kbCommentId = counterLocalService.increment();
KBComment kbComment = kbCommentPersistence.create(kbCommentId);
kbComment.setUuid(serviceContext.getUuid());
kbComment.setGroupId(groupId);
kbComment.setCompanyId(user.getCompanyId());
kbComment.setUserId(user.getUserId());
kbComment.setUserName(user.getFullName());
kbComment.setCreateDate(serviceContext.getCreateDate(now));
kbComment.setModifiedDate(serviceContext.getModifiedDate(now));
kbComment.setClassNameId(classNameId);
kbComment.setClassPK(classPK);
kbComment.setContent(content);
kbComment.setUserRating(userRating);
kbComment.setStatus(KBCommentConstants.STATUS_NEW);
kbCommentPersistence.update(kbComment);
// Social
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
putTitle(extraDataJSONObject, kbComment);
socialActivityLocalService.addActivity(userId, kbComment.getGroupId(), KBComment.class.getName(), kbCommentId, AdminActivityKeys.ADD_KB_COMMENT, extraDataJSONObject.toString(), 0);
// Subscriptions
notifySubscribers(kbComment, serviceContext);
return kbComment;
}
use of com.liferay.knowledgebase.model.KBComment in project liferay-ide by liferay.
the class BaseKBPortlet method updateKBComment.
public void updateKBComment(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
if (!themeDisplay.isSignedIn()) {
return;
}
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
long kbCommentId = ParamUtil.getLong(actionRequest, "kbCommentId");
long classNameId = ParamUtil.getLong(actionRequest, "classNameId");
long classPK = ParamUtil.getLong(actionRequest, "classPK");
String content = ParamUtil.getString(actionRequest, "content");
int status = ParamUtil.getInteger(actionRequest, "status", KBCommentConstants.STATUS_ANY);
ServiceContext serviceContext = ServiceContextFactory.getInstance(KBComment.class.getName(), actionRequest);
if (cmd.equals(Constants.ADD)) {
KBCommentLocalServiceUtil.addKBComment(themeDisplay.getUserId(), classNameId, classPK, content, serviceContext);
} else if (cmd.equals(Constants.UPDATE)) {
if (status == KBCommentConstants.STATUS_ANY) {
KBComment kbComment = KBCommentServiceUtil.getKBComment(kbCommentId);
status = kbComment.getStatus();
}
KBCommentServiceUtil.updateKBComment(kbCommentId, classNameId, classPK, content, status, serviceContext);
}
SessionMessages.add(actionRequest, "suggestionSaved");
}
use of com.liferay.knowledgebase.model.KBComment in project liferay-ide by liferay.
the class KBCommentModelImpl method equals.
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof KBComment)) {
return false;
}
KBComment kbComment = (KBComment) obj;
long primaryKey = kbComment.getPrimaryKey();
if (getPrimaryKey() == primaryKey) {
return true;
} else {
return false;
}
}
use of com.liferay.knowledgebase.model.KBComment in project liferay-ide by liferay.
the class KBCommentLocalServiceImpl method updateKBComment.
@Override
public KBComment updateKBComment(long kbCommentId, long classNameId, long classPK, String content, int userRating, int status, ServiceContext serviceContext) throws PortalException, SystemException {
// KB comment
validate(content);
KBComment kbComment = kbCommentPersistence.findByPrimaryKey(kbCommentId);
kbComment.setModifiedDate(serviceContext.getModifiedDate(null));
kbComment.setClassNameId(classNameId);
kbComment.setClassPK(classPK);
kbComment.setContent(content);
kbComment.setUserRating(userRating);
kbComment.setStatus(status);
kbCommentPersistence.update(kbComment);
// Social
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
putTitle(extraDataJSONObject, kbComment);
socialActivityLocalService.addActivity(kbComment.getUserId(), kbComment.getGroupId(), KBComment.class.getName(), kbCommentId, AdminActivityKeys.UPDATE_KB_COMMENT, extraDataJSONObject.toString(), 0);
return kbComment;
}
Aggregations