Interface DocHistoryRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<DocHistory,Long>, org.springframework.data.jpa.repository.JpaRepository<DocHistory,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<DocHistory>, org.springframework.data.repository.PagingAndSortingRepository<DocHistory,Long>, org.springframework.data.repository.query.QueryByExampleExecutor<DocHistory>, org.springframework.data.repository.Repository<DocHistory,Long>

@Repository public interface DocHistoryRepository extends org.springframework.data.jpa.repository.JpaRepository<DocHistory,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<DocHistory>
  • Method Details

    • findByDocIdAndPublishStartDate

      List<DocHistory> findByDocIdAndPublishStartDate(Integer docId, Date publishStartDate)
    • findOldHistoryIds

      @Query(value="SELECT history_id FROM documents_history WHERE doc_id = ?1 AND history_id < ?2 AND publicable = ?3 AND author_id = ?4", nativeQuery=true) List<Integer> findOldHistoryIds(int docId, Long historyId, boolean publicable, int authorId)
    • deleteHistoryOnPublish

      @Transactional @Modifying @Query("DELETE FROM DocHistory WHERE id IN :historyIds AND approvedBy = -1 AND authorId = :authorId") void deleteHistoryOnPublish(@Param("historyIds") List<Integer> historyIds, @Param("authorId") int authorId)
    • deleteByIdPublicable

      @Transactional @Modifying @Query("DELETE FROM DocHistory WHERE id = :historyIds AND publicable = :publicable") void deleteByIdPublicable(@Param("historyIds") Long historyId, @Param("publicable") boolean publicable)
    • findOldHistoryIds

      @Query(value="SELECT history_id FROM documents_history WHERE doc_id = ?1 AND history_id < ?2", nativeQuery=true) List<Integer> findOldHistoryIds(int docId, int historyId)
    • updateActualHistory

      @Transactional @Modifying @Query("UPDATE DocHistory SET actual = :actual, awaitingApprove = :awaitingApprove, syncStatus = 1 WHERE id IN :historyIds") void updateActualHistory(@Param("actual") boolean actual, @Param("awaitingApprove") String awaitingApprove, @Param("historyIds") List<Integer> historyIds)
    • rejectDocHistory

      @Transactional @Modifying @Query("UPDATE DocHistory SET awaitingApprove = :awaitingApprove, disapprovedBy = :disapprovedBy, syncStatus = 1 WHERE id = :historyId") void rejectDocHistory(@Param("awaitingApprove") String awaitingApprove, @Param("disapprovedBy") Integer disapprovedBy, @Param("historyId") Integer historyId)
    • updateAwaitingApprove

      @Transactional @Modifying @Query("UPDATE DocHistory SET awaitingApprove = :awaitingApprove, syncStatus = 1 WHERE docId = :docId") void updateAwaitingApprove(@Param("awaitingApprove") String awaitingApprove, @Param("docId") Integer docId)
    • findMaxHistoryId

      @Query(value="SELECT max(history_id) AS max FROM documents_history WHERE doc_id=? AND actual=?", nativeQuery=true) Optional<Integer> findMaxHistoryId(int docId, boolean actual)
    • findMaxHistoryId

      @Query(value="SELECT max(history_id) AS max FROM documents_history WHERE doc_id=?", nativeQuery=true) Integer findMaxHistoryId(int docId)
    • findGroupIdById

      @Query(value="SELECT group_id FROM documents_history WHERE history_id=?", nativeQuery=true) Optional<Integer> findGroupIdById(Long id)
    • findByDocIdInActual

      @Query("SELECT dh FROM DocHistory dh WHERE dh.docId IN :docIds AND dh.actual = 1") List<DocHistory> findByDocIdInActual(@Param("docIds") List<Integer> docIds)
    • findTopByDocIdOrderBySaveDateDesc

      Optional<DocHistory> findTopByDocIdOrderBySaveDateDesc(Integer docId)
    • updateActualAndSyncStatus

      @Transactional @Modifying @Query("UPDATE DocHistory dh SET dh.actual = :actual, dh.syncStatus = 1 WHERE dh.id IN :historyIds") void updateActualAndSyncStatus(@Param("actual") boolean actual, @Param("historyIds") int[] historyIds)
    • updatePublicableAndActual

      @Transactional @Modifying @Query("UPDATE DocHistory dh SET dh.publicable = :publicable, dh.actual = :actual, dh.approvedBy = :approvedBy, dh.syncStatus = 1, dh.available = :available WHERE dh.id = :historyId") void updatePublicableAndActual(@Param("publicable") boolean publicable, @Param("actual") boolean actual, @Param("approvedBy") int approvedBy, @Param("available") boolean available, @Param("historyId") int historyId)
    • getPublicableByDocIdIn

      @Query("SELECT dh.publicable FROM DocHistory dh WHERE dh.docId = :docIds") List<Boolean> getPublicableByDocIdIn(@Param("docIds") Integer docIds)
    • getHisotryIdsByDocIdIn

      @Query("SELECT dh.id FROM DocHistory dh WHERE dh.docId = :docIds") Optional<List<Integer>> getHisotryIdsByDocIdIn(@Param("docIds") Integer docIds)
    • getPublicableThatAreNotAwaitingToApprove

      @Query("SELECT dh FROM DocHistory dh WHERE dh.publicable = true AND ( dh.awaitingApprove IS NULL OR dh.awaitingApprove = \'\' ) AND dh.publishStartDate IS NOT NULL") Optional<List<DocHistory>> getPublicableThatAreNotAwaitingToApprove()