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