Package org.biouno.unochoice
Class AbstractScriptableParameter
- java.lang.Object
-
- hudson.model.ParameterDefinition
-
- hudson.model.SimpleParameterDefinition
-
- org.biouno.unochoice.AbstractUnoChoiceParameter
-
- org.biouno.unochoice.AbstractScriptableParameter
-
- All Implemented Interfaces:
ExtensionPoint,Describable<ParameterDefinition>,Serializable,ScriptableParameter<Map<Object,Object>>,UnoChoiceParameter
- Direct Known Subclasses:
AbstractCascadableParameter,ChoiceParameter
public abstract class AbstractScriptableParameter extends AbstractUnoChoiceParameter implements ScriptableParameter<Map<Object,Object>>
Base class for parameters with scripts.- Since:
- 0.20
- Author:
- Bruno P. Kinoshita
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.model.ParameterDefinition
ParameterDefinition.ParameterDescriptor
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringEQUALSUsed to split values when scripts return values like A=2, B=3.protected static StringJENKINS_BUILD_VARIABLE_NAMEConstant used to add the build in the environment variables map.protected static StringJENKINS_PARAMETER_VARIABLE_NAMEConstant used to add the parameter name in the environment variables map.protected static StringJENKINS_PROJECT_VARIABLE_NAMEConstant used to add the project in the environment variables map.protected ScriptscriptScript used to render the parameter.protected static StringSEPARATORUsed to split values that come from the UI via Ajax POST's-
Fields inherited from class org.biouno.unochoice.AbstractUnoChoiceParameter
DEFAULT_MAX_VISIBLE_ITEM_COUNT, ELEMENT_TYPE_FORMATTED_HIDDEN_HTML, ELEMENT_TYPE_FORMATTED_HTML, ELEMENT_TYPE_ORDERED_LIST, ELEMENT_TYPE_TEXT_BOX, ELEMENT_TYPE_UNORDERED_LIST, LOGGER, PARAMETER_TYPE_CHECK_BOX, PARAMETER_TYPE_MULTI_SELECT, PARAMETER_TYPE_RADIO, PARAMETER_TYPE_SINGLE_SELECT
-
Fields inherited from class hudson.model.ParameterDefinition
LIST
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractScriptableParameter(String name, String description, String randomName, Script script)Inherited constructor.protectedAbstractScriptableParameter(String name, String description, Script script)Deprecated.see JENKINS-32149
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<Object,Object>getChoices()Map<Object,Object>getChoices(Map<Object,Object> parameters)Evaluates a script and returns its result as a Map.StringgetChoicesAsString()StringgetChoicesAsString(Map<Object,Object> parameters)ParameterValuegetDefaultParameterValue()Map<Object,Object>getParameters()Gets the current parameters, be it before or after other referenced parameters triggered an update.ScriptgetScript()Gets the script.intgetVisibleItemCount()Get the number of visible items in the select.-
Methods inherited from class org.biouno.unochoice.AbstractUnoChoiceParameter
all, createValue, createValue, getChoiceType, getDescriptor, getRandomName
-
Methods inherited from class hudson.model.SimpleParameterDefinition
createValue, createValue
-
Methods inherited from class hudson.model.ParameterDefinition
copyWithDefaultValue, getDescription, getFormattedDescription, getName, getType
-
-
-
-
Field Detail
-
SEPARATOR
protected static final String SEPARATOR
Used to split values that come from the UI via Ajax POST's- See Also:
- Constant Field Values
-
EQUALS
protected static final String EQUALS
Used to split values when scripts return values like A=2, B=3.- See Also:
- Constant Field Values
-
JENKINS_PROJECT_VARIABLE_NAME
protected static final String JENKINS_PROJECT_VARIABLE_NAME
Constant used to add the project in the environment variables map.- See Also:
- Constant Field Values
-
JENKINS_BUILD_VARIABLE_NAME
protected static final String JENKINS_BUILD_VARIABLE_NAME
Constant used to add the build in the environment variables map.- See Also:
- Constant Field Values
-
JENKINS_PARAMETER_VARIABLE_NAME
protected static final String JENKINS_PARAMETER_VARIABLE_NAME
Constant used to add the parameter name in the environment variables map.- See Also:
- Constant Field Values
-
script
protected final Script script
Script used to render the parameter.
-
-
Constructor Detail
-
AbstractScriptableParameter
protected AbstractScriptableParameter(String name, String description, Script script)
Deprecated.see JENKINS-32149Inherited constructor.- Parameters:
name- namedescription- descriptionscript- script used to generate the list of parameter values
-
AbstractScriptableParameter
protected AbstractScriptableParameter(String name, String description, String randomName, Script script)
Inherited constructor.- Parameters:
name- namedescription- descriptionrandomName- parameter random generated name (uuid)script- script used to generate the list of parameter values
-
-
Method Detail
-
getScript
public Script getScript()
Gets the script.- Returns:
- the script
-
getParameters
public Map<Object,Object> getParameters()
Gets the current parameters, be it before or after other referenced parameters triggered an update. Populates parameters common to all evaluations, such as jenkinsProject, which is the current Jenkins project.- Returns:
- the current parameters with pre-populated defaults
-
getChoices
public Map<Object,Object> getChoices(Map<Object,Object> parameters)
Description copied from interface:ScriptableParameterEvaluates a script and returns its result as a Map. List values are automatically handled and converted to Maps too.- Specified by:
getChoicesin interfaceScriptableParameter<Map<Object,Object>>- Parameters:
parameters- parameters- Returns:
- script result as Map
-
getChoicesAsString
public String getChoicesAsString()
-
getDefaultParameterValue
public ParameterValue getDefaultParameterValue()
- Overrides:
getDefaultParameterValuein classParameterDefinition
-
getVisibleItemCount
public int getVisibleItemCount()
Get the number of visible items in the select.- Returns:
- the number of choices or, if it is higher than the default, then it returns the default maximum value
-
-