com.atlassian.jira.issue.search
Class SearchRequest

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

public class SearchRequest
extends Object
implements Serializable

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

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, User searcher)
           
SearchRequest(SearchRequest oldSearchRequest, User searcher)
           
SearchRequest(User searcher)
           
SearchRequest(User searcher, String name, String description)
           
 
Method Summary
 void addParameter(SearchParameter parameter)
           
 void addParameters(Collection searchParams)
           
 void addSearchSort(SearchSort searchSort)
           
 SearchRequest cloneSearchRequest()
           
 boolean equals(Object o)
           
 User getAuthor()
           
 String getDescription()
           
 String getGroup()
           
 Long getId()
           
 List getLuceneParameters()
           
 String getName()
           
 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
 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()
           
 String getUser()
           
 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)
           
 void setDescription(String description)
           
 void setGroup(String group)
           
 void setLoaded(boolean loaded)
           
 void setModified(boolean modified)
           
 void setName(String name)
           
 void setSearchContext(SearchContext searchContext)
           
 void setSearchSorts(Collection searchSorts)
           
 void setUseColumns(boolean useColumns)
           
 void setUser(String user)
           
 String toString()
           
 boolean useColumns()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SearchRequest

public SearchRequest(User searcher)

SearchRequest

public SearchRequest(User searcher,
                     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,
                     User searcher)
              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)

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.

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

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()

setName

public void setName(String name)

getId

public Long getId()

getDescription

public String getDescription()

setDescription

public void setDescription(String description)

getAuthor

public User getAuthor()

setAuthor

public void setAuthor(User author)

getSearchFilterId

public Long getSearchFilterId()

getUser

public String getUser()

setUser

public void setUser(String user)

getGroup

public String getGroup()

setGroup

public void setGroup(String group)

isModified

public boolean isModified()

setModified

public void setModified(boolean modified)

isLoaded

public boolean isLoaded()

setLoaded

public void setLoaded(boolean loaded)

useColumns

public boolean useColumns()

setUseColumns

public void setUseColumns(boolean useColumns)

isOverRideSecurity

public boolean isOverRideSecurity()


Copyright © 2002-2007 Atlassian. All Rights Reserved.