DefaultMotechDataService

public abstract class DefaultMotechDataService<T> implements MotechDataService<T>

This is a basic implementation of org.motechproject.mds.service.MotechDataService. Mainly it is used as super class to create a service related with the given entity schema in org.motechproject.mds.builder.EntityInfrastructureBuilder but it can be also used by other services inside this package.

Parameters:
  • <T> – the type of entity schema.

Methods

count

public long count()

count

protected long count(List<Property> properties)

countForFilter

public long countForFilter(Filter filter)

create

public T create(T object)

delete

public void delete(T object)

delete

public void delete(String primaryKeyName, Object value)

deleteAll

public void deleteAll()

doInTransaction

public <R> R doInTransaction(TransactionCallback<R> transactionCallback)

executeQuery

public <R> R executeQuery(QueryExecution<R> queryExecution)

filter

public List<T> filter(Filter filter)

filter

public List<T> filter(Filter filter, QueryParams queryParams)

findById

public T findById(Long id)

findTrashInstanceById

public T findTrashInstanceById(Object instanceId, Object entityId)

getDetachedField

public Object getDetachedField(T instance, String fieldName)

getId

protected Object getId(T instance)

getRepository

protected MotechDataRepository<T> getRepository()

initializeSecurityState

public void initializeSecurityState()

retrieve

public T retrieve(String primaryKeyName, Object value)

retrieveAll

public List<T> retrieveAll()

retrieveAll

public List<T> retrieveAll(QueryParams queryParams)

retrieveAll

protected List<T> retrieveAll(List<Property> properties)

retrieveAll

protected List<T> retrieveAll(List<Property> properties, QueryParams queryParams)

revertFromTrash

public void revertFromTrash(Object newInstance, Object trash)

setAllEntities

public void setAllEntities(AllEntities allEntities)

setEntityService

public void setEntityService(EntityService entityService)

setHistoryService

public void setHistoryService(HistoryService historyService)

setRepository

public void setRepository(MotechDataRepository<T> repository)

setTransactionManager

public void setTransactionManager(JdoTransactionManager transactionManager)

setTrashService

public void setTrashService(TrashService trashService)

update

public T update(T object)

validateCredentials

protected InstanceSecurityRestriction validateCredentials()

validateCredentials

protected InstanceSecurityRestriction validateCredentials(T instance)