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

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

Introduction

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

Prototype

int STATUS_APPROVED

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

Click Source Link

Usage

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

License:Open Source License

@Test
public void testGetCategoriesAndThreadsInRootCategoryWithOnlyThreads() throws Exception {

    MBMessage message1 = addMessage(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);

    MBMessage message2 = addMessage(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);

    try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_user)) {

        List<Object> categoriesAndThreads = MBCategoryServiceUtil.getCategoriesAndThreads(_group.getGroupId(),
                MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED);

        Assert.assertEquals(categoriesAndThreads.toString(), 2, categoriesAndThreads.size());
        Assert.assertEquals(message1.getThread(), categoriesAndThreads.get(0));
        Assert.assertEquals(message2.getThread(), categoriesAndThreads.get(1));
    }/*from   w  w w.  j  ava 2s.  co  m*/
}

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

License:Open Source License

@Test
public void testGetCategoriesAndThreadsWithOnlyCategories() throws Exception {

    MBCategory category1 = addCategory();

    MBCategory subcategory1 = addCategory(category1.getCategoryId());

    addCategory();//from  w  w  w.ja  v a2s.  co  m

    try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_user)) {

        List<Object> categoriesAndThreads = MBCategoryServiceUtil.getCategoriesAndThreads(_group.getGroupId(),
                category1.getCategoryId(), WorkflowConstants.STATUS_APPROVED);

        Assert.assertEquals(categoriesAndThreads.toString(), 1, categoriesAndThreads.size());
        Assert.assertEquals(subcategory1, categoriesAndThreads.get(0));
    }
}

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

License:Open Source License

@Test
public void testGetCategoriesAndThreadsWithPriorityThread() throws Exception {

    MBMessage message1 = addMessage(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);

    MBCategory category1 = addCategory();

    addMessage(category1.getCategoryId());

    MBMessage priorityMessage = addMessage(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, 2.0);

    MBMessage message2 = addMessage(MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID);

    try (ContextUserReplace contextUserReplacer = new ContextUserReplace(_user)) {

        List<Object> categoriesAndThreads = MBCategoryServiceUtil.getCategoriesAndThreads(_group.getGroupId(),
                MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED);

        Assert.assertEquals(categoriesAndThreads.toString(), 4, categoriesAndThreads.size());
        Assert.assertEquals(category1, categoriesAndThreads.get(0));
        Assert.assertEquals(priorityMessage.getThread(), categoriesAndThreads.get(1));
        Assert.assertEquals(message1.getThread(), categoriesAndThreads.get(2));
        Assert.assertEquals(message2.getThread(), categoriesAndThreads.get(3));
    }/* w  w  w  .j  a v a2s  .  co m*/
}

From source file:com.liferay.message.boards.test.util.MBTestUtil.java

License:Open Source License

protected static MBMessage updateStatus(MBMessage message, ServiceContext serviceContext) throws Exception {

    Map<String, Serializable> workflowContext = new HashMap<>();

    workflowContext.put(WorkflowConstants.CONTEXT_URL, "http://localhost");

    message = MBMessageLocalServiceUtil.updateStatus(message.getUserId(), message.getMessageId(),
            WorkflowConstants.STATUS_APPROVED, serviceContext, workflowContext);

    return message;
}

From source file:com.liferay.message.boards.trash.test.MBCategoryTrashHandlerTest.java

License:Open Source License

@Override
protected int getNotInTrashBaseModelsCount(BaseModel<?> parentBaseModel) throws Exception {

    MBCategory parentCategory = (MBCategory) parentBaseModel;

    return MBCategoryLocalServiceUtil.getCategoriesCount(parentCategory.getGroupId(),
            parentCategory.getCategoryId(), WorkflowConstants.STATUS_APPROVED);
}

From source file:com.liferay.message.boards.trash.test.MBThreadTrashHandlerTest.java

License:Open Source License

@Override
public int getMineBaseModelsCount(long groupId, long userId) throws Exception {

    return MBThreadServiceUtil.getGroupThreadsCount(groupId, userId, WorkflowConstants.STATUS_APPROVED);
}

From source file:com.liferay.message.boards.trash.test.MBThreadTrashHandlerTest.java

License:Open Source License

@Override
public int getRecentBaseModelsCount(long groupId) throws Exception {
    Calendar calendar = Calendar.getInstance();

    calendar.add(Calendar.HOUR, -1);

    return MBThreadServiceUtil.getGroupThreadsCount(groupId, 0, calendar.getTime(),
            WorkflowConstants.STATUS_APPROVED);
}

From source file:com.liferay.message.boards.trash.test.MBThreadTrashHandlerTest.java

License:Open Source License

@Override
protected int getNotInTrashBaseModelsCount(BaseModel<?> parentBaseModel) throws Exception {

    MBCategory category = (MBCategory) parentBaseModel;

    return MBThreadLocalServiceUtil.getCategoryThreadsCount(category.getGroupId(), category.getCategoryId(),
            WorkflowConstants.STATUS_APPROVED);
}

From source file:com.liferay.message.boards.web.internal.display.context.DefaultMBListDisplayContext.java

License:Open Source License

@Override
public void populateResultsAndTotal(SearchContainer searchContainer) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    if (isShowSearch()) {
        long searchCategoryId = ParamUtil.getLong(_request, "searchCategoryId");

        long[] categoryIdsArray = null;

        List categoryIds = new ArrayList();

        categoryIds.add(Long.valueOf(searchCategoryId));

        MBCategoryServiceUtil.getSubcategoryIds(categoryIds, themeDisplay.getScopeGroupId(), searchCategoryId);

        categoryIdsArray = StringUtil.split(StringUtil.merge(categoryIds), 0L);

        Indexer indexer = IndexerRegistryUtil.getIndexer(MBMessage.class);

        SearchContext searchContext = SearchContextFactory.getInstance(_request);

        searchContext.setAttribute("paginationType", "more");
        searchContext.setCategoryIds(categoryIdsArray);
        searchContext.setEnd(searchContainer.getEnd());
        searchContext.setIncludeAttachments(true);

        String keywords = ParamUtil.getString(_request, "keywords");

        searchContext.setKeywords(keywords);

        searchContext.setStart(searchContainer.getStart());

        Hits hits = indexer.search(searchContext);

        searchContainer.setResults(SearchResultUtil.getSearchResults(hits, _request.getLocale()));

        searchContainer.setSearch(true);
        searchContainer.setTotal(hits.getLength());
    } else if (isShowRecentPosts()) {
        searchContainer.setEmptyResultsMessage("there-are-no-recent-posts");

        long groupThreadsUserId = ParamUtil.getLong(_request, "groupThreadsUserId");

        Calendar calendar = Calendar.getInstance();

        MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings
                .getInstance(themeDisplay.getSiteGroupId());

        int offset = GetterUtil.getInteger(mbGroupServiceSettings.getRecentPostsDateOffset());

        calendar.add(Calendar.DATE, -offset);

        searchContainer.setTotal(MBThreadServiceUtil.getGroupThreadsCount(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, calendar.getTime(), WorkflowConstants.STATUS_APPROVED));
        searchContainer.setResults(MBThreadServiceUtil.getGroupThreads(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, calendar.getTime(), WorkflowConstants.STATUS_APPROVED,
                searchContainer.getStart(), searchContainer.getEnd()));
    } else if (isShowMyPosts()) {
        long groupThreadsUserId = ParamUtil.getLong(_request, "groupThreadsUserId");

        if (themeDisplay.isSignedIn()) {
            groupThreadsUserId = themeDisplay.getUserId();
        }//from  w w w.j a v a  2s.  c  om

        int status = WorkflowConstants.STATUS_ANY;

        searchContainer.setTotal(MBThreadServiceUtil.getGroupThreadsCount(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, status));
        searchContainer.setResults(MBThreadServiceUtil.getGroupThreads(themeDisplay.getScopeGroupId(),
                groupThreadsUserId, status, searchContainer.getStart(), searchContainer.getEnd()));
        searchContainer.setEmptyResultsMessage("you-do-not-have-any-posts");
    } else {
        int status = WorkflowConstants.STATUS_APPROVED;

        PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

        if (permissionChecker.isContentReviewer(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId())) {

            status = WorkflowConstants.STATUS_ANY;
        }

        searchContainer.setTotal(MBCategoryLocalServiceUtil
                .getCategoriesAndThreadsCount(themeDisplay.getScopeGroupId(), _categoryId, status));
        searchContainer.setResults(MBCategoryServiceUtil.getCategoriesAndThreads(themeDisplay.getScopeGroupId(),
                _categoryId, status, searchContainer.getStart(), searchContainer.getEnd()));
    }
}

From source file:com.liferay.message.boards.web.internal.portlet.action.ActionUtil.java

License:Open Source License

public static MBMessageDisplay getMessageDisplay(HttpServletRequest request) throws PortalException {

    long messageId = ParamUtil.getLong(request, "messageId");

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    int status = WorkflowConstants.STATUS_APPROVED;

    if (permissionChecker.isContentReviewer(themeDisplay.getUserId(), themeDisplay.getScopeGroupId())) {

        status = WorkflowConstants.STATUS_ANY;
    }/* w w  w. ja v a  2  s.c  o  m*/

    MBMessageDisplay messageDisplay = MBMessageServiceUtil.getMessageDisplay(messageId, status);

    if (messageDisplay != null) {
        MBMessage message = messageDisplay.getMessage();

        if ((message != null) && message.isInTrash()) {
            throw new NoSuchMessageException("{messageId=" + messageId + "}");
        }
    }

    return messageDisplay;
}