Interface DirectoryRepository

  • All Superinterfaces:
    org.springframework.data.repository.CrudRepository<Directory,​java.lang.Long>, org.springframework.data.repository.Repository<Directory,​java.lang.Long>

    @Repository
    @AggregateBuilder
    public interface DirectoryRepository
    extends org.springframework.data.repository.CrudRepository<Directory,​java.lang.Long>
    Database connection for directories.
    • Method Detail

      • getAllSubFoldersOfParent

        @Query("SELECT * FROM directory WHERE parent_id = :parentId")
        java.util.List<Directory> getAllSubFoldersOfParent​(@Param("parentId")
                                                           long parentId)
        Gets all sub folders.
        Parameters:
        parentId - the id of the parent folder
        Returns:
        a list of level one sub folder of the parent folder
      • getDirCountInGroup

        @Query("SELECT COALESCE(COUNT(*), 0) FROM directory WHERE group_owner = :groupId")
        long getDirCountInGroup​(@Param("groupId")
                                long groupId)
        Gets folder count in a group.
        Parameters:
        groupId - the group id
        Returns:
        the number of the folders the group already has
      • getRootFolder

        @Query("SELECT * FROM directory WHERE group_owner = :groupId AND parent_id IS NULL")
        java.util.Optional<Directory> getRootFolder​(@Param("groupId")
                                                    long groupId)
        Gets the root folder of a group.
        Parameters:
        groupId - the id of group
        Returns:
        the group directory
      • getAllRootDirectories

        @Query("SELECT * FROM directory WHERE parent_id IS NULL")
        java.util.List<Directory> getAllRootDirectories()
        Gets all root directories.
        Returns:
        List of all root directories.