Interface TranslationRepository
-
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Translation,Long>
,org.springframework.data.jpa.repository.JpaRepository<Translation,Long>
,org.springframework.data.repository.PagingAndSortingRepository<Translation,Long>
,org.springframework.data.repository.query.QueryByExampleExecutor<Translation>
,org.springframework.data.repository.Repository<Translation,Long>
@Repository public interface TranslationRepository extends org.springframework.data.jpa.repository.JpaRepository<Translation,Long>
Class represent repository which is responsible for translations db operations
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<Translation>
getLatestTranslation(Long user_id, Long exhibit_id, Long language_id)
Gets the latest translation of given author, exhibit and languageSet<Translation>
getLatestTranslations(Long exhibit_id, Long language_id)
Gets the latest translations for given exhibit and language from all authorsOptional<Translation>
getOfficialTranslation(Long exhibit_id, Long language_id)
Gets the official translation for given exhibit and languageList<Translation>
getSequence(Long user_id, Long exhibit_id, Long language_id)
Gets translation sequence for given author-exhibit-languageList<Translation>
getSequences(Long user_id)
Gets all latest translations for every pair exhibit-languge for given translatorSet<Translation>
getSequenceToDelete(Long user_id, Long exhibit_id, Long language_id)
Gets all translation for given user-exhibit-languageSet<Translation>
getTranslationToRollback(Long user_id, Long exhibit_id, Long language_id, Long id)
Gets all translation for given author-exhibit-language that are more recent than translation with given id-
Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save
-
Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getById, getOne, saveAll, saveAllAndFlush, saveAndFlush
-
-
-
-
Method Detail
-
getSequences
@Query(value="select * from translation where id in ( select max(id) from translation where author_id = :user_id group by exhibit_id, language_id) order by created_at desc", nativeQuery=true) List<Translation> getSequences(@Param("user_id") Long user_id)
Gets all latest translations for every pair exhibit-languge for given translator- Parameters:
user_id
- translator id- Returns:
- latest translation for every pair exhibit-languge
-
getSequenceToDelete
@Query(value="select * from translation where author_id = :user_id and exhibit_id = :exhibit_id and language_id = :language_id", nativeQuery=true) Set<Translation> getSequenceToDelete(@Param("user_id") Long user_id, @Param("exhibit_id") Long exhibit_id, @Param("language_id") Long language_id)
Gets all translation for given user-exhibit-language- Parameters:
user_id
- user's idexhibit_id
- exhibit idlanguage_id
- language id
-
getSequence
@Query(value="select * from translation where author_id = :user_id and exhibit_id = :exhibit_id and language_id = :language_id order by created_at desc", nativeQuery=true) List<Translation> getSequence(@Param("user_id") Long user_id, @Param("exhibit_id") Long exhibit_id, @Param("language_id") Long language_id)
Gets translation sequence for given author-exhibit-language- Parameters:
user_id
- author idexhibit_id
- exhibit idlanguage_id
- language id- Returns:
- translation sequence for given exhibit and language
-
getTranslationToRollback
@Query(value="select * from translation where author_id = :user_id and exhibit_id = :exhibit_id and language_id = :language_id and id > :id", nativeQuery=true) Set<Translation> getTranslationToRollback(@Param("user_id") Long user_id, @Param("exhibit_id") Long exhibit_id, @Param("language_id") Long language_id, @Param("id") Long id)
Gets all translation for given author-exhibit-language that are more recent than translation with given id- Parameters:
user_id
- user idexhibit_id
- exhibit idlanguage_id
- language idid
- most latest translation id
-
getLatestTranslation
@Query(value="select * from translation where author_id = :user_id and exhibit_id = :exhibit_id and language_id = :language_id order by created_at desc limit 1", nativeQuery=true) Optional<Translation> getLatestTranslation(@Param("user_id") Long user_id, @Param("exhibit_id") Long exhibit_id, @Param("language_id") Long language_id)
Gets the latest translation of given author, exhibit and language- Parameters:
user_id
- author idexhibit_id
- exhibit idlanguage_id
- language id- Returns:
- latest translation
-
getLatestTranslations
@Query(value="select * from translation where id in ( select max(id) from translation where exhibit_id = :exhibit_id and language_id = :language_id group by author_id)", nativeQuery=true) Set<Translation> getLatestTranslations(@Param("exhibit_id") Long exhibit_id, @Param("language_id") Long language_id)
Gets the latest translations for given exhibit and language from all authors- Parameters:
exhibit_id
- exhibit idlanguage_id
- language id- Returns:
- the latest translations for given exhibit and language from all authors
-
getOfficialTranslation
@Query(value="select * from translation where exhibit_id = :exhibit_id and language_id = :language_id and is_official = 1 limit 1", nativeQuery=true) Optional<Translation> getOfficialTranslation(@Param("exhibit_id") Long exhibit_id, @Param("language_id") Long language_id)
Gets the official translation for given exhibit and language- Parameters:
exhibit_id
- exhibit idlanguage_id
- language id- Returns:
- the official translation for given exhibit and language
-
-