CollectionsRepository
The CollectionsRepository interface is useful to manage the queries of the LinksCollection
Author
N7ghtm4r3 - Tecknobit
See also
JpaRepository
Functions
Link copied to clipboard
@Query(value = "SELECT ( " +
" ( " +
" SELECT COUNT(*) " +
" FROM " + COLLECTIONS_KEY + " AS c" + _WHERE_ + "c." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY +
" AND ( " +
" MATCH(c." + TITLE_KEY + ", c." + DESCRIPTION_KEY + ") AGAINST (:" + KEYWORDS_KEY + _IN_BOOLEAN_MODE + ") " +
" OR :" + KEYWORDS_KEY + " =''" +
" ) " +
" ) + " +
" ( " +
" SELECT COUNT(*) " +
" FROM " + COLLECTIONS_KEY + " AS c " +
" INNER JOIN " + COLLECTIONS_TEAMS_TABLE + " ON c." + IDENTIFIER_KEY + " = " +
COLLECTIONS_TEAMS_TABLE + "." + COLLECTION_IDENTIFIER_KEY + " INNER JOIN " +
MEMBERS_KEY + " ON " + MEMBERS_KEY + "." + TEAM_IDENTIFIER_KEY + "=" + COLLECTIONS_TEAMS_TABLE + "." +
TEAM_IDENTIFIER_KEY + _WHERE_ + MEMBERS_KEY + "." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY +
" AND ( " +
" MATCH(c." + TITLE_KEY + ", c." + DESCRIPTION_KEY + ") AGAINST (:" + KEYWORDS_KEY + _IN_BOOLEAN_MODE + ") " +
" OR :" + KEYWORDS_KEY + "=''" +
" ) " +
" ) " +
")", nativeQuery = true)
Method to count all the user's collections, included the collections shared in the teams
Link copied to clipboard
@Query(value = ""SELECT COUNT(*) FROM " + COLLECTIONS_KEY + " AS c INNER JOIN " + COLLECTIONS_TEAMS_TABLE + " ON c." +
IDENTIFIER_KEY + " = " + COLLECTIONS_TEAMS_TABLE + "." + COLLECTION_IDENTIFIER_KEY +
_WHERE_ + COLLECTIONS_TEAMS_TABLE + "." + TEAM_IDENTIFIER_KEY + "=:" + TEAM_IDENTIFIER_KEY", nativeQuery = true)
Method to count the collections shared with the team
Link copied to clipboard
@Query(value = ""SELECT COUNT(*) FROM " + COLLECTIONS_KEY + _WHERE_ +
OWNER_KEY + "=:" + USER_IDENTIFIER_KEY", nativeQuery = true)
Method to count get the user owned collections
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 " + COLLECTIONS_KEY + " WHERE " + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY", nativeQuery = true)
Method to execute the query to delete a collection
Link copied to clipboard
Link copied to clipboard
@Modifying(clearAutomatically = true)
@Query(value = ""DELETE FROM " + COLLECTIONS_LINKS_TABLE
+ " WHERE " + COLLECTION_IDENTIFIER_KEY + "=:" + COLLECTION_IDENTIFIER_KEY", nativeQuery = true)
Method to execute the query to detach a collection from links
Link copied to clipboard
@Modifying(clearAutomatically = true)
@Query(value = ""DELETE FROM " + COLLECTIONS_TEAMS_TABLE
+ " WHERE " + COLLECTION_IDENTIFIER_KEY + "=:" + COLLECTION_IDENTIFIER_KEY", nativeQuery = true)
Method to execute the query to detach a collection from teams
Link copied to clipboard
@Modifying(clearAutomatically = true)
@Query(value = ""DELETE FROM " + COLLECTIONS_LINKS_TABLE + " WHERE " + LINK_IDENTIFIER_KEY + "=:" + LINK_IDENTIFIER_KEY", nativeQuery = true)
Method to execute the query to detach a link from collections
Link copied to clipboard
@Modifying(clearAutomatically = true)
@Query(value = ""DELETE FROM " + TEAMS_LINKS_TABLE + " WHERE " + LINK_IDENTIFIER_KEY + "=:" + LINK_IDENTIFIER_KEY", nativeQuery = true)
Method to execute the query to detach a link from teams
Link copied to clipboard
@Modifying(clearAutomatically = true)
@Query(value = ""DELETE FROM " + COLLECTIONS_TEAMS_TABLE + " WHERE " + TEAM_IDENTIFIER_KEY + "=:" + TEAM_IDENTIFIER_KEY", nativeQuery = true)
Method to execute the query to detach a team from collections
Link copied to clipboard
@Modifying(clearAutomatically = true)
@Query(value = ""DELETE FROM " + TEAMS_LINKS_TABLE + " WHERE " + TEAM_IDENTIFIER_KEY + "=:" + TEAM_IDENTIFIER_KEY", nativeQuery = true)
Method to execute the query to detach a team from links
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@Query(value = "SELECT c.* FROM " + COLLECTIONS_KEY + " AS c " + _WHERE_ + " c."
+ OWNER_KEY + "=:" + USER_IDENTIFIER_KEY +
" AND ( " +
" MATCH(c." + TITLE_KEY + ", c." + DESCRIPTION_KEY + ") AGAINST (:" + KEYWORDS_KEY + _IN_BOOLEAN_MODE + ") " +
" OR :" + KEYWORDS_KEY + " = '' " +
") UNION " +
"SELECT c.* FROM " + COLLECTIONS_KEY + " AS c INNER JOIN " + COLLECTIONS_TEAMS_TABLE + " ON c." +
IDENTIFIER_KEY + " = " + COLLECTIONS_TEAMS_TABLE + "." + COLLECTION_IDENTIFIER_KEY + " INNER JOIN " +
MEMBERS_KEY + " ON " + MEMBERS_KEY + "." + TEAM_IDENTIFIER_KEY + "=" + COLLECTIONS_TEAMS_TABLE + "." +
TEAM_IDENTIFIER_KEY + _WHERE_ + MEMBERS_KEY + "." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY +
" AND ( " +
" MATCH(c." + TITLE_KEY + ", c." + DESCRIPTION_KEY + ") AGAINST (:" + KEYWORDS_KEY + _IN_BOOLEAN_MODE + ") " +
" OR :" + KEYWORDS_KEY + " = '' " +
")" +
" ORDER BY " + DATE_KEY + " DESC", nativeQuery = true)
Method to execute the query to get all the user's collections, included the collections shared in the teams
Link copied to clipboard
@Query(value = ""SELECT c.* FROM " + COLLECTIONS_KEY + " as c WHERE c." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY +
" AND c." + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY +
" UNION " +
"SELECT c.* FROM " + COLLECTIONS_KEY + " as c INNER JOIN " + COLLECTIONS_TEAMS_TABLE + " ON c." +
IDENTIFIER_KEY + " = " + COLLECTIONS_TEAMS_TABLE + "." + COLLECTION_IDENTIFIER_KEY + " INNER JOIN " +
MEMBERS_KEY + " ON " + MEMBERS_KEY + "." + TEAM_IDENTIFIER_KEY + "=" + COLLECTIONS_TEAMS_TABLE + "." +
TEAM_IDENTIFIER_KEY + _WHERE_ + MEMBERS_KEY + "." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY +
" AND c." + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY", nativeQuery = true)
Method to execute the query to get a collection if the user is authorized
Link copied to clipboard
Link copied to clipboard
@Query(value = "SELECT c.* FROM " + COLLECTIONS_KEY + " AS c INNER JOIN " + COLLECTIONS_TEAMS_TABLE + " ON c." +
IDENTIFIER_KEY + "=" + COLLECTIONS_TEAMS_TABLE + "." + COLLECTION_IDENTIFIER_KEY +
_WHERE_ + COLLECTIONS_TEAMS_TABLE + "." + TEAM_IDENTIFIER_KEY + "=:" + TEAM_IDENTIFIER_KEY +
" ORDER BY " + DATE_KEY + " DESC", nativeQuery = true)
Method to execute the query to get the collections shared with the team
Link copied to clipboard
@Query(value = "SELECT " + IDENTIFIER_KEY + " FROM " + COLLECTIONS_KEY + " WHERE "
+ OWNER_KEY + "=:" + OWNER_KEY +
" ORDER BY " + DATE_KEY + " DESC", nativeQuery = true)
Method to execute the query to get the user's owned collections identifiers
Link copied to clipboard
@Query(value = "SELECT * FROM " + COLLECTIONS_KEY + _WHERE_ +
OWNER_KEY + "=:" + USER_IDENTIFIER_KEY +
" ORDER BY " + DATE_KEY + " DESC", nativeQuery = true)
Method to execute the query to get the user owned collections
Link copied to clipboard
@Modifying(clearAutomatically = true)
@Query(value = ""DELETE FROM " + COLLECTIONS_LINKS_TABLE + _WHERE_ +
COLLECTION_IDENTIFIER_KEY + "=:" + COLLECTION_IDENTIFIER_KEY + " AND " +
LINK_IDENTIFIER_KEY + "=:" + LINK_IDENTIFIER_KEY", nativeQuery = true)
Method to execute the query remove a link from a collection
Link copied to clipboard
@Modifying(clearAutomatically = true)
@Query(value = ""DELETE FROM " + COLLECTIONS_TEAMS_TABLE + _WHERE_ +
COLLECTION_IDENTIFIER_KEY + "=:" + COLLECTION_IDENTIFIER_KEY + " AND " +
TEAM_IDENTIFIER_KEY + "=:" + TEAM_IDENTIFIER_KEY", nativeQuery = true)
Method to execute the query to remove a team from a collection
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@Modifying(clearAutomatically = true)
@Query(value = "INSERT INTO " + COLLECTIONS_KEY + "(" +
IDENTIFIER_KEY + "," +
COLLECTION_COLOR_KEY + "," +
TITLE_KEY + "," +
DESCRIPTION_KEY + "," +
DATE_KEY + "," +
OWNER_KEY
+ ") VALUES (" +
":" + IDENTIFIER_KEY + "," +
":" + COLLECTION_COLOR_KEY + "," +
":" + TITLE_KEY + "," +
":" + DESCRIPTION_KEY + "," +
":" + DATE_KEY + "," +
":" + OWNER_KEY +
")", nativeQuery = true)
Method to execute the query to save a collection
Link copied to clipboard
@Modifying(clearAutomatically = true)
@Query(value = ""UPDATE " + COLLECTIONS_KEY + " SET " +
COLLECTION_COLOR_KEY + "=:" + COLLECTION_COLOR_KEY + "," +
TITLE_KEY + "=:" + TITLE_KEY + "," +
DESCRIPTION_KEY + "=:" + DESCRIPTION_KEY +
_WHERE_ + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY + " AND " + OWNER_KEY + "=:" + OWNER_KEY", nativeQuery = true)
Method to execute the query to edit a collection