com.atlassian.jira.issue.search
Class SearchRequest

java.lang.Object
  extended by com.atlassian.jira.issue.search.SearchRequest
All Implemented Interfaces:
Favourite, SharedEntity, Serializable

public class SearchRequest
extends Object
implements Serializable, SharedEntity

A class representing a Search Request. Sometimes also referred to as a "Saved search", "Saved Filter", "Search Filter". This sits in the session so all non-serializable properties should be transient and accessed through accessors.

TODO SearchRequest has traditionally been backed by a collection (so you could have mutliple SP with the same name). Is this intended? I don't really see where this is used & all helper methods (getValues) picks out the first named SP anyway. Not sure if we should remove and enforce a single SR only

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.jira.sharing.SharedEntity
SharedEntity.Indentifier, SharedEntity.SharePermissions, SharedEntity.TypeDescriptor
 
Field Summary
static SharedEntity.TypeDescriptor ENTITY_TYPE
           
 
Constructor Summary
SearchRequest(boolean turnOffSecurity)
          This constructor should only be used by internal JIRA queries, as the results will be unprotected (ie no permission checks are done).
SearchRequest(electric.xml.Document doc)
          Construct a SearchRequest from its XML representation.
SearchRequest(electric.xml.Document doc, User searcher)
           
SearchRequest(org.ofbiz.core.entity.GenericValue gv)
           
SearchRequest(SearchRequest oldSearchRequest, User searcher)
           
SearchRequest(String searcherUserName)
           
SearchRequest(String searcherUserName, String name, String description)
           
SearchRequest(User searcher)
          Deprecated. since v3.13. Use SearchRequest(String) instead.
SearchRequest(User searcher, String name, String description)
          Deprecated. since v3.13. Use SearchRequest(String, String, String) instead.
 
Method Summary
 void addParameter(SearchParameter parameter)
          Add a SearchParameter to this search.
 void addParameters(Collection searchParams)
           
 void addSearchSort(SearchSort searchSort)
           
 SearchRequest asSearchRequestWithParameters(Collection searchParameters, Collection searchSorts)
          Return a new a copy of this SearchRequest with its search parameters and search sorts replaced with the passed arguments.
 SearchRequest cloneSearchRequest()
           
 SearchRequest copy()
          Return a copy of the SearchRequest.
 void createSearchSorts(Map params)
          Adds SearchSort parameters to the searchRequest, to specify ordering and sorting of results.
 boolean equals(Object o)
           
 User getAuthor()
          Deprecated. since v3.13. Use getOwnerUserName() instead.
 String getDescription()
          A general description of the entity.
 SharedEntity.TypeDescriptor getEntityType()
          The type of entity it is.
 Long getFavouriteCount()
          The number of users who have marked this entity as one of their favourites.
 Long getId()
          The id of the entity.
 List getLuceneParameters()
           
 String getName()
          The name of the entity.
 String getOwnerUserName()
          The user name of the owner of the entity.
 SearchParameter getParam(String paramName)
          Returns the first SearchParameter that matches the given name.
 List getParameters()
          Returns all the parameters for the search request as a List of SearchParameter
 SharedEntity.SharePermissions getPermissions()
          The permissions for this entity.
 org.ofbiz.core.entity.GenericValue getProject()
          Deprecated. since 3.5 (for removal in 3.8).

To retrieve the projects that are being searched by a search request check for the existance of ProjectParameter:

                                                                SearchParameter projParam = searchRequest.getParam(DocumentConstants.PROJECT_ID)
                         
If the projParam is null then all projects are being searched. (TODO Check that this is indeed true).

If the param is not null, to retrieve the project ids that are being searched, call:

                         Collection searchedProjectIds = projParam.getValues();
                         
searchedProjectIds should be a Collection of Longs.
 String getQueryString()
          Returns the encoded query string of the current search request
 String getQueryStringWithSorts()
          Returns the encoded query string of the current search request with sort info
 List getReleventSearchers()
           
 SearchContext getSearchContext()
           
 org.ofbiz.core.entity.GenericValue getSearchFilterGV()
           
 Long getSearchFilterId()
           
 SearchRequest getSearchRequestWithSubstitutions(List substitutions)
          This method will return an new instance of a SearchRequest that will have the same parameters as in this SearchRequest except that any parameters listed in the substitutions list will exist in the new SearchRequest in place of any of the same parameters that may have been in this SearchRequest.
 Collection getSearchSorts()
           
 Collection getSearchSortsReverse()
           
 List getValues(String paramName)
          Returns the values of the first SearchParameter that matches the given name.
 electric.xml.Document getXml()
          Returns the search request as an XML document
 int hashCode()
           
 boolean isContainsParam(String paramName)
          Whether the SR contains this param name
 boolean isLoaded()
           
 boolean isModified()
           
 boolean isOverRideSecurity()
           
 void removeParameter(SearchParameter parameter)
          This method will remove a parameter by name.
 void setAuthor(User author)
          Deprecated. since v3.13. Use setOwnerUserName(String) instead.
 void setDescription(String description)
           
protected  void setFavouriteCount(Long favouriteCount)
           
protected  void setId(Long id)
           
 void setLoaded(boolean loaded)
           
 void setModified(boolean modified)
           
 void setName(String name)
           
 void setOwnerUserName(String ownerUserName)
          Set the owner of the SearchRequest.
 void setPermissions(SharedEntity.SharePermissions sharePermissions)
           
 void setSearchContext(SearchContext searchContext)
           
 void setSearchSorts(Collection searchSorts)
           
 void setUseColumns(boolean useColumns)
           
 String toString()
           
 boolean useColumns()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ENTITY_TYPE

public static final SharedEntity.TypeDescriptor ENTITY_TYPE
Constructor Detail

SearchRequest

public SearchRequest(User searcher)
Deprecated. since v3.13. Use SearchRequest(String) instead.


SearchRequest

public SearchRequest(User searcher,
                     String name,
                     String description)
Deprecated. since v3.13. Use SearchRequest(String, String, String) instead.


SearchRequest

public SearchRequest(String searcherUserName)

SearchRequest

public SearchRequest(String searcherUserName,
                     String name,
                     String description)

SearchRequest

public SearchRequest(boolean turnOffSecurity)
This constructor should only be used by internal JIRA queries, as the results will be unprotected (ie no permission checks are done).

Parameters:
turnOffSecurity - security on/off flag

SearchRequest

public SearchRequest(electric.xml.Document doc)
Construct a SearchRequest from its XML representation.

Parameters:
doc - DOM document to construct this search request from

SearchRequest

public SearchRequest(electric.xml.Document doc,
                     User searcher)

SearchRequest

public SearchRequest(SearchRequest oldSearchRequest,
                     User searcher)

SearchRequest

public SearchRequest(org.ofbiz.core.entity.GenericValue gv)
              throws SearchException
Throws:
SearchException
Method Detail

getSearchContext

public SearchContext getSearchContext()

setSearchContext

public void setSearchContext(SearchContext searchContext)

getReleventSearchers

public List getReleventSearchers()

addParameter

public void addParameter(SearchParameter parameter)
Add a SearchParameter to this search. All SearchParameters are ANDed together to form the search. Compose search parameters if you want OR logic.

Parameters:
parameter - to be added to this request

addParameters

public void addParameters(Collection searchParams)

removeParameter

public void removeParameter(SearchParameter parameter)
This method will remove a parameter by name. If the SearchRequest contains any parameters of the type passed in then all instances will be removed.

Parameters:
parameter - the type of parameter to remove.

getParameters

public List getParameters()
Returns all the parameters for the search request as a List of SearchParameter

Returns:
List of SearchParameter

getLuceneParameters

public List getLuceneParameters()

getValues

public List getValues(String paramName)
Returns the values of the first SearchParameter that matches the given name.

Parameters:
paramName - name of a the SearchParameter
Returns:
values for the paramName. Null if no SearchParameter found

getParam

public SearchParameter getParam(String paramName)
Returns the first SearchParameter that matches the given name.

Parameters:
paramName - name of a the SearchParameter
Returns:
Null if no SearchParameter found else the SearchParameter itself

isContainsParam

public boolean isContainsParam(String paramName)
Whether the SR contains this param name

Parameters:
paramName - name of a the SearchParameter
Returns:
true if it exists else false

getQueryString

public String getQueryString()
Returns the encoded query string of the current search request

Returns:
the encoded query string of the current search request

getQueryStringWithSorts

public String getQueryStringWithSorts()
Returns the encoded query string of the current search request with sort info

Returns:
the encoded query string of the current search request with sort info

getSearchRequestWithSubstitutions

public SearchRequest getSearchRequestWithSubstitutions(List substitutions)
This method will return an new instance of a SearchRequest that will have the same parameters as in this SearchRequest except that any parameters listed in the substitutions list will exist in the new SearchRequest in place of any of the same parameters that may have been in this SearchRequest.

Parameters:
substitutions - a list containing SearchParameter objects that will be inserted into the new SearchRequest object.
Returns:
a new SearchRequest object based off of this SearchRequest but with the substitutions list included.

asSearchRequestWithParameters

public SearchRequest asSearchRequestWithParameters(Collection searchParameters,
                                                   Collection searchSorts)
Return a new a copy of this SearchRequest with its search parameters and search sorts replaced with the passed arguments.

We are currently assuming that the search parameters are not modified once they are saved.

Parameters:
searchParameters - a collection of SearchParameter objects for the new request. Cannot be null.
searchSorts - a collection of SearchSort objects for the the new request. Cannot be null.
Returns:
the new search request with its search parameters and search sorts replaced.
Throws:
IllegalArgumentException - if either searchParameters or searchSorts is null.

cloneSearchRequest

public SearchRequest cloneSearchRequest()

getXml

public electric.xml.Document getXml()
Returns the search request as an XML document

Returns:
XML document representation of the search request

createSearchSorts

public void createSearchSorts(Map params)
Adds SearchSort parameters to the searchRequest, to specify ordering and sorting of results.

Parameters:
params - sorts

addSearchSort

public void addSearchSort(SearchSort searchSort)

getSearchSorts

public Collection getSearchSorts()

setSearchSorts

public void setSearchSorts(Collection searchSorts)

getSearchSortsReverse

public Collection getSearchSortsReverse()
Returns:
An unmodifiable collection of Search Sorts

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getSearchFilterGV

public org.ofbiz.core.entity.GenericValue getSearchFilterGV()

getProject

public org.ofbiz.core.entity.GenericValue getProject()
Deprecated. since 3.5 (for removal in 3.8).

To retrieve the projects that are being searched by a search request check for the existance of ProjectParameter:

                                                                SearchParameter projParam = searchRequest.getParam(DocumentConstants.PROJECT_ID)
                         
If the projParam is null then all projects are being searched. (TODO Check that this is indeed true).

If the param is not null, to retrieve the project ids that are being searched, call:

                         Collection searchedProjectIds = projParam.getValues();
                         
searchedProjectIds should be a Collection of Longs.

Long time ago when earth was still young it was only possible to search one and only one project in JIRA. As earth matured the functionality was added to search multiple projects. Hence this method does not make sense! It will nastily return null if all or multiple projects are being searched.

Returns:
a GenericValue representing the project that is being searched, or null if multiple or all projects are being searched. Do not use this method, it is evil.

getName

public String getName()
Description copied from interface: SharedEntity
The name of the entity.

Specified by:
getName in interface SharedEntity
Returns:
the name. Must not be null or empty.

setName

public void setName(String name)

getId

public Long getId()
Description copied from interface: SharedEntity
The id of the entity.

Specified by:
getId in interface SharedEntity
Returns:
the id. May be null if not yet persisted. Some components may not accept a non-persisted entity.

setId

protected void setId(Long id)

getEntityType

public final SharedEntity.TypeDescriptor getEntityType()
Description copied from interface: SharedEntity
The type of entity it is. Examples include SearchRequest ("SearchRequest") and PortalPage ("PortalPage")

Specified by:
getEntityType in interface SharedEntity
Returns:
the type of entity.

getPermissions

public SharedEntity.SharePermissions getPermissions()
Description copied from interface: SharedEntity
The permissions for this entity.

Specified by:
getPermissions in interface SharedEntity
Returns:
the permissions object. Must not be null.

setPermissions

public void setPermissions(SharedEntity.SharePermissions sharePermissions)

getDescription

public String getDescription()
Description copied from interface: SharedEntity
A general description of the entity.

Specified by:
getDescription in interface SharedEntity
Returns:
the description. May be null or empty.

setDescription

public void setDescription(String description)

setFavouriteCount

protected void setFavouriteCount(Long favouriteCount)

getFavouriteCount

public Long getFavouriteCount()
Description copied from interface: Favourite
The number of users who have marked this entity as one of their favourites.

Specified by:
getFavouriteCount in interface Favourite
Returns:
long the user count

getAuthor

public User getAuthor()
               throws SearchException
Deprecated. since v3.13. Use getOwnerUserName() instead.

Returns:
the author of this SearchRequest
Throws:
SearchException

setAuthor

public void setAuthor(User author)
Deprecated. since v3.13. Use setOwnerUserName(String) instead.

Set the author of the SearchRequest.

Parameters:
author - the new owner of the SearchRequest.

getOwnerUserName

public String getOwnerUserName()
Description copied from interface: SharedEntity
The user name of the owner of the entity. Will always have permission to see it and see all shares.

Specified by:
getOwnerUserName in interface SharedEntity
Returns:
The user name of the user who owns this entity. May be null.

setOwnerUserName

public void setOwnerUserName(String ownerUserName)
Set the owner of the SearchRequest.

Parameters:
ownerUserName - the user name of the user who is the search requests owner.

getSearchFilterId

public Long getSearchFilterId()

isModified

public boolean isModified()

setModified

public void setModified(boolean modified)

isLoaded

public boolean isLoaded()

setLoaded

public void setLoaded(boolean loaded)

useColumns

public boolean useColumns()
Returns:
true if this SearchRequest should be displayed using the saved column layout, false otherwise

setUseColumns

public void setUseColumns(boolean useColumns)

isOverRideSecurity

public boolean isOverRideSecurity()

copy

public SearchRequest copy()
Return a copy of the SearchRequest. We are currently assuming that the search parameters are not modified once they are saved.

Returns:
the copied search request.


Copyright © 2002-2009 Atlassian. All Rights Reserved.