com.atlassian.jira.jql.util
Class JqlCascadingSelectLiteralUtil

java.lang.Object
  extended by com.atlassian.jira.jql.util.JqlCascadingSelectLiteralUtil

@InjectableComponent
public class JqlCascadingSelectLiteralUtil
extends java.lang.Object

Utility class for processing QueryLiteral objects when dealing with CascadingSelectCFType custom field classes.

Since:
v4.0
See Also:
CascadingSelectCustomFieldClauseQueryFactory, CascadingSelectCustomFieldValidator, CascadingSelectCustomFieldClauseContextFactory

Constructor Summary
JqlCascadingSelectLiteralUtil(JqlSelectOptionsUtil jqlSelectOptionsUtil)
           
 
Method Summary
 java.util.List<QueryLiteral> createQueryLiteralsFromOptions(Operand sourceOperand, java.util.Collection<Option> positiveOptions, java.util.Collection<Option> negativeOptions)
          Given a list of Options that should be in the result (positive) and a list of Options that shouldn't (negative) creates a list of QueryLiterals that represent the positive and negative options and be used for generating the query.
 boolean isNegativeLiteral(QueryLiteral literal)
          Determines if the QueryLiteral represents a Option that should be excluded from the result.
 void processPositiveNegativeOptionLiterals(java.util.List<QueryLiteral> inputLiterals, java.util.List<QueryLiteral> positiveLiterals, java.util.List<QueryLiteral> negativeLiterals)
          Processes the input literals into two groups: positive literals and negative literals.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JqlCascadingSelectLiteralUtil

public JqlCascadingSelectLiteralUtil(JqlSelectOptionsUtil jqlSelectOptionsUtil)
Method Detail

createQueryLiteralsFromOptions

public java.util.List<QueryLiteral> createQueryLiteralsFromOptions(Operand sourceOperand,
                                                                   java.util.Collection<Option> positiveOptions,
                                                                   java.util.Collection<Option> negativeOptions)

Given a list of Options that should be in the result (positive) and a list of Options that shouldn't (negative) creates a list of QueryLiterals that represent the positive and negative options and be used for generating the query.

Parameters:
sourceOperand - the operand that the literals are being preduced from
positiveOptions - the options that should be included
negativeOptions - the options that should be excluded
Returns:
a list of query literals representing the options to be included and excluded. All QueryLiterals will be Long values. Negative options will be represented by negative Long values. Never null.

processPositiveNegativeOptionLiterals

public void processPositiveNegativeOptionLiterals(java.util.List<QueryLiteral> inputLiterals,
                                                  java.util.List<QueryLiteral> positiveLiterals,
                                                  java.util.List<QueryLiteral> negativeLiterals)

Processes the input literals into two groups: positive literals and negative literals.

Negative literals are those which have a negative Long value, which when inverted correctly maps to the id of an option in the system.

All other literals, including EMPTY literals, are positive literals.

If a negative literal is encountered, a new QueryLiteral with the inverse Long value is added to the list.

Parameters:
inputLiterals - the literals to process
positiveLiterals - a list of positive literals to add to when processing
negativeLiterals - a list of negative literals to add to when processing

isNegativeLiteral

public boolean isNegativeLiteral(QueryLiteral literal)
Determines if the QueryLiteral represents a Option that should be excluded from the result.

Parameters:
literal - the QueryLiteral to check is negative.
Returns:
true if the QueryLiteral represents an Option to be excluded from the results. False otherwise.


Copyright © 2002-2010 Atlassian. All Rights Reserved.