com.atlassian.jira.issue.search.parameters.lucene.util
Class QueryForCommentsCreator

java.lang.Object
  extended by com.atlassian.jira.issue.search.parameters.lucene.util.QueryForCommentsCreator

public final class QueryForCommentsCreator
extends Object


Nested Class Summary
(package private) static class QueryForCommentsCreator.BoostQueryCreator
          Implement this class in order to create query for boost field
 
Method Summary
(package private) static org.apache.lucene.search.Query boostQuery(org.apache.lucene.search.Query query, List fieldsList, Map boostMap, QueryForCommentsCreator.BoostQueryCreator creator)
          Boosts the given query with the list of fields that are in the given list and the boost map.
(package private) static org.apache.lucene.search.Query createCommentInProjectAndUserInRoleQuery(Long projectId, Long projectRoleId)
          Creates a new query that sets the project id must be equal to the given value and the project role visibility of the comment must be equal to the given value.
static org.apache.lucene.search.Query createGroupLevelQuery(List groups)
          Creates a new query with OR-ed groups
static org.apache.lucene.search.Query createNoGroupOrProjectRoleLevelQuery()
          Creates new query with the restriction of comment group level set to -1 (no group level) AND comment project role level set to -1 (no project role level).
static org.apache.lucene.search.Query createProjectRoleLevelQuery(ProjectRoleManager.ProjectIdToProjectRoleIdsMap projectIdToProjectRolesMap)
          Creates a project role level based restriction query.
static org.apache.lucene.search.Query createTextQuery(List fieldsList, String searchText, Map boostMap)
          This method creates a boosted query (if boostMap is specified).
(package private) static org.apache.lucene.search.BooleanClause.Occur[] generateShoulds(int size)
          Generates the array of BooleanClause.Occur.SHOULD with given size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createNoGroupOrProjectRoleLevelQuery

public static org.apache.lucene.search.Query createNoGroupOrProjectRoleLevelQuery()
Creates new query with the restriction of comment group level set to -1 (no group level) AND comment project role level set to -1 (no project role level).

Returns:
query

createGroupLevelQuery

public static org.apache.lucene.search.Query createGroupLevelQuery(List groups)
                                                            throws IllegalArgumentException
Creates a new query with OR-ed groups

Parameters:
groups - a list of groups to include in the query (List[String])
Returns:
Query with OR-ed groups
Throws:
IllegalArgumentException - if groups is null or empty

createProjectRoleLevelQuery

public static org.apache.lucene.search.Query createProjectRoleLevelQuery(ProjectRoleManager.ProjectIdToProjectRoleIdsMap projectIdToProjectRolesMap)
Creates a project role level based restriction query.

NOTE: This method should not be called with null or empty map (i.e if the user is not a member of any roles). If the user is not a member of any roles, the right thing to do is not to call this method.

Parameters:
projectIdToProjectRolesMap - Map[Long,Collection[ProjectRole]]
Returns:
query
Throws:
IllegalArgumentException - if projectIdToProjectRolesMap is null or empty

createTextQuery

public static org.apache.lucene.search.Query createTextQuery(List fieldsList,
                                                             String searchText,
                                                             Map boostMap)
                                                      throws IllegalArgumentException,
                                                             org.apache.lucene.queryParser.ParseException
This method creates a boosted query (if boostMap is specified). The query consists of OR-ed fields with value equal to the given search text.

Parameters:
fieldsList - field list
searchText - search text
boostMap - boost map
Returns:
boosted query
Throws:
IllegalArgumentException - if field list is null
org.apache.lucene.queryParser.ParseException - if parsing erro occurs

createCommentInProjectAndUserInRoleQuery

static org.apache.lucene.search.Query createCommentInProjectAndUserInRoleQuery(Long projectId,
                                                                               Long projectRoleId)
                                                                        throws IllegalArgumentException
Creates a new query that sets the project id must be equal to the given value and the project role visibility of the comment must be equal to the given value.

Parameters:
projectId - project ID
projectRoleId - project role ID
Returns:
new query
Throws:
IllegalArgumentException - if either of the parameters is null

generateShoulds

static org.apache.lucene.search.BooleanClause.Occur[] generateShoulds(int size)
                                                               throws IllegalArgumentException
Generates the array of BooleanClause.Occur.SHOULD with given size.

Parameters:
size - size of the array to generate
Returns:
the array of BooleanClause.Occur.SHOULD with given size
Throws:
IllegalArgumentException - is size is less than 0

boostQuery

static org.apache.lucene.search.Query boostQuery(org.apache.lucene.search.Query query,
                                                 List fieldsList,
                                                 Map boostMap,
                                                 QueryForCommentsCreator.BoostQueryCreator creator)
                                          throws org.apache.lucene.queryParser.ParseException
Boosts the given query with the list of fields that are in the given list and the boost map. The boost values come from the boost map. When boostMap is null or empty, the given query is returned.

Parameters:
query - query to boost
fieldsList - list of fields to boost
boostMap - boost map
creator - boost query creator
Returns:
boosted query
Throws:
org.apache.lucene.queryParser.ParseException - if parsing error occurs


Copyright © 2002-2007 Atlassian. All Rights Reserved.