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:com.liferay.message.boards.comment.internal.MBCommentManagerImpl.java

License:Open Source License

@Override
public DiscussionComment fetchDiscussionComment(long userId, long commentId) throws PortalException {

    MBMessage mbMessage = _mbMessageLocalService.fetchMBMessage(commentId);

    if (mbMessage == null) {
        return null;
    }//  w ww  . ja  v a2s. c o m

    MBMessageDisplay messageDisplay = _mbMessageLocalService.getDiscussionMessageDisplay(userId,
            mbMessage.getGroupId(), mbMessage.getClassName(), mbMessage.getClassPK(),
            WorkflowConstants.STATUS_ANY, new MessageThreadComparator());

    return getDiscussionComment(userId, messageDisplay);
}

From source file:com.liferay.message.boards.comment.internal.MBCommentManagerImpl.java

License:Open Source License

@Override
public Discussion getDiscussion(long userId, long groupId, String className, long classPK,
        Function<String, ServiceContext> serviceContextFunction) throws PortalException {

    MBMessageDisplay messageDisplay = _mbMessageLocalService.getDiscussionMessageDisplay(userId, groupId,
            className, classPK, WorkflowConstants.STATUS_ANY, new MessageThreadComparator());

    DiscussionComment rootDiscussionComment = getDiscussionComment(userId, messageDisplay);

    MBTreeWalker treeWalker = messageDisplay.getTreeWalker();

    List<MBMessage> messages = treeWalker.getMessages();

    return new MBDiscussionImpl(rootDiscussionComment, messageDisplay.isDiscussionMaxComments(),
            messages.size() - 1);/*from  w  w w  .  ja v  a 2 s .  c om*/
}

From source file:com.liferay.message.boards.internal.service.MBStatsUserMBThreadLocalServiceWrapper.java

License:Open Source License

@Override
public void deleteThread(MBThread thread) throws PortalException {
    List<MBMessage> messages = _mbMessageLocalService.getThreadMessages(thread.getGroupId(),
            WorkflowConstants.STATUS_ANY);

    super.deleteThread(thread);

    for (MBMessage message : messages) {
        if (!message.isDiscussion()) {
            _mbStatsUserLocalService.updateStatsUser(message.getGroupId(), message.getUserId());
        }/*  www  . j av  a  2  s.  com*/
    }
}

From source file:com.liferay.message.boards.internal.service.MBStatsUserMBThreadLocalServiceWrapper.java

License:Open Source License

@Override
public void moveDependentsToTrash(long groupId, long threadId, long trashEntryId) throws PortalException {

    List<MBMessage> messages = _mbMessageLocalService.getThreadMessages(threadId, WorkflowConstants.STATUS_ANY);

    super.moveDependentsToTrash(groupId, threadId, trashEntryId);

    Stream<MBMessage> stream = messages.stream();

    stream.filter(message -> !message.isDiscussion()).mapToLong(message -> message.getUserId()).distinct()
            .forEach(userId -> _mbStatsUserLocalService.updateStatsUser(groupId, userId));
}

From source file:com.liferay.message.boards.internal.service.MBStatsUserMBThreadLocalServiceWrapper.java

License:Open Source License

@Override
public void restoreDependentsFromTrash(long groupId, long threadId) throws PortalException {

    List<MBMessage> messages = _mbMessageLocalService.getThreadMessages(threadId, WorkflowConstants.STATUS_ANY);

    super.restoreDependentsFromTrash(groupId, threadId);

    Stream<MBMessage> stream = messages.stream();

    stream.filter(mbMessage -> !mbMessage.isDiscussion()).mapToLong(message -> message.getUserId()).distinct()
            .forEach(userId -> _mbStatsUserLocalService.updateStatsUser(groupId, userId));
}

From source file:com.liferay.message.boards.internal.service.SubscriptionMBMessageLocalServiceWrapper.java

License:Open Source License

@Override
public MBMessage deleteMessage(MBMessage message) throws PortalException {
    int count = getThreadMessagesCount(message.getThreadId(), WorkflowConstants.STATUS_ANY);

    MBMessage deletedMessage = super.deleteMessage(message);

    if (count == 1) {
        _subscriptionLocalService.deleteSubscriptions(message.getCompanyId(), MBThread.class.getName(),
                message.getThreadId());/*from   ww w .j  a v  a2  s  .  c  o m*/
    }

    return deletedMessage;
}

From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesCountWithExcludedCategories() throws Exception {

    addCategory();/*from  w ww. ja va2  s  .  co m*/

    MBCategory excludedCategory1 = addCategory();
    MBCategory excludedCategory2 = addCategory();

    Assert.assertEquals(3, MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(),
            MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_ANY));
    Assert.assertEquals(1, MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(),
            new long[] { excludedCategory1.getCategoryId(), excludedCategory2.getCategoryId() },
            new long[] { MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID }, WorkflowConstants.STATUS_ANY));
}

From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesCountWithExcludedCategory() throws Exception {
    addCategory();/*from   w  ww . j a va 2s .  c  om*/
    addCategory();

    MBCategory excludedCategory = addCategory();

    Assert.assertEquals(3, MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(),
            MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_ANY));
    Assert.assertEquals(2,
            MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(), excludedCategory.getCategoryId(),
                    MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_ANY));
}

From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesWithExcludedCategories() throws Exception {
    List<MBCategory> expectedCategories = new ArrayList<>();

    expectedCategories.add(addCategory());

    MBCategory excludedCategory1 = addCategory();

    expectedCategories.add(excludedCategory1);

    MBCategory excludedCategory2 = addCategory();

    expectedCategories.add(excludedCategory2);

    List<MBCategory> categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId());

    AssertUtils.assertEquals(expectedCategories, categories);

    expectedCategories.remove(excludedCategory1);
    expectedCategories.remove(excludedCategory2);

    categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId(),
            new long[] { excludedCategory1.getCategoryId(), excludedCategory2.getCategoryId() },
            new long[] { MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID }, WorkflowConstants.STATUS_ANY,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    AssertUtils.assertEquals(expectedCategories, categories);
}

From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java

License:Open Source License

@Test
public void testGetCategoriesWithExcludedCategory() throws Exception {
    List<MBCategory> expectedCategories = new ArrayList<>();

    expectedCategories.add(addCategory());
    expectedCategories.add(addCategory());

    MBCategory excludedCategory = addCategory();

    expectedCategories.add(excludedCategory);

    List<MBCategory> categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId());

    AssertUtils.assertEquals(expectedCategories, categories);

    expectedCategories.remove(excludedCategory);

    categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId(), excludedCategory.getCategoryId(),
            MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_ANY, QueryUtil.ALL_POS,
            QueryUtil.ALL_POS);//from  w w  w. j av a 2 s  . com

    AssertUtils.assertEquals(expectedCategories, categories);
}