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

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

Introduction

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

Prototype

int STATUS_IN_TRASH

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

Click Source Link

Usage

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

License:Open Source License

@Override
public void restoreDiscussionFromTrash(String className, long classPK) {
    List<MBMessage> messages = _mbMessageLocalService.getMessages(className, classPK,
            WorkflowConstants.STATUS_IN_TRASH);

    for (MBMessage message : messages) {
        message.setStatus(WorkflowConstants.STATUS_APPROVED);

        _mbMessageLocalService.updateMBMessage(message);
    }/*from   www  . j  a  v  a  2 s.c  o m*/
}

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

License:Open Source License

@Override
public ActionableDynamicQuery getCommentExportActionableDynamicQuery(
        final PortletDataContext portletDataContext) {

    final ExportActionableDynamicQuery actionableDynamicQuery = MBMessageLocalServiceUtil
            .getExportActionableDynamicQuery(portletDataContext);

    actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override//w w w.j ava  2s  .com
        public void addCriteria(DynamicQuery dynamicQuery) {
            Criterion modifiedDateCriterion = portletDataContext.getDateRangeCriteria("modifiedDate");
            Criterion statusDateCriterion = portletDataContext.getDateRangeCriteria("statusDate");

            if ((modifiedDateCriterion != null) && (statusDateCriterion != null)) {

                Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

                disjunction.add(modifiedDateCriterion);
                disjunction.add(statusDateCriterion);

                dynamicQuery.add(disjunction);
            }

            Property classNameIdProperty = PropertyFactoryUtil.forName("classNameId");

            dynamicQuery.add(classNameIdProperty.gt(0L));

            Property parentMessageIdProperty = PropertyFactoryUtil.forName("parentMessageId");

            dynamicQuery.add(parentMessageIdProperty.gt(MBMessageConstants.DEFAULT_PARENT_MESSAGE_ID));

            Property statusProperty = PropertyFactoryUtil.forName("status");

            if (portletDataContext.isInitialPublication()) {
                dynamicQuery.add(statusProperty.ne(WorkflowConstants.STATUS_IN_TRASH));
            } else {
                StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil
                        .getStagedModelDataHandler(MBMessage.class.getName());

                dynamicQuery.add(statusProperty.in(stagedModelDataHandler.getExportableStatuses()));
            }
        }

    });

    return actionableDynamicQuery;
}

From source file:com.liferay.message.boards.internal.search.MBMessageIndexer.java

License:Open Source License

protected void reindexMessages(long companyId, long groupId, final long categoryId) throws PortalException {

    final IndexableActionableDynamicQuery indexableActionableDynamicQuery = mbMessageLocalService
            .getIndexableActionableDynamicQuery();

    indexableActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override//w  ww .  j av a 2s.c  o m
        public void addCriteria(DynamicQuery dynamicQuery) {
            Property categoryIdProperty = PropertyFactoryUtil.forName("categoryId");

            dynamicQuery.add(categoryIdProperty.eq(categoryId));

            Property statusProperty = PropertyFactoryUtil.forName("status");

            Integer[] statuses = { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_IN_TRASH };

            dynamicQuery.add(statusProperty.in(statuses));
        }

    });
    indexableActionableDynamicQuery.setCompanyId(companyId);
    indexableActionableDynamicQuery.setGroupId(groupId);
    indexableActionableDynamicQuery
            .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<MBMessage>() {

                @Override
                public void performAction(MBMessage message) {
                    if (message.isDiscussion() && message.isRoot()) {
                        return;
                    }

                    try {
                        Document document = getDocument(message);

                        indexableActionableDynamicQuery.addDocuments(document);
                    } catch (PortalException pe) {
                        if (_log.isWarnEnabled()) {
                            _log.warn("Unable to index message boards message " + message.getMessageId(), pe);
                        }
                    }
                }

            });
    indexableActionableDynamicQuery.setSearchEngineId(getSearchEngineId());

    indexableActionableDynamicQuery.performActions();
}

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

License:Open Source License

@Override
public int getTrashContainedModelsCount(long classPK) throws PortalException {

    MBCategory category = _mbCategoryLocalService.getCategory(classPK);

    return _mbThreadLocalService.getThreadsCount(category.getGroupId(), classPK,
            WorkflowConstants.STATUS_IN_TRASH);
}

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

License:Open Source License

@Override
public List<TrashRenderer> getTrashContainedModelTrashRenderers(long classPK, int start, int end)
        throws PortalException {

    List<TrashRenderer> trashRenderers = new ArrayList<>();

    MBCategory category = _mbCategoryLocalService.getCategory(classPK);

    List<MBThread> threads = _mbThreadLocalService.getThreads(category.getGroupId(), classPK,
            WorkflowConstants.STATUS_IN_TRASH, start, end);

    for (MBThread thread : threads) {
        TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(MBThread.class.getName());

        TrashRenderer trashRenderer = trashHandler.getTrashRenderer(thread.getPrimaryKey());

        trashRenderers.add(trashRenderer);
    }/*ww  w.ja  v a 2s . c o m*/

    return trashRenderers;
}

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

License:Open Source License

@Override
public int getTrashContainerModelsCount(long classPK) throws PortalException {

    MBCategory category = _mbCategoryLocalService.getCategory(classPK);

    return _mbCategoryLocalService.getCategoriesCount(category.getGroupId(), classPK,
            WorkflowConstants.STATUS_IN_TRASH);
}

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

License:Open Source License

@Override
public List<TrashRenderer> getTrashContainerModelTrashRenderers(long classPK, int start, int end)
        throws PortalException {

    List<TrashRenderer> trashRenderers = new ArrayList<>();

    MBCategory category = _mbCategoryLocalService.getCategory(classPK);

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

    for (MBCategory curCategory : categories) {
        TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(MBCategory.class.getName());

        TrashRenderer trashRenderer = trashHandler.getTrashRenderer(curCategory.getPrimaryKey());

        trashRenderers.add(trashRenderer);
    }/*ww  w  . j  a v  a2s  .co m*/

    return trashRenderers;
}

From source file:com.liferay.message.boards.service.impl.MBStatsUserLocalServiceImpl.java

License:Open Source License

@Override
public Date getLastPostDateByUserId(long groupId, long userId) {
    DynamicQuery dynamicQuery = mbThreadLocalService.dynamicQuery();

    Projection projection = ProjectionFactoryUtil.max("lastPostDate");

    dynamicQuery.setProjection(projection);

    Property userIdProperty = PropertyFactoryUtil.forName("userId");

    dynamicQuery.add(userIdProperty.eq(userId));

    Property threadIdProperty = PropertyFactoryUtil.forName("threadId");

    Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

    QueryDefinition<MBThread> queryDefinition = new QueryDefinition<>(WorkflowConstants.STATUS_IN_TRASH);

    List<MBThread> threads = mbThreadLocalService.getGroupThreads(groupId, queryDefinition);

    for (MBThread thread : threads) {
        disjunction.add(threadIdProperty.ne(thread.getThreadId()));
    }//  w w w. j a v a2  s  .  co  m

    dynamicQuery.add(disjunction);

    List<Date> results = mbThreadLocalService.dynamicQuery(dynamicQuery);

    return results.get(0);
}

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

License:Open Source License

@Test
public void testDeleteAttachmentsWhenUpdatingMessageAndTrashEnabled() throws Exception {

    MBMessage message = addMessage(null, true);

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(),
            TestPropsValues.getUserId());

    MBMessageLocalServiceUtil.updateMessage(TestPropsValues.getUserId(), message.getMessageId(),
            RandomTestUtil.randomString(), RandomTestUtil.randomString(),
            Collections.<ObjectValuePair<String, InputStream>>emptyList(), Collections.<String>emptyList(), 0,
            false, serviceContext);//from   www . jav  a  2 s.co  m

    List<FileEntry> fileEntries = PortletFileRepositoryUtil.getPortletFileEntries(message.getGroupId(),
            message.getAttachmentsFolderId());

    Assert.assertEquals(fileEntries.toString(), 1, fileEntries.size());

    FileEntry fileEntry = fileEntries.get(0);

    WorkflowCapability workflowCapability = fileEntry.getRepositoryCapability(WorkflowCapability.class);

    Assert.assertEquals(WorkflowConstants.STATUS_IN_TRASH, workflowCapability.getStatus(fileEntry));
}

From source file:com.liferay.message.boards.web.exportimport.data.handler.MBPortletDataHandler.java

License:Open Source License

protected ActionableDynamicQuery getMessageActionableDynamicQuery(final PortletDataContext portletDataContext) {

    final ExportActionableDynamicQuery actionableDynamicQuery = _mbMessageLocalService
            .getExportActionableDynamicQuery(portletDataContext);

    actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override/* w  w w .  j a v  a 2  s  .  c om*/
        public void addCriteria(DynamicQuery dynamicQuery) {
            Criterion modifiedDateCriterion = portletDataContext.getDateRangeCriteria("modifiedDate");
            Criterion statusDateCriterion = portletDataContext.getDateRangeCriteria("statusDate");

            if ((modifiedDateCriterion != null) && (statusDateCriterion != null)) {

                Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

                disjunction.add(modifiedDateCriterion);
                disjunction.add(statusDateCriterion);

                dynamicQuery.add(disjunction);
            }

            Property classNameIdProperty = PropertyFactoryUtil.forName("classNameId");

            dynamicQuery.add(classNameIdProperty.eq(0L));

            Property statusProperty = PropertyFactoryUtil.forName("status");

            if (portletDataContext.isInitialPublication()) {
                dynamicQuery.add(statusProperty.ne(WorkflowConstants.STATUS_IN_TRASH));
            } else {
                StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil
                        .getStagedModelDataHandler(MBMessage.class.getName());

                dynamicQuery.add(statusProperty.in(stagedModelDataHandler.getExportableStatuses()));
            }
        }

    });

    return actionableDynamicQuery;
}