use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class BeanDtoFactoryHelper method createDtos.
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <BEAN_TYPE> List<IBeanDto> createDtos(final IBeanDtoFactory<? extends BEAN_TYPE> beanDtoFactory, final Collection<? extends BEAN_TYPE> beans, final IExecutionCallback executionCallback) {
Assert.paramNotNull(beanDtoFactory, "beanDtoFactory");
Assert.paramNotNull(beans, "beans");
final List<IBeanDto> result = new LinkedList<IBeanDto>();
for (final BEAN_TYPE bean : beans) {
checkCanceled(executionCallback);
final IBeanDtoFactory factory = beanDtoFactory;
result.add(factory.createDto(bean));
}
return result;
}
use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class AbstractSyncCreatorServiceImpl method create.
@SuppressWarnings("unchecked")
@Override
public final List<IBeanDto> create(final List<? extends IBeanKey> parentBeanKeys, final Collection<? extends IBeanData> beansData, final IExecutionCallback executionCallback) {
final List<IBeanDto> result = new LinkedList<IBeanDto>();
final List<BEAN_TYPE> beans = new ArrayList<BEAN_TYPE>(beansData.size());
final Map<IdentityHashKey, IBeanData> beanDataMap = new HashMap<IdentityHashKey, IBeanData>();
for (final IBeanData beanData : beansData) {
CapServiceToolkit.checkCanceled(executionCallback);
final BEAN_TYPE bean = createBean((Collection<IBeanKey>) parentBeanKeys, executionCallback);
beanDataMap.put(new IdentityHashKey(bean), beanData);
beans.add(bean);
}
final IBeanDataMapper<BEAN_TYPE> beanDataMapper = new BeanDataMapper(beanDataMap);
beforeInitialize((List<IBeanKey>) parentBeanKeys, beans, beanDataMapper, executionCallback);
for (final BEAN_TYPE bean : beans) {
CapServiceToolkit.checkCanceled(executionCallback);
beanInitializer.initialize(bean, beanDataMapper.getBeanData(bean));
}
afterInitialize((List<IBeanKey>) parentBeanKeys, beans, beanDataMapper, executionCallback);
checkExecutableStates(beans, executionCallback);
validate(beans, executionCallback);
for (final BEAN_TYPE bean : beans) {
CapServiceToolkit.checkCanceled(executionCallback);
persistBean((Collection<IBeanKey>) parentBeanKeys, bean, executionCallback);
}
afterCreate((List<IBeanKey>) parentBeanKeys, beans, beanDataMapper, executionCallback);
for (final BEAN_TYPE bean : beans) {
CapServiceToolkit.checkCanceled(executionCallback);
result.add(dtoFactory.createDto(bean));
}
CapServiceToolkit.checkCanceled(executionCallback);
return result;
}
use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class BeanTableModelImplTest method testBeanChangeUpdateWithChangedPositionInSorting.
@Test
public void testBeanChangeUpdateWithChangedPositionInSorting() {
tableModel.getSortModel().setCurrentSorting(Arrays.asList(new ISort() {
@Override
public SortOrder getSortOrder() {
return SortOrder.DESC;
}
@Override
public String getPropertyName() {
return "value";
}
}));
tableModel.load();
triggerPageLoading();
final IUpdatableResultCallback<IBeanDtosUpdate, List<IBeanDto>> updatableCallback = assertUpdatableResultCallback(resultCallback);
updatableCallback.finished(new ArrayList<IBeanDto>());
updatableCallback.update(new BeanDtosInsertionUpdate(Arrays.asList((IBeanDto) bean2, (IBeanDto) bean1)));
updatableCallback.update(new BeanDtosChangeUpdate(Arrays.asList((IBeanDto) bean1a)));
assertTrue("2 beans should be loaded, but was " + tableModel.getSize(), tableModel.getSize() == 2);
assertTrue("the updated bean should be first now", tableModel.getBean(0).getValue("value").equals(bean1a.getValue("value")));
assertTrue("the previously first bean should now be second", tableModel.getBean(1).getValue("value").equals(bean2.getValue("value")));
}
use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class BeanTableModelImplTest method testBeanDeletionUpdate.
@Test
public void testBeanDeletionUpdate() {
tableModel.getSortModel().setCurrentSorting(Arrays.asList(new ISort() {
@Override
public SortOrder getSortOrder() {
return SortOrder.ASC;
}
@Override
public String getPropertyName() {
return "key";
}
}));
tableModel.load();
triggerPageLoading();
final IUpdatableResultCallback<IBeanDtosUpdate, List<IBeanDto>> updatableCallback = assertUpdatableResultCallback(resultCallback);
updatableCallback.finished(new ArrayList<IBeanDto>());
updatableCallback.update(new BeanDtosInsertionUpdate(Arrays.asList((IBeanDto) bean1, (IBeanDto) bean2)));
updatableCallback.update(new BeanDtosDeletionUpdate(Arrays.asList(bean1.getId())));
final int size = tableModel.getSize();
assertTrue("Only 1 beans should be loaded, but was " + size, size == 1);
assertTrue("bean2 should be left", tableModel.getBean(0).getValue("value").equals(bean2.getValue("value")));
}
use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class BeanSelectionClipboard method create.
public static IBeanSelectionClipboard create(final IBeanSelection<?> beanSelection) {
final IBeanSelectionClipboardBuilder builder = builder();
builder.setEntityId(beanSelection.getEntityId());
builder.setBeanTypeId(beanSelection.getBeanTypeId());
builder.setBeanType(beanSelection.getBeanType());
final List<IBeanDto> beans = new LinkedList<IBeanDto>();
for (final IBeanProxy<?> beanProxy : beanSelection.getSelection()) {
final IBeanDto beanDto = beanProxy.createUnmodifiedCopy().getBeanDto();
if (beanProxy.isTransient()) {
beans.add(new TransientBeanDto(beanDto));
} else {
beans.add(beanDto);
}
}
builder.setBeans(beans);
return builder.build();
}
Aggregations