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 Details

  • Constructor Details

    • BaseServiceAbstract

      public BaseServiceAbstract()
  • Method Details

    • getEmptyModel

      public M getEmptyModel()
    • getEmptyCriteria

      public C getEmptyCriteria()
    • get

      public List<M> get(List<I> ids, U user)
    • get

      public List<M> get(C criteria, U user)
      get all data match with given criteria
    • getOne

      public M getOne(C criteria, U user)
      Returns:
      one entity with given criteria
    • delete

      @Transactional public long delete(C criteria, U user)
    • delete

      @Transactional public long delete(List<I> ids, U user)
    • delete

      @Transactional public long delete(I id, U user)
      delete data with given id
      Specified by:
      delete in interface BaseService<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
    • preDelete

      protected void preDelete(M model, U user)
      execute before deleting data
    • postDelete

      protected void postDelete(M deletedModel, U user)
      execute after deleting data
    • save

      @Transactional public M save(D dto, U user)
      save new data
      Specified by:
      save in interface BaseService<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
    • onSave

      protected abstract M onSave(D dto, U user)
      converting dto to model for save
    • preSave

      protected void preSave(D dto, U user)
    • postSave

      protected void postSave(M savedModel, D dto, U user)
    • update

      @Transactional public M update(I id, D dto, U user)
      Specified by:
      update in interface BaseService<M extends BaseModelAbstract<I>,C extends BaseCriteriaAbstract<I>,D,R extends BaseRepository<M,C,I,U>,I extends Comparable<? super I>>
    • onUpdate

      protected abstract M onUpdate(D dto, M previousModel, U user)
    • preUpdate

      protected void preUpdate(M previousModel, D dto, U user)
    • postUpdate

      protected void postUpdate(M updatedModel, D dto, U user)
    • getIds

      public List<I> getIds(C criteria, U user)
    • getCount

      public long getCount(C criteria, U user)
    • isExist

      public boolean isExist(C criteria, U user)
    • isNotExist

      public boolean isNotExist(C criteria, U user)
    • 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:
      get in interface BaseService<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)
    • postFetch

      protected M postFetch(M model, U user)
    • get

      public final M get(I id, U user)
      get by id
      Specified by:
      get in interface BaseService<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)
    • getAll

      public List<M> getAll(U user)