Example usage for com.liferay.portal.kernel.dao.orm Property notIn

List of usage examples for com.liferay.portal.kernel.dao.orm Property notIn

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.orm Property notIn.

Prototype

public Criterion notIn(DynamicQuery subselect);

Source Link

Usage

From source file:com.liferay.adaptive.media.document.library.web.internal.optimizer.DLAMImageOptimizer.java

License:Open Source License

private void _optimize(long companyId, String configurationEntryUuid, int total, AtomicInteger atomicCounter) {

    ActionableDynamicQuery actionableDynamicQuery = _dlFileEntryLocalService.getActionableDynamicQuery();

    actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override/*from ww  w .  j ava 2  s  .  c o m*/
        public void addCriteria(DynamicQuery dynamicQuery) {
            Property companyIdProperty = PropertyFactoryUtil.forName("companyId");

            dynamicQuery.add(companyIdProperty.eq(companyId));

            Property groupIdProperty = PropertyFactoryUtil.forName("groupId");
            Property repositoryIdProperty = PropertyFactoryUtil.forName("repositoryId");

            dynamicQuery.add(groupIdProperty.eqProperty(repositoryIdProperty));

            Property mimeTypeProperty = PropertyFactoryUtil.forName("mimeType");

            dynamicQuery.add(mimeTypeProperty.in(_amImageMimeTypeProvider.getSupportedMimeTypes()));

            DynamicQuery dlFileVersionDynamicQuery = _dlFileVersionLocalService.dynamicQuery();

            dlFileVersionDynamicQuery.setProjection(
                    ProjectionFactoryUtil.distinct(ProjectionFactoryUtil.property("fileEntryId")));

            dlFileVersionDynamicQuery.add(companyIdProperty.eq(companyId));

            dlFileVersionDynamicQuery.add(groupIdProperty.eqProperty(repositoryIdProperty));

            dlFileVersionDynamicQuery
                    .add(mimeTypeProperty.in(_amImageMimeTypeProvider.getSupportedMimeTypes()));

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

            dlFileVersionDynamicQuery.add(statusProperty.eq(WorkflowConstants.STATUS_IN_TRASH));

            Property fileEntryIdProperty = PropertyFactoryUtil.forName("fileEntryId");

            dynamicQuery.add(fileEntryIdProperty.notIn(dlFileVersionDynamicQuery));
        }

    });
    actionableDynamicQuery
            .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<DLFileEntry>() {

                @Override
                public void performAction(DLFileEntry dlFileEntry) throws PortalException {

                    FileEntry fileEntry = new LiferayFileEntry(dlFileEntry);

                    try {
                        _amImageProcessor.process(fileEntry.getFileVersion(), configurationEntryUuid);

                        _sendStatusMessage(atomicCounter.incrementAndGet(), total);
                    } catch (PortalException pe) {
                        _log.error("Unable to process file entry " + fileEntry.getFileEntryId(), pe);
                    }
                }

            });

    try {
        actionableDynamicQuery.performActions();
    } catch (PortalException pe) {
        _log.error(pe, pe);
    }
}