Class LexoRankDaoImpl
java.lang.Object
com.atlassian.greenhopper.manager.lexorank.LexoRankDaoImpl
- All Implemented Interfaces:
LexoRankDao
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacquireLock
(LexoRankRow rowToLock) Attempts the acquire a database lock on the given LexoRankRow that represents a row in the LexoRank table.acquireLock
(LexoRankRow[] rowsToLock) Attempts the acquire a database lock on the given LexoRankRows that represent rows in the LexoRank table.acquireLock
(Long rowIdToLock) Attempts the acquire a database lock on the ID that represents a row in the LexoRank table.acquireLock
(Set<LexoRankRow> rowsToLock) Attempts the acquire a database lock on the given LexoRankRows that represent rows in the LexoRank table.acquireLockByFieldId
(Long fieldId) Attempts the acquire a database lock on all rows in the LexoRank table whom's fieldId matches the given fieldId.countDuplicateRowsForFieldId
(Long fieldId) Returns a map of duplicate rank values and the amount of occurences of that rank value.Create a row in the db for the given rank, issueId and fieldIdvoid
createMarkerRowsForRankField
(long fieldId) Creates the 'marker' rows for the given fieldId in the db.Deletes all rows.deleteByFieldId
(Lock lock, Long fieldId) Deletes rows for the given fieldIddeleteByFieldIdAndIssueId
(Lock lock, Long fieldId, Long issueId) Deletes a single rank row for the given fieldId and issueIddeleteByFieldIdNoLock
(Long fieldId) Deletes all rows for a given fieldId without locking them first.deleteByIssueId
(Lock lock, Long issueId) Deletes rows for the given issueIddeleteByLimitedIssueIds
(Lock lock, List<Long> issueIds) Deletes rows for the given issueIdsboolean
existsRankForFieldId
(Long rankFieldId, String rank) Checks if the given rank value already exists for the given rank field id.protected List
<LexoRankRow> find
(SqlSelectStatement selectStatement) io.atlassian.fugue.Option
<LexoRankRow> findByFieldAndIssueId
(long fieldId, long issueId) Finds a single rank row for the given fieldId and issueIdfindByFieldId
(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 idfindByIssueId
(long issueId) Returns all rank rows for a given issueId.findByIssueIds
(long fieldId, Iterable<Long> issueIds) Returns all rank rows for given item IDs.findByIssueIds
(Iterable<Long> issueIds) Returns all rank rows for a given issueIds.Retrieves a Collection of rank row IDs that require balancing.findIssueIdsByFieldId
(long fieldId) Retrieves a Set of issueIds of rank rows for the given fieldIdio.atlassian.fugue.Option
<LexoRankRow> findMaximumMarkerRow
(long fieldId) Finds the maximum marker row for the given fieldIdio.atlassian.fugue.Option
<LexoRankRow> findMaximumRankLengthRow
(long fieldId) Finds the issue row with the longest rank for the given fieldIdio.atlassian.fugue.Option
<LexoRankRow> findMinimumMarkerRow
(long fieldId) Finds the minimum marker row for the given fieldIdfindNextOneByRank
(long fieldId, String rank) Find the next rank row (skipping over any duplicates)Finds fields that no longer have a corresponding entry in Jira Core's customfield table.getByFieldAndIssueId
(long fieldId, long issueId) Gets a single LexoRankRow object with the given fieldId and issueIdWe are going to add a little bit here that will hold a reference so we don't create the context every time.getMaximumMarkerRow
(long fieldId) getMaximumMarkerRowAndPreviousRow
(long fieldId) Returns the maximum rank marker row and the previous row ranked before the maximum marker row for the given fieldIdgetMinimumMarkerRow
(long fieldId) getMinimumMarkerRowAndNextRow
(long fieldId) Returns the minimum rank marker row and the next row ranked behind the minimum marker row for the given fieldIdlong
getNumRowsWithInvalidBucket
(Long fieldId) getRowByRankAndNextRow
(long fieldId, String rank) Returns the rank row with the given rank and the row ranked after that row.getRowByRankAndNextRows
(long fieldId, String rank, int howMany) Returns the rank row with the given rank andhowMany
rows ranked after that row.getRowByRankAndPreviousRow
(long fieldId, String rank) Returns the rank row with the given rank and the row ranked before that row.getRowByRankAndPreviousRows
(long fieldId, String rank, int howMany) Returns the rank row with the given rank andhowMany
rows ranked before that row.getRowCountForFieldId
(Long fieldId) Get the number of rows for a given rank field.long
getRowCountInBucket
(Long fieldId, LexoRankBucket containingBucket) Get the number of rows for a given fieldId and bucket.long
getRowCountInBucket
(Long fieldId, LexoRankBucket containingBucket, LexoRankRow.RankRowType rankRowType) Get the number of rows for a given fieldId, bucket and type.getRowsAtBalanceBoundaryForFieldId
(Long fieldId, LexoRankBucket bucketBeingMigratedFrom, LexoRankBucket bucketBeingMigratedTo) Finds the 2 rows at the balance boundary for the given field id and bucket.listByFieldIdAndRank
(Long fieldId, String rank) Lists all the LexoRankRows for the given rank field id that have the given rank.listIssueIdsBetween
(long startIdInclusive, long endIdInclusive) Get the stored issue IDs between startIdInclusive and endIdInclusivelistIssueIdsByFieldIdAndIssueIds
(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.Gets the number of distinct ranks for a field in the dbvoid
releaseLock
(Lock lock) Releases the lock on all rows locked by the given lock.save
(Lock lock, LexoRankRow lexoRankRow) Update a LexoRankRow.unlockedSave
(LexoRankRow lexoRankRow) Update a LexoRankRow, without the need for it to be locked.
-
Field Details
-
ao
@Autowired protected com.atlassian.activeobjects.external.ActiveObjects ao
-
-
Constructor Details
-
LexoRankDaoImpl
public LexoRankDaoImpl()
-
-
Method Details
-
createMarkerRowsForRankField
public void createMarkerRowsForRankField(long fieldId) Description copied from interface:LexoRankDao
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.- Specified by:
createMarkerRowsForRankField
in interfaceLexoRankDao
- Parameters:
fieldId
-
-
create
Description copied from interface:LexoRankDao
Create a row in the db for the given rank, issueId and fieldId- Specified by:
create
in interfaceLexoRankDao
- Parameters:
fieldId
-issueId
-rank
-- Returns:
-
listIssueIdsByFieldIdAndIssueIds
Description copied from interface:LexoRankDao
Returns a list of issue IDs for which a LexoRank row with fieldId and one of the given issueIds exists.- Specified by:
listIssueIdsByFieldIdAndIssueIds
in interfaceLexoRankDao
- Parameters:
fieldId
-issueIds
-- Returns:
-
findByIssueIds
Description copied from interface:LexoRankDao
Returns all rank rows for given item IDs.- Specified by:
findByIssueIds
in interfaceLexoRankDao
- Parameters:
fieldId
-issueIds
-- Returns:
-
findByFieldId
Description copied from interface:LexoRankDao
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- Specified by:
findByFieldId
in interfaceLexoRankDao
- Parameters:
fieldId
- the field id- Returns:
- the ranking rows for this field id
-
getContext
We are going to add a little bit here that will hold a reference so we don't create the context every time.In the next release I am going to do this synchronized to validate the collation of the db also.
- Specified by:
getContext
in interfaceLexoRankDao
- Returns:
- the current context
-
findByIssueId
Description copied from interface:LexoRankDao
Returns all rank rows for a given issueId.- Specified by:
findByIssueId
in interfaceLexoRankDao
- Parameters:
issueId
-- Returns:
-
findByIssueIds
Description copied from interface:LexoRankDao
Returns all rank rows for a given issueIds.- Specified by:
findByIssueIds
in interfaceLexoRankDao
- Parameters:
issueIds
-- Returns:
-
findByFieldAndIssueId
Description copied from interface:LexoRankDao
Finds a single rank row for the given fieldId and issueId- Specified by:
findByFieldAndIssueId
in interfaceLexoRankDao
- Parameters:
fieldId
-issueId
-- Returns:
-
getByFieldAndIssueId
Description copied from interface:LexoRankDao
Gets a single LexoRankRow object with the given fieldId and issueId- Specified by:
getByFieldAndIssueId
in interfaceLexoRankDao
- Parameters:
fieldId
-issueId
-- Returns:
-
findMinimumMarkerRow
Description copied from interface:LexoRankDao
Finds the minimum marker row for the given fieldId- Specified by:
findMinimumMarkerRow
in interfaceLexoRankDao
- Parameters:
fieldId
-- Returns:
-
getMinimumMarkerRow
- Specified by:
getMinimumMarkerRow
in interfaceLexoRankDao
-
findMaximumMarkerRow
Description copied from interface:LexoRankDao
Finds the maximum marker row for the given fieldId- Specified by:
findMaximumMarkerRow
in interfaceLexoRankDao
- Parameters:
fieldId
-- Returns:
-
getMaximumMarkerRow
- Specified by:
getMaximumMarkerRow
in interfaceLexoRankDao
-
findMaximumRankLengthRow
Description copied from interface:LexoRankDao
Finds the issue row with the longest rank for the given fieldId- Specified by:
findMaximumRankLengthRow
in interfaceLexoRankDao
- Parameters:
fieldId
-- Returns:
-
getMinimumMarkerRowAndNextRow
Description copied from interface:LexoRankDao
Returns the minimum rank marker row and the next row ranked behind the minimum marker row for the given fieldId- Specified by:
getMinimumMarkerRowAndNextRow
in interfaceLexoRankDao
- Parameters:
fieldId
-- Returns:
-
getMaximumMarkerRowAndPreviousRow
Description copied from interface:LexoRankDao
Returns the maximum rank marker row and the previous row ranked before the maximum marker row for the given fieldId- Specified by:
getMaximumMarkerRowAndPreviousRow
in interfaceLexoRankDao
- Parameters:
fieldId
-- Returns:
-
getRowByRankAndNextRows
Description copied from interface:LexoRankDao
Returns the rank row with the given rank andhowMany
rows ranked after that row. The values are returned in ascending order sorted by rank field.- Specified by:
getRowByRankAndNextRows
in interfaceLexoRankDao
- Parameters:
fieldId
-rank
-- Returns:
- the rank row with the given rank and
howMany
rows ranked after that row
-
getRowByRankAndNextRow
Description copied from interface:LexoRankDao
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.- Specified by:
getRowByRankAndNextRow
in interfaceLexoRankDao
- Parameters:
fieldId
-rank
-- Returns:
-
findNextOneByRank
Description copied from interface:LexoRankDao
Find the next rank row (skipping over any duplicates)- Specified by:
findNextOneByRank
in interfaceLexoRankDao
- Parameters:
fieldId
- is the rank fieldrank
- is the rank value- Returns:
- the rank row
-
getRowByRankAndPreviousRows
Description copied from interface:LexoRankDao
Returns the rank row with the given rank andhowMany
rows ranked before that row. The values are returned in descending order sorted by rank field.- Specified by:
getRowByRankAndPreviousRows
in interfaceLexoRankDao
- Parameters:
fieldId
-rank
-- Returns:
- the rank row with the given rank and
howMany
rows ranked before that row
-
getRowByRankAndPreviousRow
Description copied from interface:LexoRankDao
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.- Specified by:
getRowByRankAndPreviousRow
in interfaceLexoRankDao
- Parameters:
fieldId
-rank
-- Returns:
-
findIssueIdsByFieldId
Description copied from interface:LexoRankDao
Retrieves a Set of issueIds of rank rows for the given fieldId- Specified by:
findIssueIdsByFieldId
in interfaceLexoRankDao
- Parameters:
fieldId
-- Returns:
-
findFieldIdsInLexoRankTable
Description copied from interface:LexoRankDao
Retrieves a Collection of rank row IDs that require balancing.- Specified by:
findFieldIdsInLexoRankTable
in interfaceLexoRankDao
- Returns:
-
findObsoleteFields
Description copied from interface:LexoRankDao
Finds fields that no longer have a corresponding entry in Jira Core's customfield table.- Specified by:
findObsoleteFields
in interfaceLexoRankDao
- Returns:
-
ranksCountByField
Description copied from interface:LexoRankDao
Gets the number of distinct ranks for a field in the db- Specified by:
ranksCountByField
in interfaceLexoRankDao
- Returns:
-
acquireLock
Description copied from interface:LexoRankDao
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.- Specified by:
acquireLock
in interfaceLexoRankDao
- Parameters:
rowIdToLock
-- Returns:
-
acquireLock
Description copied from interface:LexoRankDao
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.- Specified by:
acquireLock
in interfaceLexoRankDao
- Parameters:
rowToLock
-- Returns:
-
acquireLock
Description copied from interface:LexoRankDao
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.- Specified by:
acquireLock
in interfaceLexoRankDao
- Parameters:
rowsToLock
-- Returns:
-
acquireLock
Description copied from interface:LexoRankDao
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.- Specified by:
acquireLock
in interfaceLexoRankDao
- Parameters:
rowsToLock
-- Returns:
-
acquireLockByFieldId
Description copied from interface:LexoRankDao
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.- Specified by:
acquireLockByFieldId
in interfaceLexoRankDao
- Parameters:
fieldId
-- Returns:
-
releaseLock
Description copied from interface:LexoRankDao
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.- Specified by:
releaseLock
in interfaceLexoRankDao
- Parameters:
lock
-
-
deleteByIssueId
Description copied from interface:LexoRankDao
Deletes rows for the given issueId- Specified by:
deleteByIssueId
in interfaceLexoRankDao
- Parameters:
lock
-issueId
-- Returns:
-
deleteByLimitedIssueIds
Description copied from interface:LexoRankDao
Deletes rows for the given issueIds- Specified by:
deleteByLimitedIssueIds
in interfaceLexoRankDao
- Parameters:
lock
-issueIds
- of the issues. Must have less than 1000 elements otherwise the queries could fail on certain databases.- Returns:
-
deleteByFieldIdNoLock
Description copied from interface:LexoRankDao
Deletes all rows for a given fieldId without locking them first.- Specified by:
deleteByFieldIdNoLock
in interfaceLexoRankDao
- Parameters:
fieldId
-- Returns:
-
deleteByFieldId
Description copied from interface:LexoRankDao
Deletes rows for the given fieldId- Specified by:
deleteByFieldId
in interfaceLexoRankDao
- Parameters:
lock
-fieldId
-- Returns:
-
deleteByFieldIdAndIssueId
public LockProcessOutcome<ServiceResult> deleteByFieldIdAndIssueId(Lock lock, Long fieldId, Long issueId) Description copied from interface:LexoRankDao
Deletes a single rank row for the given fieldId and issueId- Specified by:
deleteByFieldIdAndIssueId
in interfaceLexoRankDao
- Parameters:
lock
-fieldId
-issueId
-- Returns:
-
deleteAll
Description copied from interface:LexoRankDao
Deletes all rows.- Specified by:
deleteAll
in interfaceLexoRankDao
- Returns:
-
save
Description copied from interface:LexoRankDao
Update a LexoRankRow.- Specified by:
save
in interfaceLexoRankDao
- Parameters:
lock
- is the lock objects.lexoRankRow
- the LexoRankRow to persist.- Returns:
- outcome of the save.
-
unlockedSave
Description copied from interface:LexoRankDao
Update a LexoRankRow, without the need for it to be locked.- Specified by:
unlockedSave
in interfaceLexoRankDao
- Parameters:
lexoRankRow
- the LexoRankRow to save- Returns:
- service outcome.
-
getRowsAtBalanceBoundaryForFieldId
public LexoRankRow[] getRowsAtBalanceBoundaryForFieldId(Long fieldId, LexoRankBucket bucketBeingMigratedFrom, LexoRankBucket bucketBeingMigratedTo) Description copied from interface:LexoRankDao
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- Specified by:
getRowsAtBalanceBoundaryForFieldId
in interfaceLexoRankDao
- Parameters:
fieldId
-bucketBeingMigratedFrom
-bucketBeingMigratedTo
-- Returns:
-
existsRankForFieldId
Description copied from interface:LexoRankDao
Checks if the given rank value already exists for the given rank field id.- Specified by:
existsRankForFieldId
in interfaceLexoRankDao
- Parameters:
rankFieldId
-rank
-- Returns:
-
countDuplicateRowsForFieldId
Description copied from interface:LexoRankDao
Returns a map of duplicate rank values and the amount of occurences of that rank value.- Specified by:
countDuplicateRowsForFieldId
in interfaceLexoRankDao
- Parameters:
fieldId
-- Returns:
-
listByFieldIdAndRank
Description copied from interface:LexoRankDao
Lists all the LexoRankRows for the given rank field id that have the given rank.- Specified by:
listByFieldIdAndRank
in interfaceLexoRankDao
- Parameters:
fieldId
-rank
-- Returns:
-
getRowCountForFieldId
Description copied from interface:LexoRankDao
Get the number of rows for a given rank field.- Specified by:
getRowCountForFieldId
in interfaceLexoRankDao
- Parameters:
fieldId
- Id of the rank field- Returns:
- Number of rows for the specified rank field
-
getRowCountInBucket
Description copied from interface:LexoRankDao
Get the number of rows for a given fieldId and bucket.- Specified by:
getRowCountInBucket
in interfaceLexoRankDao
- Parameters:
fieldId
- Id of the rank fieldcontainingBucket
-- Returns:
- the number of rows for a given fieldId and bucket.
-
getRowCountInBucket
public long getRowCountInBucket(Long fieldId, LexoRankBucket containingBucket, @Nullable LexoRankRow.RankRowType rankRowType) Description copied from interface:LexoRankDao
Get the number of rows for a given fieldId, bucket and type.- Specified by:
getRowCountInBucket
in interfaceLexoRankDao
- Parameters:
fieldId
- Id of the rank fieldcontainingBucket
-rankRowType
-- Returns:
- the number of rows for a given fieldId, rowType and bucket.
-
getNumRowsWithInvalidBucket
- Specified by:
getNumRowsWithInvalidBucket
in interfaceLexoRankDao
- Parameters:
fieldId
- is the rank field id- Returns:
- the number of rows where BUCKET doesn't match the bucket encoded in the RANK field.
-
listIssueIdsBetween
Description copied from interface:LexoRankDao
Get the stored issue IDs between startIdInclusive and endIdInclusive- Specified by:
listIssueIdsBetween
in interfaceLexoRankDao
- Parameters:
startIdInclusive
-endIdInclusive
-- Returns:
-
find
-