com.atlassian.greenhopper.manager.lexorank
Interface LexoRankDao

All Known Implementing Classes:
LexoRankDaoImpl

public interface LexoRankDao

DAO for LexoRank AOs.


Method Summary
 LockOutcome acquireLock(LexoRankRow[] rowsToLock, LexoRankDaoContext ctx)
          Attempts the acquire a database lock on the given LexoRankRows that represent rows in the LexoRank table.
 LockOutcome acquireLock(LexoRankRow rowToLock, LexoRankDaoContext ctx)
          Attempts the acquire a database lock on the given LexoRankRow that represents a row in the LexoRank table.
 LockOutcome acquireLock(java.lang.Long rowIdToLock, LexoRankDaoContext ctx)
          Attempts the acquire a database lock on the ID that represents a row in the LexoRank table.
 LockOutcome acquireLock(java.util.Set<LexoRankRow> rowsToLock, LexoRankDaoContext ctx)
          Attempts the acquire a database lock on the given LexoRankRows that represent rows in the LexoRank table.
 LockOutcome acquireLockByFieldId(java.lang.Long fieldId, LexoRankDaoContext ctx)
          Attempts the acquire a database lock on all rows in the LexoRank table whom's fieldId matches the given fieldId.
 java.util.Map<java.lang.String,java.lang.Long> countDuplicateRowsForFieldId(java.lang.Long fieldId, LexoRankDaoContext ctx)
          Returns a map of duplicate rank values and the amount of occurences of that rank value.
 LexoRankRow create(long fieldId, long issueId, java.lang.String rank)
          Create a row in the db for the given rank, issueId and fieldId
 int createBulk(long fieldId, java.util.Map<java.lang.Long,java.lang.String> issuesIdToRankMap)
          Creates a batch of LexoRank rows in one statement
 void createMarkerRowsForRankField(long fieldId)
          Creates the 'marker' rows for the given fieldId in the db.
 ServiceOutcome<java.lang.Void> deleteAll(LexoRankDaoContext ctx)
          Deletes all rows.
 LockProcessOutcome<ServiceOutcome<java.lang.Void>> deleteByFieldId(Lock lock, java.lang.Long fieldId, LexoRankDaoContext ctx)
          Deletes rows for the given fieldId
 LockProcessOutcome<ServiceOutcome<java.lang.Void>> deleteByFieldIdAndIssueId(Lock lock, java.lang.Long fieldId, java.lang.Long issueId, LexoRankDaoContext ctx)
          Deletes a single rank row for the given fieldId and issueId
 LockProcessOutcome<ServiceOutcome<java.lang.Void>> deleteByIssueId(Lock lock, java.lang.Long issueId, LexoRankDaoContext ctx)
          Deletes rows for the given issueId
 boolean existsRankForFieldId(java.lang.Long rankFieldId, java.lang.String rank, LexoRankDaoContext ctx)
          Checks if the given rank value already exists for the given rank field id.
 com.atlassian.fugue.Option<LexoRankRow> findByFieldAndIssueId(long fieldId, long issueId, LexoRankDaoContext ctx)
          Finds a single rank row for the given fieldId and issueId
 LexoRankRow[] findByFieldId(long fieldId, LexoRankDaoContext ctx)
          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
 LexoRankRow[] findByIssueId(long issueId, LexoRankDaoContext ctx)
          Returns all rank rows for a given issueId.
 java.util.Collection<java.lang.Long> findFieldsNeedingBalancing()
          Retrieves a Collection of rank row IDs that require balancing.
 java.util.Set<java.lang.Long> findIssueIdsByFieldId(long fieldId)
          Retrieves a Set of issueIds of rank rows for the given fieldId
 com.atlassian.fugue.Option<LexoRankRow> findMaximumMarkerRow(long fieldId, LexoRankDaoContext ctx)
          Finds the maximum marker row for the given fieldId
 com.atlassian.fugue.Option<LexoRankRow> findMinimumMarkerRow(long fieldId, LexoRankDaoContext ctx)
          Finds the minimum marker row for the given fieldId
 LexoRankRow findNextOneByRank(long fieldId, java.lang.String rank, LexoRankDaoContext ctx)
          Find the next rank row (skipping over any duplicates)
 LexoRankRow getByFieldAndIssueId(long fieldId, long issueId, LexoRankDaoContext ctx)
          Gets a single LexoRankRow object with the given fieldId and issueId
 LexoRankDaoContext getContext()
          Returns a LexoRankDaoContext object that should be passed to any methods on the LexoRankDao that require it.
 LexoRankRow getMaximumMarkerRow(long fieldId, LexoRankDaoContext ctx)
           
 LexoRankRow[] getMaximumMarkerRowAndPreviousRow(long fieldId, LexoRankDaoContext ctx)
          Returns the maximum rank marker row and the previous row ranked before the maximum marker row for the given fieldId
 LexoRankRow getMinimumMarkerRow(long fieldId, LexoRankDaoContext ctx)
           
 LexoRankRow[] getMinimumMarkerRowAndNextRow(long fieldId, LexoRankDaoContext ctx)
          Returns the minimum rank marker row and the next row ranked behind the minimum marker row for the given fieldId
 LexoRankRow[] getRowByRankAndNextRow(long fieldId, java.lang.String rank, LexoRankDaoContext ctx)
          Returns the rank row with the given rank and the row ranked after that row.
 LexoRankRow[] getRowByRankAndPreviousRow(long fieldId, java.lang.String rank, LexoRankDaoContext ctx)
          Returns the rank row with the given rank and the row ranked before that row.
 LexoRankRow[] getRowsAtBalanceBoundaryForFieldId(java.lang.Long fieldId, LexoRankBucket bucketBeingMigratedFrom, LexoRankBucket bucketBeingMigratedTo, LexoRankDaoContext ctx)
          Finds the 2 rows at the balance boundary for the given field id and bucket.
 java.util.List<LexoRankRow> listByFieldIdAndRank(java.lang.Long fieldId, java.lang.String rank, LexoRankDaoContext ctx)
          Lists all the LexoRankRows for the given rank field id that have the given rank.
 java.util.List<java.lang.Long> listIssueIdsByFieldIdAndIssueIds(long fieldId, java.util.List<java.lang.Long> issueIds)
          Returns a list of issue IDs for which a LexoRank row with fieldId and one of the given issueIds exists.
 java.util.Map<java.lang.Long,java.lang.Long> ranksCountByField()
          Gets the number of distinct ranks for a field in the db
 void releaseLock(Lock lock, LexoRankDaoContext ctx)
          Releases the lock on all rows locked by the given lock.
 LockProcessOutcome<ServiceOutcome<LexoRankRow>> save(Lock lock, LexoRankRow lexoRankRow, LexoRankDaoContext lexoRankDaoContext)
          Update a LexoRankRow.
 ServiceOutcome<LexoRankRow> unlockedSave(LexoRankRow lexoRankRow, LexoRankDaoContext lexoRankDaoContext)
          Update a LexoRankRow, without the need for it to be locked.
 

Method Detail

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,
                   java.lang.String rank)
Create a row in the db for the given rank, issueId and fieldId

Parameters:
fieldId -
issueId -
rank -
Returns:

createBulk

int createBulk(long fieldId,
               java.util.Map<java.lang.Long,java.lang.String> issuesIdToRankMap)
Creates a batch of LexoRank rows in one statement

Returns:
the number of ranks inserted

findByFieldId

LexoRankRow[] findByFieldId(long fieldId,
                            LexoRankDaoContext ctx)
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,
                            LexoRankDaoContext ctx)
Returns all rank rows for a given issueId.

Parameters:
issueId -
ctx -
Returns:

findByFieldAndIssueId

com.atlassian.fugue.Option<LexoRankRow> findByFieldAndIssueId(long fieldId,
                                                              long issueId,
                                                              LexoRankDaoContext ctx)
Finds a single rank row for the given fieldId and issueId

Parameters:
fieldId -
issueId -
ctx -
Returns:

listIssueIdsByFieldIdAndIssueIds

java.util.List<java.lang.Long> listIssueIdsByFieldIdAndIssueIds(long fieldId,
                                                                java.util.List<java.lang.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:

getByFieldAndIssueId

LexoRankRow getByFieldAndIssueId(long fieldId,
                                 long issueId,
                                 LexoRankDaoContext ctx)
Gets a single LexoRankRow object with the given fieldId and issueId

Parameters:
fieldId -
issueId -
ctx -
Returns:

getMinimumMarkerRowAndNextRow

LexoRankRow[] getMinimumMarkerRowAndNextRow(long fieldId,
                                            LexoRankDaoContext ctx)
Returns the minimum rank marker row and the next row ranked behind the minimum marker row for the given fieldId

Parameters:
fieldId -
ctx -
Returns:

getMaximumMarkerRowAndPreviousRow

LexoRankRow[] getMaximumMarkerRowAndPreviousRow(long fieldId,
                                                LexoRankDaoContext ctx)
Returns the maximum rank marker row and the previous row ranked before the maximum marker row for the given fieldId

Parameters:
fieldId -
ctx -
Returns:

getRowByRankAndNextRow

LexoRankRow[] getRowByRankAndNextRow(long fieldId,
                                     java.lang.String rank,
                                     LexoRankDaoContext ctx)
Returns the rank row with the given rank and the row ranked after that row.

Parameters:
fieldId -
rank -
ctx -
Returns:

getRowByRankAndPreviousRow

LexoRankRow[] getRowByRankAndPreviousRow(long fieldId,
                                         java.lang.String rank,
                                         LexoRankDaoContext ctx)
Returns the rank row with the given rank and the row ranked before that row.

Parameters:
fieldId -
rank -
ctx -
Returns:

findNextOneByRank

LexoRankRow findNextOneByRank(long fieldId,
                              java.lang.String rank,
                              LexoRankDaoContext ctx)
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

com.atlassian.fugue.Option<LexoRankRow> findMinimumMarkerRow(long fieldId,
                                                             LexoRankDaoContext ctx)
Finds the minimum marker row for the given fieldId

Parameters:
fieldId -
ctx -
Returns:

getMinimumMarkerRow

LexoRankRow getMinimumMarkerRow(long fieldId,
                                LexoRankDaoContext ctx)

findMaximumMarkerRow

com.atlassian.fugue.Option<LexoRankRow> findMaximumMarkerRow(long fieldId,
                                                             LexoRankDaoContext ctx)
Finds the maximum marker row for the given fieldId

Parameters:
fieldId -
ctx -
Returns:

getMaximumMarkerRow

LexoRankRow getMaximumMarkerRow(long fieldId,
                                LexoRankDaoContext ctx)

findIssueIdsByFieldId

java.util.Set<java.lang.Long> findIssueIdsByFieldId(long fieldId)
Retrieves a Set of issueIds of rank rows for the given fieldId

Parameters:
fieldId -
Returns:

findFieldsNeedingBalancing

java.util.Collection<java.lang.Long> findFieldsNeedingBalancing()
Retrieves a Collection of rank row IDs that require balancing.

Returns:

ranksCountByField

java.util.Map<java.lang.Long,java.lang.Long> ranksCountByField()
Gets the number of distinct ranks for a field in the db

Returns:

getContext

LexoRankDaoContext getContext()
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:

acquireLock

LockOutcome acquireLock(java.lang.Long rowIdToLock,
                        LexoRankDaoContext ctx)
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,
                        LexoRankDaoContext ctx)
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(java.util.Set<LexoRankRow> rowsToLock,
                        LexoRankDaoContext ctx)
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,
                        LexoRankDaoContext ctx)
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(java.lang.Long fieldId,
                                 LexoRankDaoContext ctx)
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,
                 LexoRankDaoContext ctx)
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 -
ctx -

save

LockProcessOutcome<ServiceOutcome<LexoRankRow>> save(Lock lock,
                                                     LexoRankRow lexoRankRow,
                                                     LexoRankDaoContext lexoRankDaoContext)
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,
                                         LexoRankDaoContext lexoRankDaoContext)
Update a LexoRankRow, without the need for it to be locked.

Parameters:
lexoRankRow - the LexoRankRow to save
Returns:
service outcome.

deleteByIssueId

LockProcessOutcome<ServiceOutcome<java.lang.Void>> deleteByIssueId(Lock lock,
                                                                   java.lang.Long issueId,
                                                                   LexoRankDaoContext ctx)
Deletes rows for the given issueId

Parameters:
lock -
issueId -
ctx -
Returns:

deleteAll

ServiceOutcome<java.lang.Void> deleteAll(LexoRankDaoContext ctx)
Deletes all rows.

Parameters:
ctx -
Returns:

deleteByFieldId

LockProcessOutcome<ServiceOutcome<java.lang.Void>> deleteByFieldId(Lock lock,
                                                                   java.lang.Long fieldId,
                                                                   LexoRankDaoContext ctx)
Deletes rows for the given fieldId

Parameters:
lock -
fieldId -
ctx -
Returns:

deleteByFieldIdAndIssueId

LockProcessOutcome<ServiceOutcome<java.lang.Void>> deleteByFieldIdAndIssueId(Lock lock,
                                                                             java.lang.Long fieldId,
                                                                             java.lang.Long issueId,
                                                                             LexoRankDaoContext ctx)
Deletes a single rank row for the given fieldId and issueId

Parameters:
lock -
fieldId -
issueId -
ctx -
Returns:

getRowsAtBalanceBoundaryForFieldId

LexoRankRow[] getRowsAtBalanceBoundaryForFieldId(java.lang.Long fieldId,
                                                 LexoRankBucket bucketBeingMigratedFrom,
                                                 LexoRankBucket bucketBeingMigratedTo,
                                                 LexoRankDaoContext ctx)
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 -
ctx -
Returns:

existsRankForFieldId

boolean existsRankForFieldId(java.lang.Long rankFieldId,
                             java.lang.String rank,
                             LexoRankDaoContext ctx)
Checks if the given rank value already exists for the given rank field id.

Parameters:
rankFieldId -
rank -
ctx -
Returns:

countDuplicateRowsForFieldId

java.util.Map<java.lang.String,java.lang.Long> countDuplicateRowsForFieldId(java.lang.Long fieldId,
                                                                            LexoRankDaoContext ctx)
Returns a map of duplicate rank values and the amount of occurences of that rank value.

Parameters:
fieldId -
ctx -
Returns:

listByFieldIdAndRank

java.util.List<LexoRankRow> listByFieldIdAndRank(java.lang.Long fieldId,
                                                 java.lang.String rank,
                                                 LexoRankDaoContext ctx)
Lists all the LexoRankRows for the given rank field id that have the given rank.

Parameters:
fieldId -
rank -
ctx -
Returns:


Copyright © 2007-2014 Atlassian. All Rights Reserved.