Search in sources :

Example 26 with Foo

use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.

the class FooLocalServiceBaseImpl method getExportActionableDynamicQuery.

@Override
public ExportActionableDynamicQuery getExportActionableDynamicQuery(final PortletDataContext portletDataContext) {
    final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {

        @Override
        public long performCount() throws PortalException {
            ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
            StagedModelType stagedModelType = getStagedModelType();
            long modelAdditionCount = super.performCount();
            manifestSummary.addModelAdditionCount(stagedModelType, modelAdditionCount);
            long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext, stagedModelType);
            manifestSummary.addModelDeletionCount(stagedModelType, modelDeletionCount);
            return modelAdditionCount;
        }
    };
    initActionableDynamicQuery(exportActionableDynamicQuery);
    exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override
        public void addCriteria(DynamicQuery dynamicQuery) {
            portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
        }
    });
    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
    exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Foo>() {

        @Override
        public void performAction(Foo foo) throws PortalException {
            StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, foo);
        }
    });
    exportActionableDynamicQuery.setStagedModelType(new StagedModelType(PortalUtil.getClassNameId(Foo.class.getName())));
    return exportActionableDynamicQuery;
}
Also used : ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) DefaultActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery) ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) IndexableActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) ManifestSummary(com.liferay.exportimport.kernel.lar.ManifestSummary) Foo(com.liferay.blade.samples.servicebuilder.model.Foo) StagedModelType(com.liferay.exportimport.kernel.lar.StagedModelType) PortalException(com.liferay.portal.kernel.exception.PortalException) DefaultActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery) ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) IndexableActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)

Example 27 with Foo

use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.

the class AddTestData method addTestData.

@Activate
public void addTestData() {
    int entries = 2;
    while (entries > 0) {
        Foo foo = _fooLocalService.createFoo(0);
        foo.setField1("new field1 entry" + entries);
        foo.setField2(true);
        foo.setField3(10);
        foo.setField4(new Date());
        foo.setField5("new field5 entry" + entries);
        foo.isNew();
        _fooLocalService.addFooWithoutId(foo);
        entries--;
    }
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Date(java.util.Date) Activate(org.osgi.service.component.annotations.Activate)

Example 28 with Foo

use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.

the class JSPWARPortlet method updateFoo.

public void updateFoo(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    long fooId = ParamUtil.getLong(actionRequest, "fooId");
    String field1 = ParamUtil.getString(actionRequest, "field1");
    boolean field2 = ParamUtil.getBoolean(actionRequest, "field2");
    int field3 = ParamUtil.getInteger(actionRequest, "field3");
    String field5 = ParamUtil.getString(actionRequest, "field5");
    int dateMonth = ParamUtil.getInteger(actionRequest, "field4Month");
    int dateDay = ParamUtil.getInteger(actionRequest, "field4Day");
    int dateYear = ParamUtil.getInteger(actionRequest, "field4Year");
    int dateHour = ParamUtil.getInteger(actionRequest, "field4Hour");
    int dateMinute = ParamUtil.getInteger(actionRequest, "field4Minute");
    int dateAmPm = ParamUtil.getInteger(actionRequest, "field4AmPm");
    if (dateAmPm == Calendar.PM) {
        dateHour += 12;
    }
    Date field4 = PortalUtil.getDate(dateMonth, dateDay, dateYear, dateHour, dateMinute, PortalException.class);
    if (fooId <= 0) {
        if (_log.isInfoEnabled()) {
            _log.info("Adding a new foo...");
        }
        Foo foo = getFooLocalService().createFoo(0);
        foo.setField1(field1);
        foo.setField2(field2);
        foo.setField3(field3);
        foo.setField4(field4);
        foo.setField5(field5);
        foo.isNew();
        getFooLocalService().addFooWithoutId(foo);
    } else {
        if (_log.isInfoEnabled()) {
            _log.info("Updating a new foo...");
        }
        Foo foo = getFooLocalService().fetchFoo(fooId);
        foo.setFooId(fooId);
        foo.setField1(field1);
        foo.setField2(field2);
        foo.setField3(field3);
        foo.setField4(field4);
        foo.setField5(field5);
        getFooLocalService().updateFoo(foo);
    }
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Date(java.util.Date)

Example 29 with Foo

use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.

the class BladeServiceBuilderIntegrationTest method testDeleteFoo.

@Test
public void testDeleteFoo() throws PortalException {
    long id = CounterLocalServiceUtil.increment();
    Foo foo = FooLocalServiceUtil.createFoo(id);
    foo.setField1("deleteFooEntryField1");
    foo.setField2(false);
    foo.setField3(2);
    Date createDate = new Date();
    foo.setField4(createDate);
    foo.setField5("deleteFooEntryField5");
    foo.isNew();
    Foo fooEntry = FooLocalServiceUtil.addFoo(foo);
    FooLocalServiceUtil.deleteFoo(fooEntry);
    Assert.assertTrue("Expected \"0\", but saw " + FooLocalServiceUtil.getFoosCount(), FooLocalServiceUtil.getFoosCount() == 0);
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Date(java.util.Date) Test(org.junit.Test)

Example 30 with Foo

use of com.liferay.blade.samples.servicebuilder.model.Foo in project liferay-blade-samples by liferay.

the class FooPersistenceTest method testResetOriginalValues.

@Test
public void testResetOriginalValues() throws Exception {
    Foo newFoo = addFoo();
    _persistence.clearCache();
    Foo existingFoo = _persistence.findByPrimaryKey(newFoo.getPrimaryKey());
    Assert.assertTrue(Objects.equals(existingFoo.getUuid(), ReflectionTestUtil.invoke(existingFoo, "getOriginalUuid", new Class<?>[0])));
    Assert.assertEquals(Long.valueOf(existingFoo.getGroupId()), ReflectionTestUtil.<Long>invoke(existingFoo, "getOriginalGroupId", new Class<?>[0]));
}
Also used : Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Test(org.junit.Test)

Aggregations

Foo (com.liferay.blade.samples.servicebuilder.model.Foo)48 NoSuchFooException (com.liferay.blade.samples.servicebuilder.exception.NoSuchFooException)18 Test (org.junit.Test)17 StringBundler (com.liferay.portal.kernel.util.StringBundler)16 Session (com.liferay.portal.kernel.dao.orm.Session)11 Query (com.liferay.portal.kernel.dao.orm.Query)9 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)7 Date (java.util.Date)7 FooImpl (com.liferay.blade.samples.servicebuilder.model.impl.FooImpl)6 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)5 Serializable (java.io.Serializable)5 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)4 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)4 HashSet (java.util.HashSet)3 List (java.util.List)2 ManifestSummary (com.liferay.exportimport.kernel.lar.ManifestSummary)1 StagedModelType (com.liferay.exportimport.kernel.lar.StagedModelType)1 DefaultActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery)1 ExportActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery)1 IndexableActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery)1