Configuring batch processes

Cloud API supports the ability to start batch processes. For information on how to use the /systemtools/v1/batch-processes/{batchProcessType}/start endpoint, see Batch processes.

Some batch processes let you specify arguments when you run the batch process. These arguments perform the function of input parameters, and they can change the way the batch process runs.

You can create custom batch processes which take arguments. If you want to be able to submit arguments to the /start endpoint, then some configuration of Cloud API is required. This topic describes this configuration.

Configuring Cloud API to support custom batch process arguments

InsuranceSuite applications do not have a uniform format for arguments for batch processes. Some batch processes may expect strings, while others may expect custom POJOs (Plain Old Java Objects). There is no general way for Cloud API to support batch process arguments for all batch process types. Therefore, if you have implemented a custom batch process that uses arguments and you want to start that batch process through Cloud API with arguments, you must configure Cloud API to handle the arguments.

This configuration requires two steps:

  • Adding a schema property to the BatchProcessArguments schema.
  • Adding handling code to the BatchProcessExtResource class to convert the payload into arguments

Configuring the BatchProcessArguments schema

The BatchProcessArguments schema defines the information that can be included as arguments with a call to the /systemtools/v1/batch-processes/{batchProcessType}/start endpoint. For more information on general schema configuration, see Endpoint architecture.

To configure a custom batch process for arguments, you must add a property to this schema.

  • The name of the property must be the same as the code of the BatchProcessType typecode, ignoring case. Guidewire recommends using all lowercase letters.
  • The type of this property depends on the underlying argument type that the batch process expects. Guidewire recommends that the property be an object with well-defined property names that describe what the arguments conceptually represent.

The schema extension must be declared in the systemtools_ext-1.0.schema.json schema file.

For example, suppose you created a custom batch process named GroupMetrics_Ext that calculates performance metrics for every group based on work assigned to users in the group. It takes an optional argument of a single group name, specified as a string. To implement this argument, the systemtools_ext-1.0.schema.json schema file would include the following:
  "definitions": {
    "BatchProcessArguments": {
      "properties": {
        "groupmetrics_ext": {
          "title": "GroupMetrics_Ext",
          "description": "Arguments for the GroupMetrics_Ext batch process",
          "$ref": "#/definitions/GroupMetrics_ExtArguments"
        }
      }
    },
    "GroupMetrics_ExtArguments": {
      "title": "GroupMetrics_ExtArguments",
      "description": "Arguments for the GroupMetrics_Ext batch process",
      "type": "object",
      "properties": {
        "groupName": {
          "title": "GroupName",
          "description": "The name of the group to process",
          "type": "string"
      }
    }
  }

Configuring the BatchProcessExtResource class

The BatchProcessExtResource resource class is a Gosu file that defines required behaviors for working with batch process elements.

To configure a custom batch process for arguments, you must add handling code to the populateCustomBatchProcessArgumentsArray method in the BatchProcessExtResource resource class to convert the payload into arguments. Override the method (if it has not already been overridden) and add an if statement for this batch process type that inspects the JSON object, extracts the relevant data, and puts it into an array.

Following on from the previous example, suppose you are configuring the BatchProcessExtResource resource class to implement the GroupName argument for the GroupMetrics_Ext custom batch process. The populateCustomBatchProcessArgumentsArray method would look like this:
protected override function populateCustomBatchProcessArgumentsArray
                                    (json : JsonObject) : Serializable[] {
   var result : Serializable[]
   if (this.Element.getType() == BatchProcessType.TC_GroupMetrics_Ext) {
     result = {json.getString("groupName")}
   } else if ( /* other batch process type handling goes here */ ) {
     ...
   }
   return result
 }