Search in sources :

Example 1 with IBeanData

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

the class BeanCreatorCommand method createBean.

private void createBean(final IExecutionContext executionContext, final IBeanProxy<BEAN_TYPE> bean) {
    final IExecutionTask executionTask = CapUiToolkit.executionTaskFactory().create(executionContext);
    bean.setExecutionTask(executionTask);
    final IUiThreadAccess uiThreadAccess = Toolkit.getUiThreadAccess();
    executionTask.addExecutionCallbackListener(new IExecutionCallbackListener() {

        @Override
        public void canceled() {
            uiThreadAccess.invokeLater(new Runnable() {

                @Override
                public void run() {
                    bean.setExecutionTask(null);
                    model.removeBeans(Collections.singletonList(bean));
                    model.fireBeansChanged();
                    executionObservable.fireAfterExecutionCanceled(executionContext);
                }
            });
        }
    });
    model.addBean(bean);
    final IBeanData beanData = createBeanData(bean);
    final List<IBeanData> data = Collections.singletonList(beanData);
    executionObservable.fireAfterExecutionPrepared(executionContext);
    creatorService.create(new ResultCallback(executionContext, bean), parentBeanKeysProvider.get(), data, executionTask);
}
Also used : IExecutionCallbackListener(org.jowidgets.cap.common.api.execution.IExecutionCallbackListener) AbstractUiResultCallback(org.jowidgets.cap.ui.tools.execution.AbstractUiResultCallback) IExecutionTask(org.jowidgets.cap.ui.api.execution.IExecutionTask) IBeanData(org.jowidgets.cap.common.api.bean.IBeanData) IUiThreadAccess(org.jowidgets.api.threads.IUiThreadAccess)

Example 2 with IBeanData

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

the class LinkCreatorServiceImpl method createInverseDirectLinkBeans.

private List<IBeanDto> createInverseDirectLinkBeans(final IBeanDto linkedBean, final Collection<IBeanData> beanDatas, final ICreatorService creatorService, final IExecutionCallback executionCallback) {
    final List<IBeanDto> result = new LinkedList<IBeanDto>();
    for (final IBeanData beanData : beanDatas) {
        final DecoratedLinkBeanData decoratedBeanData = new DecoratedLinkBeanData(beanData, linkedBean, null);
        result.add(createBean(decoratedBeanData, creatorService, executionCallback));
    }
    return result;
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) IBeanData(org.jowidgets.cap.common.api.bean.IBeanData) LinkedList(java.util.LinkedList)

Example 3 with IBeanData

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

the class LinkCreatorServiceImpl method createLink.

private IBeanDto createLink(final IBeanDto sourceBean, final IBeanDto linkedBean, final IBeanData additionalProperties, final IExecutionCallback executionCallback) {
    final IBeanData decoratedBeanData = new DecoratedLinkBeanData(additionalProperties, linkedBean, sourceBean);
    final IBeanDto linkBean = createBean(decoratedBeanData, linkCreatorService, executionCallback);
    if (linkBean == null) {
        throw new ServiceException("Can not create link for source: " + sourceBean + ", linked: " + linkedBean + ", additional properties: " + additionalProperties + ".");
    }
    if (linkBeanType.equals(linkedBeanAccess.getBeanType()) && linkedBean == null) {
        return linkBean;
    } else {
        return linkedBean;
    }
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ServiceException(org.jowidgets.cap.common.api.exception.ServiceException) IBeanData(org.jowidgets.cap.common.api.bean.IBeanData)

Example 4 with IBeanData

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

the class LinkCreatorServiceImpl method createDirectLinkBeans.

private List<IBeanDto> createDirectLinkBeans(final IBeanDto sourceBean, final Collection<IBeanData> beanDatas, final ICreatorService creatorService, final IExecutionCallback executionCallback) {
    final List<IBeanDto> result = new LinkedList<IBeanDto>();
    for (final IBeanData beanData : beanDatas) {
        final DecoratedLinkBeanData decoratedBeanData = new DecoratedLinkBeanData(beanData, null, sourceBean);
        result.add(createBean(decoratedBeanData, creatorService, executionCallback));
    }
    return result;
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) IBeanData(org.jowidgets.cap.common.api.bean.IBeanData) LinkedList(java.util.LinkedList)

Example 5 with IBeanData

use of org.jowidgets.cap.common.api.bean.IBeanData 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;
}
Also used : IBeanDataMapper(org.jowidgets.cap.service.api.creator.IBeanDataMapper) IdentityHashKey(org.jowidgets.util.collection.IdentityHashKey) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IBeanData(org.jowidgets.cap.common.api.bean.IBeanData)

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