Package mc.core.domain.base.dobj
Class AbstractBaseDO<T extends IBaseEntity>
java.lang.Object
mc.core.system.base.BaseBean
mc.core.domain.base.dobj.AbstractBaseDO<T>
- All Implemented Interfaces:
IBaseDO<T>
- Direct Known Subclasses:
AbstractEntityBaseDO,BaseDO,CSSystemPropertyDO,MemoDO,NotificationDO,TextSetDO,WorkflowDataDO
public abstract class AbstractBaseDO<T extends IBaseEntity>
extends mc.core.system.base.BaseBean
implements IBaseDO<T>
common abstract base class for DOs and aspects. TX demarcation if not already active through the @Transactional
interceptor. the interceptor binding is derived to all subclasses
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classhelper class for framework to avoid a setEntityClass method in public DO API -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDefaultSearchCriteria(List<mc.core.system.search.BaseSearchCriteria<?>> critList, String param) add entity specific default search criteria to list for search by given paramvoidWARNING: this method must not be overridden, only overridedelete(IBaseEntity, boolean)! It cannot be final because J2EE-container does not allow final on methods that require transactional interceptor.voidNOTE: when overriding this method and you delete any other objects you need to call validateNotUsed before in case flag force is false!getAll(mc.core.system.search.SearchFilter filter) get all active entities.getEntityDisplay(T entity, Locale locale) getFromId(long entityId) getFromKey(Object key) get entity by key through entity specific property matchinggetOne(mc.core.system.search.SearchFilter filter) get at least needed user base role for the entity classvoidmap(List<T> entities, MapContext context, OutputStream os) map list of entities to output stream through reader, filter and renderer.IN mapping: map data to entity through writer and handlermc.core.system.search.SearchFilterprepareSearchFilter(mc.core.system.search.SearchFilter sf) prepare searchFilter for (paged) SearchService search() methods.map data to entity if any, validate and saveAbstractBaseDO<T>.mc.core.domain.base.dobj.AbstractBaseDO.Validatorfor persistent entity copy constructor be used, the copy of entity be mapped and validated
WARNING: in error case param map be changed! non valid fields be deleted from it
all error be collect as ValidationResults in ValidationException and throw only by validate() call
Examples to use:
1.
-
Constructor Details
-
AbstractBaseDO
public AbstractBaseDO()
-
-
Method Details
-
getUserRole
Description copied from interface:IBaseDOget at least needed user base role for the entity class- Specified by:
getUserRolein interfaceIBaseDO<T extends IBaseEntity>
-
getFromId
- Parameters:
entityId-- Returns:
- the attached entity if found, otherwise throws EntityNotFoundException
- Throws:
EntityNotFoundException- if no entity of this DO's entity class and given id could be found in persistence context.
-
getFromKey
Description copied from interface:IBaseDOget entity by key through entity specific property matching- Specified by:
getFromKeyin interfaceIBaseDO<T extends IBaseEntity>- Returns:
- entity if found and unique
- Throws:
EntityNotFoundExceptionNotUniqueResultException
-
getOne
public T getOne(mc.core.system.search.SearchFilter filter) throws EntityNotFoundException, NotUniqueResultException -
getAll
-
addDefaultSearchCriteria
public void addDefaultSearchCriteria(List<mc.core.system.search.BaseSearchCriteria<?>> critList, String param) Description copied from interface:IBaseDOadd entity specific default search criteria to list for search by given param- Specified by:
addDefaultSearchCriteriain interfaceIBaseDO<T extends IBaseEntity>param- mandatory
-
prepareSearchFilter
public mc.core.system.search.SearchFilter prepareSearchFilter(mc.core.system.search.SearchFilter sf) prepare searchFilter for (paged) SearchService search() methods. override to add type specific criteria or ordering. always call super first when overriding and use returned filter- Returns:
- prepared
SearchFilter. never null
-
getAllActive
Description copied from interface:IBaseDOget all active entities. method is not implemented for all entity classes:- Principal: get all with active flag true and isSystem flag false
- SimpleEntity: get all with isActive flag true and isSystem flag false
- TypeEntity: get all with isActive flag true
- all other: throws UnsupportedOperationException cause result may be too large
- Specified by:
getAllActivein interfaceIBaseDO<T extends IBaseEntity>- Returns:
- list of entities matching the above rules
-
delete
WARNING: this method must not be overridden, only overridedelete(IBaseEntity, boolean)! It cannot be final because J2EE-container does not allow final on methods that require transactional interceptor.- Specified by:
deletein interfaceIBaseDO<T extends IBaseEntity>- Parameters:
entity- mandatory- Throws:
ApplicationException
-
delete
NOTE: when overriding this method and you delete any other objects you need to call validateNotUsed before in case flag force is false!- Parameters:
entity- mandatoryforce- if true delete without usage check, which can result in db constraints error unless references are taken care of- Throws:
ApplicationException
-
save
- Throws:
ApplicationException
-
save
Description copied from interface:IBaseDOmap data to entity if any, validate and save- Specified by:
savein interfaceIBaseDO<T extends IBaseEntity>- Parameters:
entity- mandatorydataMap- optional- Returns:
- mapped entity
- Throws:
ApplicationException
-
copy
- Throws:
ApplicationException
-
map
IN mapping: map data to entity through writer and handler- Throws:
ApplicationException
-
map
Description copied from interface:IBaseDOmap list of entities to output stream through reader, filter and renderer. optionally using settings in publish context.- Specified by:
mapin interfaceIBaseDO<T extends IBaseEntity>- Parameters:
entities- mandatory, may be emptycontext- optional, if null suitable defaults are usedos- mandatory- Throws:
ApplicationException
-
getEntityDisplay
- Specified by:
getEntityDisplayin interfaceIBaseDO<T extends IBaseEntity>- Parameters:
entity- Attached entity to render as text. Must not benull.locale- Language of desired output. Ifnull, master locale is used.- Returns:
- Entity display according to DO classes or empty string. Never
null.
-
validator
public AbstractBaseDO<T>.mc.core.domain.base.dobj.AbstractBaseDO.Validator validator(T entity, DataMap map) throws ApplicationException for persistent entity copy constructor be used, the copy of entity be mapped and validated
WARNING: in error case param map be changed! non valid fields be deleted from it
all error be collect as ValidationResults in ValidationException and throw only by validate() call
Examples to use:
1. validator( navigationHrc, dataMap).thatValidField( NavigationHrc.Field.navigationHrcType).validate(); 2. validator( navigation, dataMap).thatValidField( Navigation.Field.navigationType, Navigation.Field.navigationHrc) .thatNotNullIf( HrcEntity.Field.parent, n -> n.getNavigationType().getParentNavigationType() != null).validate(); 3. validator( entity, dataMap).thatValidField( Country.Field.iso2Code, "message.validate.Country.iso2Code.missing").thatUnique( Country.Field.iso2Code).validate();- Parameters:
entity- mandatorymap- optional- Returns:
- the validator
- Throws:
ApplicationException- the application exception
-