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.internal.service.MBDiscussionMBMessageLocalServiceWrapper.java

License:Open Source License

protected void validateDiscussionMaxComments(String className, long classPK) throws PortalException {

    if (PropsValues.DISCUSSION_MAX_COMMENTS <= 0) {
        return;//from   w  w  w . j a v a  2  s  .  c  o  m
    }

    int count = getDiscussionMessagesCount(className, classPK, WorkflowConstants.STATUS_APPROVED);

    if (count >= PropsValues.DISCUSSION_MAX_COMMENTS) {
        int max = PropsValues.DISCUSSION_MAX_COMMENTS - 1;

        throw new DiscussionMaxCommentsException(count + " exceeds " + max);
    }
}

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

License:Open Source License

@Override
public MBMessage updateStatus(long userId, long messageId, int status, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    MBMessage message = super.updateStatus(userId, messageId, status, serviceContext, workflowContext);

    if (status == WorkflowConstants.STATUS_APPROVED) {
        notifySubscribers(userId, (MBMessage) message.clone(),
                (String) workflowContext.get(WorkflowConstants.CONTEXT_URL), serviceContext);
    }// w ww.j av a  2s. c o m

    return message;
}

From source file:com.liferay.message.boards.internal.trash.MBCategoryTrashHandler.java

License:Open Source License

@Override
public List<ContainerModel> getContainerModels(long classPK, long parentContainerModelId, int start, int end)
        throws PortalException {

    MBCategory category = _mbCategoryLocalService.getCategory(classPK);

    List<MBCategory> categories = _mbCategoryLocalService.getCategories(category.getGroupId(),
            parentContainerModelId, WorkflowConstants.STATUS_APPROVED, start, end);

    List<ContainerModel> containerModels = new ArrayList<ContainerModel>();

    for (MBCategory curCategory : categories) {
        containerModels.add(curCategory);
    }//w  w w.j  a  va 2 s . co  m

    return containerModels;
}

From source file:com.liferay.message.boards.internal.trash.MBCategoryTrashHandler.java

License:Open Source License

@Override
public int getContainerModelsCount(long classPK, long parentContainerModelId) throws PortalException {

    MBCategory category = _mbCategoryLocalService.getCategory(classPK);

    return _mbCategoryLocalService.getCategoriesCount(category.getGroupId(), parentContainerModelId,
            WorkflowConstants.STATUS_APPROVED);
}

From source file:com.liferay.message.boards.internal.trash.MBThreadTrashHandler.java

License:Open Source License

@Override
public List<ContainerModel> getContainerModels(long classPK, long parentContainerModelId, int start, int end)
        throws PortalException {

    List<ContainerModel> containerModels = new ArrayList<>();

    MBThread thread = _mbThreadLocalService.getThread(classPK);

    List<MBCategory> categories = _mbCategoryLocalService.getCategories(thread.getGroupId(),
            parentContainerModelId, WorkflowConstants.STATUS_APPROVED, start, end);

    for (MBCategory category : categories) {
        containerModels.add(category);//  w  w  w.  ja v  a  2  s  . co m
    }

    return containerModels;
}

From source file:com.liferay.message.boards.internal.trash.MBThreadTrashHandler.java

License:Open Source License

@Override
public int getContainerModelsCount(long classPK, long parentContainerModelId) throws PortalException {

    MBThread thread = _mbThreadLocalService.getThread(classPK);

    return _mbCategoryLocalService.getCategoriesCount(thread.getGroupId(), parentContainerModelId,
            WorkflowConstants.STATUS_APPROVED);
}

From source file:com.liferay.message.boards.internal.util.MBSubscriptionHelper.java

License:Open Source License

public List<MBCategory> addSubscribedRootCategory(long groupId, long userId, List<MBCategory> categories)
        throws PortalException {

    Group group = _groupLocalService.getGroup(groupId);

    Subscription subscription = _subscriptionLocalService.fetchSubscription(group.getCompanyId(), userId,
            MBCategory.class.getName(), groupId);

    if (subscription != null) {
        int threadCount = _mbThreadLocalService.getCategoryThreadsCount(groupId,
                MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED);
        int messageCount = _mbMessageLocalService.getCategoryMessagesCount(groupId,
                MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED);

        MBCategory category = new MBCategoryImpl();

        category.setGroupId(group.getGroupId());
        category.setCompanyId(group.getCompanyId());
        category.setName(group.getDescriptiveName());
        category.setDescription(HtmlUtil.extractText(group.getDescription()));
        category.setThreadCount(threadCount);
        category.setMessageCount(messageCount);

        List<MBCategory> list = new ArrayList<>(categories);

        list.add(category);/*  ww w.  j  ava2 s.c  om*/

        return Collections.unmodifiableList(list);
    }

    return categories;
}

From source file:com.liferay.message.boards.internal.verify.MessageBoardsServiceVerifyProcess.java

License:Open Source License

protected void verifyStatisticsForCategories() throws Exception {
    try (LoggingTimer loggingTimer = new LoggingTimer()) {
        if (_log.isDebugEnabled()) {
            _log.debug("Processing categories for statistics accuracy");
        }//w  w  w .  j a v  a  2 s.  c om

        StringBundler sb = new StringBundler(6);

        sb.append("update MBCategory set threadCount = (select count(*) ");
        sb.append("from MBThread where (MBCategory.groupId = ");
        sb.append("MBThread.groupId) and (MBCategory.categoryId = ");
        sb.append("MBThread.categoryId) and (MBThread.status = ");
        sb.append(WorkflowConstants.STATUS_APPROVED);
        sb.append("))");

        runSQL(sb.toString());

        sb.setIndex(0);

        sb.append("update MBCategory set messageCount = (select count(*) ");
        sb.append("from MBMessage where (MBCategory.groupId = ");
        sb.append("MBMessage.groupId) and (MBCategory.categoryId = ");
        sb.append("MBMessage.categoryId) and (MBMessage.status = ");
        sb.append(WorkflowConstants.STATUS_APPROVED);
        sb.append("))");

        runSQL(sb.toString());

        if (_log.isDebugEnabled()) {
            _log.debug("Statistics verified for categories");
        }
    }
}

From source file:com.liferay.message.boards.internal.verify.MessageBoardsServiceVerifyProcess.java

License:Open Source License

protected void verifyStatisticsForThreads() throws Exception {
    try (LoggingTimer loggingTimer = new LoggingTimer()) {
        if (_log.isDebugEnabled()) {
            _log.debug("Processing threads for statistics accuracy");
        }//w  w w  .  j a  va 2  s.c  o  m

        StringBundler sb = new StringBundler(5);

        sb.append("update MBThread set messageCount = (select count(*) ");
        sb.append("from MBMessage where (MBThread.threadId = ");
        sb.append("MBMessage.threadId) and (MBMessage.status = ");
        sb.append(WorkflowConstants.STATUS_APPROVED);
        sb.append("))");

        runSQL(sb.toString());

        if (_log.isDebugEnabled()) {
            _log.debug("Statistics verified for threads");
        }
    }
}

From source file:com.liferay.message.boards.search.test.MBMessageSearchTest.java

License:Open Source License

@Override
protected Hits searchGroupEntries(long groupId, long creatorUserId) throws Exception {

    return MBThreadServiceUtil.search(groupId, creatorUserId, WorkflowConstants.STATUS_APPROVED,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS);
}