Class JqlOrderByBuilder
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
Modifier and TypeMethodDescriptionAdd a search sort with the jqlClauseName and use the claues default sort to the end of the sort list in the order by.Add a search sort with the jqlClauseName and the specified sort to the end of the sort list in the order by.Add a search sort with the jqlClauseName and the specified sort to the order by.addSortForFieldName
(String fieldName, SortOrder order, boolean makePrimarySort) Add a search sort with the fieldName and the specified sort to the order by.affectedVersion
(SortOrder order) affectedVersion
(SortOrder order, boolean makePrimarySort) Call this method to build aQuery
using the current builder.clear()
Reset the builder to its empty state.createdDate
(SortOrder order) createdDate
(SortOrder order, boolean makePrimarySort) currentEstimate
(SortOrder order) currentEstimate
(SortOrder order, boolean makePrimarySort) description
(SortOrder order) description
(SortOrder order, boolean makePrimarySort) Call this to return to the parent JqlQueryBuilder.environment
(SortOrder order) environment
(SortOrder order, boolean makePrimarySort) fixForVersion
(SortOrder order) fixForVersion
(SortOrder order, boolean makePrimarySort) lastViewedDate
(SortOrder order) lastViewedDate
(SortOrder order, boolean makePrimarySort) originalEstimate
(SortOrder order) originalEstimate
(SortOrder order, boolean makePrimarySort) resolution
(SortOrder order) resolution
(SortOrder order, boolean makePrimarySort) resolutionDate
(SortOrder order) resolutionDate
(SortOrder order, boolean makePrimarySort) securityLevel
(SortOrder order) securityLevel
(SortOrder order, boolean makePrimarySort) Creates a builder who's state will be a mutable copy of the passed in order by.setSorts
(Collection<SearchSort> newSorts) Override any sorts that may have been setup in the builder with the provided list of sorts.updatedDate
(SortOrder order) updatedDate
(SortOrder order, boolean makePrimarySort)
-
Method Details
-
setSorts
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
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
Call this method to build aQuery
using the current builder. WhenendOrderBy()
is not null, this equates to callingendOrderBy().buildQuery()
. WhenendOrderBy()
is null, this equates to callingnew 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
- 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
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
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 viaSearchHandlerManager.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
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
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
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
-
priority
-
currentEstimate
-
currentEstimate
-
originalEstimate
-
originalEstimate
-
votes
-
votes
-
watches
-
watches
-
issueKey
-
issueKey
-
issueId
-
issueId
-
project
-
project
-
issueType
-
issueType
-
createdDate
-
createdDate
-
dueDate
-
dueDate
-
lastViewedDate
-
lastViewedDate
-
updatedDate
-
updatedDate
-
summary
-
summary
-
resolution
-
resolution
-
status
-
status
-
component
-
component
-
affectedVersion
-
affectedVersion
-
fixForVersion
-
fixForVersion
-
description
-
description
-
environment
-
environment
-
resolutionDate
-
resolutionDate
-
reporter
-
reporter
-
assignee
-
assignee
-
workRatio
-
workRatio
-
timeSpent
-
timeSpent
-
securityLevel
-
securityLevel
-