com.atlassian.jira.web.action.util.sharing
Class SharedEntitySearchViewHelper<E extends SharedEntity>

java.lang.Object
  extended by com.atlassian.jira.web.action.util.sharing.SharedEntitySearchViewHelper<E>
Direct Known Subclasses:
ConfigurePortalPages.PortalPageViewHelper, FilterViewHelper

public abstract class SharedEntitySearchViewHelper<E extends SharedEntity>
extends Object

A class that makes searching for Shared Entities easier.

Since:
v3.13

Nested Class Summary
static class SharedEntitySearchViewHelper.SearchResult<E>
          Represents a page of results of the search.
static class SharedEntitySearchViewHelper.SortColumn
          Container for sorting constants.
 
Constructor Summary
SharedEntitySearchViewHelper(ShareTypeFactory shareTypeFactory, JiraAuthenticationContext authCtx, String applicationContext, String actionUrlPrefix, String viewParameter, String viewValue, SharedEntity.TypeDescriptor entityType)
           
 
Method Summary
protected  StringBuffer addParameter(StringBuffer url, String key, Object value)
           
protected  StringBuffer createBasicUrlSearchParams()
          Creates the basic URL parameters needed to keep the current search state.
protected abstract  SharedEntitySearchResult<E> doExecuteSearch(JiraServiceContext ctx, SharedEntitySearchParameters searchParameters, int pageOffset, int pageWidth)
          Execute the search for the passed parameters.
 String generateSortCssClass(String sortColumnName)
          Return the CSS class(es) to display the passed column's sort status.
 String generateSortIcon(String sortColumnName)
          Return the HTML for the sort icon used to display the sort order for the passed column.
 String generateSortUrl(String sortColumnName)
          Return the URL that can be used to sort by the passed column.
abstract  SharedEntitySearchContext getEntitySearchContext()
           
 String getGroupShare()
           
 Long getPagingOffset()
           
 List<E> getPopularFilters(JiraServiceContext jiraServiceContext)
          Gets the filters which have been made favourite by the most people.
 String getProjectShare()
           
 String getRoleShare()
           
 String getSearchName()
           
 String getSearchOwnerUserName()
           
 String getSearchShareType()
           
 String getSearchShareTypeJSON()
          Produces a JSON representation of the current form state.
 List<ShareTypeRendererBean> getShareTypeRendererBeans()
          Returns the ShareTypeRendererBeans used by the front end to render each type of sharing that a filter could have.
 String getSortColumn()
           
 boolean isSortAscending()
           
 SharedEntitySearchViewHelper.SearchResult<E> search(JiraServiceContext jiraServiceContext)
          Performs the search for filters based on the configured state.
 void setGroupShare(String groupShare)
           
 void setPagingOffset(Long pagingOffset)
           
 void setProjectShare(String projectShare)
           
 void setRoleShare(String roleShare)
           
 void setSearchName(String searchName)
           
 void setSearchOwnerUserName(String searchOwnerUserName)
           
 void setSearchShareType(String searchShareType)
           
 void setSortAscending(boolean sortAscending)
           
 void setSortColumn(String sortColumn)
           
protected abstract  boolean validateSearchParameters(JiraServiceContext ctx, SharedEntitySearchParameters searchParameters, int pageOffset, int pageWidth)
          Ensure that it is possible to execute a search with the passed parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SharedEntitySearchViewHelper

public SharedEntitySearchViewHelper(ShareTypeFactory shareTypeFactory,
                                    JiraAuthenticationContext authCtx,
                                    String applicationContext,
                                    String actionUrlPrefix,
                                    String viewParameter,
                                    String viewValue,
                                    SharedEntity.TypeDescriptor entityType)
Method Detail

getSearchName

public String getSearchName()

setSearchName

public void setSearchName(String searchName)

getSearchOwnerUserName

public String getSearchOwnerUserName()

setSearchOwnerUserName

public void setSearchOwnerUserName(String searchOwnerUserName)

getSearchShareType

public String getSearchShareType()

setSearchShareType

public void setSearchShareType(String searchShareType)

setGroupShare

public void setGroupShare(String groupShare)

getGroupShare

public String getGroupShare()

getPagingOffset

public Long getPagingOffset()

setProjectShare

public void setProjectShare(String projectShare)

getProjectShare

public String getProjectShare()

setRoleShare

public void setRoleShare(String roleShare)

getRoleShare

public String getRoleShare()

setPagingOffset

public void setPagingOffset(Long pagingOffset)

getSortColumn

public String getSortColumn()

setSortColumn

public void setSortColumn(String sortColumn)

isSortAscending

public boolean isSortAscending()

setSortAscending

public void setSortAscending(boolean sortAscending)

getEntitySearchContext

public abstract SharedEntitySearchContext getEntitySearchContext()

getShareTypeRendererBeans

public List<ShareTypeRendererBean> getShareTypeRendererBeans()
Returns the ShareTypeRendererBeans used by the front end to render each type of sharing that a filter could have. Does lazy initialisation so it's performant to call multiple times in a view. Is only used by the search form.

Returns:
the available ShareTypes.

generateSortUrl

public String generateSortUrl(String sortColumnName)
Return the URL that can be used to sort by the passed column.

Parameters:
sortColumnName - the column to sort by.
Returns:
the URL that can be used to sort the passed column.

generateSortIcon

public String generateSortIcon(String sortColumnName)
Return the HTML for the sort icon used to display the sort order for the passed column. The returned String can be empty if the passed passed column should not display an icon.

Parameters:
sortColumnName - the name of the column
Returns:
the HTML for the icon to display.

generateSortCssClass

public String generateSortCssClass(String sortColumnName)
Return the CSS class(es) to display the passed column's sort status.

Parameters:
sortColumnName - the column to get the classes for.
Returns:
the CSS class(es) to represent the passed column's sorting status.

search

public SharedEntitySearchViewHelper.SearchResult<E> search(JiraServiceContext jiraServiceContext)
Performs the search for filters based on the configured state.

Parameters:
jiraServiceContext - the service context to use for performing the search with the underlying service.
Returns:
the SearchResult for the search currently configured. null can be returned to indicate an error.

getPopularFilters

public List<E> getPopularFilters(JiraServiceContext jiraServiceContext)
Gets the filters which have been made favourite by the most people.

Parameters:
jiraServiceContext - the service context to use for performing the search.
Returns:
the list of SharedEntity objects.

getSearchShareTypeJSON

public String getSearchShareTypeJSON()
Produces a JSON representation of the current form state. Used to pre-populate the JavaScript-controlled component in select-share-types.jsp.

Returns:
the JSON representation to be used by the client to set up the search form controls state.

createBasicUrlSearchParams

protected StringBuffer createBasicUrlSearchParams()
Creates the basic URL parameters needed to keep the current search state.

Returns:
a string buffer containing a URL with the basic search parameters.

addParameter

protected StringBuffer addParameter(StringBuffer url,
                                    String key,
                                    Object value)

doExecuteSearch

protected abstract SharedEntitySearchResult<E> doExecuteSearch(JiraServiceContext ctx,
                                                               SharedEntitySearchParameters searchParameters,
                                                               int pageOffset,
                                                               int pageWidth)
Execute the search for the passed parameters.

Parameters:
ctx - the context to execute the search under.
searchParameters - the parameters for the search.
pageOffset - the offset of the search result page to return.
pageWidth - the width of a search result page.
Returns:
the result of the search or null if an error occurred.

validateSearchParameters

protected abstract boolean validateSearchParameters(JiraServiceContext ctx,
                                                    SharedEntitySearchParameters searchParameters,
                                                    int pageOffset,
                                                    int pageWidth)
Ensure that it is possible to execute a search with the passed parameters.

Parameters:
ctx - the context to execute the search under.
searchParameters - the parameters for the search.
pageOffset - the offset of the search result page to return.
pageWidth - the width of a search result page.
Returns:
true iff the search can be performed.


Copyright © 2002-2012 Atlassian. All Rights Reserved.