Package org.cyclos.impl.utils.conversion
Class BaseEntityConverter<E extends SimpleEntity>
- java.lang.Object
-
- org.cyclos.impl.utils.conversion.AbstractBeanConverter<T>
-
- org.cyclos.impl.utils.conversion.ObjectConverter<E>
-
- org.cyclos.impl.utils.conversion.BaseEntityConverter<E>
-
- All Implemented Interfaces:
BeanConverter<E>
- Direct Known Subclasses:
AccessClientConverter,AccountConverter,BasicAdConverter,BasicUserConverter,ChannelConfigurationConverter,ConfigurationConverter,ContentItemConverter,CustomFieldConverter,ExportFormatConverter,OrderConverter,PinConverter,ProductProfileFieldConverter,RecordConverter,TransactionConverter,TransferConverter,VoucherConverter
@Component public class BaseEntityConverter<E extends SimpleEntity> extends ObjectConverter<E>
Abstract converter for entities. Handles the following flow:- When the source is an
EntityVOor basic type, just load the entity by id or internal name - When the source is an
EntityDTO, if transient, create a new entity, else, load by id and check the version (throwingStaleEntityExceptionif it doesn't match with the latest version). Then copy the properties to the entity - Other cases only handle new entities: instantiate and copy properties
-
-
Field Summary
Fields Modifier and Type Field Description protected ApplicationHandlerapplicationHandler-
Fields inherited from class org.cyclos.impl.utils.conversion.AbstractBeanConverter
beanHandler, configurationHandler, conversionHandler, entityManagerHandler, profileFieldHandler
-
-
Constructor Summary
Constructors Constructor Description BaseEntityConverter()BaseEntityConverter(Class<E> entityType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidfill(Object source, E result, Object[] excludingProperties, InvocationContext.ConversionContext context)Copy properties from the source to the destination objectprotected Efind(Class<E> entityType, Long id)protected Einstantiate(Class<E> beanType, Object source, InvocationContext.ConversionContext context)Instantiate the result object from the given source object.-
Methods inherited from class org.cyclos.impl.utils.conversion.ObjectConverter
convert, getSessionData, registerMapping, resolveDestinationType
-
Methods inherited from class org.cyclos.impl.utils.conversion.AbstractBeanConverter
canBeUsedAsSourceForFilling, getApplicationContext, getBeanType, getFormatter
-
-
-
-
Field Detail
-
applicationHandler
@Autowired protected ApplicationHandler applicationHandler
-
-
Method Detail
-
fill
protected void fill(Object source, E result, Object[] excludingProperties, InvocationContext.ConversionContext context)
Description copied from class:ObjectConverterCopy properties from the source to the destination object- Overrides:
fillin classObjectConverter<E extends SimpleEntity>
-
instantiate
protected E instantiate(Class<E> beanType, Object source, InvocationContext.ConversionContext context)
Description copied from class:ObjectConverterInstantiate the result object from the given source object. By default, just invoke the default constructor on the bean type- Overrides:
instantiatein classObjectConverter<E extends SimpleEntity>
-
-