public abstract class AbstractCrudService<E extends PersistentObject,D extends GenericHibernateDao<E,Integer>> extends AbstractDaoService<E,D>
AbstractDaoServicedao, logger| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCrudService(Class<E> entityClass)
Constructor that sets the concrete entity class for the service.
|
| Modifier and Type | Method and Description |
|---|---|
void |
delete(E e) |
List<E> |
findAll() |
List<E> |
findAllRestricted(org.springframework.util.MultiValueMap<String,String> restrictToRequest)
Returns all entities, but possibly with only the passed fields set with actual values.
|
List<E> |
findAllWhereFieldEquals(String fieldName,
Object fieldValue)
Returns a list of entity objects that have field named
fieldName, which has an object fieldEntity
as value. |
List<E> |
findAllWithCollectionContaining(String fieldName,
PersistentObject subElement)
Returns a list of entity objects that have a collection named
fieldName, which contains the passed
subElement. |
E |
findById(Integer id)
Return the real object from the database.
|
List<E> |
findBySimpleFilter(org.springframework.util.MultiValueMap<String,String> requestedFilter)
Finds all entities that match the given filter (multi value map).
|
E |
loadById(int id)
Return a proxy of the object (without hitting the database).
|
void |
saveOrUpdate(E e) |
E |
updatePartialWithJsonNode(E entity,
com.fasterxml.jackson.databind.JsonNode jsonObject,
com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
getDao, getEntityClass, setDao@PreAuthorize(value="hasRole(@configHolder.getSuperAdminRoleName()) or (#e.id == null and hasPermission(#e, \'CREATE\')) or (#e.id != null and hasPermission(#e, \'UPDATE\'))") public void saveOrUpdate(E e)
e - @PreAuthorize(value="hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(#entity, \'UPDATE\')") public E updatePartialWithJsonNode(E entity, com.fasterxml.jackson.databind.JsonNode jsonObject, com.fasterxml.jackson.databind.ObjectMapper objectMapper) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
jsonObject - entity - IOExceptioncom.fasterxml.jackson.core.JsonProcessingException@PostAuthorize(value="hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(returnObject, \'READ\')") @Transactional(readOnly=true) public E findById(Integer id)
id - @PostAuthorize(value="hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(returnObject, \'READ\')") @Transactional(readOnly=true) public E loadById(int id)
id - @PostFilter(value="hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(filterObject, \'READ\')") @Transactional(readOnly=true) public List<E> findAll()
@PostFilter(value="hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(filterObject, \'READ\')") public List<E> findAllRestricted(org.springframework.util.MultiValueMap<String,String> restrictToRequest)
@PostFilter(value="hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(filterObject, \'READ\')") @Transactional(readOnly=true) public List<E> findBySimpleFilter(org.springframework.util.MultiValueMap<String,String> requestedFilter)
Each key in the multi value map is the name of a field/property of the entity. These values may be case insensitive! Each field name is mapped to a list of values (passed as Strings).
Fields that do not exist in the entity will be ignored.
Example:
int=['1','2'] string=['foo'] bool1=['0'] bool2=['true']
would be translated to a filter like (values are casted to the target type of the field)
(int == 1 || int == 2) && (string == 'foo') && (bool1 == false) && (bool2 == true)
and return all entities that match this condition.
This will only work on simple properties of an entity.
The optional special key can contain a
comma separated list of fieldNames you want to be filled with actual values. If you
e.g. pass output:only=id,Name, the returned object will have all other
fields being set to null, except for id and name (Notice
how casing does not matter).
requestedFilter - @PostFilter(value="hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(filterObject, \'READ\')") @Transactional(readOnly=true) public List<E> findAllWhereFieldEquals(String fieldName, Object fieldValue)
fieldName, which has an object fieldEntity
as value.fieldName - The name of the fieldfieldValue - The element that should be set as value@PostFilter(value="hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(filterObject, \'READ\')") @Transactional(readOnly=true) public List<E> findAllWithCollectionContaining(String fieldName, PersistentObject subElement)
fieldName, which contains the passed
subElement.
The can e.g. be used to return all applications that contain a certain layer.
fieldName - The name of the collection fieldsubElement - The element that should be contained in the collection@PreAuthorize(value="hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(#e, \'DELETE\')") public void delete(E e)
e - Copyright © 2020 terrestris GmbH & Co. KG. All rights reserved.