Add new rule action
Implement the following steps to add an additional action to an existing base configuration rule.
About this task
Procedure
-
Open PolicyCenter Studio and navigate to the following location in the Studio Project window:
-
Create a RuleActionKey typelist extension, if one does not
exist.
-
Add the following typecode to the typelist extension.
code AddCustomIssue name AddCustomIssue desc Create a custom issue -
Manually add an
UWRulecategory to the new typecode.As the Rule typelist is a generated typelist (from Rule.eti), you need to enter the category information manually using the RuleActionKey typelist Text tab.-
<category code="UWRule" typelist="Rule"/>
The resulting typecode definition looks similar to the following code.<typecode code="AddCustomIssue" desc="Create a custom issue" name="AddCustomIssue"> <category code="UWRule" typelist="Rule"/> </typecode> -
-
Add the following typecode to the typelist extension.
- In the Studio Project window, navigate to gsrc and create a package to hold your work.
-
Add a new AddCustomizedRuleAction class to your work package that
implements the IRuleAction interface.
For example, create a class that is similar to the following code.
package ... uses gw.bizrules.CommandParameterDefinition uses gw.bizrules.IRuleAction uses gw.bizrules.IRuleCommand class AddCustomizedRuleAction implements IRuleAction { override property get Key() : RuleActionKey { return RuleActionKey.TC_ADDCUSTOMISSUE //new RuleActionKey typecode created in a previous step } override property get CommandParameterDefinitions() : Map<String, CommandParameterDefinition> { return null //add your own implementation here } override function execute(command : IRuleCommand) { //custom action code } override function describe(ruleCommandDefinition : RuleCommandDefinition) : String { return null //add new custom implementation here } }Important: For this class to be functional, you must add your own implementation code to the class. -
Open the implementation class for the IBizRulesPlugin plugin.
You need to register your new AddCustomizedRuleAction class in the plugin implementation code.
-
Find the
RuleActionsproperty, which, in the base configuration looks similar to the following code:override property get RuleActions() : Set<IRuleAction> { return { new AddUWIssueRuleAction() } } -
Add your new AddCustomizedRuleAction class to this
property.
For example, do something similar to the following code.
override property get RuleActions() : Set<IRuleAction> { return { new AddUWIssueRuleAction(), new AddCustomizedRuleAction() } }Notice that this change now triggers the execution of two underwriting rule actions.
-
Find the
-
Open class UWRuleBuilder.
-
Find the constructor that begins with the following code:
construct (excludeHead : boolean) { ... } -
Modify this constructor to add a new populator for
RuleActionKey.TC_ADDCUSTOMISSUE.For example, add something similar to the following code to the constructor.construct (excludeHead : boolean) { //exisitng code.. //add new populator for the RuleActionKey.TC_ADDCUSTOMISSUE addPopulator(\bean -> { var builder = new RuleCommandDefinitionBuilder() .withRule(bean as UWRule) .withOrderNumber(1) .withRuleActionKey(RuleActionKey.TC_ADDCUSTOMISSUE) for (name in _commandParams.Keys) { var param = _commandParams.get(name) switch (param.Second) { case formula: builder.addRuleCommandParameter(name, ExpressionFragmentBuilders.forCodeExpression(param.First)) break case template: builder.addRuleCommandParameter(name, ExpressionFragmentBuilders.forGosuTemplateExpression(param.First)) break default: throw new IllegalArgumentException("Illegal parameter mode: ${param.Second}}") } } builder.create(bean.Bundle) }) //exisiting code... }Notice also that the code increments the order number by 1 as well.
-
Find the constructor that begins with the following code:
-
Open class UWRulesPageHelper.
You need to modify class UWRulesPageHelper to include the new
TC_ADDCUSTOMISSUEtypecode.-
Search for static property
UIConfigs. -
Add the
TC_ADDCUSTOMISSUEtypecode.For example, add code similar to the following to this property.static property get UIConfigs(): Map<RuleActionKey, CommandDefinitionUIConfig> { return { RuleActionKey.TC_ADDUWISSUE->new AddUWIssueCommandDefinitionUIConfig(), RuleActionKey.TC_ADDCUSTOMISSUE->new AddUWIssueCommandDefinitionUIConfig() } }
-
Search for static property
