Search in sources :

Example 6 with IBeanData

use of org.jowidgets.cap.common.api.bean.IBeanData in project jo-client-platform by jo-source.

the class BeanListSaveDelegate method create.

private void create(final Runnable finishedCallback) {
    final Set<IBeanProxy<BEAN_TYPE>> beansToCreate = beansStateTracker.getBeansToCreate();
    if (!EmptyCheck.isEmpty(beansToCreate)) {
        if (creatorService == null) {
            throw new IllegalStateException("No creator service set. Could not create transient beans");
        }
        final BeanListExecutionHelper<BEAN_TYPE> executionHelper = new BeanListExecutionHelper<BEAN_TYPE>(CREATION_FAILED.get(), listModel, beansToCreate, beanExecutionPolicy, exceptionConverter, true, fireBeansChanged);
        final List<List<IBeanProxy<BEAN_TYPE>>> preparedExecutions = executionHelper.prepareExecutions(true, 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(CREATE.get());
                    final List<IBeanData> beansData = new LinkedList<IBeanData>();
                    for (final IBeanProxy<BEAN_TYPE> bean : preparedBeans) {
                        beansData.add(createBeanData(bean));
                    }
                    final IResultCallback<List<IBeanDto>> helperCallback = executionHelper.createResultCallback(preparedBeans, countDownRunnable);
                    creatorService.create(helperCallback, parentBeansProvider.get(), beansData, 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) IBeanData(org.jowidgets.cap.common.api.bean.IBeanData) LinkedList(java.util.LinkedList) List(java.util.List)

Aggregations

IBeanData (org.jowidgets.cap.common.api.bean.IBeanData)6 LinkedList (java.util.LinkedList)4 IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)4 IExecutionTask (org.jowidgets.cap.ui.api.execution.IExecutionTask)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 IUiThreadAccess (org.jowidgets.api.threads.IUiThreadAccess)1 IBeanKey (org.jowidgets.cap.common.api.bean.IBeanKey)1 ServiceException (org.jowidgets.cap.common.api.exception.ServiceException)1 IExecutionCallbackListener (org.jowidgets.cap.common.api.execution.IExecutionCallbackListener)1 IBeanDataMapper (org.jowidgets.cap.service.api.creator.IBeanDataMapper)1 IBeanProxy (org.jowidgets.cap.ui.api.bean.IBeanProxy)1 AbstractUiResultCallback (org.jowidgets.cap.ui.tools.execution.AbstractUiResultCallback)1 IdentityHashKey (org.jowidgets.util.collection.IdentityHashKey)1