com.atlassian.jira.plugin.jql.function
Class AbstractUserCapabilityFunction

java.lang.Object
  extended by com.atlassian.jira.plugin.jql.function.AbstractJqlFunction
      extended by com.atlassian.jira.plugin.jql.function.AbstractUserCapabilityFunction
All Implemented Interfaces:
JqlFunction
Direct Known Subclasses:
ProjectsWhereUserHasPermissionFunction, ProjectsWhereUserHasRoleFunction

public abstract class AbstractUserCapabilityFunction
extends AbstractJqlFunction

This is an abstract parent to user based functions that rely on returning a list of a list of QueryLiteral based on either the current user or a user passed as a parameter.

This function expects one or two arguments. The first argument is the capability requested, typically a permission or role etc, The second argument is the user, if this is not supplied the current logged in user will be used.

Since:
v4.2

Field Summary
protected  UserUtil userUtil
           
 
Constructor Summary
AbstractUserCapabilityFunction(UserUtil userUtil)
           
 
Method Summary
protected abstract  List<QueryLiteral> getFunctionValuesList(QueryCreationContext queryCreationContext, FunctionOperand operand, com.atlassian.crowd.embedded.api.User user, String capability)
          Get the function return values based on the actual user and capability.
 int getMinimumNumberOfExpectedArguments()
          This method must return the number of arguments that the function expects to perform its operation correctly.
protected abstract  String getUserNotFoundMessageKey()
          Get the I18n message key for the error when the passed in user does not exist.
 List<QueryLiteral> getValues(QueryCreationContext queryCreationContext, FunctionOperand functionOperand, TerminalClause terminalClause)
          Gets the unexpanded values provided by the user on input.
 MessageSet validate(com.atlassian.crowd.embedded.api.User searcher, FunctionOperand functionOperand, TerminalClause terminalClause)
          Will validate the function operand's arguments and report back any errors.
protected abstract  MessageSet validateCapability(String capability, I18nHelper i18n)
          Check the capability requested.
 
Methods inherited from class com.atlassian.jira.plugin.jql.function.AbstractJqlFunction
getFunctionName, getI18n, getModuleDescriptor, init, isList, validateNumberOfArgs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.jira.plugin.jql.function.JqlFunction
getDataType
 

Field Detail

userUtil

protected final UserUtil userUtil
Constructor Detail

AbstractUserCapabilityFunction

public AbstractUserCapabilityFunction(UserUtil userUtil)
Method Detail

validate

public MessageSet validate(com.atlassian.crowd.embedded.api.User searcher,
                           FunctionOperand functionOperand,
                           TerminalClause terminalClause)
Description copied from interface: JqlFunction
Will validate the function operand's arguments and report back any errors.

Parameters:
searcher - the user performing the search
functionOperand - the operand to validate
terminalClause - the terminal clause that contains the operand
Returns:
a MessageSet which will contain any validation errors or warnings or will be empty if there is nothing to report; never null.

getMinimumNumberOfExpectedArguments

public int getMinimumNumberOfExpectedArguments()
Description copied from interface: JqlFunction
This method must return the number of arguments that the function expects to perform its operation correctly. If the function can accept a variable number of arguments this value should be the lower limit. It is perfectly legal for a function to take no arguments and return 0 for this method.

Returns:
the number of arguments that the function expects to perform its operation correctly. Must be >=0.

validateCapability

protected abstract MessageSet validateCapability(String capability,
                                                 I18nHelper i18n)
Check the capability requested.

Parameters:
capability - The name of the capability being checked. This will be the name of something like a permission or role
i18n - I18Helper
Returns:
a MessageSet which must not be null, but may be empty when there are no errors.

getValues

public List<QueryLiteral> getValues(QueryCreationContext queryCreationContext,
                                    FunctionOperand functionOperand,
                                    TerminalClause terminalClause)
Description copied from interface: JqlFunction

Gets the unexpanded values provided by the user on input. This is the output values that will later be transformed into index values.

For example, a function who returns all the released versions of a specified project should return QueryLiterals representing the ids of those versions. For correctness, always opt to return the most specific identifier for the object; if you can return either the id (which is stored in the index) or a string name (that would require resolving to get the index value), choose the id.

Parameters:
queryCreationContext - the context of query creation
functionOperand - the operand to get values from
terminalClause - the terminal clause that contains the operand
Returns:
a List of objects that represent this Operands raw values. Cannot be null.

getFunctionValuesList

protected abstract List<QueryLiteral> getFunctionValuesList(QueryCreationContext queryCreationContext,
                                                            FunctionOperand operand,
                                                            com.atlassian.crowd.embedded.api.User user,
                                                            String capability)
Get the function return values based on the actual user and capability. transformed into index values.

Parameters:
queryCreationContext - the context of query creation
operand - the operand to get values from
user - the user. This value may be the searcher or a user the searcher is enquiring on behalf of. If the 2nd parameter (a User) of the function is supplied then the capability of that user is quueried. The functionality to run this for a user other than the logged in user has been removed until decisions can be made regarding http://jira.atlassian.com/browse/JRA-21476
capability - the capability being requested
Returns:
a List of objects that represent this Operands raw values. Cannot be null.

getUserNotFoundMessageKey

protected abstract String getUserNotFoundMessageKey()
Get the I18n message key for the error when the passed in user does not exist.

Returns:
message key.


Copyright © 2002-2013 Atlassian. All Rights Reserved.