Interface TemplateRepository

  • All Superinterfaces:
    org.springframework.data.repository.CrudRepository<Template,​java.lang.Long>, org.springframework.data.jpa.repository.JpaRepository<Template,​java.lang.Long>, org.springframework.data.repository.PagingAndSortingRepository<Template,​java.lang.Long>, org.springframework.data.repository.query.QueryByExampleExecutor<Template>, org.springframework.data.repository.Repository<Template,​java.lang.Long>

    public interface TemplateRepository
    extends org.springframework.data.jpa.repository.JpaRepository<Template,​java.lang.Long>
    The database repository storing the job templates
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.List<Template> findByAccountAndPublic​(Account account)
      Finds all templates that are owned by the account or are public
      java.util.List<Template> findByAccountAndPublicAndLanguage​(Account account, java.lang.String language)
      Finds all templates of a specific language that are owned by the account or are public
      Template findByIdAndPublic​(long id, Account account)
      Finds the template with the id supplied only if it is owned by the account supplied or is public
      • Methods inherited from interface org.springframework.data.repository.CrudRepository

        count, delete, deleteAll, deleteAll, deleteById, existsById, findById, save
      • Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

        deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getOne, saveAll, saveAndFlush
      • Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

        findAll
      • Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

        count, exists, findAll, findOne
    • Method Detail

      • findByIdAndPublic

        @Query("SELECT t FROM Template t WHERE t.id = :id AND (t.account = :account OR t.isPublic = true)")
        Template findByIdAndPublic​(@Param("id")
                                   long id,
                                   @Param("account")
                                   Account account)
        Finds the template with the id supplied only if it is owned by the account supplied or is public
        Parameters:
        id - the id of the template to find
        account - the account object of the current user
        Returns:
        the template found
      • findByAccountAndPublic

        @Query("SELECT t FROM Template t WHERE t.account = :account OR t.isPublic = true")
        java.util.List<Template> findByAccountAndPublic​(@Param("account")
                                                        Account account)
        Finds all templates that are owned by the account or are public
        Parameters:
        account - the account object of the current user
        Returns:
        the list of templates found
      • findByAccountAndPublicAndLanguage

        @Query("SELECT t FROM Template t WHERE t.language = :language AND (t.account = :account OR t.isPublic = true)")
        java.util.List<Template> findByAccountAndPublicAndLanguage​(@Param("account")
                                                                   Account account,
                                                                   @Param("language")
                                                                   java.lang.String language)
        Finds all templates of a specific language that are owned by the account or are public
        Parameters:
        account - the account object of the current user
        language - the language to filter by
        Returns:
        the list of templates found