Package io.tesler.core.crudma.impl
Class AbstractResponseService<T extends DataResponseDTO,E extends BaseEntity>
- java.lang.Object
-
- io.tesler.core.crudma.impl.AbstractResponseService<T,E>
-
- All Implemented Interfaces:
ResponseService<T,E>
- Direct Known Subclasses:
AudDictionaryServiceImpl
,DeptServiceImpl
,DictionaryLnkRuleValueAssocServiceImpl
,DictionaryLnkRuleValueServiceImpl
,TaskChildBcServiceImpl
,VersionAwareResponseService
,WorkflowTaskMigrationServiceImpl
@Transactional public abstract class AbstractResponseService<T extends DataResponseDTO,E extends BaseEntity> extends Object implements ResponseService<T,E>
-
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.context.ApplicationContext
applicationContext
protected BaseDAO
baseDAO
protected Class<? extends BcSpecificationHolder<E>>
bcSpecificationHolder
protected Class<? extends LinkSpecificationHolder<E>>
linkSpecificationHolder
protected javax.persistence.metamodel.SingularAttribute<? super E,? extends BaseEntity>
parentSpec
protected Class<? extends PreActionConditionHolderAssoc>
preActionConditionHolderAssoc
protected Class<? extends PreActionConditionHolderDataResponse<T>>
preActionConditionHolderDataResponse
protected Class<? extends SecuritySpecificationHolder<E>>
securitySpecificationHolder
protected Class<T>
typeOfDTO
protected Class<E>
typeOfEntity
-
Constructor Summary
Constructors Constructor Description AbstractResponseService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AssociateResultDTO
associate(List<AssociateDTO> data, BusinessComponent bc)
Сreates links between entitiesstatic <T> T
cast(Object o, Class<T> clazz)
long
count(BusinessComponent bc)
Returns the number of matching entitiesprotected long
count(BaseDAO dao, BusinessComponent bc)
protected long
count(BaseDAO dao, BusinessComponent bc, Class<E> typeOfEntity, Class<T> typeOfDTO)
CreateResult<T>
createEntity(BusinessComponent bc)
Creates an entity based on a business componentActionResultDTO<T>
deleteEntity(BusinessComponent bc)
Deletes an entity based on a business componentprotected AssociateResultDTO
doAssociate(List<AssociateDTO> data, BusinessComponent bc)
protected T
doGetOne(BusinessComponent bc)
protected ResultPage<T>
dtoListToResultPage(List<T> dtos, int limit)
protected ResultPage<T>
entitiesToDtos(BusinessComponent bc, ResultPage<E> entities)
protected ResultPage<E>
entityListToResultPage(List<E> entities, int limit)
Deprecated.protected T
entityToDto(BusinessComponent bc, E entity)
Actions<T>
getActions()
Returns actions for entity with conditions of their availability invoked by method getAvailableActionsList<String>
getAssociatedSsNames()
ActionsDTO
getAvailableActions(RowMetaType metaType, DataResponseDTO data, BusinessComponent bc)
Returns actions for entity with conditions of their availability invoke method getActionsprotected org.springframework.data.jpa.domain.Specification<E>
getBcSpecification(InnerBcDescription bcDescription)
protected javax.persistence.EntityGraph<? super E>
getFetchGraph(BusinessComponent bc)
protected String
getFetchGraphName(BusinessComponent bc)
Class<? extends FieldMetaBuilder<T>>
getFieldMetaBuilder()
Returns FieldMetaBuilder for classprotected org.springframework.data.jpa.domain.Specification<E>
getLinkSpecification(BusinessComponent bc)
ResultPage<T>
getList(BusinessComponent bc)
Returns a list of matched objects based on a business componentprotected ResultPage<T>
getList(BaseDAO dao, BusinessComponent bc)
protected ResultPage<T>
getList(BaseDAO dao, BusinessComponent bc, Class<E> typeOfEntity, Class<T> typeOfDTO)
T
getOne(BusinessComponent bc)
Returns object based on a business componentE
getOneAsEntity(BusinessComponent bc)
Returns an entity based on a business componentprotected ResultPage<E>
getPageEntities(BusinessComponent bc, QueryParameters queryParameters)
protected org.springframework.data.jpa.domain.Specification<E>
getParentSpecification(BusinessComponent bc)
protected List<PreActionEvent>
getPreActionsForSave()
protected org.springframework.data.jpa.domain.Specification<E>
getSecuritySpecification(InnerBcDescription bcDescription)
protected org.springframework.data.jpa.domain.Specification<E>
getSpecification(BusinessComponent bc)
boolean
hasPersister()
Determines whether the service interacts with an entity from the databaseActionResultDTO<T>
invokeAction(BusinessComponent bc, String actionName, DataResponseDTO data)
Invokes action with given name, add preactions, loads or updates entity if necessaryboolean
isDeferredCreationSupported(BusinessComponent bc)
Determines is deferred saving of new objects supportedprotected E
isExist(Long id)
protected E
loadEntity(BusinessComponent bc, DataResponseDTO data)
ActionResultDTO
onCancel(BusinessComponent bc)
Returns actions invoked with cancelActionResultDTO<T>
preview(BusinessComponent bc, DataResponseDTO data)
Updates an entity based on a business component by DTO Used in forceactive fields<V> V
unwrap(Class<V> cls)
ActionResultDTO<T>
updateEntity(BusinessComponent bc, DataResponseDTO data)
Updates an entity based on a business component by DTOvoid
validate(BusinessComponent bc, DataResponseDTO data)
Validates the entry on save-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.tesler.core.service.ResponseService
getTypeOfDTO, getTypeOfEntity
-
-
-
-
Field Detail
-
typeOfDTO
protected final Class<T extends DataResponseDTO> typeOfDTO
-
typeOfEntity
protected final Class<E extends BaseEntity> typeOfEntity
-
parentSpec
protected final javax.persistence.metamodel.SingularAttribute<? super E extends BaseEntity,? extends BaseEntity> parentSpec
-
securitySpecificationHolder
protected Class<? extends SecuritySpecificationHolder<E extends BaseEntity>> securitySpecificationHolder
-
bcSpecificationHolder
protected Class<? extends BcSpecificationHolder<E extends BaseEntity>> bcSpecificationHolder
-
linkSpecificationHolder
protected Class<? extends LinkSpecificationHolder<E extends BaseEntity>> linkSpecificationHolder
-
preActionConditionHolderDataResponse
protected Class<? extends PreActionConditionHolderDataResponse<T extends DataResponseDTO>> preActionConditionHolderDataResponse
-
preActionConditionHolderAssoc
protected Class<? extends PreActionConditionHolderAssoc> preActionConditionHolderAssoc
-
baseDAO
@Autowired protected BaseDAO baseDAO
-
applicationContext
@Autowired protected org.springframework.context.ApplicationContext applicationContext
-
-
Method Detail
-
unwrap
public <V> V unwrap(Class<V> cls)
- Specified by:
unwrap
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
-
isDeferredCreationSupported
public boolean isDeferredCreationSupported(BusinessComponent bc)
Description copied from interface:ResponseService
Determines is deferred saving of new objects supported- Specified by:
isDeferredCreationSupported
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponent
-
hasPersister
public boolean hasPersister()
Description copied from interface:ResponseService
Determines whether the service interacts with an entity from the database- Specified by:
hasPersister
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Returns:
- true/false
-
getOneAsEntity
public E getOneAsEntity(BusinessComponent bc)
Description copied from interface:ResponseService
Returns an entity based on a business component- Specified by:
getOneAsEntity
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponent- Returns:
BaseEntity
entity
-
getOne
@Cacheable(cacheNames="requestCache", key="{#root.targetClass, #root.methodName, #bc.name, #bc.id}") public T getOne(BusinessComponent bc)
Description copied from interface:ResponseService
Returns object based on a business component- Specified by:
getOne
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponent- Returns:
- object
-
doGetOne
protected T doGetOne(BusinessComponent bc)
-
deleteEntity
public ActionResultDTO<T> deleteEntity(BusinessComponent bc)
Description copied from interface:ResponseService
Deletes an entity based on a business component- Specified by:
deleteEntity
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponent- Returns:
ActionResultDTO
class with DataResponseDTO and postactions
-
getList
public ResultPage<T> getList(BusinessComponent bc)
Description copied from interface:ResponseService
Returns a list of matched objects based on a business component- Specified by:
getList
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponent- Returns:
- list of matched objects
-
getList
protected ResultPage<T> getList(BaseDAO dao, BusinessComponent bc)
-
getList
protected final ResultPage<T> getList(BaseDAO dao, BusinessComponent bc, Class<E> typeOfEntity, Class<T> typeOfDTO)
-
getPageEntities
protected final ResultPage<E> getPageEntities(BusinessComponent bc, QueryParameters queryParameters)
-
getFetchGraphName
protected String getFetchGraphName(BusinessComponent bc)
-
getFetchGraph
protected javax.persistence.EntityGraph<? super E> getFetchGraph(BusinessComponent bc)
-
getAvailableActions
public ActionsDTO getAvailableActions(RowMetaType metaType, DataResponseDTO data, BusinessComponent bc)
Description copied from interface:ResponseService
Returns actions for entity with conditions of their availability invoke method getActions- Specified by:
getAvailableActions
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
metaType
- type of metadata
- information about entity, it's changed fields, errorsbc
- businessComponent- Returns:
AssociateResultDTO
class with DataResponseDTO and postactions
-
onCancel
public ActionResultDTO onCancel(BusinessComponent bc)
Description copied from interface:ResponseService
Returns actions invoked with cancel- Specified by:
onCancel
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponent- Returns:
AssociateResultDTO
class with DataResponseDTO and postactions
-
invokeAction
public ActionResultDTO<T> invokeAction(BusinessComponent bc, String actionName, DataResponseDTO data)
Description copied from interface:ResponseService
Invokes action with given name, add preactions, loads or updates entity if necessary- Specified by:
invokeAction
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponentactionName
- name of actiondata
- information about entity, it's changed fields, errors- Returns:
ActionResultDTO
class with DataResponseDTO and postactions
-
count
public long count(BusinessComponent bc)
Description copied from interface:ResponseService
Returns the number of matching entities- Specified by:
count
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponent- Returns:
- count
-
count
protected long count(BaseDAO dao, BusinessComponent bc)
-
count
protected final long count(BaseDAO dao, BusinessComponent bc, Class<E> typeOfEntity, Class<T> typeOfDTO)
-
validate
public void validate(BusinessComponent bc, DataResponseDTO data)
Description copied from interface:ResponseService
Validates the entry on save- Specified by:
validate
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponentdata
- information about entity, it's changed fields, errors
-
getActions
public Actions<T> getActions()
Description copied from interface:ResponseService
Returns actions for entity with conditions of their availability invoked by method getAvailableActions- Specified by:
getActions
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Returns:
AssociateResultDTO
class with DataResponseDTO and postactions
-
getPreActionsForSave
protected List<PreActionEvent> getPreActionsForSave()
-
entitiesToDtos
protected ResultPage<T> entitiesToDtos(BusinessComponent bc, ResultPage<E> entities)
-
entityToDto
protected T entityToDto(BusinessComponent bc, E entity)
-
entityListToResultPage
@Deprecated protected ResultPage<E> entityListToResultPage(List<E> entities, int limit)
Deprecated.deprecated, the hasNext formation logic has been moved to the DAO layer Left for custom DAOs that return List instead of ResultPage
-
dtoListToResultPage
protected ResultPage<T> dtoListToResultPage(List<T> dtos, int limit)
-
getParentSpecification
protected org.springframework.data.jpa.domain.Specification<E> getParentSpecification(BusinessComponent bc)
-
loadEntity
protected E loadEntity(BusinessComponent bc, DataResponseDTO data)
-
getFieldMetaBuilder
public Class<? extends FieldMetaBuilder<T>> getFieldMetaBuilder()
Description copied from interface:ResponseService
Returns FieldMetaBuilder for class- Specified by:
getFieldMetaBuilder
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Returns:
FieldMetaBuilder
class for building field meta
-
updateEntity
public ActionResultDTO<T> updateEntity(BusinessComponent bc, DataResponseDTO data)
Description copied from interface:ResponseService
Updates an entity based on a business component by DTO- Specified by:
updateEntity
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponentdata
- information about entity, it's changed fields, errors- Returns:
ActionResultDTO
class with DataResponseDTO and postactions
-
preview
public ActionResultDTO<T> preview(BusinessComponent bc, DataResponseDTO data)
Description copied from interface:ResponseService
Updates an entity based on a business component by DTO Used in forceactive fields- Specified by:
preview
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponentdata
- information about entity, it's changed fields, errors- Returns:
ActionResultDTO
class with DataResponseDTO and postactions
-
createEntity
public CreateResult<T> createEntity(BusinessComponent bc)
Description copied from interface:ResponseService
Creates an entity based on a business component- Specified by:
createEntity
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
bc
- businessComponent- Returns:
CreateResult
class with DataResponseDTO and postactions
-
associate
public AssociateResultDTO associate(List<AssociateDTO> data, BusinessComponent bc)
Description copied from interface:ResponseService
Сreates links between entities- Specified by:
associate
in interfaceResponseService<T extends DataResponseDTO,E extends BaseEntity>
- Parameters:
data
- information about an entity, whether the entity was associatedbc
- businessComponent- Returns:
AssociateResultDTO
class with DataResponseDTO and postactions
-
doAssociate
protected AssociateResultDTO doAssociate(List<AssociateDTO> data, BusinessComponent bc)
-
getSpecification
protected org.springframework.data.jpa.domain.Specification<E> getSpecification(BusinessComponent bc)
-
getSecuritySpecification
protected org.springframework.data.jpa.domain.Specification<E> getSecuritySpecification(InnerBcDescription bcDescription)
-
getBcSpecification
protected org.springframework.data.jpa.domain.Specification<E> getBcSpecification(InnerBcDescription bcDescription)
-
getLinkSpecification
protected org.springframework.data.jpa.domain.Specification<E> getLinkSpecification(BusinessComponent bc)
-
-