Companion Twirl Templates
Before to use Companion Twirl Template take a look how Twirl Templates work inside Companion for Delivery Project.
Getting Started
Configuration
To use Companion Twirl Templates inside Companion for Delivery projects you must include it in the plugin dependencies. Furthermore, to have autocompletion in your IDE you must include it in your projet dependencies.
<dependencies>
<!-- optional used for autocomplete-->
<dependency>
<groupId>fr.cantor.c4d.templates</groupId>
<artifactId>twirl-templates</artifactId>
<version>${c4d-templates-versions}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>fr.cantor.c4d</groupId>
<artifactId>c4d-maven-plugin</artifactId>
<version>${c4d-maven-plugin.version}</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>fr.cantor.c4d.templates</groupId>
<artifactId>twirl-templates</artifactId>
<!-- Here set companion template version -->
<version>${c4d-templates-versions}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Usage
To use Companion Twirl Template inside .companion.xml
you must include follow imports :
@import fr.cantor.c4d.xml.extensions.CompanionParams
@import fr.cantor.c4d.xml.extensions.Extensions._
@import fr.cantor.c4d.templates.xml._
@import fr.cantor.c4d.templates.functions.xml._
@import fr.cantor.c4d.templates.lookup.xml._
@import fr.cantor.c4d.templates.bindings.xml._
@import fr.cantor.c4d.templates.approve.xml._
@import fr.cantor.c4d.templates.plugins.xml._
@import fr.cantor.c4d.templates.setup.xml._
Configuration Templates
LookupTable Templates
Templates to use for LookupTable.
LookupTable
Generate LookupTable xml.
@LookupTable(config, id, name, parentID, ignoreCase, replaceEmptyWithKey, mappings, defaultSubstitution)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |
id | String | LookupTable id | Yes | No |
name | String | LookupTable name | Yes | No |
parentID | String | LookupTable Parent ID (Expect a classification) | Yes | No |
ignoreCase | Boolean | Ignore case on values | No | false |
replaceEmptyWithKey | Boolean | Replace empty value with key | No | false |
mappings | Any | Expect an array of LookupTableEntry | No | Array() |
defaultSubstitution | String | Default value when no matches are found in source values | No | No |
LookupTableEntry
Define LookupTable entry that enable to transform a value with a LookUpTable.
Can only be used with LookupTable twirl template.
@LookupTableEntry(fromValue, toValue)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
fromValue | String | Source value inside the LookupTable | Yes | No |
toValue | String | Translated value of fromValue inside LookupTable | Yes | No |
LookupTableFromFile
Generate LookupTable xml from a csv File with ; separator.
@LookupTableFromFile(config, id, name, parentID, ignoreCase, replaceEmptyWithKey, fileRelativeFromModule, defaultSubstitution)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |
id | String | LookupTable id | Yes | No |
name | String | LookupTable name | Yes | No |
parentID | String | LookupTable Parent ID (Expect a classification) | Yes | No |
ignoreCase | Boolean | Ignore case on values | No | false |
replaceEmptyWithKey | Boolean | Replace empty value with key | No | false |
fileRelativeFromModule | String | Path of used to generate LookupTable. This path is relative to the module directory where the template is used | Yes | String |
defaultSubstitution | String | Default value when no matches are found in source values | No | No |
BusinessRules Templates
BusinessLibrary
Generate business library xml.
@BusinessLibrary(config, id, name, setupGroup, jsContent, dependencies, description)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |
id | String | Business library id | Yes | No |
name | String | Business library name | Yes | "" |
setupGroup | String | Business library setupGroup | Yes | No |
jsContent | Any | Business library JavaScript content | Yes | No |
dependencies | Array[Xml] | Bind business libraries dependencies in JavaScript see Dependency | No | Array() |
description | String | Business library description | No | "" |
Example of using the BusinessLibrary template
@import fr.cantor.c4d.xml.extensions.Extensions._
@import fr.cantor.c4d.xml.extensions.CompanionParams
@import fr.cantor.c4d.templates.xml.BusinessLibrary
@(config: CompanionParams)
@BusinessLibrary(config = config,
id = "Utils",
name = "Utils",
setupGroup = "Libraries",
jsContent = file("BusinessLibraries/Utils.js", true)
)
GlobalBusinessAction
Generate global business action xml.
@GlobalBusinessAction(config, id, name, description, setupGroup, dependencies, appliesIfPlugins, plugins, functionDependencies, validities, allTypesValid, runPrivileged, approve)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |
id | String | Global business action id | Yes | No |
name | String | Global business action name | No | "" |
description | String | Global business action description | No | "" |
setupGroup | String | Global business action setupGroup | Yes | No |
dependencies | Array[Xml] | Bind business libraries dependencies see Dependency | No | Array() |
appliesIfPlugins | Array[Any] | Bind business rule plugins to specify a precondition to be evaluated before the business rule is applied | No | Array() |
plugins | Array[Any] | Bind business rule plugins that apply when business rule is run | No | Array() |
functionDependencies | Array[String] | Set business function dependencies | No | Array() |
validities | Array[String] | Set valid global business action usertypes | No | Array() |
allTypesValid | Boolean | Determines if the business rule will be valid for all usertypes in step. Note validities must not be set | No | false |
runPrivileged | Boolean | Determines if the business rule will be executed or tested with global read / write privileges | No | true |
approve | Xml | Determines if the business rule will be tested or executed on approval and if changes will be approved | No | Never() |
Example of using the GlobalBusinessAction template
The two templates presented below can be simplified with the JavascriptGlobalBusinessAction template
Example of using the GlobalBusinessAction template with a custom plugin
@import fr.cantor.c4d.xml.extensions.Extensions._
@import fr.cantor.c4d.xml.extensions.CompanionParams
@import fr.cantor.c4d.templates.xml.GlobalBusinessAction
@import fr.cantor.c4d.templates.approve.xml.TriggerAndApprove
@(config: CompanionParams)
@javaScriptBusinessActionWithBindsPlugin = {
<BusinessPlugin BusinessRulePluginID="JavaScriptBusinessActionWithBinds">
<Parameters>
<Parameter ID="Binds" Type="java.lang.String">
@escapeXml {
<BindMap>
<Bind Alias="node" ParameterClass="null" contractID="CurrentObjectBindContract"></Bind>
<Bind Alias="manager" ParameterClass="null" contractID="ManagerBindContract"></Bind>
<Bind Alias="logger" ParameterClass="null" contractID="LoggerBindContract"></Bind>
</BindMap>
}
</Parameter>
<Parameter ID="ErrorMessages" Type="java.lang.String"></Parameter>
<Parameter ID="JavaScript" Type="java.lang.String">@file("BusinessRules/Actions/ApproveVariant.js", true)</Parameter>
</Parameters>
</BusinessPlugin>
}
@GlobalBusinessAction(config = config,
id = "ApproveVariant",
name = "ApproveVariant",
setupGroup = "Actions",
plugins = Array(javaScriptBusinessActionWithBindsPlugin),
validities = Array("P_PRODUCT_VARIANT","P_PRODUCT_VARIANT_FAMILY"),
approve = TriggerAndApprove()
)
Example of using the GlobalBusinessAction template with a predefined plugin :
@import fr.cantor.c4d.xml.extensions.Extensions._
@import fr.cantor.c4d.xml.extensions.CompanionParams
@import fr.cantor.c4d.templates.xml.GlobalBusinessAction
@import fr.cantor.c4d.templates.approve.xml.TriggerAndApprove
@import fr.cantor.c4d.templates.plugins.xml.JavascriptBusinessActionPlugin
@import fr.cantor.c4d.templates.bindings.xml._
@(config: CompanionParams)
@GlobalBusinessAction(config = config,
id = "ApproveVariant",
name = "ApproveVariant",
setupGroup = "Actions",
plugins = Array(
JavascriptBusinessActionPlugin(
jsContent = file("BusinessRules/Actions/ApproveVariant.js", true),
bindings = Array(BindCurrentObject(),
BindManager(),
BindLogger()))
),
validities = Array("P_PRODUCT_VARIANT","P_PRODUCT_VARIANT_FAMILY"),
approve = TriggerAndApprove()
)
GlobalBusinessCondition
Generate global business condition xml.
@GlobalBusinessCondition(config, id, name, description, setupGroup, dependencies, appliesIfPlugins, plugins, functionDependencies, validities, allTypesValid, runPrivileged, approve)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |
id | String | Global business condition id | Yes | No |
name | String | Global business condition name | No | "" |
setupGroup | String | Global business condition setupGroup | Yes | No |
dependencies | Array[Xml] | Bind business libraries dependencies in JavaScript see Dependency | No | Array() |
description | String | Global business condition description | No | "" |
appliesIfPlugins | Array[Any] | Bind business rule plugins to specify a precondition to be evaluated before the business rule is applied | No | Array() |
plugins | Array[Any] | Bind business rule plugins that apply when business rule is run | No | Array() |
functionDependencies | Array[String] | Set business function dependencies | No | Array() |
validities | Array[String] | Set valid global business condition usertypes | No | No |
allTypesValid | Boolean | Determines if the business rule will be valid for all usertypes in step. Note validities must not be set | No | false |
runPrivileged | Boolean | Determines if the business rule will be executed or tested with global read / write privileges | No | true |
approve | Xml | Determines if the business rule will be tested or executed before or after approval | No | Never() |
Example of using the GlobalBusinessCondition template
The two templates presented below can be simplified with the JavascriptGlobalBusinessCondition template
Example of using the GlobalBusinessCondition template with a custom plugin
@import fr.cantor.c4d.xml.extensions.Extensions._
@import fr.cantor.c4d.xml.extensions.CompanionParams
@import fr.cantor.c4d.templates.xml.GlobalBusinessCondition
@import fr.cantor.c4d.templates.approve.xml.ValidateBefore
@(config: CompanionParams)
@javaScriptBusinessConditionWithBindsPlugin = {
<BusinessPlugin BusinessRulePluginID="JavaScriptBusinessConditionWithBinds">
<Parameters>
<Parameter ID="Binds" Type="java.lang.String">
@escapeXml {
<BindMap>
<Bind Alias="node" ParameterClass="null" contractID="CurrentObjectBindContract"></Bind>
<Bind Alias="manager" ParameterClass="null" contractID="ManagerBindContract"></Bind>
<Bind Alias="logger" ParameterClass="null" contractID="LoggerBindContract"></Bind>
</BindMap>
}
</Parameter>
<Parameter ID="ErrorMessages" Type="java.lang.String"></Parameter>
<Parameter ID="JavaScript" Type="java.lang.String">@file("BusinessRules/Conditions/CheckVariants.js", true)</Parameter>
</Parameters>
</BusinessPlugin>
}
@GlobalBusinessCondition(config = config,
id = "CheckVariants",
name = "CheckVariants",
setupGroup = "Conditions",
plugins = Array(javaScriptBusinessConditionWithBindsPlugin),
validities = Array("P_PRODUCT_VARIANT","P_PRODUCT_VARIANT_FAMILY"),
approve = ValidateBefore()
)
Example of using the GlobalBusinessCondition template with a predefined plugin :
@import fr.cantor.c4d.xml.extensions.Extensions._
@import fr.cantor.c4d.xml.extensions.CompanionParams
@import fr.cantor.c4d.templates.xml.GlobalBusinessCondition
@import fr.cantor.c4d.templates.approve.xml.ValidateBefore
@import fr.cantor.c4d.templates.plugins.xml.JavascriptBusinessConditionPlugin
@import fr.cantor.c4d.templates.bindings.xml._
@(config: CompanionParams)
@GlobalBusinessCondition(config = config,
id = "CheckVariants",
name = "CheckVariants",
setupGroup = "Conditions",
plugins = Array(
JavascriptBusinessConditionPlugin(
jsContent = file("BusinessRules/Conditions/CheckVariants.js", true),
bindings = Array(BindCurrentObject(),
BindManager(),
BindLogger())
)
),
validities = Array("P_PRODUCT_VARIANT","P_PRODUCT_VARIANT_FAMILY"),
approve = ValidateBefore()
)
LocalBusinessAction
Generate local business action xml.
@LocalBusinessAction(id, name, description, dependencies, appliesIfPlugins, plugins, functionDependencies, runPrivileged)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
id | String | Local business action id | Yes | No |
name | String | Local business action name | No | "" |
description | String | Local business action description in step | No | "" |
dependencies | Array[Xml] | Bind business libraries dependencies in JavaScript see Dependency | No | Array() |
appliesIfPlugins | Array[Any] | Bind business rule plugins to specify a precondition to be evaluated before the business rule is applied | No | Array() |
plugins | Array[Any] | Bind business rule plugins that apply when business rule is run | No | Array() |
functionDependencies | Array[String] | Set business function dependencies | No | Array() |
runPrivileged | Boolean | Determines if the business rule will be executed or tested with global read / write privileges | No | true |
LocalBusinessCondition
Generate local business condition xml.
@LocalBusinessCondition(id, name, description, dependencies, appliesIfPlugins, plugins, functionDependencies, runPrivileged)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
id | String | Local business condition id | Yes | No |
name | String | Local business condition name | No | "" |
description | String | Local business condition description in step | No | "" |
dependencies | Array[Xml] | Bind business libraries dependencies in JavaScript see Dependency | No | Array() |
appliesIfPlugins | Array[Any] | Bind business rule plugins to specify a precondition to be evaluated before the business rule is applied | No | Array() |
plugins | Array[Any] | Bind business rule plugins that apply when business rule is run | No | Array() |
functionDependencies | Array[String] | Set business function dependencies | No | Array() |
runPrivileged | Boolean | Determines if the business rule will be executed or tested with global read / write privileges | No | true |
Approve
Generates the xml used to define that the business rule is executed at a specific approval step
Never
The given business rule isn't executed on approval
@Never()
Trigger
The given business action is executed on approval but changes aren't approved
@Trigger()
TriggerAndApprove
The given business action is executed on approval and changes are approved
@TriggerAndApprove()
ValidateAfter
The given business condition is executed after approval
@ValidateAfter()
ValidateBefore
The given business condition is executed before approval
@ValidateBefore()
ValidateBeforeAndAfter
The given business condition is executed before and after approval
@ValidateBeforeAndAfter()
Dependency
Generate xml of business library dependency
@Dependency(id, alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
id | String | Target business library id | Yes | No |
alias | String | Target business library name in business rule JavaScript | Yes | No |
Plugins
AssignedGeneratedValue
Plugin to assign a value to an attribute using a value generator
@AssignedGeneratedValue(attribute, valueGenerator)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
attribute | String | Id of the attribute | Yes | No |
valueGenerator | String | Id of the value generator | Yes | No |
JavascriptBusinessActionPlugin
Plugin to execute Javascript for an action
@JavascriptBusinessActionPlugin(jsContent, bindings, errorMessages)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
jsContent | Any | Business action JavaScript content | Yes | No |
bindings | Template twirl / XML | Business action bindings see JavaScript Bindings | No | No |
errorMessages | Array[Xml] | Bind error messages in Javascript see ErrorMessage | No | Array() |
JavascriptBusinessConditionPlugin
Plugin to execute Javascript for a condition
@JavascriptBusinessConditionPlugin(jsContent, bindings, errorMessages)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
jsContent | Any | Business condition JavaScript content | Yes | No |
bindings | Template twirl / XML | Business condition bindings see JavaScript Bindings | No | No |
errorMessages | Array[Xml] | Bind error messages in Javascript see ErrorMessage | No | Array() |
ReferenceOtherBusinessAction
Plugin to reference another business action
@ReferenceOtherBusinessAction(businessRuleId)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
businessRuleId | String | Id of the business action to reference | Yes | No |
ReferenceOtherBusinessCondition
Plugin to reference another business condition
@ReferenceOtherBusinessCondition(businessRuleId)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
businessRuleId | String | Id of the business condition to reference | Yes | No |
valueWhenNA | Boolean | Value of the business condition if assessed at NA | No | false |
Business Functions Templates
BusinessFunction
- Base template to generate business function xml.
@BusinessFunction(config, id, name, setupGroup, jsContent, returnType, dependencies, additionalBindings, functionParameterBindings, description, errorMessages, runPrivileged)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |
id | String | Business function id | Yes | No |
name | String | Business function name | Yes | No |
setupGroup | String | Business function setupGroup | Yes | No |
jsContent | Any | Business function JavaScript content | Yes | No |
returnType | String | Business function return object type | Yes | No |
dependencies | Array[Xml] | Bind business libraries dependencies in JavaScript see Dependency | No | Array() |
additionalBindings | Template twirl / XML | Business function bindings see JavaScript Bindings | No | No |
functionParameterBindings | Template twirl / XML | Bind business function input parameters (See BusinessFunctionToNode), for available bindings see JavaScript Bindings | No | No |
description | String | Business function description | No | "" |
errorMessages | Array[Xml] | Bind error messages in Javascript see ErrorMessage | No | Array() |
runPrivileged | Boolean | Determines if the business rule will be executed or tested with global read / write privileges | No | true |
Example of using the BusinessFunction template
Example with a business function similar to BusinessFunctionToNode :
@import fr.cantor.c4d.xml.extensions.Extensions._
@import fr.cantor.c4d.xml.extensions.CompanionParams
@import fr.cantor.c4d.templates.functions.xml.BusinessFunction
@(config: CompanionParams)
@BusinessFunction(config = config,
id = "BF_GET_PARENT_NODE",
name = "getParentNode",
setupGroup = "BusinessFunctions",
jsContent = file("functions/getParentNode.js", true),
returnType = "com.stibo.core.domain.Node",
functionParameterBindings = Array(
<Bind Alias="node" Description="" ParameterClass="null" contractID="NodeBindContract"></Bind>
),
description = "return parent node of the given node"
)
return node.getParent();
BusinessFunctionToNode
- Preconfigured template to return a node from input parameter node :
returnType
:com.stibo.core.domain.Node
functionParameterBindings
:- node : currentNode (CurrentNode)
@BusinessFunctionToNode(config, id, name, setupGroup, jsContent, dependencies, additionalBindings, description, errorMessages, runPrivileged)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |
id | String | Business function id | Yes | No |
name | String | Business function name | Yes | No |
setupGroup | String | Business function setupGroup | Yes | No |
jsContent | Any | Business function JavaScript content | Yes | No |
dependencies | Array[Xml] | Bind business libraries dependencies in JavaScript see Dependency | No | Array() |
additionalBindings | Template twirl / XML | Business function bindings see JavaScript Bindings | No | No |
description | String | Business function description | No | "" |
errorMessages | Array[Xml] | Bind error messages in Javascript see ErrorMessage | No | Array() |
runPrivileged | Boolean | Determines if the business rule will be executed or tested with global read / write privileges | No | true |
js sample (return current node parent) :
return node.getParent();
JavaScript specific templates
JavascriptGlobalBusinessAction
Generate global business action with a javascript plugin.
Javascript plugin is configured by default with the following bindings in this order : BindCurrentObject, BindManager, BindLogger
@JavascriptGlobalBusinessAction(config, id, name, description, setupGroup, dependencies, jsContent, removeDefaultBindings, additionalBindings, errorMessages, functionDependencies, validities, allTypesValid, runPrivileged, approve)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |
id | String | Global business action id | Yes | No |
name | String | Global business action name | No | "" |
description | String | Global business action description | No | "" |
setupGroup | String | Global business action setupGroup | Yes | No |
dependencies | Array[Xml] | Bind business libraries dependencies in JavaScript see Dependency | No | Array() |
jsContent | Any | Global business action JavaScript content | Yes | No |
removeDefaultBindings | Boolean | Determines whether the business rule should apply the default bindings | No | false |
additionalBindings | Template twirl / XML | Global business action bindings see JavaScript Bindings | No | No |
errorMessages | Array[Xml] | Bind error messages in Javascript see ErrorMessage | No | Array() |
functionDependencies | Array[String] | Set business function dependencies | No | Array() |
validities | Array[String] | Set valid global business action usertypes | No | Array() |
allTypesValid | Boolean | Determines if the business rule will be valid for all usertypes in step. Note validities must not be set | No | false |
runPrivileged | Boolean | Determines if the business rule will be executed or tested with global read / write privileges | No | true |
approve | Xml | Determines if the business rule will be tested or executed on approval and if changes will be approved | No | Never() |
Example of using the JavascriptGlobalBusinessAction template
@import fr.cantor.c4d.xml.extensions.Extensions._
@import fr.cantor.c4d.xml.extensions.CompanionParams
@import fr.cantor.c4d.templates.xml.JavascriptGlobalBusinessAction
@import fr.cantor.c4d.templates.approve.xml.TriggerAndApprove
@(config: CompanionParams)
@JavascriptGlobalBusinessAction(config = config,
id = "ApproveVariant",
name = "ApproveVariant",
setupGroup = "Actions",
jsContent = file("BusinessRules/Actions/ApproveVariant.js", true),
validities = Array("P_PRODUCT_VARIANT","P_PRODUCT_VARIANT_FAMILY"),
approve = TriggerAndApprove()
)
JavascriptGlobalBusinessCondition
Generate global business condition with a javascript plugin.
Javascript plugin is configured by default with the following bindings in this order : BindCurrentObject, BindManager, BindLogger
@JavascriptGlobalBusinessCondition(config, id, name, description, setupGroup, dependencies, jsContent, removeDefaultBindings, additionalBindings, errorMessages, functionDependencies, validities, allTypesValid, runPrivileged, approve)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |
id | String | Global business condition id | Yes | No |
name | String | Global business condition name | No | "" |
description | String | Global business condition description | No | "" |
setupGroup | String | Global business condition setupGroup | Yes | No |
dependencies | Array[Xml] | Bind business libraries dependencies in JavaScript see Dependency | No | Array() |
jsContent | Any | Global business condition JavaScript content | Yes | No |
removeDefaultBindings | Boolean | Determines whether the business rule should apply the default bindings | No | false |
additionalBindings | Template twirl / XML | Global business condition bindings see JavaScript Bindings | No | No |
errorMessages | Array[Xml] | Bind error messages in Javascript see ErrorMessage | No | Array() |
functionDependencies | Array[String] | Set business function dependencies | No | Array() |
validities | Array[String] | Set valid global business condition usertypes | No | No |
allTypesValid | Boolean | Determines if the business rule will be valid for all usertypes in step. Note validities must not be set | No | false |
runPrivileged | Boolean | Determines if the business rule will be executed or tested with global read / write privileges | No | true |
approve | Xml | Determines if the business rule will be tested or executed before or after approval | No | Never() |
Example of using the JavascriptGlobalBusinessCondition template
@import fr.cantor.c4d.xml.extensions.Extensions._
@import fr.cantor.c4d.xml.extensions.CompanionParams
@import fr.cantor.c4d.templates.xml.JavascriptGlobalBusinessCondition
@import fr.cantor.c4d.templates.approve.xml.ValidateBefore
@(config: CompanionParams)
@JavascriptGlobalBusinessCondition(config = config,
id = "CheckVariants",
name = "CheckVariants",
setupGroup = "Conditions",
jsContent = file("BusinessRules/Conditions/CheckVariants.js", true),
validities = Array("P_PRODUCT_VARIANT","P_PRODUCT_VARIANT_FAMILY"),
approve = ValidateBefore()
)
JavascriptLocalBusinessAction
Generate local business action with a javascript plugin.
Javascript plugin is configured by default with the following bindings in this order : BindCurrentObject, BindManager, BindLogger, BindCurrentWorkflow
@JavascriptLocalBusinessAction(id, name, description, dependencies, jsContent, removeDefaultBindings, additionalBindings, errorMessages, functionDependencies, runPrivileged)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
id | String | Local business action id | Yes | No |
name | String | Local business action name | No | "" |
description | String | Local business action description in step | No | "" |
dependencies | Array[Xml] | Bind business libraries dependencies in JavaScript see Dependency | No | Array() |
jsContent | Any | Local business action JavaScript content | Yes | No |
removeDefaultBindings | Boolean | Determines whether the business rule should apply the default bindings | No | false |
additionalBindings | Template twirl / XML | Local business action bindings see JavaScript Bindings | No | No |
errorMessages | Array[Xml] | Bind error messages in Javascript see ErrorMessage | No | Array() |
functionDependencies | Array[String] | Set business function dependencies | No | Array() |
runPrivileged | Boolean | Determines if the business rule will be executed or tested with global read / write privileges | No | true |
JavascriptLocalBusinessCondition
Generate local business condition with a javascript plugin.
Javascript plugin is configured by default with the following bindings in this order : BindCurrentObject, BindManager, BindLogger, BindCurrentWorkflow
@JavascriptLocalBusinessCondition(id, name, description, dependencies, jsContent, removeDefaultBindings, additionalBindings, errorMessages, functionDependencies, runPrivileged)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
id | String | Local business condition id | Yes | No |
name | String | Local business condition name | No | "" |
description | String | Local business condition description in step | No | "" |
dependencies | Array[Xml] | Bind business libraries dependencies in JavaScript see Dependency | No | Array() |
jsContent | Any | Local business condition JavaScript content | Yes | No |
removeDefaultBindings | Boolean | Determines whether the business rule should apply the default bindings | No | false |
additionalBindings | Template twirl / XML | Local business condition bindings see JavaScript Bindings | No | No |
errorMessages | Array[Xml] | Bind error messages in Javascript see ErrorMessage | No | Array() |
functionDependencies | Array[String] | Set business function dependencies | No | Array() |
runPrivileged | Boolean | Determines if the business rule will be executed or tested with global read / write privileges | No | true |
ErrorMessage
Generate xml of error message
@ErrorMessage(key, message)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
key | String | Error message key | Yes | No |
message | String | Error message value | Yes | No |
Bindings
BindAttributeValidatedParameter
Bind attribut validated parameter in Javascript file, allows to give a parameterized value for an attribute before executing the business rule.
@BindAttributeValidatedParameter(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Alias of the given value in business rule JavaScript | Yes | No |
attributeId | String | ID of the attribute used as input | Yes | No |
externalId | String | External id of the parameter | Yes | No |
BindBusinessAction
Bind business action with an alias in JavaScript file.
@BindBusinessAction(alias, businessRuleId)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Business rule alias in javaScript | Yes | No |
businessRuleId | String | Id of the business rule to be binded | Yes | No |
BindBusinessCondition
Bind business condition with an alias in JavaScript file.
@BindBusinessCondition(alias, businessRuleId)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Business rule alias in javaScript | Yes | No |
businessRuleId | String | Id of the business rule to be binded | Yes | No |
BindBusinessFunction
Bind business function with an alias in JavaScript file.
@BindBusinessFunction(alias, businessRuleId)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Business rule alias in javaScript | Yes | No |
businessRuleId | String | Id of the business rule to be binded | Yes | No |
BindCurrentEventType
Bind current event type evaluated/executed by the business rule with an alias in JavaScript file.
@BindCurrentEventType(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Current event type alias in business rule JavaScript | No | "eventType" |
BindCurrentObject
Bind current object evaluated/executed by the business rule with an alias in JavaScript file.
@BindCurrentObject(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Current object alias in business rule JavaScript | No | "node" |
BindCurrentTransition
Bind current object transition evaluated/executed by the business rule with an alias in JavaScript file.
@BindCurrentTransition(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Current object transition alias in BusinessRule JavaScript | No | "transition" |
BindCurrentWorkflow
Bind current object workflow evaluated/executed by the business rule with an alias in JavaScript file.
@BindCurrentWorkflow(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Current object workflow alias in BusinessRule JavaScript | No | "workflow" |
BindDerivedEvent
Bind selected derived event type in JavaScript file.
@BindDerivedEvent(alias, derivedEvent)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Selected derived event type alias in business rule JavaScript | Yes | No |
derivedEvent | String | Selected derived event type to bind | Yes | No |
BindEventBatch
Bind current event batch in JavaScript file.
@BindEventBatch(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Current event batch alias in business rule JavaScript | Yes | No |
BindEventProcessor
Bind an event processor in JavaScript file
@BindEventProcessor(alias, eventProcessorID)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Selected event processor alias in business rule JavaScript | Yes | No |
eventProcessorID | String | Selected event processor id to bind | Yes | No |
BindEventProcessorEventBatch
Bind current event processor event batch in JavaScript file.
@BindEventProcessorEventBatch(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Current event batch alias in business rule JavaScript | Yes | No |
BindEventQueue
Bind an event queue in JavaScript file
@BindEventQueue(alias, eventQueueId)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Selected event queue alias in business rule JavaScript | Yes | No |
eventQueueId | String | Selected event queue id to bind | Yes | No |
BindGatewayIntegrationEndpoint
Bind a gateway integration endpoint with an alias in JavaScript file.
@BindGatewayIntegrationEndpoint(alias, gatewayIntegrationEndpointId)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Gateway integration endpoint alias in javaScript | Yes | No |
gatewayIntegrationEndpointId | String | Id of the gateway integration endpoint to be binded | Yes | No |
BindImportChangeInfo
Bind the current import change info in JavaScript file.
@BindImportChangeInfo(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Alias of the import change info | No | "changeInfo" |
BindLogger
Bind a logger in JavaScript file
@BindLogger(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Logger alias in business rule JavaScript | No | "logger" |
BindLookupTableHome
Bind LookupTableHome in Javascript file
@BindLookupTableHome(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | LookupTableHome alias in business rule JavaScript | No | "lookup" |
BindMailHome
Bind MailHome in Javascript file
@BindMailHome(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | MailHome alias in business rule JavaScript | No | "mailHome" |
BindManager
Bind step manager in JavaScript file
@BindManager(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Manager alias in business rule JavaScript | No | "manager" |
BindOutboundIntegrationEndpoint
Bind outbound integration endpoint in JavaScript file
@BindOutboundIntegrationEndpoint(alias, outboundIntegrationEndpointId)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Selected outbound integration endpoint alias in business rule JavaScript | Yes | No |
outboundIntegrationEndpointId | String | Selected outbound integration endpoint id | Yes | No |
BindQueryHome
Bind QueryHome in Javascript file
@BindQueryHome(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | QueryHome alias in business rule JavaScript | No | "queryHome" |
BindUser
Bind current user in JavaScript file.
@BindUser(alias, userID)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | Current user alias in business rule JavaScript | Yes | No |
userID | String | User ID to bind in business rule JavaScript | Yes | No |
BindWebUiContext
Bind WebUiContext in Javascript file
@BindWebUiContext(alias)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
alias | String | WebUiContext alias in business rule JavaScript | No | "webUiContext" |
Setup Templates
These templates are used to configure the environment to work correctly with Companion for Delivery.
c4dDocumentationSetup
Template for initializing all setup configurations to enable exporting Step configuration to Companion for Delivery Documentation. The following entities have been established:
- Establish the configuration of the
GatewayEndpoint user-type root
within theGateway Integration Endpoints
setup groups. - Set up the
stibo.businessrule.function
in theBusinessRuleGroup
andGlobalBusinessRules
setup groups. - Optionally, you can create the
Gateway Integration Endpoints
andBRG_Companion
setup groups (refer to the option details). - Generate the business rule
BF_AUTH_C4D_DOCUMENTATION
and the gateway integration endpointGIEP_COMPANION_DOCUMENTATION
for authenticating with Companion for Delivery Documentation. - Generate the outbound integration endpoint
OIEP_COMPANION_DOCUMENTATION
for exporting Step configuration aimed at documentation purposes.
@c4dDocumentationSetup(config, username, environment, clientId, version, projectName, advancedStepXmlTemplate, authBusinessFunctionSetupGroup, oiepSetupGroup, authGatewaySetupGroup)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |
username | String | Username to authenticate to Companion for Delivery Documentation | Yes | No |
environment | String | Companion for Delivery Documentation parameter: Name of the environment to be overwritten for example: dev, test, prod | Yes | No |
clientId | String | Companion for Delivery Documentation parameter: Client name provided by Cantor | Yes | No |
version | String | Companion for Delivery Documentation parameter: Environment version | Yes | No |
projectName | String | Companion for Delivery Documentation parameter: Environment name | Yes | No |
advancedStepXmlTemplate | String | Advanced step xml template to define export configuration see Example of export configuration for documentation | Yes | No |
authBusinessFunctionSetupGroup | String | SetupGroup to create BF_AUTH_C4D_DOCUMENTATION business function | No | "BRG_Companion" |
oiepSetupGroup | String | SetupGroup to create OIEP_COMPANION_DOCUMENTATION outbound integration endpoint | No | "Outbound Integration Endpoints" |
authGatewaySetupGroup | String | SetupGroup to create GIEP_COMPANION_DOCUMENTATION gateway integration endpoint | No | "Gateway Integration Endpoints" |
To set the password to authenticate you have to modify the binding
password
inside BF_AUTH_C4D_DOCUMENTATION
@import fr.cantor.c4d.xml.extensions.CompanionParams
@import fr.cantor.c4d.templates.setup.xml.c4dDocumentationSetup
@(config: CompanionParams)
@c4dDocumentationSetup(
config = config,
username = "user",
environment = "dev",
clientId = "customer",
version = "1.0.0",
projectName = "example",
advancedStepXmlTemplate = {
<STEP-ProductInformation>
<!-- Context -->
<DimensionList ExportSize="All"/>
<ContextList ExportSize="All"/>
<!-- Datamodel -->
<UserTypes ExportSize="All"/>
<AttributeGroupList ExportSize="All"/>
<AttributeList ExportSize="All"/>
<UnitList ExportSize="All"/>
<ListOfValuesGroupList ExportSize="All"/>
<ListsOfValues ExportSize="All"/>
<CrossReferenceTypes ExportSize="All"/>
<Keys/>
<!-- Integration -->
<STEPWorkflows ExportSize="All"/>
<BusinessLibraries ExportSize="All"/>
<BusinessRules ExportSize="All"/>
<!-- Datas -->
<!-- Products with attributesLinks-->
<!-- Remove this tag if you dont want to document node from Primary Product Hierarchy -->
<Products ExportSize="Selected" FlattenHierarchy="true">
<!-- Specify the product you need to export for documentation -->
<FilterUserType ID="TYPE_PRODUIT_1"/>
<FilterUserType ID="TYPE_PRODUIT_2"/>
<Product>
<Name/>
<AttributeLink>
<MetaData/>
</AttributeLink>
<Product/>
</Product>
</Products>
<!-- Classifications with attributesLinks-->
<Classifications ExportSize="Minimum" FlattenHierarchy="true">
<Classification IncludeParent='true'>
<AttributeLink>
<MetaData/>
</AttributeLink>
</Classification>
</Classifications>
</STEP-ProductInformation>
})
c4dSetup
Template for initializing all setup configurations to use Companion for Delivery on Step (see Companion for Delivery Datamodel)
@c4dSetup(config)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |
c4dTestsSetup
Template for initializing all setup configurations to use Companion for Delivery Tests on Step (see Companion for Delivery Datamodel)
@c4dTestsSetup(config)
Parameter | Type | Description | Required | Default Value |
---|---|---|---|---|
config | CompanionParams | Companion parameters see Template definition | Yes | No |