Interface LexoRankDao

All Known Implementing Classes:
LexoRankDaoImpl

public interface LexoRankDao
DAO for LexoRank AOs.
  • Method Details

    • createMarkerRowsForRankField

      void createMarkerRowsForRankField(long fieldId)
      Creates the 'marker' rows for the given fieldId in the db. These marker rows represent the minimum and maximum rank rows for a rank field. They aid in rank to top and bottom operations.
      Parameters:
      fieldId -
    • create

      LexoRankRow create(long fieldId, long issueId, String rank)
      Create a row in the db for the given rank, issueId and fieldId
      Parameters:
      fieldId -
      issueId -
      rank -
      Returns:
    • findByFieldId

      LexoRankRow[] findByFieldId(long fieldId)
      WARNING: Do not use unless you know what you are doing because it returns all issues (which can be 100k+) Returns all ranking rows by field id
      Parameters:
      fieldId - the field id
      Returns:
      the ranking rows for this field id
    • findByIssueId

      LexoRankRow[] findByIssueId(long issueId)
      Returns all rank rows for a given issueId.
      Parameters:
      issueId -
      Returns:
    • findByIssueIds

      LexoRankRow[] findByIssueIds(Iterable<Long> issueIds)
      Returns all rank rows for a given issueIds.
      Parameters:
      issueIds -
      Returns:
    • findByIssueIds

      LexoRankRow[] findByIssueIds(long fieldId, Iterable<Long> issueIds)
      Returns all rank rows for given item IDs.
      Parameters:
      fieldId -
      issueIds -
      Returns:
    • findByFieldAndIssueId

      io.atlassian.fugue.Option<LexoRankRow> findByFieldAndIssueId(long fieldId, long issueId)
      Finds a single rank row for the given fieldId and issueId
      Parameters:
      fieldId -
      issueId -
      Returns:
    • listIssueIdsByFieldIdAndIssueIds

      List<Long> listIssueIdsByFieldIdAndIssueIds(long fieldId, List<Long> issueIds)
      Returns a list of issue IDs for which a LexoRank row with fieldId and one of the given issueIds exists.
      Parameters:
      fieldId -
      issueIds -
      Returns:
    • listIssueIdsBetween

      List<Long> listIssueIdsBetween(long startIdInclusive, long endIdInclusive)
      Get the stored issue IDs between startIdInclusive and endIdInclusive
      Parameters:
      startIdInclusive -
      endIdInclusive -
      Returns:
    • getByFieldAndIssueId

      LexoRankRow getByFieldAndIssueId(long fieldId, long issueId)
      Gets a single LexoRankRow object with the given fieldId and issueId
      Parameters:
      fieldId -
      issueId -
      Returns:
    • getMinimumMarkerRowAndNextRow

      LexoRankRow[] getMinimumMarkerRowAndNextRow(long fieldId)
      Returns the minimum rank marker row and the next row ranked behind the minimum marker row for the given fieldId
      Parameters:
      fieldId -
      Returns:
    • getMaximumMarkerRowAndPreviousRow

      LexoRankRow[] getMaximumMarkerRowAndPreviousRow(long fieldId)
      Returns the maximum rank marker row and the previous row ranked before the maximum marker row for the given fieldId
      Parameters:
      fieldId -
      Returns:
    • getRowByRankAndNextRow

      LexoRankRow[] getRowByRankAndNextRow(long fieldId, String rank)
      Returns the rank row with the given rank and the row ranked after that row. The values are returned in ascending order sorted by rank field.
      Parameters:
      fieldId -
      rank -
      Returns:
    • getRowByRankAndNextRows

      LexoRankRow[] getRowByRankAndNextRows(long fieldId, String rank, int howMany)
      Returns the rank row with the given rank and howMany rows ranked after that row. The values are returned in ascending order sorted by rank field.
      Parameters:
      fieldId -
      rank -
      Returns:
      the rank row with the given rank and howMany rows ranked after that row
    • getRowByRankAndPreviousRow

      LexoRankRow[] getRowByRankAndPreviousRow(long fieldId, String rank)
      Returns the rank row with the given rank and the row ranked before that row. The values are returned in descending order sorted by rank field.
      Parameters:
      fieldId -
      rank -
      Returns:
    • getRowByRankAndPreviousRows

      LexoRankRow[] getRowByRankAndPreviousRows(long fieldId, String rank, int howMany)
      Returns the rank row with the given rank and howMany rows ranked before that row. The values are returned in descending order sorted by rank field.
      Parameters:
      fieldId -
      rank -
      Returns:
      the rank row with the given rank and howMany rows ranked before that row
    • findNextOneByRank

      LexoRankRow findNextOneByRank(long fieldId, String rank)
      Find the next rank row (skipping over any duplicates)
      Parameters:
      fieldId - is the rank field
      rank - is the rank value
      Returns:
      the rank row
    • findMinimumMarkerRow

      io.atlassian.fugue.Option<LexoRankRow> findMinimumMarkerRow(long fieldId)
      Finds the minimum marker row for the given fieldId
      Parameters:
      fieldId -
      Returns:
    • getMinimumMarkerRow

      LexoRankRow getMinimumMarkerRow(long fieldId)
    • findMaximumMarkerRow

      io.atlassian.fugue.Option<LexoRankRow> findMaximumMarkerRow(long fieldId)
      Finds the maximum marker row for the given fieldId
      Parameters:
      fieldId -
      Returns:
    • getMaximumMarkerRow

      LexoRankRow getMaximumMarkerRow(long fieldId)
    • findMaximumRankLengthRow

      io.atlassian.fugue.Option<LexoRankRow> findMaximumRankLengthRow(long fieldId)
      Finds the issue row with the longest rank for the given fieldId
      Parameters:
      fieldId -
      Returns:
    • findIssueIdsByFieldId

      Set<Long> findIssueIdsByFieldId(long fieldId)
      Retrieves a Set of issueIds of rank rows for the given fieldId
      Parameters:
      fieldId -
      Returns:
    • findFieldIdsInLexoRankTable

      Collection<Long> findFieldIdsInLexoRankTable()
      Retrieves a Collection of rank row IDs that require balancing.
      Returns:
    • findObsoleteFields

      Collection<Long> findObsoleteFields()
      Finds fields that no longer have a corresponding entry in Jira Core's customfield table.
      Returns:
    • ranksCountByField

      Map<Long,Long> ranksCountByField()
      Gets the number of distinct ranks for a field in the db
      Returns:
    • getContext

      Deprecated.
      please do not use this method anymore, is an exposure of AO entity manager wrapped that it is not needed to be out of this interface If you see method calls to any test or class please remove them.
      Returns a LexoRankDaoContext object that should be passed to any methods on the LexoRankDao that require it. Once finished, the context should be closed.
      Returns:
      the lexorank context
    • acquireLock

      LockOutcome acquireLock(Long rowIdToLock)
      Attempts the acquire a database lock on the ID that represents a row in the LexoRank table. If successfull, a LockOutcome object is returned which can be used to unlock the rows this lock operation locked.
      Parameters:
      rowIdToLock -
      Returns:
    • acquireLock

      LockOutcome acquireLock(LexoRankRow rowToLock)
      Attempts the acquire a database lock on the given LexoRankRow that represents a row in the LexoRank table. If successfull, a LockOutcome object is returned which can be used to unlock the rows this lock operation locked.
      Parameters:
      rowToLock -
      Returns:
    • acquireLock

      LockOutcome acquireLock(Set<LexoRankRow> rowsToLock)
      Attempts the acquire a database lock on the given LexoRankRows that represent rows in the LexoRank table. If successfull, a LockOutcome object is returned which can be used to unlock the rows this lock operation locked.
      Parameters:
      rowsToLock -
      Returns:
    • acquireLock

      LockOutcome acquireLock(LexoRankRow[] rowsToLock)
      Attempts the acquire a database lock on the given LexoRankRows that represent rows in the LexoRank table. If successfull, a LockOutcome object is returned which can be used to unlock the rows this lock operation locked.
      Parameters:
      rowsToLock -
      Returns:
    • acquireLockByFieldId

      LockOutcome acquireLockByFieldId(Long fieldId)
      Attempts the acquire a database lock on all rows in the LexoRank table whom's fieldId matches the given fieldId. If successfull, a LockOutcome object is returned which can be used to unlock the rows this lock operation locked.
      Parameters:
      fieldId -
      Returns:
    • releaseLock

      void releaseLock(Lock lock)
      Releases the lock on all rows locked by the given lock. This will clear out the lockHash and lockTime column for rows whom's current value match the given Lock object's hash and time.
      Parameters:
      lock -
    • save

      Update a LexoRankRow.
      Parameters:
      lock - is the lock objects.
      lexoRankRow - the LexoRankRow to persist.
      Returns:
      outcome of the save.
    • unlockedSave

      ServiceOutcome<LexoRankRow> unlockedSave(LexoRankRow lexoRankRow)
      Update a LexoRankRow, without the need for it to be locked.
      Parameters:
      lexoRankRow - the LexoRankRow to save
      Returns:
      service outcome.
    • deleteByIssueId

      LockProcessOutcome<ServiceResult> deleteByIssueId(Lock lock, Long issueId)
      Deletes rows for the given issueId
      Parameters:
      lock -
      issueId -
      Returns:
    • deleteByLimitedIssueIds

      LockProcessOutcome<ServiceResult> deleteByLimitedIssueIds(Lock lock, List<Long> issueIds)
      Deletes rows for the given issueIds
      Parameters:
      lock -
      issueIds - of the issues. Must have less than 1000 elements otherwise the queries could fail on certain databases.
      Returns:
    • deleteAll

      ServiceResult deleteAll()
      Deletes all rows.
      Returns:
    • deleteByFieldIdNoLock

      ServiceResult deleteByFieldIdNoLock(Long fieldId)
      Deletes all rows for a given fieldId without locking them first.
      Parameters:
      fieldId -
      Returns:
    • deleteByFieldId

      LockProcessOutcome<ServiceResult> deleteByFieldId(Lock lock, Long fieldId)
      Deletes rows for the given fieldId
      Parameters:
      lock -
      fieldId -
      Returns:
    • deleteByFieldIdAndIssueId

      LockProcessOutcome<ServiceResult> deleteByFieldIdAndIssueId(Lock lock, Long fieldId, Long issueId)
      Deletes a single rank row for the given fieldId and issueId
      Parameters:
      lock -
      fieldId -
      issueId -
      Returns:
    • getRowsAtBalanceBoundaryForFieldId

      LexoRankRow[] getRowsAtBalanceBoundaryForFieldId(Long fieldId, LexoRankBucket bucketBeingMigratedFrom, LexoRankBucket bucketBeingMigratedTo)
      Finds the 2 rows at the balance boundary for the given field id and bucket. The balance boundary is where the last migrated rank row and the next rank row to be migrated meet. An array with 2 LexoRankRow objects is returned where the first row is the row to be migrated and the second row is the row that was last migrated
      Parameters:
      fieldId -
      bucketBeingMigratedFrom -
      bucketBeingMigratedTo -
      Returns:
    • existsRankForFieldId

      boolean existsRankForFieldId(Long rankFieldId, String rank)
      Checks if the given rank value already exists for the given rank field id.
      Parameters:
      rankFieldId -
      rank -
      Returns:
    • countDuplicateRowsForFieldId

      Map<String,Long> countDuplicateRowsForFieldId(Long fieldId)
      Returns a map of duplicate rank values and the amount of occurences of that rank value.
      Parameters:
      fieldId -
      Returns:
    • listByFieldIdAndRank

      List<LexoRankRow> listByFieldIdAndRank(Long fieldId, String rank)
      Lists all the LexoRankRows for the given rank field id that have the given rank.
      Parameters:
      fieldId -
      rank -
      Returns:
    • getRowCountForFieldId

      Integer getRowCountForFieldId(Long fieldId)
      Get the number of rows for a given rank field.
      Parameters:
      fieldId - Id of the rank field
      Returns:
      Number of rows for the specified rank field
    • getRowCountInBucket

      long getRowCountInBucket(Long fieldId, LexoRankBucket containingBucket)
      Get the number of rows for a given fieldId and bucket.
      Parameters:
      fieldId - Id of the rank field
      containingBucket -
      Returns:
      the number of rows for a given fieldId and bucket.
    • getRowCountInBucket

      long getRowCountInBucket(Long fieldId, LexoRankBucket containingBucket, @Nullable LexoRankRow.RankRowType rankRowType)
      Get the number of rows for a given fieldId, bucket and type.
      Parameters:
      fieldId - Id of the rank field
      containingBucket -
      rankRowType -
      Returns:
      the number of rows for a given fieldId, rowType and bucket.
    • getNumRowsWithInvalidBucket

      long getNumRowsWithInvalidBucket(Long fieldId)
      Parameters:
      fieldId - is the rank field id
      Returns:
      the number of rows where BUCKET doesn't match the bucket encoded in the RANK field.