Links
Repository
The LinksRepository
interface is
useful to manage the queries of the RefyLink
Author
N7ghtm4r3 - Tecknobit
See also
Functions
Link copied to clipboard
@Query(value = "SELECT ( " +
"SELECT COUNT(*) FROM " + LINKS_KEY + " AS l " + _WHERE_ +
" l." + OWNER_KEY + " = :" + USER_IDENTIFIER_KEY +
" AND dtype = '" + LINK_KEY + "'" +
" AND ( " +
" MATCH(l." + TITLE_KEY + ", l." + DESCRIPTION_KEY + ") AGAINST (:" + KEYWORDS_KEY + _IN_BOOLEAN_MODE + ") " +
" OR :" + KEYWORDS_KEY + " = '' " +
" )" +
") + ( " +
"SELECT COUNT(*) " +
" FROM " + LINKS_KEY + " AS l " +
" LEFT JOIN " + COLLECTIONS_LINKS_TABLE + " ON " + COLLECTIONS_LINKS_TABLE + "." + LINK_IDENTIFIER_KEY
+ " = l." + LINK_IDENTIFIER_KEY +
" LEFT JOIN " + TEAMS_LINKS_TABLE + " ON " + TEAMS_LINKS_TABLE + "." + LINK_IDENTIFIER_KEY +
" = l." + LINK_IDENTIFIER_KEY +
" LEFT JOIN " + COLLECTIONS_TEAMS_TABLE + " ON " + COLLECTIONS_TEAMS_TABLE + "." + COLLECTION_IDENTIFIER_KEY +
" = " + COLLECTIONS_LINKS_TABLE + "." + COLLECTION_IDENTIFIER_KEY +
" LEFT JOIN " + MEMBERS_KEY + " ON " + COLLECTIONS_TEAMS_TABLE + "." + TEAM_IDENTIFIER_KEY + "=" +
MEMBERS_KEY + "." + TEAM_IDENTIFIER_KEY +
" OR " + TEAMS_LINKS_TABLE + "." + TEAM_IDENTIFIER_KEY + "=" + MEMBERS_KEY + "." + TEAM_IDENTIFIER_KEY +
" WHERE " + MEMBERS_KEY + "." + OWNER_KEY + " = :" + USER_IDENTIFIER_KEY +
" AND l.dtype = '" + LINK_KEY + "' " +
" AND ( " +
" MATCH(l." + TITLE_KEY + ", l." + DESCRIPTION_KEY + ") AGAINST (:" + KEYWORDS_KEY + _IN_BOOLEAN_MODE + ") " +
" OR :" + KEYWORDS_KEY + " = '' " +
" )" +
")",
nativeQuery = true
)
Method to count all the user's links,
included the links shared in the teams and in the
collections shared in the teams
Link copied to clipboard
@Query(value = "SELECT COUNT(*) " +
"FROM " + LINKS_KEY + " AS l " +
"INNER JOIN " + COLLECTIONS_LINKS_TABLE + " ON " + COLLECTIONS_LINKS_TABLE + "." + LINK_IDENTIFIER_KEY +
" = l." + LINK_IDENTIFIER_KEY + _WHERE_ +
COLLECTIONS_LINKS_TABLE + "." + COLLECTION_IDENTIFIER_KEY + "=:" + COLLECTION_IDENTIFIER_KEY +
" AND dtype = '" + LINK_KEY + "' " +
" AND ( " +
" MATCH(l." + TITLE_KEY + ", l." + DESCRIPTION_KEY + ") AGAINST (:" + KEYWORDS_KEY + _IN_BOOLEAN_MODE + ") " +
" OR :" + KEYWORDS_KEY + " = '' " +
" )",
nativeQuery = true
)
Method to count all the links shared in a
collection
Link copied to clipboard
@Query(value = "SELECT COUNT(*) " +
"FROM " + LINKS_KEY + " AS l " +
"INNER JOIN " + TEAMS_LINKS_TABLE + " ON " + TEAMS_LINKS_TABLE + "." + LINK_IDENTIFIER_KEY +
" = l." + LINK_IDENTIFIER_KEY + _WHERE_ +
TEAMS_LINKS_TABLE + "." + TEAM_IDENTIFIER_KEY + "=:" + TEAM_IDENTIFIER_KEY +
" AND dtype = '" + LINK_KEY + "' " +
" AND ( " +
" MATCH(l." + TITLE_KEY + ", l." + DESCRIPTION_KEY + ") AGAINST (:" + KEYWORDS_KEY + _IN_BOOLEAN_MODE + ") " +
" OR :" + KEYWORDS_KEY + " = '' " +
" )",
nativeQuery = true
)
Method to count all the links shared in a
team
Link copied to clipboard
@Query(value = "SELECT COUNT(*) FROM " + LINKS_KEY + _WHERE_
+ OWNER_KEY + "=:" + USER_IDENTIFIER_KEY + " AND dtype='" + LINK_KEY + "'",
nativeQuery = true
)
Method to count the user's owned links
Link copied to clipboard
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 " + LINKS_KEY + " WHERE " + LINK_IDENTIFIER_KEY + "=:" + LINK_IDENTIFIER_KEY",
nativeQuery = true
)
Method to execute the query to delete a
link
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 l.* " +
"FROM " + LINKS_KEY + " AS l " +
"WHERE l." + OWNER_KEY + " = :" + USER_IDENTIFIER_KEY +
" AND dtype = '" + LINK_KEY + "' " +
" AND ( " +
" MATCH(l." + TITLE_KEY + ", l." + DESCRIPTION_KEY + ") AGAINST (:" + KEYWORDS_KEY + _IN_BOOLEAN_MODE + ") " +
" OR :" + KEYWORDS_KEY + " = '' " +
" ) " +
"UNION " +
"SELECT l.* " +
"FROM " + LINKS_KEY + " AS l " +
"LEFT JOIN " + COLLECTIONS_LINKS_TABLE + " ON " + COLLECTIONS_LINKS_TABLE + "." + LINK_IDENTIFIER_KEY +
" = l." + LINK_IDENTIFIER_KEY +
" LEFT JOIN " + TEAMS_LINKS_TABLE + " ON " + TEAMS_LINKS_TABLE + "." + LINK_IDENTIFIER_KEY +
" = l." + LINK_IDENTIFIER_KEY +
" LEFT JOIN " + COLLECTIONS_TEAMS_TABLE + " ON " + COLLECTIONS_TEAMS_TABLE + "." + COLLECTION_IDENTIFIER_KEY +
" = " + COLLECTIONS_LINKS_TABLE + "." + COLLECTION_IDENTIFIER_KEY +
" LEFT JOIN " + MEMBERS_KEY + " ON " + COLLECTIONS_TEAMS_TABLE + "." + TEAM_IDENTIFIER_KEY + "=" +
MEMBERS_KEY + "." + TEAM_IDENTIFIER_KEY +
" OR " + TEAMS_LINKS_TABLE + "." + TEAM_IDENTIFIER_KEY + "=" + MEMBERS_KEY + "." + TEAM_IDENTIFIER_KEY +
" WHERE " + MEMBERS_KEY + "." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY +
" AND l.dtype = '" + LINK_KEY + "' " +
" AND ( " +
" MATCH(l." + TITLE_KEY + ", l." + 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 links, included the links shared in the teams and in
the collections shared in the teams
Link copied to clipboard
@Query(value = "SELECT l.* " +
"FROM " + LINKS_KEY + " AS l " +
"INNER JOIN " + COLLECTIONS_LINKS_TABLE + " ON " + COLLECTIONS_LINKS_TABLE + "." + LINK_IDENTIFIER_KEY +
" = l." + LINK_IDENTIFIER_KEY + _WHERE_ +
COLLECTIONS_LINKS_TABLE + "." + COLLECTION_IDENTIFIER_KEY + "=:" + COLLECTION_IDENTIFIER_KEY +
" AND dtype = '" + LINK_KEY + "' " +
" AND ( " +
" MATCH(l." + TITLE_KEY + ", l." + 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
links shared in a collection
Link copied to clipboard
@Query(value = "SELECT l.* FROM " + LINKS_KEY + " AS l WHERE l." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY + " AND l." +
LINK_IDENTIFIER_KEY + "=:" + LINK_IDENTIFIER_KEY +
" UNION " +
"SELECT l.* FROM " + LINKS_KEY + " AS l INNER JOIN " + COLLECTIONS_LINKS_TABLE + " ON " +
COLLECTIONS_LINKS_TABLE + "." + LINK_IDENTIFIER_KEY + " = l." + LINK_IDENTIFIER_KEY + " INNER JOIN " +
COLLECTIONS_TEAMS_TABLE + " ON " + COLLECTIONS_TEAMS_TABLE + "." + COLLECTION_IDENTIFIER_KEY + " = " +
COLLECTIONS_LINKS_TABLE + "." + COLLECTION_IDENTIFIER_KEY + " INNER JOIN " + MEMBERS_KEY + " ON " +
COLLECTIONS_TEAMS_TABLE + "." + TEAM_IDENTIFIER_KEY + " = " + MEMBERS_KEY + "." + TEAM_IDENTIFIER_KEY +
" WHERE " + MEMBERS_KEY + "." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY +
" AND l." + LINK_IDENTIFIER_KEY + "=:" + LINK_IDENTIFIER_KEY + " AND dtype='" + LINK_KEY + "'",
nativeQuery = true
)
Method to execute the query to get a link if
the owner is authorized
Link copied to clipboard
Link copied to clipboard
@Query(value = "SELECT l.* " +
"FROM " + LINKS_KEY + " AS l " +
"INNER JOIN " + TEAMS_LINKS_TABLE + " ON " + TEAMS_LINKS_TABLE + "." + LINK_IDENTIFIER_KEY +
" = l." + LINK_IDENTIFIER_KEY + _WHERE_ +
TEAMS_LINKS_TABLE + "." + TEAM_IDENTIFIER_KEY + "=:" + TEAM_IDENTIFIER_KEY +
" AND dtype = '" + LINK_KEY + "' " +
" AND ( " +
" MATCH(l." + TITLE_KEY + ", l." + 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
links shared in a team
Link copied to clipboard
@Query(value = "SELECT " + LINK_IDENTIFIER_KEY + " FROM " + LINKS_KEY + " WHERE "
+ OWNER_KEY + "=:" + OWNER_KEY +
" ORDER BY " + DATE_KEY + " DESC",
nativeQuery = true
)
Method to execute the query to get the
user's owned links identifiers
Link copied to clipboard
@Query(value = "SELECT * FROM " + LINKS_KEY + _WHERE_
+ OWNER_KEY + "=:" + USER_IDENTIFIER_KEY + " AND dtype='" + LINK_KEY + "'" +
" ORDER BY " + DATE_KEY + " DESC",
nativeQuery = true
)
Method to execute the query to get the
user's owned links
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@Modifying(clearAutomatically = true
)
@Query(value = "INSERT INTO " + LINKS_KEY + "(" +
DISCRIMINATOR_VALUE_KEY + "," +
LINK_IDENTIFIER_KEY + "," +
TITLE_KEY + "," +
DATE_KEY + "," +
THUMBNAIL_PREVIEW_KEY + "," +
DESCRIPTION_KEY + "," +
REFERENCE_LINK_KEY + "," +
OWNER_KEY
+ ") VALUES (" +
":" + DISCRIMINATOR_VALUE_KEY + "," +
":" + LINK_IDENTIFIER_KEY + "," +
":" + TITLE_KEY + "," +
":" + DATE_KEY + "," +
":" + THUMBNAIL_PREVIEW_KEY + "," +
":" + DESCRIPTION_KEY + "," +
":" + REFERENCE_LINK_KEY + "," +
":" + OWNER_KEY +
")",
nativeQuery = true
)
Method to execute the query to save a link
Link copied to clipboard
@Modifying(clearAutomatically = true
)
@Query(value = ""UPDATE " + LINKS_KEY + " SET " +
TITLE_KEY + "=:" + TITLE_KEY + "," +
THUMBNAIL_PREVIEW_KEY + "=:" + THUMBNAIL_PREVIEW_KEY + "," +
DESCRIPTION_KEY + "=:" + DESCRIPTION_KEY + "," +
REFERENCE_LINK_KEY + "=:" + REFERENCE_LINK_KEY +
" WHERE " + LINK_IDENTIFIER_KEY + "=:" + LINK_IDENTIFIER_KEY + " AND " + OWNER_KEY + "=:" + OWNER_KEY",
nativeQuery = true
)
Method to execute the query to update a
link