Class ConfiguratorEntry
Object
AbstractPortletDto
ConfiguratorEntry
- All Implemented Interfaces:
Serializable
,Portlet
,ComplexCalculationResult
public class ConfiguratorEntry
extends AbstractPortletDto
implements ComplexCalculationResult
This class is used to transport a configurator entry.
Example:
def opts = ["Europe", "USA"]
def configurationEntry = api.createConfiguratorEntry(InputType.OPTION, "Sales_Org_inline_01")
def contextParameter = configurationEntry.getFirstInput()
contextParameter.setValueOptions(opts)
- Author:
- cat
- See Also:
-
Field Summary
Fields inherited from class AbstractPortletDto
dragDropEnabled, layout, resizingEnabled
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAdditionalConfigValue
(String name, String value) Sets an additional configuration pair.addParameter
(ContextParameter input) Deprecated.createParameter
(InputType type, String name) Creates a parameter and adds it to the list of inputs.createParameter
(InputType type, String name, Date targetDate) Creates a parameter and adds it to the list of inputs.createParameter
(ContextParameter input) Creates a parameter and adds it to the list of inputs.createParameter
(ContextParameter input, Closure<?> defaultValue) Creates a parameter and adds it to the list of inputs.Gets the Map of additional configurationsgetDefaultValue
(String name) Return default value of the tracked input (i.e.Gets the first context parameter.Retrieves a list of hidden pop-up Configurator buttons.Gets the list of context parameters.Collect last value changed by the logic together with the timestamp.Gets the message.getPreviousValue
(String name) Return previous value of the tracked input (i.e.The CalculationResultType for this class.boolean
isDefaultValueTracked
(String name) Method to test whether particularContextParameter
is tracked with the default value Example:boolean
isPreviousValueTracked
(String name) Method to test whether particularContextParameter
is tracked with the previous valueboolean
Method to test whether particularContextParameter
is tracked with the value change by the Groovy logicvoid
setAdditionalConfig
(Map<String, String> additionalConfig) Sets all the additional configurations at oncevoid
setContext
(FormulaEngineContext ctx) Sets the FormulaEngineContext.void
setHiddenActions
(InputButtonAction... hiddenActions) Hides all or specified buttons from the pop-up Configurator.void
setInputs
(List<ContextParameter> inputs) Sets the list of context parameters.void
setMessage
(String message) Sets a message that will appear on top of the configuration entry.setTrackedValue
(String name, Object value) SetContextParameter
value, enriched by the groovy logic value tracking feature.Methods inherited from class AbstractPortletDto
layout, setLayout, value, withDragDrop, withHeight, withHeight, withLayout, withLayout, withLayout, withResizing, withWidth, withWidth
-
Constructor Details
-
ConfiguratorEntry
public ConfiguratorEntry()Creates an empty configurator entry object. Must be filled with input parameters by calling createParameter on the object. Example:def cStartDate = input.CStartDate def configurationEntry = api.createConfiguratorEntry().createParameter(startDate, {cStartDate})
-
-
Method Details
-
getInputs
Gets the list of context parameters.- Returns:
- the list of context parameters, or null if no context parameters were previously added
-
getFirstInput
Gets the first context parameter. Example:api.logInfo("fist input value",configuratorEntry.getFirstInput().getValue())
- Returns:
- the first context parameter, or null if no context parameter was previously added
-
setInputs
Sets the list of context parameters.- Parameters:
inputs
- a list of context parameters. Can be null.- See Also:
-
getMessage
Gets the message.- Returns:
- the message, or null if it was not set
-
setMessage
Sets a message that will appear on top of the configuration entry. You may use HTML markup. Example:entry.setMessage("<BR /><Center><B><Font Size='3'>Competitor Price Information</Font></B></Center></BR/ >")
- Parameters:
message
- the text to display as message
-
setHiddenActions
Hides all or specified buttons from the pop-up Configurator.Example – hides all buttons:
import net.pricefx.common.api.InputButtonAction def ce = api.createConfiguratorEntry() ce.setHiddenActions(InputButtonAction.ALL) return ce
- Parameters:
hiddenActions
- Specify the button you want to hide. SeeInputButtonAction
for possible values.- Since:
- 6.1.0 - Vesper
- See Also:
-
getHiddenActions
Retrieves a list of hidden pop-up Configurator buttons.- Returns:
- the list of hidden
InputButtonAction
- Since:
- 6.1.0 - Vesper
- See Also:
-
createParameter
Creates a parameter and adds it to the list of inputs. The parameter will be created without target date. If the FormulaEngineContext is set and contains the parameter with the name, it will be used to set the value of the context parameter by retrieving a parameter from the context with the specified name. Example:Date targetDate = context == null? new Date() : context.getTargetDate(); ContextParameter param = ce.createParameter(InputType.OPTION, "Customer_inline_01");
- Parameters:
type
- Input type of the parameter.name
- Name of the parameter.- Returns:
- the context parameter
-
createParameter
Creates a parameter and adds it to the list of inputs. If the FormulaEngineContext is set and contains the parameter with the name, it will be used to set the value of the context parameter by retrieving a parameter from the context with the specified name.- Parameters:
type
- Input type of the parameter.name
- Name of the parameter.targetDate
- Target date for the input parameter (not applicable to all input types).- Returns:
- the context parameter
- See Also:
-
createParameter
Creates a parameter and adds it to the list of inputs. If the FormulaEngineContext is set and contains the parameter with the name, it will be used to set the value of the context parameter by retrieving a parameter from the context with the specified name. If the FormulaEngineContext is not set, or no parameter that matches the name of the input is found in the context, then defaultValue from the closure will be used. Example:ContextParameter contextParameter = api.inputBuilderFactory() ... (other methods from the builder) .buildContextParameter() ConfiguratorEntry configuratorEntry = api.createConfiguratorEntry().createParameter(contextParameter, { "hop" })
- Parameters:
input
- the input element to adddefaultValue
- the value to be used if nothing is selected in the input- Returns:
- this ConfiguratorEntry object instance
-
isDefaultValueTracked
Method to test whether particularContextParameter
is tracked with the default value Example:// Element 'First' with logic def configuratorEntry = api.createConfiguratorEntry() api.inputBuilderFactory() .createOptionEntry('test') .setDefaultValueTracking(true) .addToConfiguratorEntry(configuratorEntry) return configuratorEntry // Other element returning default value of 'test' ContextParameter (if available) return out.First.isDefaultValueTracked('test') ? configurator.getDefaultValue('test') : 'not supported'
- Parameters:
name
-ContextParameter
's name available around the currentConfiguratorEntry
- Returns:
- true if
ContextParameter
is tracked with the default value, false if not - See Also:
-
getDefaultValue
Return default value of the tracked input (i.e. created through theInputBuilderFactory
withAbstractInputBuilder.setDefaultValueTracking(boolean)
). Usage of the method when default is not track will throwIllegalArgumentException
, to prevent exception useisDefaultValueTracked(String)
firstExample:
// First element (creates test input in configurator entry with value set to 'Actual' in the inputs generation mode) def configuratorEntry = api.createConfiguratorEntry() api.inputBuilderFactory() .createOptionEntry('test') .setOptions(['Forecast', 'Actual']) .setValue('Actual') .setDefaultValueTracking(true) .addToConfiguratorEntry(configuratorEntry) return configuratorEntry // Second element (aboard on the input generation mode) if (api.isInputGenerationExecution()) api.abortCalculation() // Third element (get default value of the test-input and return it in the text-user-entry) def configurator = out.First def firstDefault = configurator.isDefaultValueTracked('test') ? configurator.getDefaultValue('test') : 'not supported' def configuratorEntry = api.createConfiguratorEntry() configuratorEntry.inputs = [ api.inputBuilderFactory() .createTextUserEntry('Test input default value') .setValue(firstDefault) .buildContextParameter()] return configuratorEntry
- Parameters:
name
- name of the tracked input- Returns:
- default value of the tracked input
- See Also:
-
isPreviousValueTracked
Method to test whether particularContextParameter
is tracked with the previous valueExample:
// Element 'First' with logic def configuratorEntry = api.createConfiguratorEntry() api.inputBuilderFactory() .createOptionEntry('test') .setPreviousValueTracking(true) .addToConfiguratorEntry(configuratorEntry) return configuratorEntry // Other element returning previous value of 'test' ContextParameter (if available) return out.First.isPreviousValueTracked('test') ? configurator.getPreviousValue('test') : 'not supported'
- Parameters:
name
-ContextParameter
's name available around the currentConfiguratorEntry
- Returns:
- true if
ContextParameter
is tracked with the previous value, false if not - See Also:
-
getPreviousValue
Return previous value of the tracked input (i.e. created throughInputBuilderFactory
withAbstractInputBuilder.setPreviousValueTracking(boolean)
).Example:
// First element (creates test input in configurator entry with value set to 'Actual' in the inputs generation mode) def configuratorEntry = api.createConfiguratorEntry() api.inputBuilderFactory() .createOptionEntry('test') .setOptions(['Forecast', 'Actual']) .setValue('Actual') .setPreviousValueTracking(true) .addToConfiguratorEntry(configuratorEntry) return configuratorEntry // Second element (aboard on the input generation mode) if (api.isInputGenerationExecution()) api.abortCalculation() // Third element (get previous value of the test-input and return it in the text-user-entry) def firstPrevious = out.First.getPreviousValue('test') def configuratorEntry = api.createConfiguratorEntry() configuratorEntry.inputs = [ api.inputBuilderFactory() .createTextUserEntry('Test input previous value') .setValue(firstPrevious) .buildContextParameter()] return configuratorEntry
- Parameters:
name
- name of the tracked input- Returns:
- previous value of the tracked input
- See Also:
-
isValueChangeTrackingEnable
Method to test whether particularContextParameter
is tracked with the value change by the Groovy logicExample:
// Element 'First' with logic def configuratorEntry = api.createConfiguratorEntry() api.inputBuilderFactory() .createOptionEntry('test') .setValueChangeTracking(true) .addToConfiguratorEntry(configuratorEntry) return configuratorEntry // Other element returning value of 'test' ContextParameter changed by the logic (if available) return out.First.isValueChangeTrackingEnable('test') ? configurator.getLastValueChangedByLogic('test') : 'not supported'
- Parameters:
name
-ContextParameter
's name available around the currentConfiguratorEntry
- Returns:
- true if
ContextParameter
is tracked with the value changed by the logic, false if not - See Also:
-
setTrackedValue
SetContextParameter
value, enriched by the groovy logic value tracking feature.Value changed by this method will be stored in
ContextParameter.getParameterConfig()
together with timestamp (only last value change is tracked and will be kept)Value is stored under the key
PriceFxInterface.VALUE_CHANGED_TEMPLATE
as theMap
withLocalDateTime
as the key.Example:
// SomeType element in Groovy logic def configuratorEntry = api.createConfiguratorEntry() api.inputBuilderFactory() .createOptionEntry('FirstOrSecond') .setOptions(['First', 'Second']) .setValueChangeTracking(true) .addToConfiguratorEntry(configuratorEntry) return configuratorEntry // OtherElement in Groovy logic def configuratorEntry = out.SomeType if(//particular condition is met) { configuratorEntry.setTrackedValue('FirstOrSecond', 'valueChangedByTheLogic') }
- Parameters:
name
-ContextParameter
name as input around theConfiguratorEntry
instancevalue
-ContextParameter
value to be set and keep as the one changed by groovy logic- Returns:
ContextParameter
which value was changed by the logic- See Also:
-
getLastValueChangedByLogic
Collect last value changed by the logic together with the timestamp.Example:
// SomeType element in Groovy logic def configuratorEntry = api.createConfiguratorEntry() api.inputBuilderFactory() .createOptionEntry('FirstOrSecond') .setOptions(['First', 'Second']) .setValueChangeTracking(true) .addToConfiguratorEntry(configuratorEntry) return configuratorEntry // OtherElement in Groovy logic def configuratorEntry = out.SomeType if(//particular condition is met) { configuratorEntry.setTrackedValue('FirstOrSecond', 'valueChangedByTheLogic') } // OtherElement in Groovy logic returning timestamp and value changed by the groovy logic def configuratorEntry = out.SomeType return configuratorEntry.getLastValueChangedByLogic(''FirstOrSecond)
- Parameters:
name
-ContextParameter
name as input around theConfiguratorEntry
instance- Returns:
- value of the
ContextParameter
which was changed by the logic (with timestamp) - See Also:
-
createParameter
Creates a parameter and adds it to the list of inputs. If the FormulaEngineContext is set and contains the parameter with the name, it will be used to set the value of the context parameter by retrieving a parameter from the context with the specified name. Example:ContextParameter contextParameter = api.inputBuilderFactory() ... (other methods from the builder) .buildContextParameter() ConfiguratorEntry configuratorEntry = api.createConfiguratorEntry().createParameter(contextParameter)
- Parameters:
input
- the input element to add- Returns:
- this ConfiguratorEntry object instance
-
addParameter
Deprecated.PrefercreateParameter(ContextParameter)
that ensures the input value is initialisedAdds a parameter to the list of parameters of this object without setting its value from the formula context. In general, it is prefered to directly usecreateParameter(ContextParameter)
. Example:ContextParameter contextParameter = api.inputBuilderFactory() ... (other methods from the builder) .buildContextParameter() ConfiguratorEntry configuratorEntry = api.createConfiguratorEntry().addParameter(contextParameter)
- Parameters:
input
- The ContextParameter to add (f.e an input)- Returns:
- this ConfiguratorEntry object instance
-
getAdditionalConfig
Gets the Map of additional configurations- Returns:
- the additional config, or null, if nothing was set
-
setAdditionalConfig
Sets all the additional configurations at once- Parameters:
additionalConfig
- a map of additional configuration- See Also:
-
addAdditionalConfigValue
Sets an additional configuration pair.Example:
def invoicePriceBoundaries = api.createConfiguratorEntry() invoicePriceBoundaries.addAdditionalConfigValue("groupLabel", "Business Rules") invoicePriceBoundaries.addAdditionalConfigValue("showInSectionsPanel", "true")
- Parameters:
name
- the name of the configuration key. Possible key names:layout
(enum) - default: vertical
groupLabel
(String)recalculateParentEntityOnConfirm
(Boolean) - default: false
value
- the value of the configuration key
-
getResultType
The CalculationResultType for this class.- Specified by:
getResultType
in interfaceComplexCalculationResult
- Returns:
- CONFIGURATORENTRY
-
setContext
public void setContext(FormulaEngineContext ctx) Sets the FormulaEngineContext. It is use for retrieving values when creating parameters- Parameters:
ctx
-
-
createParameter(ContextParameter)
that ensures the input value is initialised