com.atlassian.greenhopper.service.rank
Class RankIndexServiceImpl

java.lang.Object
  extended by com.atlassian.greenhopper.global.AbstractLoggable
      extended by com.atlassian.greenhopper.service.rank.RankIndexServiceImpl
All Implemented Interfaces:
RankIndexService

@Service
public class RankIndexServiceImpl
extends AbstractLoggable
implements RankIndexService

The rank system is made of two main components: The stored rank, which is a single linked list of issueIDs in an AO table, and the runtime rank index, which is an in-memory lookup map of chained Rank objects that maintain a numeric position index. The index is loaded from the database once the plugin is initialised. During normal operations, this service takes care of rank change operations by updating the database, the rank object chain and the position index. All runtime queries against the position of an issue are hitting the index.


Field Summary
 
Fields inherited from class com.atlassian.greenhopper.global.AbstractLoggable
logger
 
Constructor Summary
RankIndexServiceImpl()
           
 
Method Summary
 void clearIndices(com.atlassian.jira.event.ClearCacheEvent event)
           
 int compare(long customFieldId, long firstId, long secondId)
          Used by Lucene to sort issues by rank
 long getIssuePosition(long customFieldId, long issueId)
          Fetch the position, add issue as last if it's not tracked
 RankChange rankAfter(long customFieldId, long issueId, long rankAfterId)
          We define after as the default
 RankChange rankBefore(long customFieldId, long issueId, long rankBeforeId)
          RankBefore is just a special case of RankAfter
 RankChange rankFirst(long customFieldId, long issueId)
          Rank first : rank after head
 RankChange rankLast(long customFieldId, long issueId)
          Rank last : rank after the parent of tail
 java.util.List<RankChange> rankLastForAllFields(long issueId)
           
 RankChange removeIssue(long customFieldId, long issueId)
          Remove issue from DB and index
 java.util.List<RankChange> removeIssueForAllFields(long issueId)
           
 void selfDestruct()
          Destroy this service to ensure that we don't have several instances talking to the database in parallel, in the event of a leaked classloader.
 
Methods inherited from class com.atlassian.greenhopper.global.AbstractLoggable
logDebug, logError, logException, logInfo, logTrace, logWarn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RankIndexServiceImpl

public RankIndexServiceImpl()
Method Detail

compare

public int compare(long customFieldId,
                   long firstId,
                   long secondId)
Used by Lucene to sort issues by rank

Specified by:
compare in interface RankIndexService

getIssuePosition

public long getIssuePosition(long customFieldId,
                             long issueId)
Fetch the position, add issue as last if it's not tracked

Specified by:
getIssuePosition in interface RankIndexService

rankFirst

public RankChange rankFirst(long customFieldId,
                            long issueId)
Rank first : rank after head

Specified by:
rankFirst in interface RankIndexService
Returns:
the old index of the ranked issue. null if the issue was inserted as part of the rank operation

rankBefore

public RankChange rankBefore(long customFieldId,
                             long issueId,
                             long rankBeforeId)
RankBefore is just a special case of RankAfter

Specified by:
rankBefore in interface RankIndexService
issueId - : The ID of the issue to be ranked
rankBeforeId - : The ID of the issue to be ranked before. If this doesn't exist in the index, it will be added at the last position.
Returns:
the old index of the ranked issue. null if the issue was inserted as part of the rank operation

rankAfter

public RankChange rankAfter(long customFieldId,
                            long issueId,
                            long rankAfterId)
We define after as the default

Specified by:
rankAfter in interface RankIndexService
issueId - : The ID of the issue to be ranked
rankAfterId - : The ID of the issue to be ranked after. If this doesn't exist in the index, it will be added at the last position.
Returns:
the old index of the ranked issue. null if the issue was inserted as part of the rank operation

rankLast

public RankChange rankLast(long customFieldId,
                           long issueId)
Rank last : rank after the parent of tail

Specified by:
rankLast in interface RankIndexService
Returns:
the old index of the ranked issue. null if the issue was inserted as part of the rank operation

rankLastForAllFields

public java.util.List<RankChange> rankLastForAllFields(long issueId)
Specified by:
rankLastForAllFields in interface RankIndexService

removeIssue

public RankChange removeIssue(long customFieldId,
                              long issueId)
Remove issue from DB and index

Specified by:
removeIssue in interface RankIndexService

removeIssueForAllFields

public java.util.List<RankChange> removeIssueForAllFields(long issueId)
Specified by:
removeIssueForAllFields in interface RankIndexService

selfDestruct

public void selfDestruct()
Destroy this service to ensure that we don't have several instances talking to the database in parallel, in the event of a leaked classloader.


clearIndices

@EventListener
public void clearIndices(com.atlassian.jira.event.ClearCacheEvent event)


Copyright © 2007-2012 Atlassian. All Rights Reserved.