Class GenericHandler

    • Field Detail

      • LOG

        protected static final org.slf4j.Logger LOG
    • Constructor Detail

      • GenericHandler

        public GenericHandler()
    • Method Detail

      • getAllBy

        public <T extends ITransferableEntity,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding> List<T> getAllBy​(Class<T> entityClass,
                                                                                                                                                                                                                                                                                                                       UserContext uc,
                                                                                                                                                                                                                                                                                                                       C cm)
        Gets the all by.
        Specified by:
        getAllBy in interface IGenericHandler
        Type Parameters:
        T - the generic type
        Parameters:
        entityClass - the entity class
        uc - the uc
        cm - the qcm
        Returns:
        the all by @
      • getBy

        public <T extends ITransferableEntity,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding> T getBy​(Class<T> entityClass,
                                                                                                                                                                                                                                                                                                              UserContext uc,
                                                                                                                                                                                                                                                                                                              C cm)
        Gets the by.
        Specified by:
        getBy in interface IGenericHandler
        Type Parameters:
        T - the generic type
        Parameters:
        entityClass - the entity class
        uc - the uc
        cm - the qcm
        Returns:
        the by @
      • getById

        public <T extends ITransferableEntity> T getById​(Class<T> entityClass,
                                                         UserContext uc,
                                                         Long id)
        Gets the by id.
        Specified by:
        getById in interface IGenericHandler
        Type Parameters:
        T - the generic type
        Parameters:
        entityClass - the entity class
        uc - the uc
        id - the id
        Returns:
        the by id @
      • getAttributes

        public <T extends ITransferableEntity,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> List<Map<String,​Serializable>> getAttributes​(Class<T> entityClass,
                                                                                                                                                                                                                                                                                                                                                                                                                      UserContext uc,
                                                                                                                                                                                                                                                                                                                                                                                                                      C cm)
                                                                                                                                                                                                                                                                                                                                                                                                               throws NotSerializableException
        Gets a list of attributes specified in the given criteria manager C
        Specified by:
        getAttributes in interface IGenericHandler
        Type Parameters:
        T - type of the entity
        C - type of the criteria manager
        Parameters:
        entityClass - The class of the entity
        uc - A UserContext that will be used
        cm - A criteria manager specifying the filtering, sorting, paging and selection of attributes
        Returns:
        List of Tuples containing the attribute values
        Throws:
        NotSerializableException - When any of the requested entity fields are not serializable.
      • getAttributes

        public <R,​T extends ITransferableEntity,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> List<R> getAttributes​(Class<T> entityClass,
                                                                                                                                                                                                                                                                                                                                                                                                 UserContext uc,
                                                                                                                                                                                                                                                                                                                                                                                                 C cm,
                                                                                                                                                                                                                                                                                                                                                                                                 Class<R> resultClass)
        Gets a list of attributes specified in the given criteria manager. the attribute values will be returned as objects defined by the result class
        Specified by:
        getAttributes in interface IGenericHandler
        Type Parameters:
        R - type of result object
        T - type of the entity
        C - type of the criteria manager
        Parameters:
        entityClass - Class of the entity
        uc - UserContext that will be used
        cm - A criteria manager specifying the filtering, sorting, paging and selection of attributes
        resultClass - Class of the result objects
        Returns:
        A list of results containing the attribute values
      • getSingleAttributes

        public <T extends ITransferableEntity,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> javax.persistence.Tuple getSingleAttributes​(Class<T> entityClass,
                                                                                                                                                                                                                                                                                                                                                                                                               UserContext uc,
                                                                                                                                                                                                                                                                                                                                                                                                               C cm)
        This method allows for the selection of certain attributes of an entity instead of reading the entire entity
        Specified by:
        getSingleAttributes in interface IGenericHandler
        Type Parameters:
        T - type of entity
        C - type of the criteria manager
        Parameters:
        entityClass - Class the class of the searched entity
        uc - UserContext which will be used
        cm - A criteria manager object, that contains lists for filtering, sorting and selecting. These lists, if available, are included in the SQL query. This value can be null. The lists contained in the criteria manager can also be null or empty.
        Returns:
        Tuple that contains the values of the selected attributes
      • getSingleAttributes

        public <R,​T extends ITransferableEntity,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding & de.xima.cmn.criteria.interfaces.ISelectableCriteriaManager> R getSingleAttributes​(Class<T> entityClass,
                                                                                                                                                                                                                                                                                                                                                                                                 UserContext uc,
                                                                                                                                                                                                                                                                                                                                                                                                 C cm,
                                                                                                                                                                                                                                                                                                                                                                                                 Class<R> resultClass)
        This method allows for the selection of certain attributes of an entity instead of reading the entire entity
        Specified by:
        getSingleAttributes in interface IGenericHandler
        Type Parameters:
        R - type of object, in which the result values will be placed
        T - type of entity
        C - type of the criteria manager
        Parameters:
        entityClass - Class the class of the searched entity
        uc - UserContext which will be used
        cm - A criteria manager object, that contains lists for filtering, sorting and selecting. These lists, if available, are included in the SQL query. This value can be null. The lists contained in the criteria manager can also be null or empty.
        resultClass - Class of the object, in which the result value will be placed
        Returns:
        A result that contains the values of the selected attributes
      • create

        public <T extends ITransferableEntity> T[] create​(Class<T> entityClass,
                                                          UserContext uc,
                                                          T... entities)
        Creates the.
        Specified by:
        create in interface IGenericHandler
        Type Parameters:
        T - the generic type
        Parameters:
        entityClass - the entity class
        uc - the uc
        entities - the entities
        Returns:
        the t[] @
      • create

        public <T extends ITransferableEntity> T create​(Class<T> entityClass,
                                                        UserContext uc,
                                                        T entity)
        Creates the.
        Specified by:
        create in interface IGenericHandler
        Type Parameters:
        T - the generic type
        Parameters:
        entityClass - the entity class
        uc - the uc
        entity - the entity
        Returns:
        the t @
      • update

        public <T extends ITransferableEntity> T[] update​(Class<T> entityClass,
                                                          UserContext uc,
                                                          T... entities)
        Update.
        Specified by:
        update in interface IGenericHandler
        Type Parameters:
        T - the generic type
        Parameters:
        entityClass - the entity class
        uc - the uc
        entities - the entities
        Returns:
        the t[] @
      • update

        public <T extends ITransferableEntity> T update​(Class<T> entityClass,
                                                        UserContext uc,
                                                        T entity)
        Update.
        Specified by:
        update in interface IGenericHandler
        Type Parameters:
        T - the generic type
        Parameters:
        entityClass - the entity class
        uc - the uc
        entity - the entity
        Returns:
        the t @
      • delete

        public <T extends ITransferableEntityBoolean delete​(Class<T> entityClass,
                                                              UserContext uc,
                                                              T... entities)
        Delete.
        Specified by:
        delete in interface IGenericHandler
        Type Parameters:
        T - the generic type
        Parameters:
        entityClass - the entity class
        uc - the uc
        entities - the entities
        Returns:
        the boolean @
      • delete

        public <T extends ITransferableEntityBoolean delete​(Class<T> entityClass,
                                                              UserContext uc,
                                                              T entities)
        Delete.
        Specified by:
        delete in interface IGenericHandler
        Type Parameters:
        T - the generic type
        Parameters:
        entityClass - the entity class
        uc - the uc
        entities - the entities
        Returns:
        the boolean @
      • deleteBy

        public <T extends ITransferableEntity,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.ISortableCriteriaManager & de.xima.cmn.criteria.interfaces.IPageableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding> Boolean deleteBy​(Class<T> entityClass,
                                                                                                                                                                                                                                                                                                                       UserContext uc,
                                                                                                                                                                                                                                                                                                                       C cm)
        Delete by.
        Specified by:
        deleteBy in interface IGenericHandler
        Type Parameters:
        T - the generic type
        Parameters:
        entityClass - the entity class
        uc - the uc
        cm - the qcm
        Returns:
        the boolean @
      • resultTotalCount

        public <T extends ITransferableEntity,​C extends de.xima.cmn.criteria.interfaces.IFilterableCriteriaManager & de.xima.cmn.criteria.interfaces.IQueryHintProviding> Integer resultTotalCount​(Class<T> entityClass,
                                                                                                                                                                                                         UserContext uc,
                                                                                                                                                                                                         C cm)
        Result total count.
        Specified by:
        resultTotalCount in interface IGenericHandler
        Type Parameters:
        T - the generic type
        Parameters:
        entityClass - the entity class
        uc - the uc
        cm - the qcm
        Returns:
        the integer @
      • serializableList

        protected <T> List<T> serializableList​(Iterable<T> sequence)
        Takes any Collection or Iterable and converts it to a serializable list that can be transferred via the API.
        Type Parameters:
        T - Type of the list items.
        Parameters:
        sequence - A sequence of items to put into a list.
        Returns:
        A serializable list with the given items.