Class VersioningDao<Q extends JiraRelationalPathBase<?>,D extends DTO>

java.lang.Object
com.atlassian.jira.versioning.VersioningDao<Q,D>

public class VersioningDao<Q extends JiraRelationalPathBase<?>,D extends DTO> extends Object
  • Method Details

    • markDeletedAndUpdateVersion

      public long markDeletedAndUpdateVersion(long entityId)
      Marks the specified entity as deleted and bumps its version by 1.
      Parameters:
      entityId - identifier for entity to mark as deleted & whose version number to bump
      Returns:
      the number of updated rows
    • markRelatedToIssueAsDeletedAndUpdateVersion

      public long markRelatedToIssueAsDeletedAndUpdateVersion(long parentIssueId)
      Marks all entities related to the specified parentIssueId as deleted and bumps the version in a single batch update.
      Parameters:
      parentIssueId - identifier for the Issue whose related entities will be marked as deleted and have their versions bumped
      Returns:
      the number of updated rows
    • getCurrentVersion

      public Optional<Long> getCurrentVersion(long entityId)
      Return the version for the entity identified by entityId or Optional.empty() if there is no version.
      Parameters:
      entityId - identifies the entity whose current version will be retrieved
      Returns:
      An optional containing the current version for the specified entity; an empty optional if no version is found.
    • getCurrentEntityVersion

      public Optional<D> getCurrentEntityVersion(long entityId)
    • getEntityVersionsRelatedToIssue

      public List<D> getEntityVersionsRelatedToIssue(long parentIssueId)
    • cleanDeletedVersionsOlderThan

      public long cleanDeletedVersionsOlderThan(Duration ageThreshold)
      Removes all entity version records marked as deleted and older than duration.
      Parameters:
      ageThreshold - threshold for deletion; entities marked as deleted and older than this will be removed.
      Returns:
      the number of rows that were deleted.
    • cleanDeletedVersion

      public long cleanDeletedVersion(long entityId)
    • cleanDeletedRelatedVersions

      public long cleanDeletedRelatedVersions(long parentIssueId)
    • fetchAllRows

      public List<D> fetchAllRows(int limit)
    • fetchOneRow

      public D fetchOneRow(long entityId)
    • insertNewRow

      public long insertNewRow(long entityId, long parentIssueId, LocalDateTime updateTime, long version, String deleted)
    • incrementEntityVersionsRelatedToIssue

      public void incrementEntityVersionsRelatedToIssue(long parentIssueId)
      Bumps the version for all entities related to the specified parentIssueId in a single batch update which are not marked as deleted.
      Note: no new rows will be added for entities that don't already have a version in the db
      Parameters:
      parentIssueId - identifier for the Issue whose related entities will have their versions bumped
    • findVersionsUpdatedInTheLast

      public List<D> findVersionsUpdatedInTheLast(Duration duration)
      Searches for entity versions that were updated (including deletes) within the last 'duration' amount of time. That is, for versions updated between (currDbTime - duration) and currDbTime.
      Parameters:
      duration - how far back from the present to search for updated entities
      Returns:
      DTOs for entity versions that were updated since 'duration' ago
    • getMostRecentlyUpdatedVersion

      public Optional<D> getMostRecentlyUpdatedVersion()
      Grabs the most recently updated issue version, regardless of whether or not it's marked as deleted.
      Returns:
      an Optional with the latest versioning entry; an empty Optional if there's no entries found.