Search in sources :

Example 31 with KBComment

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;
}
Also used : KBComment(com.liferay.knowledgebase.model.KBComment)

Example 32 with 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;
}
Also used : KBComment(com.liferay.knowledgebase.model.KBComment) User(com.liferay.portal.model.User) JSONObject(com.liferay.portal.kernel.json.JSONObject) Date(java.util.Date)

Example 33 with 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");
}
Also used : KBComment(com.liferay.knowledgebase.model.KBComment) ServiceContext(com.liferay.portal.service.ServiceContext) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 34 with KBComment

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;
    }
}
Also used : KBComment(com.liferay.knowledgebase.model.KBComment)

Example 35 with KBComment

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;
}
Also used : KBComment(com.liferay.knowledgebase.model.KBComment) JSONObject(com.liferay.portal.kernel.json.JSONObject)

Aggregations

KBComment (com.liferay.knowledgebase.model.KBComment)60 NoSuchCommentException (com.liferay.knowledgebase.NoSuchCommentException)38 StringBundler (com.liferay.portal.kernel.util.StringBundler)36 Session (com.liferay.portal.kernel.dao.orm.Session)21 SystemException (com.liferay.portal.kernel.exception.SystemException)21 Query (com.liferay.portal.kernel.dao.orm.Query)19 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)18 KBCommentImpl (com.liferay.knowledgebase.model.impl.KBCommentImpl)11 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)11 ArrayList (java.util.ArrayList)11 List (java.util.List)11 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)9 JSONObject (com.liferay.portal.kernel.json.JSONObject)2 ServiceContext (com.liferay.portal.service.ServiceContext)2 KBArticle (com.liferay.knowledgebase.model.KBArticle)1 KBTemplate (com.liferay.knowledgebase.model.KBTemplate)1 User (com.liferay.portal.model.User)1 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)1 Date (java.util.Date)1 Map (java.util.Map)1