public abstract class CalculableLineItemCollectionBuilder<T extends CalculableLineItemCollectionBuilder>
extends AbstractBuilder
Modifier and Type | Field and 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 and Description |
---|
CalculableLineItemCollectionBuilder(String instanceId,
String classId,
IdGenerator idGenerator,
Invocations<MethodInvocation> invocations,
HeaderPhase phase) |
Modifier and Type | Method and Description |
---|---|
T |
addLineItem(String key)
This method adds a new line item in the root folder
|
T |
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(Map<String,Object> contextParameter)
This method adds or updates an input value on the root level
|
T |
addOrUpdateInput(String lineId,
Map<String,Object> contextParameter)
This method adds or updates an input value on a line item
|
T |
addOrUpdateOutput(Map<String,Object> calculationResult)
This method adds or updates a result value (an output value) on the root level
|
T |
addOrUpdateOutput(String lineId,
Map<String,Object> calculationResult)
This method adds or updates a result value (an output value) on a line item
|
T |
clearRenderInfo(String fieldName)
Clears existing render info for a field or for all fields
|
T |
deleteItem(String lineId)
Deletes an item or folder.
|
boolean |
isPostPhase()
Determines current calculation phase of logic execution
|
boolean |
isPrePhase()
Determines current calculation phase of logic execution
|
T |
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.
|
protected final HeaderPhase phase
public static final String METHOD_ADD_OR_UPDATE_OUTPUT
public static final String METHOD_ADD_OR_UPDATE_INPUT
public static final String METHOD_UPDATE_FIELD
public static final String METHOD_ADD_LINE_ITEM
public static final String ROOT_LINE_ID
public boolean isPrePhase()
public boolean isPostPhase()
public T addOrUpdateOutput(Map<String,Object> calculationResult)
calculationResult
- A map describing a calculation resultpublic T addOrUpdateOutput(String lineId, Map<String,Object> calculationResult)
Example 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])
lineId
- The id of the linecalculationResult
- A map describing a calculation resultpublic T addOrUpdateInput(Map<String,Object> contextParameter)
contextParameter
- A map describing the context parameterpublic T addOrUpdateInput(String lineId, Map<String,Object> contextParameter)
lineId
- The id of the linecontextParameter
- A map describing the context parameterpublic T updateField(String lineId, String fieldName, Object value)
lineId
- The id of the linefieldName
- The field namevalue
- The new valuepublic T updateField(String fieldName, Object value)
additionalInfo1
additionalInfo2
additionalInfo3
additionalInfo4
externalRef
expiryDate
editabilityStatus
targetDate
label
userGroupEdit
userGroupViewDetails
fieldName
- The field namevalue
- The new valuepublic T setRenderInfo(String fieldName, String key, Object value)
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
and creationWorkflowBack
. Buttons only support a key of hide
.
Once you hide a button, you will have to explicitely set hide to false or use clearRenderInfo(String)
in order to let the button reappear.fieldName
- The field or button this setting should be applied onkey
- The setting namevalue
- The setting valuepublic T clearRenderInfo(String fieldName)
fieldName
- The field name to clear all info for, or null for all info for all fieldspublic T addLineItem(String key)
key
- The key (usually the sku)public T addLineItem(String parentLineId, String key)
parentLineId
- id of parent itemkey
- The key (usually the sku)public T addLineItem(String parentLineId, String key, List<Map<String,Object>> contextParameter)
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:
In the line calculation logic, this value then can be retrieved by:def params = [[name:"MyHiddenParam", type: InputType.HIDDEN, value:"ABC"]] quoteProcessor.addLineItem("ROOT","MB-0003",params)
Notes:def val = api.input("MyHiddenParam")
def params = [[name:"MyHiddenParam", type: InputType.HIDDEN, value:"ABC"]] def qs = new QuoteStructure() qs.addPart("MySKU",params) //use add.Folder for a folder
parentLineId
- id of parent itemkey
- The key (usually the sku)contextParameter
- A list of maps describing the context parameterspublic T moveItem(String lineId, String newParentId)
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 folderpublic T renameFolder(String lineId, String newFolderLabel)
lineId
- The line ID of the folder to renamenewFolderLabel
- New labelCopyright © 2019. All rights reserved.