com.atlassian.jira.issue.index.indexers.impl
Class IssueLinkIndexer

java.lang.Object
  extended by com.atlassian.jira.issue.index.indexers.impl.IssueLinkIndexer
All Implemented Interfaces:
FieldIndexer

public class IssueLinkIndexer
extends Object
implements FieldIndexer


Field Summary
 
Fields inherited from interface com.atlassian.jira.issue.index.indexers.FieldIndexer
LABELS_NO_VALUE_INDEX_VALUE, NO_VALUE_INDEX_VALUE
 
Constructor Summary
IssueLinkIndexer(IssueLinkManager issueLinkManager)
           
 
Method Summary
 void addIndex(org.apache.lucene.document.Document doc, Issue issue)
          We index the links in 3 ways.
static String createValue(Long issueLinkTypeId)
          Creates a term query value based only on the link type.
static String createValue(Long issueLinkTypeId, Direction direction)
          Creates a term query value based on the link type and direction.
static String createValue(Long issueLinkTypeId, Direction direction, Long otherIssueId)
          Creates a term query value based on the link type, direction and destination issue.
 String getDocumentFieldId()
           
 String getId()
           
 boolean isFieldVisibleAndInScope(Issue issue)
          We have to always index the link because we want to support the use of links for system-level issue relationships implemented by system links without linking enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IssueLinkIndexer

public IssueLinkIndexer(IssueLinkManager issueLinkManager)
Method Detail

createValue

public static String createValue(Long issueLinkTypeId)
Creates a term query value based only on the link type.

Parameters:
issueLinkTypeId - the id of the issue link type.
Returns:
the value as found in the index.

createValue

public static String createValue(Long issueLinkTypeId,
                                 Direction direction)
Creates a term query value based on the link type and direction.

Parameters:
issueLinkTypeId - the id of the issue link type.
direction - the direction of the link.
Returns:
the value as found in the index

createValue

public static String createValue(Long issueLinkTypeId,
                                 Direction direction,
                                 Long otherIssueId)
Creates a term query value based on the link type, direction and destination issue.

Parameters:
issueLinkTypeId - the id of the issue link type.
direction - the direction of the link.
otherIssueId - the id of issue the link links to.
Returns:
the value as found in the index

getId

public String getId()
Specified by:
getId in interface FieldIndexer
Returns:
the String representation of the field id that this indexer is indexing, this must be unique for each independant FieldIndexer. If the Indexer does not represent a System or Custom field in JIRA this should still return a unique string that describes the indexer.

getDocumentFieldId

public String getDocumentFieldId()
Specified by:
getDocumentFieldId in interface FieldIndexer
Returns:
the String representation of the primary field id that will be added to the Document as a result of a successful call to the FieldIndexer.addIndex(org.apache.lucene.document.Document, com.atlassian.jira.issue.Issue) method.

isFieldVisibleAndInScope

public boolean isFieldVisibleAndInScope(Issue issue)
We have to always index the link because we want to support the use of links for system-level issue relationships implemented by system links without linking enabled.

Specified by:
isFieldVisibleAndInScope in interface FieldIndexer
Parameters:
issue - the issue with the link (unused).
Returns:
true always.

addIndex

public void addIndex(org.apache.lucene.document.Document doc,
                     Issue issue)
We index the links in 3 ways. First, we index just the link type, so queries can be done like see if something is a duplicate of another issue. Second, we index the link type with a direction flag which enables queries of all issues that are blockers of other issues. Third, we link the link type plus direction plus the OTHER issue id so that we can do a search like "all cloners of this issue" (or all cloners of other issues!).

Specified by:
addIndex in interface FieldIndexer
Parameters:
doc - the lucene document that should be modified by adding relevant fields to.
issue - the issue that contains the data that will be indexed and which can be used to determine the project/issue type context that will allow you to determine if we should add the value as searchable


Copyright © 2002-2012 Atlassian. All Rights Reserved.