@DeclareRoles(value="editor") public abstract class AbstractCrudService extends Object implements CrudReadService, CrudWriteService
This base class enables you to create minimal crud service beans. All you have to do is override, implement getEntityManager and add annotation @Stateless, @Local(CrudReadService.class, CrudWriteService.class).
Inject the crud interfaces using @Inject in your frontend (problems with inhertitance and @EJB).
This base class declares appropriate transactions and an EDITOR role to protect write operations.
An injected JpqlBuilder is used for building where and order by clauses in dynamic queries, i.e. used in
findPaged(int, int, java.util.Map, java.util.List, java.lang.Class) and
find(java.util.Map, java.util.List, java.lang.Integer, java.lang.Class). The JpqlBuilder is also used for setting parameter values.CrudReadService.SORTORDER| Modifier and Type | Field and Description |
|---|---|
static String |
EDITOR |
static int |
MAX_RESULT_AUTOCOMPLETE |
| Constructor and Description |
|---|
AbstractCrudService() |
| Modifier and Type | Method and Description |
|---|---|
<T extends EntityInterface> |
autoComplete(String namedQuery,
String paramName,
String paramValue,
Integer max,
Class<T> type) |
int |
count(List<Param> params,
Class type) |
<T extends EntityInterface> |
createOrUpdate(T t) |
void |
delete(EntityInterface t) |
<T extends EntityInterface> |
find(Map<String,CrudReadService.SORTORDER> sort,
List<Param> params,
Integer max,
Class<T> type) |
<T extends EntityInterface> |
find(Serializable id,
Class<T> type) |
<T extends EntityInterface> |
find(String namedQuery,
List<Param> params,
Integer max,
Class<T> type) |
<T extends EntityInterface> |
findAll(Class<T> type) |
<T extends EntityInterface> |
findOne(String namedQuery,
List<Param> params,
Class<T> type) |
<T extends EntityInterface> |
findOne(String namedQuery,
String paramName,
Object paramValue,
Class<T> type) |
<T extends EntityInterface> |
findPaged(int first,
int pageSize,
Map<String,CrudReadService.SORTORDER> sort,
List<Param> params,
Class<T> type) |
protected abstract javax.persistence.EntityManager |
getEntityManager() |
<T extends EntityInterface> |
getRevision(Number n,
Class<T> type)
get historical data for a certain revision
|
<T extends EntityInterface> |
getRevisionInfo(T entity,
Integer max,
Class<T> type)
return a list holding revision information, newest come first
|
<T extends EntityInterface> |
getRevisionNumbers(Object id,
Class<T> type)
return list of revision numbers, first is the oldest
|
public static final int MAX_RESULT_AUTOCOMPLETE
public static final String EDITOR
protected abstract javax.persistence.EntityManager getEntityManager()
public <T extends EntityInterface> T find(Serializable id, Class<T> type)
find in interface CrudReadServicepublic <T extends EntityInterface> List<T> findAll(Class<T> type)
findAll in interface CrudReadServicepublic <T extends EntityInterface> List<T> findPaged(int first, int pageSize, Map<String,CrudReadService.SORTORDER> sort, List<Param> params, Class<T> type)
findPaged in interface CrudReadServicepublic <T extends EntityInterface> List<T> find(Map<String,CrudReadService.SORTORDER> sort, List<Param> params, Integer max, Class<T> type)
find in interface CrudReadServicepublic <T extends EntityInterface> List<T> find(String namedQuery, List<Param> params, Integer max, Class<T> type)
find in interface CrudReadServicepublic <T extends EntityInterface> List<T> autoComplete(String namedQuery, String paramName, String paramValue, Integer max, Class<T> type)
autoComplete in interface CrudReadServicepublic <T extends EntityInterface> T findOne(String namedQuery, List<Param> params, Class<T> type)
findOne in interface CrudReadServicepublic <T extends EntityInterface> T findOne(String namedQuery, String paramName, Object paramValue, Class<T> type)
findOne in interface CrudReadServicepublic int count(List<Param> params, Class type)
count in interface CrudReadServicepublic <T extends EntityInterface> T getRevision(Number n, Class<T> type)
CrudReadServicegetRevision in interface CrudReadServicepublic <T extends EntityInterface> List<RevInfo<T>> getRevisionInfo(T entity, Integer max, Class<T> type)
CrudReadServicegetRevisionInfo in interface CrudReadServicemax - the maximum to number of results to return, defaults to 5@RolesAllowed(value="editor") public <T extends EntityInterface> T createOrUpdate(T t)
createOrUpdate in interface CrudWriteService@RolesAllowed(value="editor") public void delete(EntityInterface t)
delete in interface CrudWriteServicepublic <T extends EntityInterface> List<Number> getRevisionNumbers(Object id, Class<T> type)
CrudReadServicegetRevisionNumbers in interface CrudReadServiceCopyright © 2018 Fryske Akademy. All rights reserved.