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)

countForFilters

public long countForFilters(Filters filters)

create

public T create(T object)

createOrUpdate

public T createOrUpdate(T object)

delete

public void delete(T object)

delete

public void delete(String primaryKeyName, Object value)

deleteAll

public void deleteAll()

deleteById

public void deleteById(long id)

doInTransaction

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

evictAllCache

public void evictAllCache()

evictCacheForInstance

public void evictCacheForInstance(T instance)

evictEntityCache

public void evictEntityCache(boolean withSubclasses)

executeQuery

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

executeSQLQuery

public <R> R executeSQLQuery(SqlQueryExecution<R> queryExecution)

filter

public List<T> filter(Filters filters, QueryParams queryParams)

findById

public T findById(Long id)

findTrashInstanceById

public T findTrashInstanceById(Object instanceId, Object entityId)

getClassType

public Class<T> getClassType()

getDetachedField

public Object getDetachedField(T instance, String fieldName)

getId

protected Object getId(T instance)

getLogger

protected Logger getLogger()

getRepository

protected MotechDataRepository<T> getRepository()

getVersionFieldName

public String getVersionFieldName()

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)

setHistoryService

public void setHistoryService(HistoryService historyService)

setOsgiEventProxy

public void setOsgiEventProxy(OsgiEventProxy osgiEventProxy)

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)

updateFromTransient

public T updateFromTransient(T transientObject)

updateFromTransient

public T updateFromTransient(T transientObject, Set<String> fieldsToUpdate)

validateCredentials

protected InstanceSecurityRestriction validateCredentials()

validateCredentials

protected InstanceSecurityRestriction validateCredentials(T instance)