Class AbstractCrudService<E extends PersistentObject,​D extends GenericHibernateDao<E,​Integer>>

    • Constructor Detail

      • AbstractCrudService

        protected AbstractCrudService​(Class<E> entityClass)
        Constructor that sets the concrete entity class for the service. Subclasses MUST call this constructor.
    • Method Detail

      • saveOrUpdate

        @PreAuthorize("hasRole(@configHolder.getSuperAdminRoleName()) or (#e.id == null and hasPermission(#e, \'CREATE\')) or (#e.id != null and hasPermission(#e, \'UPDATE\'))")
        public void saveOrUpdate​(E e)
        Parameters:
        e -
      • updatePartialWithJsonNode

        @PreAuthorize("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
        Parameters:
        jsonObject -
        entity -
        Returns:
        Throws:
        IOException
        com.fasterxml.jackson.core.JsonProcessingException
      • findById

        @PostAuthorize("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(returnObject, \'READ\')")
        @Transactional(readOnly=true)
        public E findById​(Integer id)
        Return the real object from the database. Returns null if the object does not exist.
        Parameters:
        id -
      • loadById

        @PostAuthorize("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(returnObject, \'READ\')")
        @Transactional(readOnly=true)
        public E loadById​(int id)
        Return a proxy of the object (without hitting the database). This should only be used if it is assumed that the object really exists and where non-existence would be an actual error.
        Parameters:
        id -
      • findAll

        @PostFilter("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(filterObject, \'READ\')")
        @Transactional(readOnly=true)
        public List<E> findAll()
      • findAllRestricted

        @PostFilter("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(filterObject, \'READ\')")
        public List<E> findAllRestricted​(org.springframework.util.MultiValueMap<String,​String> restrictToRequest)
        Returns all entities, but possibly with only the passed fields set with actual values.
      • findBySimpleFilter

        @PostFilter("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(filterObject, \'READ\')")
        @Transactional(readOnly=true)
        public List<E> findBySimpleFilter​(org.springframework.util.MultiValueMap<String,​String> requestedFilter)
        Finds all entities that match the given filter (multi value map).

        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 "output:only" 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).

        Parameters:
        requestedFilter -
        Returns:
      • findAllWhereFieldEquals

        @PostFilter("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(filterObject, \'READ\')")
        @Transactional(readOnly=true)
        public 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.
        Parameters:
        fieldName - The name of the field
        fieldValue - The element that should be set as value
        Returns:
        The list of objects
      • findAllWithCollectionContaining

        @PostFilter("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(filterObject, \'READ\')")
        @Transactional(readOnly=true)
        public List<E> findAllWithCollectionContaining​(String fieldName,
                                                       PersistentObject subElement)
        Returns a list of entity objects that have a collection named fieldName, which contains the passed subElement.

        The can e.g. be used to return all applications that contain a certain layer.

        Parameters:
        fieldName - The name of the collection field
        subElement - The element that should be contained in the collection
        Returns:
        The list of objects
      • delete

        @PreAuthorize("hasRole(@configHolder.getSuperAdminRoleName()) or hasPermission(#e, \'DELETE\')")
        public void delete​(E e)
        Parameters:
        e -