Example usage for com.liferay.portal.kernel.dao.orm ActionableDynamicQuery setPerformActionMethod

List of usage examples for com.liferay.portal.kernel.dao.orm ActionableDynamicQuery setPerformActionMethod

Introduction

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

Prototype

public void setPerformActionMethod(PerformActionMethod<?> performActionMethod);

Source Link

Usage

From source file:blade.servicebuilder.service.persistence.test.FooPersistenceTest.java

License:Open Source License

@Test
public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery = FooLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Foo>() {
        @Override/*from  w w w .j a  v a  2  s  .  c om*/
        public void performAction(Foo foo) {
            Assert.assertNotNull(foo);

            count.increment();
        }
    });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
}

From source file:ch.inofix.referencemanager.service.persistence.test.ReferencePersistenceTest.java

License:Open Source License

@Test
public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery = ReferenceLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Reference>() {
        @Override/* w  w  w  .  ja  v a 2  s  .  c  o  m*/
        public void performAction(Reference reference) {
            Assert.assertNotNull(reference);

            count.increment();
        }
    });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
}

From source file:com.bemis.portal.customer.service.persistence.test.CustomerLocationPersistenceTest.java

License:Open Source License

@Test
public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery = CustomerLocationLocalServiceUtil
            .getActionableDynamicQuery();

    actionableDynamicQuery
            .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<CustomerLocation>() {
                @Override// ww  w  .  j  a v a2s .  co m
                public void performAction(CustomerLocation customerLocation) {
                    Assert.assertNotNull(customerLocation);

                    count.increment();
                }
            });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
}

From source file:com.bemis.portal.inventory.service.persistence.test.InventoryPersistenceTest.java

License:Open Source License

@Test
public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery = InventoryLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Inventory>() {
        @Override//from  w w  w  .j  av  a  2  s. c o  m
        public void performAction(Inventory inventory) {
            Assert.assertNotNull(inventory);

            count.increment();
        }
    });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
}

From source file:com.bemis.portal.order.service.persistence.test.OrderPersistenceTest.java

License:Open Source License

@Test
public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery = OrderLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Order>() {
        @Override//from  ww  w  .ja  v a  2s.  co m
        public void performAction(Order order) {
            Assert.assertNotNull(order);

            count.increment();
        }
    });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
}

From source file:com.bemis.portal.order.service.persistence.test.OrderRequestPersistenceTest.java

License:Open Source License

@Test
public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery = OrderRequestLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery
            .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<OrderRequest>() {
                @Override//  w  ww . jav  a2s .c  o m
                public void performAction(OrderRequest orderRequest) {
                    Assert.assertNotNull(orderRequest);

                    count.increment();
                }
            });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
}

From source file:com.bemis.portal.shipment.service.persistence.test.ShipmentPersistenceTest.java

License:Open Source License

@Test
public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery = ShipmentLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Shipment>() {
        @Override//from ww w  . ja  v a  2  s .co m
        public void performAction(Shipment shipment) {
            Assert.assertNotNull(shipment);

            count.increment();
        }
    });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
}

From source file:com.liferay.adaptive.media.blogs.web.internal.optimizer.BlogsAdaptiveMediaImageOptimizer.java

License:Open Source License

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

    ActionableDynamicQuery actionableDynamicQuery = _dlFileEntryLocalService.getActionableDynamicQuery();

    long classNameId = _classNameLocalService.getClassNameId(BlogsEntry.class.getName());

    actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override/*from  w  w  w  .  j  a  v a  2s  .  co  m*/
        public void addCriteria(DynamicQuery dynamicQuery) {
            Property companyIdProperty = PropertyFactoryUtil.forName("companyId");

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

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

            dynamicQuery.add(classNameIdProperty.eq(classNameId));

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

            dynamicQuery.add(mimeTypeProperty.in(AdaptiveMediaImageConstants.getSupportedMimeTypes()));
        }

    });

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

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

                    FileEntry fileEntry = new LiferayFileEntry(dlFileEntry);

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

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

            });

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

From source file:com.liferay.adaptive.media.blogs.web.internal.optimizer.BlogsAMImageOptimizer.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 w w w  .j a  va  2s  .  c  om
        public void addCriteria(DynamicQuery dynamicQuery) {
            Property companyIdProperty = PropertyFactoryUtil.forName("companyId");

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

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

            long classNameId = _classNameLocalService.getClassNameId(BlogsEntry.class.getName());

            dynamicQuery.add(classNameIdProperty.eq(classNameId));

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

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

    });
    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);
    }
}

From source file:com.liferay.adaptive.media.document.library.repository.internal.optimizer.BlogsAdaptiveMediaImageOptimizer.java

License:Open Source License

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

    ActionableDynamicQuery actionableDynamicQuery = _dlFileEntryLocalService.getActionableDynamicQuery();

    long classNameId = _classNameLocalService.getClassNameId(BlogsEntry.class.getName());

    actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

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

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

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

            dynamicQuery.add(classNameIdProperty.eq(classNameId));

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

            dynamicQuery.add(mimeTypeProperty.in(AdaptiveMediaImageConstants.getSupportedMimeTypes()));
        }

    });

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

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

                    FileEntry fileEntry = new LiferayFileEntry(dlFileEntry);

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

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

            });

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