Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY.

Prototype

int STATUS_ANY

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_ANY.

Click Source Link

Usage

From source file:se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.java

License:Open Source License

private void addAutoComment(Idea idea, long classPK, String message) {
    try {/*from  www.  j  a va 2  s.  c o  m*/

        MBMessageDisplay messageDisplay = mbMessageLocalService.getDiscussionMessageDisplay(idea.getUserId(),
                idea.getGroupId(), IdeaContent.class.getName(), classPK, WorkflowConstants.STATUS_ANY);
        MBThread thread = messageDisplay.getThread();

        long threadId = thread.getThreadId();
        long rootThreadId = thread.getRootMessageId();
        ServiceContext serviceContext = new ServiceContext();

        long userId = Long.valueOf(autoCommentDefaultUserId);

        mbMessageLocalService.addDiscussionMessage(userId, autoCommentDefaultUserId, idea.getGroupId(),
                IdeaContent.class.getName(), idea.getIdeaContentPrivate().getId(), threadId, rootThreadId,
                autoCommentDefaultSubject, message, serviceContext);

    } catch (PortalException e) {
        e.printStackTrace();
    } catch (SystemException e) {
        e.printStackTrace();
    }
}

From source file:se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.java

License:Open Source License

public Idea addMBMessage(Idea idea, ServiceContext serviceContext, long groupId, long userId, String comment,
        long ideaCommentClassPK) throws PortalException, SystemException {

    User user = UserLocalServiceUtil.getUser(userId);

    MBMessageDisplay messageDisplay = MBMessageLocalServiceUtil.getDiscussionMessageDisplay(userId, groupId,
            IdeaContent.class.getName(), ideaCommentClassPK, WorkflowConstants.STATUS_ANY);

    MBThread thread = messageDisplay.getThread();
    long threadId = thread.getThreadId();
    long rootThreadId = thread.getRootMessageId();

    String commentContentCleaned = comment;
    final int maxLenghtCommentSubject = 50;
    String commentSubject = comment;
    commentSubject = StringUtil.shorten(commentSubject, maxLenghtCommentSubject);
    commentSubject += "...";

    // TODO - validate comment and preserve line breaks
    MBMessageLocalServiceUtil.addDiscussionMessage(userId, user.getScreenName(), groupId,
            IdeaContent.class.getName(), ideaCommentClassPK, threadId, rootThreadId, commentSubject,
            commentContentCleaned, serviceContext);

    return idea;//from  w  ww .  ja v  a 2 s  . co m
}

From source file:se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.java

License:Open Source License

protected List<CommentItemVO> getComments(IdeaContent ideaContent) {

    ArrayList<CommentItemVO> commentsList = new ArrayList<CommentItemVO>();

    try {/*from   w ww .j a  v  a  2 s  . com*/

        MBMessageDisplay messageDisplay = null;

        try {
            messageDisplay = mbMessageLocalService.getDiscussionMessageDisplay(ideaContent.getUserId(),
                    ideaContent.getGroupId(), IdeaContent.class.getName(), ideaContent.getId(),
                    WorkflowConstants.STATUS_ANY);
        } catch (NullPointerException e) {
            return commentsList;
        }

        Idea idea = ideaContent.getIdea();

        MBThread thread = messageDisplay.getThread();

        long threadId = thread.getThreadId();
        long rootMessageId = thread.getRootMessageId();

        messageComparator = new MessageCreateDateComparator(false);

        @SuppressWarnings("unchecked")
        List<MBMessage> mbMessages = mbMessageLocalService.getThreadMessages(threadId,
                WorkflowConstants.STATUS_ANY, messageComparator);

        for (MBMessage mbMessage : mbMessages) {

            String curCommentText = mbMessage.getBody();
            Date createDate = mbMessage.getCreateDate();
            long commentId = mbMessage.getMessageId();

            if (commentId != rootMessageId) {
                long curCommentUserId = mbMessage.getUserId();
                long scopeGroupId = mbMessage.getGroupId();

                boolean isUserIdeaCreator = isUserIdeaCreator(curCommentUserId, idea);
                boolean isUserPrioCouncilMember = isUserPrioCouncilMember(curCommentUserId, scopeGroupId);
                boolean isUserInnovationsslussenEmployee = isUserInnovationsslussenEmployee(curCommentUserId,
                        scopeGroupId);
                boolean isUserIdeaTransporter = isUserIdeaTransporter(curCommentUserId, scopeGroupId);

                CommentItemVO commentItem = new CommentItemVO();
                commentItem.setCommentText(curCommentText);
                commentItem.setCreateDate(createDate);
                commentItem.setId(commentId);
                commentItem.setUserCreator(isUserIdeaCreator);
                commentItem.setUserIdeaTransporter(isUserIdeaTransporter);
                commentItem.setUserPrioCouncilMember(isUserPrioCouncilMember);
                commentItem.setUserInnovationsslussenEmployee(isUserInnovationsslussenEmployee);
                commentItem.setUserId(curCommentUserId);
                commentItem.setMessageId(mbMessage.getMessageId());

                try {
                    User curCommentUser = userLocalService.getUser(curCommentUserId);
                    String curCommentUserFullName = curCommentUser.getFullName();
                    commentItem.setName(curCommentUserFullName);
                } catch (Exception e) {
                    LOGGER.error(e.getMessage(), e);
                }

                commentsList.add(commentItem);
            }
        }

    } catch (PortalException e) {
        LOGGER.error(e.getMessage(), e);
    } catch (SystemException e) {
        LOGGER.error(e.getMessage(), e);
    }

    return commentsList;
}

From source file:se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.java

License:Open Source License

protected int getCommentsCount(IdeaContent ideaContent) {

    int commentsCount = 0;

    try {// w  w  w .  ja v  a 2 s . c o m

        MBMessageDisplay messageDisplay = null;

        try {
            messageDisplay = mbMessageLocalService.getDiscussionMessageDisplay(ideaContent.getUserId(),
                    ideaContent.getGroupId(), IdeaContent.class.getName(), ideaContent.getId(),
                    WorkflowConstants.STATUS_ANY);
        } catch (NullPointerException e) {
            return commentsCount;
        }

        MBThread thread = messageDisplay.getThread();

        long threadId = thread.getThreadId();
        long rootMessageId = thread.getRootMessageId();

        messageComparator = new MessageCreateDateComparator(false);

        @SuppressWarnings("unchecked")
        List<MBMessage> mbMessages = mbMessageLocalService.getThreadMessages(threadId,
                WorkflowConstants.STATUS_ANY, messageComparator);

        for (MBMessage mbMessage : mbMessages) {

            long commentId = mbMessage.getMessageId();

            if (commentId != rootMessageId) {
                commentsCount++;
            }
        }

    } catch (PortalException e) {
        LOGGER.error(e.getMessage(), e);
    } catch (SystemException e) {
        LOGGER.error(e.getMessage(), e);
    }

    return commentsCount;
}