use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class BeanKeyFactoryImpl method createKeysFromDtos.
@Override
public List<IBeanKey> createKeysFromDtos(final Collection<? extends IBeanDto> beanDtos) {
Assert.paramNotNull(beanDtos, "beanDtos");
final List<IBeanKey> result = new LinkedList<IBeanKey>();
for (final IBeanDto dto : beanDtos) {
result.add(createKeyFromDto(dto));
}
return result;
}
use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class BeanListExecutionHelper method updateTransientBeans.
private void updateTransientBeans(final List<IBeanProxy<BEAN_TYPE>> executedBeans, final List<IBeanDto> result) {
if (executedBeans.size() != result.size()) {
listModel.removeBeans(executedBeans);
for (final IBeanDto beanDto : result) {
listModel.addBeanDto(beanDto);
}
} else {
final Iterator<IBeanProxy<BEAN_TYPE>> sourceIterator = executedBeans.iterator();
final Iterator<IBeanDto> resultIterator = result.iterator();
while (sourceIterator.hasNext()) {
sourceIterator.next().update(resultIterator.next());
}
}
}
use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class BeanListExecutionHelper method updateBeans.
private void updateBeans(final List<IBeanProxy<BEAN_TYPE>> executedBeans, final List<IBeanDto> result) {
// put the resulting beans into a map for faster access later
final Map<Object, IBeanDto> resultMap = new LinkedHashMap<Object, IBeanDto>();
for (final IBeanDto beanDto : result) {
resultMap.put(beanDto.getId(), beanDto);
}
// update the executed beans with the beans get as result from the service
final List<IBeanProxy<BEAN_TYPE>> beansToDelete = new LinkedList<IBeanProxy<BEAN_TYPE>>();
for (final IBeanProxy<BEAN_TYPE> bean : executedBeans) {
final IBeanDto updatedBean = resultMap.remove(bean.getId());
if (updatedBean != null) {
bean.update(updatedBean);
} else {
beansToDelete.add(bean);
}
}
// remove the beans from the model that was not returned by the service
if (!beansToDelete.isEmpty()) {
listModel.removeBeans(beansToDelete);
}
// add the beans to the model that was created by the service
for (final IBeanDto beanDto : resultMap.values()) {
listModel.addBeanDto(beanDto);
}
}
use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class BeanProxyFactoryImpl method createProxies.
@Override
public List<IBeanProxy<BEAN_TYPE>> createProxies(final Collection<? extends IBeanDto> beanDtos, final IAttributeSet attributes) {
Assert.paramNotNull(beanDtos, "beanDtos");
Assert.paramNotNull(attributes, "attributes");
final List<IBeanProxy<BEAN_TYPE>> result = new LinkedList<IBeanProxy<BEAN_TYPE>>();
for (final IBeanDto beanDto : beanDtos) {
result.add(createProxy(beanDto, attributes));
}
return result;
}
use of org.jowidgets.cap.common.api.bean.IBeanDto in project jo-client-platform by jo-source.
the class CsvExporter method writeBeans.
private int writeBeans(final List<IBeanDto> beans, final PrintStream ps, int exportedCount, final Integer totalCount, final IExecutionCallback executionCallback) throws Exception {
for (final IBeanDto bean : beans) {
if (!executionCallback.isCanceled()) {
exportedCount++;
if (totalCount != null) {
executionCallback.setDescription(MessageReplacer.replace(Messages.getString("CsvExporter.Export") + " ' %1 ' " + Messages.getString("CsvExporter.of") + " ' %2 ' %3 ", String.valueOf(exportedCount), Integer.toString(totalCount), model.getEntityLabelPlural()));
executionCallback.workedOne();
} else {
executionCallback.setDescription(MessageReplacer.replace(Messages.getString("CsvExporter.Export") + "' %1 ' %2 ", String.valueOf(exportedCount), model.getEntityLabelPlural()));
}
ps.println(beanToCsv(bean));
} else {
return -1;
}
}
return exportedCount;
}
Aggregations