use of org.jowidgets.cap.common.api.bean.IBeanDto 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.IBeanDto 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.IBeanDto in project jo-client-platform by jo-source.
the class LinkCreatorServiceImpl method createDirectLinkedBeans.
private List<IBeanDto> createDirectLinkedBeans(final List<IBeanDto> sourceBeans, final ILinkCreation link, final IExecutionCallback executionCallback) {
if (sourceBeans.size() == 1) {
final List<IBeanDto> result;
final IBeanDto sourceBean = sourceBeans.iterator().next();
result = getBeans(sourceBean, sourceProperties, link.getLinkableBeans(), linkedBeanAccess, linkedDtoFactory, executionCallback);
result.addAll(createDirectLinkBeans(sourceBean, link.getTransientLinkableBeans(), linkableCreatorService, executionCallback));
return result;
} else {
throw new IllegalArgumentException("A direct link must have exactly one source bean!");
}
}
use of org.jowidgets.cap.common.api.bean.IBeanDto 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.IBeanDto in project jo-client-platform by jo-source.
the class LinkCreatorServiceImpl method getBeans.
private <BEAN_TYPE extends IBean> List<IBeanDto> getBeans(final IBeanDto linkedBean, final IEntityLinkProperties linkProperties, final Collection<IBeanKey> beanKeys, final IBeanAccess<BEAN_TYPE> beanAccess, final IBeanDtoFactory<BEAN_TYPE> dtoFactory, final IExecutionCallback executionCallback) {
final List<IBeanDto> result = new LinkedList<IBeanDto>();
for (final IBeanKey beanKey : beanKeys) {
CapServiceToolkit.checkCanceled(executionCallback);
final List<IBeanKey> singletonList = Collections.singletonList(beanKey);
final List<BEAN_TYPE> beans = beanAccess.getBeans(singletonList, executionCallback);
if (!EmptyCheck.isEmpty(beans) && beans.size() == 1) {
final BEAN_TYPE bean = beans.iterator().next();
if (linkedBean != null && linkProperties != null) {
final Object sourceKey = linkedBean.getValue(linkProperties.getKeyPropertyName());
BeanUtils.setProperty(bean, linkProperties.getForeignKeyPropertyName(), sourceKey);
}
result.add(dtoFactory.createDto(bean));
} else if (!EmptyCheck.isEmpty(beans) && beans.size() > 1) {
throw new BeanException(beanKey.getId(), "More than one bean found for the key '" + beanKey + "'");
} else {
throw new DeletedBeanException(beanKey.getId());
}
}
return result;
}
Aggregations