use of org.jowidgets.cap.common.api.bean.IBeanDtoBuilder in project jo-client-platform by jo-source.
the class BeanProxyImpl method createUnmodifiedCopy.
@Override
public IBeanProxy<BEAN_TYPE> createUnmodifiedCopy() {
final IBeanDtoBuilder dtoBuilder = CapCommonToolkit.dtoBuilder(getBeanTypeId());
dtoBuilder.setId(getId());
dtoBuilder.setVersion(getVersion());
for (final String propertyName : getProperties()) {
if (!ALL_META_ATTRIBUTES.contains(propertyName) && !IBean.ID_PROPERTY.equals(propertyName) && !IBean.VERSION_PROPERTY.equals(propertyName)) {
dtoBuilder.setValue(propertyName, getValue(propertyName));
}
}
final BeanProxyImpl<BEAN_TYPE> result = new BeanProxyImpl<BEAN_TYPE>(dtoBuilder.build(), beanTypeId, beanType, attributes, isDummy, isTransient, isLastRowDummy, beanPropertyValidators, validateUnmodified, uiThreadAccess);
return result;
}
use of org.jowidgets.cap.common.api.bean.IBeanDtoBuilder in project jo-client-platform by jo-source.
the class BeanDtoComparatorTest method createBeanDto.
private static IBeanDto createBeanDto(final Long number, final String string) {
final IBeanDtoBuilder builder = CapCommonToolkit.dtoBuilder(BEAN_TYPE_ID);
builder.setId(UUID.randomUUID().toString());
builder.setValue(NUMBER_PROPERTY_NAME, number);
builder.setValue(STRING_PROPRTY_NAME, string);
return builder.build();
}
use of org.jowidgets.cap.common.api.bean.IBeanDtoBuilder in project jo-client-platform by jo-source.
the class BeanDtoFactoryImpl method createDto.
@Override
public IBeanDto createDto(final BEAN_TYPE bean) {
Assert.paramNotNull(bean, "bean");
final IBeanDtoBuilder builder = CapCommonToolkit.dtoBuilder(beanType);
// interceptor annotation before
if (interceptor != null) {
interceptor.beforeCreate(bean, builder);
}
// plugin before invocation
for (final IBeanDtoFactoryPlugin<BEAN_TYPE> plugin : interceptorPlugins) {
plugin.beforeCreate(bean, builder);
}
builder.setId(identityResolver.getId(bean));
builder.setVersion(identityResolver.getVersion(bean));
for (final String propertyName : propertyNames) {
final Method method = methods.get(propertyName);
if (method != null) {
try {
builder.setValue(propertyName, method.invoke(bean));
} catch (final Exception e) {
throw new RuntimeException(e);
}
} else if (bean instanceof IPropertyMap) {
builder.setValue(propertyName, ((IPropertyMap) bean).getValue(propertyName));
}
}
// interceptor annotation after
if (interceptor != null) {
interceptor.afterCreate(bean, builder);
}
// plugin after invocation
for (final IBeanDtoFactoryPlugin<BEAN_TYPE> plugin : interceptorPlugins) {
plugin.afterCreate(bean, builder);
}
return builder.build();
}
use of org.jowidgets.cap.common.api.bean.IBeanDtoBuilder in project jo-client-platform by jo-source.
the class BeanPropertyMapDtoFactory method createDto.
@Override
public IBeanDto createDto(final IBeanPropertyMap bean) {
final IBeanDtoBuilder builder = CapCommonToolkit.dtoBuilder(bean.getBeanTypeId());
builder.setId(bean.getId());
builder.setVersion(bean.getVersion());
for (final String propertyName : propertyNames) {
builder.setValue(propertyName, bean.getValue(propertyName));
}
return builder.build();
}
use of org.jowidgets.cap.common.api.bean.IBeanDtoBuilder in project jo-client-platform by jo-source.
the class BeanProxyImplTest method createPersonDto.
private static IBeanDto createPersonDto(final long id, final String name, final String lastName, final Gender gender) {
final IBeanDtoBuilder builder = new BeanDtoBuilder(IPerson.class);
builder.setId(Long.valueOf(id));
builder.setValue(IPerson.NAME_PROPERTY, name);
builder.setValue(IPerson.LAST_NAME_PROPERTY, lastName);
builder.setValue(IPerson.GENDER_PROPERTY, gender);
return builder.build();
}
Aggregations