Package mops.persistence
Interface FileInfoRepository
-
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<FileInfo,java.lang.Long>
,org.springframework.data.repository.Repository<FileInfo,java.lang.Long>
@Repository @AggregateBuilder public interface FileInfoRepository extends org.springframework.data.repository.CrudRepository<FileInfo,java.lang.Long>
Database connection for file meta data.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Set<java.lang.Long>
findAllIds()
Fetches all file info ids.java.util.List<FileInfo>
findAllInDirectory(long dirId)
Gets all files from one directory.java.util.Set<java.lang.Long>
findAllOrphansByDirectory()
Finds all FileInfo IDs, where no dir exists anymore.long
getFileCountInGroup(long groupId)
Counts the total number of files in a group.long
getStorageUsageInGroup(long groupId)
Counts the total number of bytes used in a group.long
getTotalStorageUsage()
Counts the total number of bytes in all groups.
-
-
-
Method Detail
-
findAllInDirectory
@Query("SELECT * FROM file_info WHERE directory_id = :dirId") java.util.List<FileInfo> findAllInDirectory(@Param("dirId") long dirId)
Gets all files from one directory.- Parameters:
dirId
- directory id- Returns:
- a list of files in that directory
-
getStorageUsageInGroup
@Query("SELECT COALESCE(SUM(size), 0) FROM file_info INNER JOIN directory ON file_info.directory_id = directory.id WHERE group_owner = :groupId") long getStorageUsageInGroup(@Param("groupId") long groupId)
Counts the total number of bytes used in a group.- Parameters:
groupId
- group id- Returns:
- total storage usage in bytes
-
getTotalStorageUsage
@Query("SELECT COALESCE(SUM(size), 0) FROM file_info") long getTotalStorageUsage()
Counts the total number of bytes in all groups.- Returns:
- total storage usage in bytes
-
getFileCountInGroup
@Query("SELECT COALESCE(COUNT(*), 0) FROM file_info INNER JOIN directory ON file_info.directory_id = directory.id WHERE group_owner = :groupId") long getFileCountInGroup(@Param("groupId") long groupId)
Counts the total number of files in a group.- Parameters:
groupId
- group id- Returns:
- total file count
-
findAllIds
@Query("SELECT id FROM file_info") java.util.Set<java.lang.Long> findAllIds()
Fetches all file info ids.- Returns:
- all ids
-
findAllOrphansByDirectory
@Query("SELECT id from file_info WHERE directory_id NOT IN (SELECT id from directory)") java.util.Set<java.lang.Long> findAllOrphansByDirectory()
Finds all FileInfo IDs, where no dir exists anymore. Should theoretically always be an empty list.- Returns:
- all IDs of found orphans
-
-