Add new rule action

Implement the following steps to add an additional action to an existing base configuration rule.

About this task

By default, PolicyCenter shows only a single action for each underwriting rule. This procedure outlines how to modify PolicyCenter to support multiple actions within PolicyCenter business rules.

Procedure

  1. Open PolicyCenter Studio and navigate to the following location in the Studio Project window:
    • config > Extensions > Typelist
  2. Create a RuleActionKey typelist extension, if one does not exist.
    1. Add the following typecode to the typelist extension.
      code AddCustomIssue
      name AddCustomIssue
      desc Create a custom issue
    2. Manually add an UWRule category 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> 
  3. In the Studio Project window, navigate to gsrc and create a package to hold your work.
  4. 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.
  5. Open the implementation class for the IBizRulesPlugin plugin.
    You need to register your new AddCustomizedRuleAction class in the plugin implementation code.
    1. Find the RuleActions property, which, in the base configuration looks similar to the following code:
      override property get RuleActions() : Set<IRuleAction> {
        return {
          new AddUWIssueRuleAction()
        }
      } 
    2. 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.

  6. Open class UWRuleBuilder.
    1. Find the constructor that begins with the following code:
      construct (excludeHead :  boolean) {
        ...
      }
    2. 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.

  7. Open class UWRulesPageHelper.
    You need to modify class UWRulesPageHelper to include the new TC_ADDCUSTOMISSUE typecode.
    1. Search for static property UIConfigs.
    2. Add the TC_ADDCUSTOMISSUE typecode.
      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()
        }
      }

What to do next

To actually view multiple rule actions in PolicyCenter, you also need to modify PCF file UWRuleDetail.pcf to use RuleCommandDefinitionsListDetailView.pcf instead of UWIssueCommandDefinitionDV.pcf.