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.ListCrudRepository<DocHistory,Long>, org.springframework.data.repository.ListPagingAndSortingRepository<DocHistory,Long>, 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

    • findByDocIdAndPublicableTrueOrderByIdDesc

      List<DocHistory> findByDocIdAndPublicableTrueOrderByIdDesc(Integer docId)
    • findByPublicableTrue

      List<DocHistory> findByPublicableTrue()
    • findByDocIdAndPublishStartDateBetween

      List<DocHistory> findByDocIdAndPublishStartDateBetween(Integer docId, Date publishStartDateFrom, Date publishStartDateTo)
    • 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)
    • deleteDeletableById

      @Transactional @Modifying @Query("DELETE FROM DocHistory dh WHERE dh.id = :historyId AND dh.docId = :docId AND (dh.actual IS NULL OR dh.actual = false) AND (dh.awaitingApprove IS NULL OR dh.awaitingApprove = \'\') AND (:cleanup = true OR (dh.publicable = true AND dh.publishStartDate > :now))") int deleteDeletableById(@Param("historyId") Long historyId, @Param("docId") int docId, @Param("cleanup") boolean cleanup, @Param("now") Date now)
      Rechecks publication and approval state when deleting a version of the authorized page.
    • 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 WHERE id IN :historyIds") void updateActualHistory(@Param("actual") boolean actual, @Param("awaitingApprove") String awaitingApprove, @Param("historyIds") List<Integer> historyIds)
    • updateActual

      @Transactional @Modifying @Query("UPDATE DocHistory SET actual = :actual WHERE id IN :historyIds") void updateActual(@Param("actual") boolean actual, @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)
    • updateActual

      @Transactional @Modifying @Query("UPDATE DocHistory dh SET dh.actual = :actual WHERE dh.id IN :historyIds") void updateActual(@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()
    • findPendingByGroupId

      @Query("SELECT dh FROM DocHistory dh WHERE dh.groupId = :groupId AND (dh.isDelete IS NULL OR dh.isDelete = false) AND (dh.publicable = true OR (dh.awaitingApprove IS NOT NULL AND dh.awaitingApprove <> \'\') OR (dh.actual = false AND dh.approvedBy = -1 AND (dh.disapprovedBy IS NULL OR dh.disapprovedBy <= 0) AND dh.id = (SELECT MAX(latest.id) FROM DocHistory latest WHERE latest.docId = dh.docId)))") List<DocHistory> findPendingByGroupId(@Param("groupId") int groupId)
      Returns scheduled versions, approval requests and the latest unapproved draft, excluding deleted versions.
    • updateVirtualPath

      @Transactional @Modifying(flushAutomatically=true, clearAutomatically=true) @Query("UPDATE DocHistory SET virtualPath = :virtualPath, syncStatus = 1 WHERE id = :historyId") void updateVirtualPath(@Param("historyId") Long historyId, @Param("virtualPath") String virtualPath)