Class CalculableLineItemCollectionBuilder<T extends CalculableLineItemCollectionBuilder>
- Object
-
- ObjectIdentity
-
- AbstractBuilder
-
- CalculableLineItemCollectionBuilder<T>
-
- Direct Known Subclasses:
BasicRebateAgreementBuilder
,ContractBuilder
,QuoteBuilder
public abstract class CalculableLineItemCollectionBuilder<T extends CalculableLineItemCollectionBuilder> extends AbstractBuilder
This is the shared builder class for Quotes, RebateAgreements and Contracts.
Some important notes on the sequence that changes to the document structure a re processed:
Any modifying action (adding lines, inputs etc or a structure object etc) IS NOT executed as per sequence of the groovy logic! The groovy logic should be more considered as a routine that collects all necessary changes. These changes are not executed immediately. They are rather collected (per execution phase) and then executed in this order:
- Add line items
- Delete line items (PRE phase only!)
- Move line items (PRE phase only!)
- Rename folders
- Add inputs
- Add outputs
- Update header fields
-
-
Field Summary
Fields Modifier and Type Field Description static String
METHOD_ADD_LINE_ITEM
static String
METHOD_ADD_OR_UPDATE_INPUT
static String
METHOD_ADD_OR_UPDATE_OUTPUT
static String
METHOD_UPDATE_FIELD
protected HeaderPhase
phase
static String
ROOT_LINE_ID
-
Constructor Summary
Constructors Constructor Description CalculableLineItemCollectionBuilder(String instanceId, String classId, IdGenerator idGenerator, Invocations<MethodInvocation> invocations, HeaderPhase phase)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
addLineItem(String key)
This method adds a new line item in the root folderT
addLineItem(String parentLineId, String key)
This method adds a new line item in the specified parent (folder id)T
addLineItem(String parentLineId, String key, List<Map<String,Object>> contextParameter)
This method adds a new line item in the specified parent (folder id) and sets some context parameters.T
addOrUpdateInput(String lineId, Map<String,Object> contextParameter)
This method adds or updates an input value on a line itemT
addOrUpdateInput(Map<String,Object> contextParameter)
This method adds or updates an input value on the root levelT
addOrUpdateOutput(String lineId, Map<String,Object> calculationResult)
This method adds or updates a result value (an output value) on a line itemT
addOrUpdateOutput(Map<String,Object> calculationResult)
This method adds or updates a result value (an output value) on the root levelT
clearRenderInfo(String fieldName)
Clears existing render info for a field or for all fieldsT
deleteItem(String lineId)
Deletes an item or folder.boolean
isPostPhase()
Determines current calculation phase of logic executionboolean
isPrePhase()
Determines current calculation phase of logic executionT
moveItem(String lineId, String newParentId)
Moves an item or folder underneath a new parent.T
renameFolder(String lineId, String newFolderLabel)
Renames a folder (not items!)T
setRenderInfo(String fieldName, String key, Object value)
Sets (adds or updates) rendering information for particular header fields (or buttons).T
updateField(String fieldName, Object value)
Updates a header field value For quotes supported fields are:additionalInfo1
additionalInfo2
additionalInfo3
additionalInfo4
externalRef
expiryDate
editabilityStatus
targetDate
label
userGroupEdit
userGroupViewDetails
T
updateField(String lineId, String fieldName, Object value)
Updates a field on the line.
-
-
-
Field Detail
-
phase
protected final HeaderPhase phase
-
METHOD_ADD_OR_UPDATE_OUTPUT
public static final String METHOD_ADD_OR_UPDATE_OUTPUT
- See Also:
- Constant Field Values
-
METHOD_ADD_OR_UPDATE_INPUT
public static final String METHOD_ADD_OR_UPDATE_INPUT
- See Also:
- Constant Field Values
-
METHOD_UPDATE_FIELD
public static final String METHOD_UPDATE_FIELD
- See Also:
- Constant Field Values
-
METHOD_ADD_LINE_ITEM
public static final String METHOD_ADD_LINE_ITEM
- See Also:
- Constant Field Values
-
ROOT_LINE_ID
public static final String ROOT_LINE_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
isPrePhase
public boolean isPrePhase()
Determines current calculation phase of logic execution- Returns:
- true if the current context is "pre"/before line item calculation
-
isPostPhase
public boolean isPostPhase()
Determines current calculation phase of logic execution- Returns:
- true if the current context is "post"/after line item calculation
-
addOrUpdateOutput
public T addOrUpdateOutput(Map<String,Object> calculationResult)
This method adds or updates a result value (an output value) on the root level- Parameters:
calculationResult
- A map describing a calculation result- Returns:
- itself (for flow pattern)
-
addOrUpdateOutput
public T addOrUpdateOutput(String lineId, Map<String,Object> calculationResult)
This method adds or updates a result value (an output value) on a line itemExample how to set a background color for the header output results:
quoteprocessor.addOrUpdateOutput(folderId, ["resultName": "RedMinimumMargin", "resultLabel": "Red (Minimum) Margin", "suffix": "", "cssProperties": "background-color: red;", "result": totalMinimumRed])
- Parameters:
lineId
- The id of the linecalculationResult
- A map describing a calculation result- Returns:
- itself (for flow pattern)
-
addOrUpdateInput
public T addOrUpdateInput(Map<String,Object> contextParameter)
This method adds or updates an input value on the root level- Parameters:
contextParameter
- A map describing the context parameter- Returns:
- itself (for flow pattern)
-
addOrUpdateInput
public T addOrUpdateInput(String lineId, Map<String,Object> contextParameter)
This method adds or updates an input value on a line item- Parameters:
lineId
- The id of the linecontextParameter
- A map describing the context parameter- Returns:
- itself (for flow pattern)
-
updateField
public T updateField(String lineId, String fieldName, Object value)
Updates a field on the line. Note: Not supported for all objects e.g. quotes- Parameters:
lineId
- The id of the linefieldName
- The field namevalue
- The new value- Returns:
- itself (for flow pattern)
-
updateField
public T updateField(String fieldName, Object value)
Updates a header field value For quotes supported fields are:additionalInfo1
additionalInfo2
additionalInfo3
additionalInfo4
externalRef
expiryDate
editabilityStatus
targetDate
label
userGroupEdit
userGroupViewDetails
- Parameters:
fieldName
- The field namevalue
- The new value- Returns:
- itself (for flow pattern)
-
setRenderInfo
public T setRenderInfo(String fieldName, String key, Object value)
Sets (adds or updates) rendering information for particular header fields (or buttons). The available key/value pairs depend on the particular field. If a key is used that is unknown to the client it will be simply ignored. For fields these 3 keys are currently supported:hide
,required
,disabled
. All three with a value attribute of boolean type. As field names currently supported are all fields shown in the header input portlet. The field names correspond to the names in the json data structure There are four buttons currently supported:saveButton
,submitButton
,creationWorkflowSubmitAndNext
andcreationWorkflowBack
. Buttons only support a key ofhide
. Once you hide a button, you will have to explicitely set hide to false or useclearRenderInfo(String)
in order to let the button reappear.- Parameters:
fieldName
- The field or button this setting should be applied onkey
- The setting namevalue
- The setting value- Returns:
- itself (for flow pattern)
-
clearRenderInfo
public T clearRenderInfo(String fieldName)
Clears existing render info for a field or for all fields- Parameters:
fieldName
- The field name to clear all info for, or null for all info for all fields- Returns:
-
addLineItem
public T addLineItem(String key)
This method adds a new line item in the root folder- Parameters:
key
- The key (usually the sku)- Returns:
- itself (for flow pattern)
-
addLineItem
public T addLineItem(String parentLineId, String key)
This method adds a new line item in the specified parent (folder id)- Parameters:
parentLineId
- id of parent itemkey
- The key (usually the sku)- Returns:
- itself (for flow pattern)
-
addLineItem
public T addLineItem(String parentLineId, String key, List<Map<String,Object>> contextParameter)
This method adds a new line item in the specified parent (folder id) and sets some context parameters.Sometimes it is required to pass values from a header logic to line items that this logic creates. You can use the HIDDEN input type and reference it in the calculation logic. The following code sample creates a new quote line with parameters fetched from the header logic:
def params = [[name:"MyHiddenParam", type: InputType.HIDDEN, value:"ABC"]] quoteProcessor.addLineItem("ROOT","MB-0003",params)
def val = api.input("MyHiddenParam")
- This way you can also set default values of "real" input parameters as determined by the line calculation logic. Set the value in the header logic and make sure that the names of the parameter match in both logics.
- If you use this method only to transport values between header & line, set the parameter type to HIDDEN. The value can also be a map to transport more structured data.
- Any parameter that is non-HIDDEN and not determined by the line logic will be removed.
- Be aware that this hidden data is also exposed to the user (it is part of the quote response). It is not visible in the UI, but it is neither a secure storage! Also, try to keep the data volume reasonably low.
def params = [[name:"MyHiddenParam", type: InputType.HIDDEN, value:"ABC"]] def qs = new QuoteStructure() qs.addPart("MySKU",params) //use add.Folder for a folder
- Parameters:
parentLineId
- id of parent itemkey
- The key (usually the sku)contextParameter
- A list of maps describing the context parameters- Returns:
- itself (for flow pattern)
-
moveItem
public T moveItem(String lineId, String newParentId)
Moves an item or folder underneath a new parent. Only works in PRE phase!- Parameters:
lineId
- The line ID of the item to movenewParentId
- The line ID of the target folder. null if you want to move it to root folder- Returns:
- itself (for flow pattern)
-
renameFolder
public T renameFolder(String lineId, String newFolderLabel)
Renames a folder (not items!)- Parameters:
lineId
- The line ID of the folder to renamenewFolderLabel
- New label- Returns:
- itself (for flow pattern)
-
-