com.atlassian.jira.jql.builder
Class JqlOrderByBuilder

java.lang.Object
  extended by com.atlassian.jira.jql.builder.JqlOrderByBuilder

@NotThreadSafe
public class JqlOrderByBuilder
extends Object

Used to create OrderBy clauses to be included in Query's. The OrderBy portion of a JQL query is made up of zero of more order clauses. Each clause composes of a field and either a SortOrder.ASC or a SortOrder.DESC sort order. The order of sorting is from the first search clause in the list to the last. For example builder.status(SortOrder.DESC).component(SortOrder.ASC).buildOrderBy() will produce the Order By statement Order By status DESC component ASC which will first sort the result by status descending, and then by component ascending.

Since:
v4.0

Method Summary
 JqlOrderByBuilder add(String jqlClauseName)
          Add a search sort with the jqlClauseName and use the claues default sort to the end of the sort list in the order by.
 JqlOrderByBuilder add(String jqlClauseName, SortOrder order)
          Add a search sort with the jqlClauseName and the specified sort to the end of the sort list in the order by.
 JqlOrderByBuilder add(String jqlClauseName, SortOrder order, boolean makePrimarySort)
          Add a search sort with the jqlClauseName and the specified sort to the order by.
 JqlOrderByBuilder addSortForFieldName(String fieldName, SortOrder order, boolean makePrimarySort)
          Add a search sort with the fieldName and the specified sort to the order by.
 JqlOrderByBuilder affectedVersion(SortOrder order)
           
 JqlOrderByBuilder affectedVersion(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder assignee(SortOrder order)
           
 JqlOrderByBuilder assignee(SortOrder order, boolean makePrimarySort)
           
 OrderBy buildOrderBy()
           
 Query buildQuery()
          Call this method to build a Query using the current builder.
 JqlOrderByBuilder clear()
          Reset the builder to its empty state.
 JqlOrderByBuilder component(SortOrder order)
           
 JqlOrderByBuilder component(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder createdDate(SortOrder order)
           
 JqlOrderByBuilder createdDate(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder currentEstimate(SortOrder order)
           
 JqlOrderByBuilder currentEstimate(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder description(SortOrder order)
           
 JqlOrderByBuilder description(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder dueDate(SortOrder order)
           
 JqlOrderByBuilder dueDate(SortOrder order, boolean makePrimarySort)
           
 JqlQueryBuilder endOrderBy()
          Call this to return to the parent JqlQueryBuilder.
 JqlOrderByBuilder environment(SortOrder order)
           
 JqlOrderByBuilder environment(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder fixForVersion(SortOrder order)
           
 JqlOrderByBuilder fixForVersion(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder issueId(SortOrder order)
           
 JqlOrderByBuilder issueId(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder issueKey(SortOrder order)
           
 JqlOrderByBuilder issueKey(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder issueType(SortOrder order)
           
 JqlOrderByBuilder issueType(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder originalEstimate(SortOrder order)
           
 JqlOrderByBuilder originalEstimate(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder priority(SortOrder order)
           
 JqlOrderByBuilder priority(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder project(SortOrder order)
           
 JqlOrderByBuilder project(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder reporter(SortOrder order)
           
 JqlOrderByBuilder reporter(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder resolution(SortOrder order)
           
 JqlOrderByBuilder resolution(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder resolutionDate(SortOrder order)
           
 JqlOrderByBuilder resolutionDate(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder securityLevel(SortOrder order)
           
 JqlOrderByBuilder securityLevel(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder setSorts(Collection<SearchSort> newSorts)
          Override any sorts that may have been setup in the builder with the provided list of sorts.
 JqlOrderByBuilder setSorts(OrderBy existingOrderBy)
          Creates a builder who's state will be a mutable copy of the passed in order by.
 JqlOrderByBuilder status(SortOrder order)
           
 JqlOrderByBuilder status(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder summary(SortOrder order)
           
 JqlOrderByBuilder summary(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder timeSpent(SortOrder order)
           
 JqlOrderByBuilder timeSpent(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder updatedDate(SortOrder order)
           
 JqlOrderByBuilder updatedDate(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder votes(SortOrder order)
           
 JqlOrderByBuilder votes(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder watches(SortOrder order)
           
 JqlOrderByBuilder watches(SortOrder order, boolean makePrimarySort)
           
 JqlOrderByBuilder workRatio(SortOrder order)
           
 JqlOrderByBuilder workRatio(SortOrder order, boolean makePrimarySort)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setSorts

public JqlOrderByBuilder setSorts(Collection<SearchSort> newSorts)
Override any sorts that may have been setup in the builder with the provided list of sorts.

Parameters:
newSorts - the new sorts to include in the builder, must not be null.
Returns:
this builder.

setSorts

public JqlOrderByBuilder setSorts(OrderBy existingOrderBy)
Creates a builder who's state will be a mutable copy of the passed in order by.

Parameters:
existingOrderBy - the template which defines the state the builder will be in once this method returns.
Returns:
a builder who's state will be a mutable copy of the passed in order by.

buildQuery

public Query buildQuery()
Call this method to build a Query using the current builder. When endOrderBy() is not null, this equates to calling endOrderBy().buildQuery(). When endOrderBy() is null, this equates to calling new QueryImpl(null, buildOrderBy(), null).

Returns:
the newly generated query.
Throws:
IllegalStateException - if it is not possible to build the current query given the state of the builder.

buildOrderBy

public OrderBy buildOrderBy()
Returns:
the OrderBy that is defined by the state of the builder.

NOTE: Calling this method does not change the state of the builder, there are no limitations on the number of times this method can be invoked.


endOrderBy

public JqlQueryBuilder endOrderBy()
Call this to return to the parent JqlQueryBuilder.

Returns:
the query builder who created this order by builder. May be null if there is no associated JqlQueryBuilder.

clear

public JqlOrderByBuilder clear()
Reset the builder to its empty state.

Returns:
the builder in its empty state.

addSortForFieldName

public JqlOrderByBuilder addSortForFieldName(String fieldName,
                                             SortOrder order,
                                             boolean makePrimarySort)
Add a search sort with the fieldName and the specified sort to the order by. This is a convienience method that trys to lookup the primary JQL clause name for the provided field name.

If we are unable to find the associated clause name then the sort will be added with the provided field name and will likely not pass JQL validation.

Parameters:
fieldName - the field name used to lookup the JQL clause name via SearchHandlerManager.getJqlClauseNames(String) method.
order - the order, ASC, or DESC.
makePrimarySort - if true this will be added to the beginning of the sorts, otherwise it will be added to the end.
Returns:
the current builder.

add

public JqlOrderByBuilder add(String jqlClauseName,
                             SortOrder order,
                             boolean makePrimarySort)
Add a search sort with the jqlClauseName and the specified sort to the order by. No validation is done in this builder so you must make sure you create valid sorts.

Parameters:
jqlClauseName - the JQL clause name to sort by.
order - the order, ASC, or DESC.
makePrimarySort - if true this will be added to the beginning of the sorts, otherwise it will be added to the end.
Returns:
the current builder.

add

public JqlOrderByBuilder add(String jqlClauseName,
                             SortOrder order)
Add a search sort with the jqlClauseName and the specified sort to the end of the sort list in the order by. No validation is done in this builder so you must make sure you create valid sorts.

This is the same as calling add(String, com.atlassian.query.order.SortOrder, boolean) with false.

Parameters:
jqlClauseName - the JQL clause name to sort by.
order - the order, ASC, or DESC.
Returns:
the current builder.

add

public JqlOrderByBuilder add(String jqlClauseName)
Add a search sort with the jqlClauseName and use the claues default sort to the end of the sort list in the order by. No validation is done in this builder so you must make sure you create valid sorts.

This is the same as calling add(String, com.atlassian.query.order.SortOrder, boolean) with null and false.

Parameters:
jqlClauseName - the JQL clause name to sort by.
Returns:
the current builder.

priority

public JqlOrderByBuilder priority(SortOrder order,
                                  boolean makePrimarySort)

priority

public JqlOrderByBuilder priority(SortOrder order)

currentEstimate

public JqlOrderByBuilder currentEstimate(SortOrder order)

currentEstimate

public JqlOrderByBuilder currentEstimate(SortOrder order,
                                         boolean makePrimarySort)

originalEstimate

public JqlOrderByBuilder originalEstimate(SortOrder order)

originalEstimate

public JqlOrderByBuilder originalEstimate(SortOrder order,
                                          boolean makePrimarySort)

votes

public JqlOrderByBuilder votes(SortOrder order)

votes

public JqlOrderByBuilder votes(SortOrder order,
                               boolean makePrimarySort)

watches

public JqlOrderByBuilder watches(SortOrder order)

watches

public JqlOrderByBuilder watches(SortOrder order,
                                 boolean makePrimarySort)

issueKey

public JqlOrderByBuilder issueKey(SortOrder order)

issueKey

public JqlOrderByBuilder issueKey(SortOrder order,
                                  boolean makePrimarySort)

issueId

public JqlOrderByBuilder issueId(SortOrder order)

issueId

public JqlOrderByBuilder issueId(SortOrder order,
                                 boolean makePrimarySort)

project

public JqlOrderByBuilder project(SortOrder order)

project

public JqlOrderByBuilder project(SortOrder order,
                                 boolean makePrimarySort)

issueType

public JqlOrderByBuilder issueType(SortOrder order)

issueType

public JqlOrderByBuilder issueType(SortOrder order,
                                   boolean makePrimarySort)

createdDate

public JqlOrderByBuilder createdDate(SortOrder order)

createdDate

public JqlOrderByBuilder createdDate(SortOrder order,
                                     boolean makePrimarySort)

dueDate

public JqlOrderByBuilder dueDate(SortOrder order)

dueDate

public JqlOrderByBuilder dueDate(SortOrder order,
                                 boolean makePrimarySort)

updatedDate

public JqlOrderByBuilder updatedDate(SortOrder order)

updatedDate

public JqlOrderByBuilder updatedDate(SortOrder order,
                                     boolean makePrimarySort)

summary

public JqlOrderByBuilder summary(SortOrder order)

summary

public JqlOrderByBuilder summary(SortOrder order,
                                 boolean makePrimarySort)

resolution

public JqlOrderByBuilder resolution(SortOrder order)

resolution

public JqlOrderByBuilder resolution(SortOrder order,
                                    boolean makePrimarySort)

status

public JqlOrderByBuilder status(SortOrder order)

status

public JqlOrderByBuilder status(SortOrder order,
                                boolean makePrimarySort)

component

public JqlOrderByBuilder component(SortOrder order)

component

public JqlOrderByBuilder component(SortOrder order,
                                   boolean makePrimarySort)

affectedVersion

public JqlOrderByBuilder affectedVersion(SortOrder order)

affectedVersion

public JqlOrderByBuilder affectedVersion(SortOrder order,
                                         boolean makePrimarySort)

fixForVersion

public JqlOrderByBuilder fixForVersion(SortOrder order)

fixForVersion

public JqlOrderByBuilder fixForVersion(SortOrder order,
                                       boolean makePrimarySort)

description

public JqlOrderByBuilder description(SortOrder order)

description

public JqlOrderByBuilder description(SortOrder order,
                                     boolean makePrimarySort)

environment

public JqlOrderByBuilder environment(SortOrder order)

environment

public JqlOrderByBuilder environment(SortOrder order,
                                     boolean makePrimarySort)

resolutionDate

public JqlOrderByBuilder resolutionDate(SortOrder order)

resolutionDate

public JqlOrderByBuilder resolutionDate(SortOrder order,
                                        boolean makePrimarySort)

reporter

public JqlOrderByBuilder reporter(SortOrder order)

reporter

public JqlOrderByBuilder reporter(SortOrder order,
                                  boolean makePrimarySort)

assignee

public JqlOrderByBuilder assignee(SortOrder order)

assignee

public JqlOrderByBuilder assignee(SortOrder order,
                                  boolean makePrimarySort)

workRatio

public JqlOrderByBuilder workRatio(SortOrder order)

workRatio

public JqlOrderByBuilder workRatio(SortOrder order,
                                   boolean makePrimarySort)

timeSpent

public JqlOrderByBuilder timeSpent(SortOrder order)

timeSpent

public JqlOrderByBuilder timeSpent(SortOrder order,
                                   boolean makePrimarySort)

securityLevel

public JqlOrderByBuilder securityLevel(SortOrder order)

securityLevel

public JqlOrderByBuilder securityLevel(SortOrder order,
                                       boolean makePrimarySort)


Copyright © 2002-2012 Atlassian. All Rights Reserved.