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);
}
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;
}
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;
}
}
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;
}
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;
}
Aggregations