Package org.bardframework.crud.api.base
Class BaseServiceAbstract<M extends BaseModelAbstract<I>,C extends BaseCriteriaAbstract<I>,D,R extends BaseRepository<M,C,I,U>,I extends Comparable<? super I>,U>
- java.lang.Object
-
- org.bardframework.crud.api.base.BaseServiceAbstract<M,C,D,R,I,U>
-
- All Implemented Interfaces:
BaseService<M,C,D,I,U>
public abstract class BaseServiceAbstract<M extends BaseModelAbstract<I>,C extends BaseCriteriaAbstract<I>,D,R extends BaseRepository<M,C,I,U>,I extends Comparable<? super I>,U> extends Object implements BaseService<M,C,D,I,U>
Created by vahid on 1/17/17.
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<C>criteriaClazzprotected org.slf4j.LoggerLOGGERprotected Class<M>modelClazzprotected Rrepository
-
Constructor Summary
Constructors Constructor Description BaseServiceAbstract()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description longdelete(C criteria, U user)longdelete(I id, U user)delete data with given idlongdelete(List<I> ids, U user)org.springframework.data.domain.Page<M>get(C criteria, org.springframework.data.domain.Pageable pageable, U user)List<M>get(C criteria, U user)get all data match with givencriteriaMget(I id, U user)get by idList<M>get(List<I> ids, U user)List<M>getAll(U user)longgetCount(C criteria, U user)CgetEmptyCriteria()MgetEmptyModel()List<I>getIds(C criteria, U user)org.slf4j.LoggergetLogger()MgetOne(C criteria, U user)RgetRepository()booleanisExist(C criteria, U user)booleanisNotExist(C criteria, U user)protected abstract MonSave(D dto, U user)converting dto to model for saveprotected abstract MonUpdate(D dto, M previousModel, U user)protected org.springframework.data.domain.Page<M>paging(List<M> list, org.springframework.data.domain.Pageable pageable, LongSupplier supplier)protected voidpostDelete(M deletedModel, U user)execute after deleting dataprotected MpostFetch(M model, U user)protected org.springframework.data.domain.Page<M>postFetch(org.springframework.data.domain.Page<M> page, org.springframework.data.domain.Pageable pageable, U user)protected voidpostSave(M savedModel, D dto, U user)protected voidpostUpdate(M updatedModel, D dto, U user)protected voidpreDelete(M model, U user)execute before deleting dataprotected voidpreSave(D dto, U user)protected voidpreUpdate(M previousModel, D dto, U user)Msave(D dto, U user)save new dataList<M>save(List<D> dtos, U user)save new dataMupdate(I id, D dto, U user)
-
-
-
Field Detail
-
LOGGER
protected final org.slf4j.Logger LOGGER
-
modelClazz
protected final Class<M extends BaseModelAbstract<I>> modelClazz
-
criteriaClazz
protected final Class<C extends BaseCriteriaAbstract<I>> criteriaClazz
-
-
Method Detail
-
getEmptyModel
public M getEmptyModel()
-
getEmptyCriteria
public C getEmptyCriteria()
-
delete
@Transactional public long delete(I id, U user)
delete data with given id- Specified by:
deletein interfaceBaseService<M extends BaseModelAbstract<I>,C extends BaseCriteriaAbstract<I>,D,R extends BaseRepository<M,C,I,U>,I extends Comparable<? super I>>- Parameters:
id- identifier of data that must be delete- Returns:
- count of deleted data
-
save
@Transactional public M save(D dto, U user)
save new data- Specified by:
savein interfaceBaseService<M extends BaseModelAbstract<I>,C extends BaseCriteriaAbstract<I>,D,R extends BaseRepository<M,C,I,U>,I extends Comparable<? super I>>- Returns:
- saved data model
-
save
@Transactional public List<M> save(List<D> dtos, U user)
save new data- Returns:
- saved data models
-
update
@Transactional public M update(I id, D dto, U user)
- Specified by:
updatein interfaceBaseService<M extends BaseModelAbstract<I>,C extends BaseCriteriaAbstract<I>,D,R extends BaseRepository<M,C,I,U>,I extends Comparable<? super I>>
-
getRepository
public R getRepository()
-
getLogger
public org.slf4j.Logger getLogger()
-
get
public final org.springframework.data.domain.Page<M> get(C criteria, org.springframework.data.domain.Pageable pageable, U user)
- Specified by:
getin interfaceBaseService<M extends BaseModelAbstract<I>,C extends BaseCriteriaAbstract<I>,D,R extends BaseRepository<M,C,I,U>,I extends Comparable<? super I>>
-
postFetch
protected org.springframework.data.domain.Page<M> postFetch(org.springframework.data.domain.Page<M> page, org.springframework.data.domain.Pageable pageable, U user)
-
get
public final M get(I id, U user)
get by id- Specified by:
getin interfaceBaseService<M extends BaseModelAbstract<I>,C extends BaseCriteriaAbstract<I>,D,R extends BaseRepository<M,C,I,U>,I extends Comparable<? super I>>
-
paging
protected org.springframework.data.domain.Page<M> paging(List<M> list, org.springframework.data.domain.Pageable pageable, LongSupplier supplier)
-
-