use of org.jowidgets.cap.common.api.bean.IBeanModification in project jo-client-platform by jo-source.
the class BeanListSaveDelegate method update.
private void update(final Runnable finishedCallback) {
final Set<IBeanProxy<BEAN_TYPE>> modifiedBeans = beansStateTracker.getMasterBeansToUpdate();
if (!EmptyCheck.isEmpty(modifiedBeans)) {
if (updaterService == null) {
throw new IllegalStateException("No updater service set. Can not update modified beans");
}
final BeanListExecutionHelper<BEAN_TYPE> executionHelper = new BeanListExecutionHelper<BEAN_TYPE>(SAVE_FAILED.get(), listModel, modifiedBeans, beanExecutionPolicy, exceptionConverter, false, fireBeansChanged);
final List<List<IBeanProxy<BEAN_TYPE>>> preparedExecutions = executionHelper.prepareExecutions(false, executionContext);
final CountDownRunnable countDownRunnable = new CountDownRunnable(finishedCallback, preparedExecutions.size());
for (final List<IBeanProxy<BEAN_TYPE>> preparedBeans : preparedExecutions) {
if (preparedBeans.size() > 0) {
final IExecutionTask executionTask = preparedBeans.get(0).getExecutionTask();
if (executionTask != null) {
executionTask.setDescription(SAVE.get());
final List<IBeanModification> modifications = new LinkedList<IBeanModification>();
for (final IBeanProxy<?> bean : preparedBeans) {
modifications.addAll(bean.getModifications());
}
final IResultCallback<List<IBeanDto>> helperCallback = executionHelper.createResultCallback(preparedBeans, countDownRunnable);
updaterService.update(helperCallback, modifications, executionTask);
}
}
}
} else {
finishedCallback.run();
}
}
use of org.jowidgets.cap.common.api.bean.IBeanModification in project jo-client-platform by jo-source.
the class BeanProxyImpl method getPropertyChangesForClear.
private List<PropertyChangeEvent> getPropertyChangesForClear() {
final List<PropertyChangeEvent> result = new LinkedList<PropertyChangeEvent>();
for (final Entry<String, IBeanModification> modificationEntry : modifications.entrySet()) {
final String propertyName = modificationEntry.getKey();
result.add(new PropertyChangeEvent(this, propertyName, modificationEntry.getValue().getNewValue(), beanDto.getValue(propertyName)));
}
return result;
}
use of org.jowidgets.cap.common.api.bean.IBeanModification in project jo-client-platform by jo-source.
the class OrderedBeansCrudInterceptorImpl method hasBeanRelevantModifications.
private boolean hasBeanRelevantModifications(final IOrderedBean bean, final List<IBeanModification> modifications) {
final Set<String> groupChangingAttributes = groupMapper.getGroupChangingAttributes();
boolean hasGroupChangingModifications = false;
for (final IBeanModification modification : modifications) {
if (IOrderedBean.ORDER_NUMBER_PROPERTY.equals(modification.getPropertyName())) {
final Object lastOrderNumber = modification.getOldValue();
final Object newOrderNumber = modification.getNewValue();
if (lastOrderNumber instanceof Long || newOrderNumber instanceof Long) {
return true;
}
} else if (groupChangingAttributes.contains(modification.getPropertyName())) {
hasGroupChangingModifications = true;
}
}
if (hasGroupChangingModifications && bean.getOrderNumber() != null) {
return true;
} else {
return false;
}
}
use of org.jowidgets.cap.common.api.bean.IBeanModification in project jo-client-platform by jo-source.
the class SyncUpdaterServiceImpl method createModificationsMap.
private Map<Object, List<IBeanModification>> createModificationsMap(final Collection<? extends IBeanModification> modifications) {
final Map<Object, List<IBeanModification>> result = new LinkedHashMap<Object, List<IBeanModification>>();
for (final IBeanModification beanModification : modifications) {
List<IBeanModification> modificationList = result.get(beanModification.getId());
if (modificationList == null) {
modificationList = new LinkedList<IBeanModification>();
result.put(beanModification.getId(), modificationList);
}
modificationList.add(beanModification);
}
return result;
}
use of org.jowidgets.cap.common.api.bean.IBeanModification in project jo-client-platform by jo-source.
the class BeanProxyImpl method getPropertyChangesForUndo.
private List<PropertyChangeEvent> getPropertyChangesForUndo() {
final List<PropertyChangeEvent> result = new LinkedList<PropertyChangeEvent>();
for (final Entry<String, IBeanModification> modificationEntry : undoneModifications.entrySet()) {
final String propertyName = modificationEntry.getKey();
result.add(new PropertyChangeEvent(this, propertyName, modificationEntry.getValue().getNewValue(), beanDto.getValue(propertyName)));
}
return result;
}
Aggregations