Groups
Repository
The GroupsRepository
interface is
useful to manage the queries for the groups
Author
N7ghtm4r3 - Tecknobit
See also
JpaRepository
Functions
Link copied to clipboard
@Modifying(clearAutomatically = true
)
@Query(value = "INSERT INTO " + PROJECTS_GROUPS_TABLE + "("
+ PROJECT_IDENTIFIER_KEY + ","
+ GROUP_IDENTIFIER_KEY
+ ") VALUES ("
+ ":" + PROJECT_IDENTIFIER_KEY + ","
+ ":" + GROUP_IDENTIFIER_KEY + ")",
nativeQuery = true
)
Method to execute the query to add a project
to a group
Link copied to clipboard
@Modifying(clearAutomatically = true
)
@Query(value = "INSERT INTO " + GROUPS_KEY
+ "( "
+ IDENTIFIER_KEY + ","
+ NAME_KEY + ","
+ GROUP_LOGO_KEY + ","
+ CREATION_DATE_KEY + ","
+ GROUP_DESCRIPTION_KEY + ","
+ AUTHOR_KEY + ") VALUES "
+ "( "
+ ":" + IDENTIFIER_KEY + ","
+ ":" + NAME_KEY + ","
+ ":" + GROUP_LOGO_KEY + ","
+ ":" + CREATION_DATE_KEY + ","
+ ":" + GROUP_DESCRIPTION_KEY + ","
+ ":" + AUTHOR_KEY + ")",
nativeQuery = true
)
Method to execute the query to create a new
Group
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@Modifying(clearAutomatically = true
)
@Query(value = ""DELETE FROM " + GROUPS_KEY + " WHERE " + GROUPS_KEY + ".id=:" + GROUP_IDENTIFIER_KEY",
nativeQuery = true
)
Method to execute the query to delete an
existing Group
Link copied to clipboard
Link copied to clipboard
@Modifying(clearAutomatically = true
)
@Query(value = ""UPDATE " + GROUPS_KEY + " SET " +
NAME_KEY + "=:" + NAME_KEY + "," +
GROUP_DESCRIPTION_KEY + "=:" + GROUP_DESCRIPTION_KEY +
" WHERE " + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY",
nativeQuery = true
)
@Modifying(clearAutomatically = true
)
@Query(value = ""UPDATE " + GROUPS_KEY + " SET " +
GROUP_LOGO_KEY + "=:" + GROUP_LOGO_KEY + "," +
NAME_KEY + "=:" + NAME_KEY + "," +
GROUP_DESCRIPTION_KEY + "=:" + GROUP_DESCRIPTION_KEY +
" WHERE " + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY",
nativeQuery = true
)
Method to execute the query to edit an
existing Group
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@Query(value = "SELECT * FROM " + GROUPS_KEY +
" WHERE " + AUTHOR_KEY + "=:" + AUTHOR_KEY +
" AND " + NAME_KEY + " LIKE %:" + NAME_KEY + "%" +
" ORDER BY " + CREATION_DATE_KEY + " DESC ",
nativeQuery = true
)
Method to execute the query to select the
list of a Group
where the user is the author of the group
Link copied to clipboard
@Query(value = "SELECT COUNT(*) FROM " + GROUPS_KEY + " WHERE " +
AUTHOR_KEY + "=:" + AUTHOR_KEY +
" AND " + NAME_KEY + " LIKE %:" + NAME_KEY + "%",
nativeQuery = true
)
Method to execute the query to count the
total groups where the user is the author of the group
Link copied to clipboard
@Query(value = ""SELECT " + GROUPS_KEY + ".* FROM " + GROUPS_KEY + " AS " + GROUPS_KEY +
" INNER JOIN " + GROUP_MEMBERS_TABLE + " ON " + GROUPS_KEY + "." + IDENTIFIER_KEY +
" = " + GROUP_MEMBERS_TABLE + "." + GROUP_MEMBER_KEY +
" WHERE " + GROUP_MEMBERS_TABLE + "." + IDENTIFIER_KEY + "=:" + AUTHOR_KEY +
" AND " + GROUPS_KEY + "." + IDENTIFIER_KEY + "=:" + GROUP_IDENTIFIER_KEY",
nativeQuery = true
)
Method to execute the query to select a Group
by its id
Link copied to clipboard
@Query(value = ""SELECT * FROM " + GROUPS_KEY + " WHERE " + AUTHOR_KEY + "=:" + AUTHOR_KEY
+ " AND " + NAME_KEY + "=:" + NAME_KEY",
nativeQuery = true
)
Method to execute the query to select a Group
by its name
Link copied to clipboard
@Modifying(clearAutomatically = true
)
@Query(value = ""SELECT " + PROJECT_IDENTIFIER_KEY + " FROM " + PROJECTS_GROUPS_TABLE + " WHERE "
+ GROUP_IDENTIFIER_KEY + "=:" + GROUP_IDENTIFIER_KEY",
nativeQuery = true
)
Method to execute the query to select the
list of a Project's
id of a group
Link copied to clipboard
@Query(value = "SELECT groups.* FROM " + GROUPS_KEY + " AS groups LEFT JOIN " + GROUP_MEMBERS_TABLE +
" ON groups." + IDENTIFIER_KEY + " = group_members." + GROUP_MEMBER_KEY + " WHERE " +
GROUP_MEMBERS_TABLE + "." + IDENTIFIER_KEY + "=:" + AUTHOR_KEY + " AND " +
GROUP_MEMBERS_TABLE + "." + INVITATION_STATUS_KEY + " = " + "'JOINED'" +
" ORDER BY " + CREATION_DATE_KEY + " DESC ",
nativeQuery = true
)
@Query(value = "SELECT groups.* FROM " + GROUPS_KEY + " AS groups LEFT JOIN " + GROUP_MEMBERS_TABLE +
" ON groups." + IDENTIFIER_KEY + " = group_members." + GROUP_MEMBER_KEY + " WHERE " +
GROUP_MEMBERS_TABLE + "." + IDENTIFIER_KEY + "=:" + AUTHOR_KEY + " AND " +
"groups." + NAME_KEY + " LIKE %:" + NAME_KEY + "%" +
" AND (" +
"COALESCE(:" + ROLES_FILTER_KEY + ") IS NULL" +
" OR " + GROUP_MEMBERS_TABLE + "." + MEMBER_ROLE_KEY + " IN (:" + ROLES_FILTER_KEY + ")" +
") AND " +
GROUP_MEMBERS_TABLE + "." + INVITATION_STATUS_KEY + " = " + "'JOINED'" +
" ORDER BY " + CREATION_DATE_KEY + " DESC ",
nativeQuery = true
)
Method to execute the query to select the
list of a Group
Link copied to clipboard
@Query(value = "SELECT COUNT(*) FROM " + GROUPS_KEY + " AS groups LEFT JOIN " + GROUP_MEMBERS_TABLE +
" ON groups." + IDENTIFIER_KEY + " = group_members." + GROUP_MEMBER_KEY + " WHERE " +
GROUP_MEMBERS_TABLE + "." + IDENTIFIER_KEY + "=:" + AUTHOR_KEY + " AND " +
"groups." + NAME_KEY + " LIKE %:" + NAME_KEY + "%" +
" AND (" +
"COALESCE(:" + ROLES_FILTER_KEY + ") IS NULL" +
" OR " + GROUP_MEMBERS_TABLE + "." + MEMBER_ROLE_KEY + " IN (:" + ROLES_FILTER_KEY + ")" +
") AND " +
GROUP_MEMBERS_TABLE + "." + MEMBER_ROLE_KEY + " IN (:" + ROLES_FILTER_KEY + ")" + " AND " +
GROUP_MEMBERS_TABLE + "." + INVITATION_STATUS_KEY + " = " + "'JOINED'",
nativeQuery = true
)
Method to execute the query to count the
total groups where the user is a GroupMember
Link copied to clipboard
Link copied to clipboard
@Modifying(clearAutomatically = true
)
@Query(value = ""DELETE FROM " + PROJECTS_GROUPS_TABLE + " WHERE " +
PROJECT_IDENTIFIER_KEY + "=:" + PROJECT_IDENTIFIER_KEY +
" AND " + GROUP_IDENTIFIER_KEY + "=:" + GROUP_IDENTIFIER_KEY",
nativeQuery = true
)
Method to execute the query to remove a
project from a group
Link copied to clipboard
Link copied to clipboard