Interface UserGroupAssoRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<UserGroupAsso,
,UserGroupId> org.springframework.data.jpa.repository.JpaRepository<UserGroupAsso,
,UserGroupId> org.springframework.data.repository.ListCrudRepository<UserGroupAsso,
,UserGroupId> org.springframework.data.repository.ListPagingAndSortingRepository<UserGroupAsso,
,UserGroupId> org.springframework.data.repository.PagingAndSortingRepository<UserGroupAsso,
,UserGroupId> org.springframework.data.repository.query.QueryByExampleExecutor<UserGroupAsso>
,org.springframework.data.repository.Repository<UserGroupAsso,
UserGroupId>
public interface UserGroupAssoRepository
extends org.springframework.data.jpa.repository.JpaRepository<UserGroupAsso,UserGroupId>
Repository interface for the UserGroupAsso association entity
- Version:
- 1.3
- Author:
- Pedro, Birk, Anders
-
Method Summary
Modifier and TypeMethodDescriptioncreateConnectionAfterCreateGroup
(String username, long groupId) Creates a new user-group association with the specified user and group IDs and assigns the user as the primary group administrator with ADMIN authority.findAllByGroup
(Group group) Retrieves a list of UserGroupAsso objects for the specified Group object.findAllByGroupAndUser
(Group group, User user) Finds all UserGroupAsso objects associated with the specified group and user.findAllByUserUsername
(String username) Finds all groups a user is a member offindAuthorityByUser_UsernameAndGroup_GroupId
(String username, long groupId) Finds the authority level of a user in a groupfindByUser_UsernameAndPrimaryGroupTrue
(String username) Finds primary group for given userfindByUserGroupId
(UserGroupId userGroupId) Finds UserGroupAsso by UserGroupIdfindFirstByUserAndPrimaryGroup
(User user, boolean primaryGroup) Finds the first UserGroupAsso object associated with the specified user and primary group status.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save
Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush
Methods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAll
Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAll
Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAll
Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
createConnectionAfterCreateGroup
@Query(value="insert into user_group (\'username\', \'group_id\', \'primary_group\',\'group_authority\') values (:username , :groupId , TRUE , \'ADMIN\')", nativeQuery=true) Optional<Group> createConnectionAfterCreateGroup(String username, long groupId) Creates a new user-group association with the specified user and group IDs and assigns the user as the primary group administrator with ADMIN authority.- Parameters:
username
- the username of the user to add to the groupgroupId
- the ID of the group to add the user to- Returns:
- an Optional containing the Group object for the newly created user-group association, or an empty Optional if the operation failed
-
findAllByGroup
Retrieves a list of UserGroupAsso objects for the specified Group object.- Parameters:
group
- the Group object to retrieve information for- Returns:
- a List of UserGroupAsso objects for the specified Group object
-
findAllByGroupAndUser
Finds all UserGroupAsso objects associated with the specified group and user.- Parameters:
group
- the group for which to find the user-group associationsuser
- the user for which to find the user-group associations- Returns:
- an optional object containing a list of UserGroupAsso objects associated with the specified group and user, or an empty optional if no such user-group associations exist in the database
-
findFirstByUserAndPrimaryGroup
Finds the first UserGroupAsso object associated with the specified user and primary group status.- Parameters:
user
- the user for which to find the user-group associationprimaryGroup
- the primary group status for which to find the user-group association- Returns:
- an optional object containing the first UserGroupAsso object associated with the specified user and primary group status, or an empty optional if no such user-group associations exist in the database
-
findByUserGroupId
Finds UserGroupAsso by UserGroupId- Parameters:
userGroupId
- the UserGroupId to find by- Returns:
- an optional containing the UserGroupAsso if it exists
-
findByUser_UsernameAndPrimaryGroupTrue
Finds primary group for given user- Parameters:
username
- the username of the user- Returns:
- an optional containing the UserGroupAsso if it exists
-
findAuthorityByUser_UsernameAndGroup_GroupId
Finds the authority level of a user in a group- Parameters:
username
- the username of the usergroupId
- the id of the group- Returns:
- the authority level of the user in the group
-
findAllByUserUsername
Finds all groups a user is a member of- Parameters:
username
- the username of the user- Returns:
- a list of all groups the user is a member of
-