Search in sources :

Example 1 with IBeanModification

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();
    }
}
Also used : IExecutionTask(org.jowidgets.cap.ui.api.execution.IExecutionTask) LinkedList(java.util.LinkedList) IBeanProxy(org.jowidgets.cap.ui.api.bean.IBeanProxy) LinkedList(java.util.LinkedList) List(java.util.List) IBeanModification(org.jowidgets.cap.common.api.bean.IBeanModification)

Example 2 with IBeanModification

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;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) IBeanModification(org.jowidgets.cap.common.api.bean.IBeanModification) LinkedList(java.util.LinkedList)

Example 3 with IBeanModification

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;
    }
}
Also used : IBeanModification(org.jowidgets.cap.common.api.bean.IBeanModification)

Example 4 with IBeanModification

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;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) IBeanModification(org.jowidgets.cap.common.api.bean.IBeanModification) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with IBeanModification

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;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) IBeanModification(org.jowidgets.cap.common.api.bean.IBeanModification) LinkedList(java.util.LinkedList)

Aggregations

IBeanModification (org.jowidgets.cap.common.api.bean.IBeanModification)7 LinkedList (java.util.LinkedList)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 List (java.util.List)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 IBeanProxy (org.jowidgets.cap.ui.api.bean.IBeanProxy)1 IExecutionTask (org.jowidgets.cap.ui.api.execution.IExecutionTask)1 IFilterToolkit (org.jowidgets.cap.ui.api.filter.IFilterToolkit)1 IUiBooleanFilterBuilder (org.jowidgets.cap.ui.api.filter.IUiBooleanFilterBuilder)1 IUiFilterFactory (org.jowidgets.cap.ui.api.filter.IUiFilterFactory)1