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.document.library.service.test.DLFileEntryFinderTest.java

License:Open Source License

@Test
public void testFindByG_U_F_M_StatusInTrash_EmptyRepositories() throws Exception {

    QueryDefinition<DLFileEntry> queryDefinition = new QueryDefinition<>();

    queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true);

    List<DLFileEntry> dlFileEntries = doFindBy_G_U_R_F_M_EmptyRepositories(0, ContentTypes.TEXT_PLAIN,
            queryDefinition);//  w w  w . ja  v  a2  s  . c  om

    Assert.assertEquals(dlFileEntries.toString(), 2, dlFileEntries.size());
}

From source file:com.liferay.document.library.service.test.DLFileEntryFinderTest.java

License:Open Source License

@Test
public void testFindByG_U_F_M_StatusInTrash_NewRepository() throws Exception {

    QueryDefinition<DLFileEntry> queryDefinition = new QueryDefinition<>();

    queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true);

    List<DLFileEntry> dlFileEntries = doFindBy_G_U_R_F_M_NewRepository(0, ContentTypes.TEXT_PLAIN,
            queryDefinition);//from  ww w .  ja v  a2 s  .  c  o  m

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

    DLFileEntry dlFileEntry = dlFileEntries.get(0);

    Assert.assertEquals("FE1.txt-NewRepository", dlFileEntry.getTitle());
}

From source file:com.liferay.document.library.service.test.DLFolderFinderTest.java

License:Open Source License

@Test
public void testCountF_FE_FS_ByG_F_M_M() throws Exception {
    QueryDefinition<?> queryDefinition = new QueryDefinition<>();

    queryDefinition.setStatus(WorkflowConstants.STATUS_ANY);

    Assert.assertEquals(6, DLFolderFinderUtil.filterCountF_FE_FS_ByG_F_M_M(_group.getGroupId(),
            _folder.getFolderId(), null, false, queryDefinition));
    Assert.assertEquals(5, DLFolderFinderUtil.filterCountF_FE_FS_ByG_F_M_M(_group.getGroupId(),
            _folder.getFolderId(), new String[] { ContentTypes.TEXT_PLAIN }, false, queryDefinition));
    Assert.assertEquals(1, DLFolderFinderUtil.filterCountF_FE_FS_ByG_F_M_M(_group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, null, false, queryDefinition));
    Assert.assertEquals(2, DLFolderFinderUtil.filterCountF_FE_FS_ByG_F_M_M(_group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, null, true, queryDefinition));

    queryDefinition.setStatus(WorkflowConstants.STATUS_APPROVED);

    Assert.assertEquals(4, DLFolderFinderUtil.filterCountF_FE_FS_ByG_F_M_M(_group.getGroupId(),
            _folder.getFolderId(), null, false, queryDefinition));
    Assert.assertEquals(2, DLFolderFinderUtil.filterCountF_FE_FS_ByG_F_M_M(_group.getGroupId(),
            _folder.getFolderId(), new String[] { ContentTypes.TEXT_HTML }, false, queryDefinition));

    queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH);

    Assert.assertEquals(2, DLFolderFinderUtil.filterCountF_FE_FS_ByG_F_M_M(_group.getGroupId(),
            _folder.getFolderId(), null, false, queryDefinition));

    queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true);

    Assert.assertEquals(4, DLFolderFinderUtil.filterCountF_FE_FS_ByG_F_M_M(_group.getGroupId(),
            _folder.getFolderId(), null, false, queryDefinition));
    Assert.assertEquals(3, DLFolderFinderUtil.filterCountF_FE_FS_ByG_F_M_M(_group.getGroupId(),
            _folder.getFolderId(), new String[] { ContentTypes.TEXT_PLAIN }, false, queryDefinition));
}

From source file:com.liferay.document.library.service.test.DLFolderFinderTest.java

License:Open Source License

@Test
public void testCountFE_ByG_F() throws Exception {
    QueryDefinition<?> queryDefinition = new QueryDefinition<>();

    queryDefinition.setStatus(WorkflowConstants.STATUS_ANY);

    Assert.assertEquals(3,//  ww w . j  ava 2s.c o  m
            DLFolderFinderUtil.countFE_ByG_F(_group.getGroupId(), _folder.getFolderId(), queryDefinition));

    queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH);

    Assert.assertEquals(1,
            DLFolderFinderUtil.countFE_ByG_F(_group.getGroupId(), _folder.getFolderId(), queryDefinition));

    queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true);

    Assert.assertEquals(2,
            DLFolderFinderUtil.countFE_ByG_F(_group.getGroupId(), _folder.getFolderId(), queryDefinition));
}

From source file:com.liferay.document.library.service.test.DLFolderFinderTest.java

License:Open Source License

@Test
public void testCountFE_FS_ByG_F() throws Exception {
    QueryDefinition<?> queryDefinition = new QueryDefinition<>();

    queryDefinition.setStatus(WorkflowConstants.STATUS_ANY);

    Assert.assertEquals(4, DLFolderFinderUtil.filterCountFE_FS_ByG_F(_group.getGroupId(), _folder.getFolderId(),
            queryDefinition));//from   w ww .  ja va  2 s.  c  o  m

    queryDefinition.setStatus(WorkflowConstants.STATUS_APPROVED);

    Assert.assertEquals(3, DLFolderFinderUtil.filterCountFE_FS_ByG_F(_group.getGroupId(), _folder.getFolderId(),
            queryDefinition));

    queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH);

    Assert.assertEquals(1, DLFolderFinderUtil.filterCountFE_FS_ByG_F(_group.getGroupId(), _folder.getFolderId(),
            queryDefinition));

    queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true);

    Assert.assertEquals(3, DLFolderFinderUtil.filterCountFE_FS_ByG_F(_group.getGroupId(), _folder.getFolderId(),
            queryDefinition));
}

From source file:com.liferay.document.library.service.test.DLFolderFinderTest.java

License:Open Source License

@Test
public void testCountFE_FS_ByG_F_M() throws Exception {
    QueryDefinition<?> queryDefinition = new QueryDefinition<>();

    queryDefinition.setStatus(WorkflowConstants.STATUS_ANY);

    Assert.assertEquals(4, DLFolderFinderUtil.filterCountFE_FS_ByG_F_M(_group.getGroupId(),
            _folder.getFolderId(), null, queryDefinition));
    Assert.assertEquals(3, DLFolderFinderUtil.filterCountFE_FS_ByG_F_M(_group.getGroupId(),
            _folder.getFolderId(), new String[] { ContentTypes.TEXT_PLAIN }, queryDefinition));

    queryDefinition.setStatus(WorkflowConstants.STATUS_APPROVED);

    Assert.assertEquals(3, DLFolderFinderUtil.filterCountFE_FS_ByG_F_M(_group.getGroupId(),
            _folder.getFolderId(), null, queryDefinition));
    Assert.assertEquals(1, DLFolderFinderUtil.filterCountFE_FS_ByG_F_M(_group.getGroupId(),
            _folder.getFolderId(), new String[] { ContentTypes.TEXT_HTML }, queryDefinition));

    queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH);

    Assert.assertEquals(1, DLFolderFinderUtil.filterCountFE_FS_ByG_F_M(_group.getGroupId(),
            _folder.getFolderId(), null, queryDefinition));
    Assert.assertEquals(1, DLFolderFinderUtil.filterCountFE_FS_ByG_F_M(_group.getGroupId(),
            _folder.getFolderId(), new String[] { ContentTypes.TEXT_PLAIN }, queryDefinition));

    queryDefinition.setStatus(WorkflowConstants.STATUS_IN_TRASH, true);

    Assert.assertEquals(3, DLFolderFinderUtil.filterCountFE_FS_ByG_F_M(_group.getGroupId(),
            _folder.getFolderId(), null, queryDefinition));
    Assert.assertEquals(2, DLFolderFinderUtil.filterCountFE_FS_ByG_F_M(_group.getGroupId(),
            _folder.getFolderId(), new String[] { ContentTypes.TEXT_PLAIN }, queryDefinition));
}

From source file:com.liferay.exportimport.test.util.internal.exportimport.staged.model.repository.DummyFolderStagedModelRepository.java

License:Open Source License

@Override
public ExportActionableDynamicQuery getExportActionableDynamicQuery(PortletDataContext portletDataContext) {

    final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {

        @Override/*ww  w.ja  v  a2 s  .co m*/
        public long performCount() throws PortalException {
            ManifestSummary manifestSummary = portletDataContext.getManifestSummary();

            StagedModelType stagedModelType = getStagedModelType();

            long modelAdditionCount = _dummyFolders.size();

            manifestSummary.addModelAdditionCount(stagedModelType, modelAdditionCount);

            manifestSummary.addModelDeletionCount(stagedModelType, 0);

            return modelAdditionCount;
        }

        @Override
        protected Projection getCountProjection() {
            return ProjectionFactoryUtil.countDistinct("resourcePrimKey");
        }

    };

    exportActionableDynamicQuery.setBaseLocalService(new DummyFolderBaseLocalServiceImpl());

    Class<?> clazz = getClass();

    exportActionableDynamicQuery.setClassLoader(clazz.getClassLoader());

    exportActionableDynamicQuery.setModelClass(DummyFolder.class);

    exportActionableDynamicQuery.setPrimaryKeyPropertyName("id");

    exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override
        public void addCriteria(DynamicQuery dynamicQuery) {
            Criterion modifiedDateCriterion = portletDataContext.getDateRangeCriteria("modifiedDate");

            if (modifiedDateCriterion != null) {
                Conjunction conjunction = RestrictionsFactoryUtil.conjunction();

                conjunction.add(modifiedDateCriterion);

                Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

                disjunction.add(RestrictionsFactoryUtil.gtProperty("modifiedDate", "lastPublishDate"));

                Property lastPublishDateProperty = PropertyFactoryUtil.forName("lastPublishDate");

                disjunction.add(lastPublishDateProperty.isNull());

                conjunction.add(disjunction);

                modifiedDateCriterion = conjunction;
            }

            Criterion statusDateCriterion = portletDataContext.getDateRangeCriteria("statusDate");

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

                Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

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

                dynamicQuery.add(disjunction);
            }

            StagedModelType stagedModelType = exportActionableDynamicQuery.getStagedModelType();

            long referrerClassNameId = stagedModelType.getReferrerClassNameId();

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

            if ((referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ALL)
                    && (referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ANY)) {

                dynamicQuery.add(classNameIdProperty.eq(stagedModelType.getReferrerClassNameId()));
            } else if (referrerClassNameId == StagedModelType.REFERRER_CLASS_NAME_ID_ANY) {

                dynamicQuery.add(classNameIdProperty.isNotNull());
            }

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

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

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

    });

    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());

    exportActionableDynamicQuery.setGroupId(portletDataContext.getScopeGroupId());

    exportActionableDynamicQuery
            .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<DummyFolder>() {

                @Override
                public void performAction(DummyFolder dummyFolder) throws PortalException {

                    StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, dummyFolder);
                }

            });

    exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
            portal.getClassNameId(DummyFolder.class.getName()), StagedModelType.REFERRER_CLASS_NAME_ID_ALL));

    return exportActionableDynamicQuery;
}

From source file:com.liferay.exportimport.test.util.internal.exportimport.staged.model.repository.DummyReferenceStagedModelRepository.java

License:Open Source License

@Override
public ExportActionableDynamicQuery getExportActionableDynamicQuery(PortletDataContext portletDataContext) {

    final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {

        @Override//from   w w w  .j  a  va2  s . c om
        public long performCount() throws PortalException {
            ManifestSummary manifestSummary = portletDataContext.getManifestSummary();

            StagedModelType stagedModelType = getStagedModelType();

            long modelAdditionCount = _dummyReferences.size();

            manifestSummary.addModelAdditionCount(stagedModelType, modelAdditionCount);

            manifestSummary.addModelDeletionCount(stagedModelType, 0);

            return modelAdditionCount;
        }

        @Override
        protected Projection getCountProjection() {
            return ProjectionFactoryUtil.countDistinct("resourcePrimKey");
        }

    };

    exportActionableDynamicQuery.setBaseLocalService(new DummyReferenceBaseLocalServiceImpl());

    Class<?> clazz = getClass();

    exportActionableDynamicQuery.setClassLoader(clazz.getClassLoader());

    exportActionableDynamicQuery.setModelClass(DummyReference.class);

    exportActionableDynamicQuery.setPrimaryKeyPropertyName("id");

    exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override
        public void addCriteria(DynamicQuery dynamicQuery) {
            Criterion modifiedDateCriterion = portletDataContext.getDateRangeCriteria("modifiedDate");

            if (modifiedDateCriterion != null) {
                Conjunction conjunction = RestrictionsFactoryUtil.conjunction();

                conjunction.add(modifiedDateCriterion);

                Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

                disjunction.add(RestrictionsFactoryUtil.gtProperty("modifiedDate", "lastPublishDate"));

                Property lastPublishDateProperty = PropertyFactoryUtil.forName("lastPublishDate");

                disjunction.add(lastPublishDateProperty.isNull());

                conjunction.add(disjunction);

                modifiedDateCriterion = conjunction;
            }

            Criterion statusDateCriterion = portletDataContext.getDateRangeCriteria("statusDate");

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

                Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

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

                dynamicQuery.add(disjunction);
            }

            StagedModelType stagedModelType = exportActionableDynamicQuery.getStagedModelType();

            long referrerClassNameId = stagedModelType.getReferrerClassNameId();

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

            if ((referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ALL)
                    && (referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ANY)) {

                dynamicQuery.add(classNameIdProperty.eq(stagedModelType.getReferrerClassNameId()));
            } else if (referrerClassNameId == StagedModelType.REFERRER_CLASS_NAME_ID_ANY) {

                dynamicQuery.add(classNameIdProperty.isNotNull());
            }

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

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

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

    });

    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());

    exportActionableDynamicQuery.setGroupId(portletDataContext.getScopeGroupId());

    exportActionableDynamicQuery
            .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<DummyReference>() {

                @Override
                public void performAction(DummyReference dummyReference) throws PortalException {

                    StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, dummyReference);
                }

            });

    exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
            portal.getClassNameId(DummyReference.class.getName()), StagedModelType.REFERRER_CLASS_NAME_ID_ALL));

    return exportActionableDynamicQuery;
}

From source file:com.liferay.exportimport.test.util.internal.exportimport.staged.model.repository.DummyStagedModelRepository.java

License:Open Source License

@Override
public ExportActionableDynamicQuery getExportActionableDynamicQuery(PortletDataContext portletDataContext) {

    final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {

        @Override//from ww  w.  ja  v a2s  .c o  m
        public long performCount() throws PortalException {
            ManifestSummary manifestSummary = portletDataContext.getManifestSummary();

            StagedModelType stagedModelType = getStagedModelType();

            long modelAdditionCount = _dummies.size();

            manifestSummary.addModelAdditionCount(stagedModelType, modelAdditionCount);

            manifestSummary.addModelDeletionCount(stagedModelType, 0);

            return modelAdditionCount;
        }

        @Override
        protected Projection getCountProjection() {
            return ProjectionFactoryUtil.countDistinct("resourcePrimKey");
        }

    };

    exportActionableDynamicQuery.setBaseLocalService(new DummyBaseLocalServiceImpl());

    Class<?> clazz = getClass();

    exportActionableDynamicQuery.setClassLoader(clazz.getClassLoader());

    exportActionableDynamicQuery.setModelClass(Dummy.class);

    exportActionableDynamicQuery.setPrimaryKeyPropertyName("id");

    exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override
        public void addCriteria(DynamicQuery dynamicQuery) {
            Criterion modifiedDateCriterion = portletDataContext.getDateRangeCriteria("modifiedDate");

            if (modifiedDateCriterion != null) {
                Conjunction conjunction = RestrictionsFactoryUtil.conjunction();

                conjunction.add(modifiedDateCriterion);

                Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

                disjunction.add(RestrictionsFactoryUtil.gtProperty("modifiedDate", "lastPublishDate"));

                Property lastPublishDateProperty = PropertyFactoryUtil.forName("lastPublishDate");

                disjunction.add(lastPublishDateProperty.isNull());

                conjunction.add(disjunction);

                modifiedDateCriterion = conjunction;
            }

            Criterion statusDateCriterion = portletDataContext.getDateRangeCriteria("statusDate");

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

                Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

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

                dynamicQuery.add(disjunction);
            }

            StagedModelType stagedModelType = exportActionableDynamicQuery.getStagedModelType();

            long referrerClassNameId = stagedModelType.getReferrerClassNameId();

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

            if ((referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ALL)
                    && (referrerClassNameId != StagedModelType.REFERRER_CLASS_NAME_ID_ANY)) {

                dynamicQuery.add(classNameIdProperty.eq(stagedModelType.getReferrerClassNameId()));
            } else if (referrerClassNameId == StagedModelType.REFERRER_CLASS_NAME_ID_ANY) {

                dynamicQuery.add(classNameIdProperty.isNotNull());
            }

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

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

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

    });

    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());

    exportActionableDynamicQuery.setGroupId(portletDataContext.getScopeGroupId());

    exportActionableDynamicQuery
            .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Dummy>() {

                @Override
                public void performAction(Dummy dummy) throws PortalException {
                    StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, dummy);
                }

            });

    exportActionableDynamicQuery.setStagedModelType(new StagedModelType(
            portal.getClassNameId(Dummy.class.getName()), StagedModelType.REFERRER_CLASS_NAME_ID_ALL));

    return exportActionableDynamicQuery;
}

From source file:com.liferay.journal.internal.trash.JournalBaseTrashHandler.java

License:Open Source License

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

    JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK);

    return JournalArticleLocalServiceUtil.searchCount(folder.getGroupId(), classPK,
            WorkflowConstants.STATUS_IN_TRASH);
}