Creating custom risk units

You can manage subtypes of risk units (which inherently must use Policy as a parent resource) with an endpoint. Generating custom risk units differs from standard the REST endpoint generator script behavior as well as its glue and impl file configuration.

Risk unit criteria

The REST endpoint generator can create a custom subtype for only risk units. This includes the following:
  • The EntityType must use subtype.
  • The entity must use RiskUnit as its subtype.
  • The entity must use Policy or a descendant of Policy as its parent, regardless of how distant the ancestor. Endpoints that use Policy or descendant of policy employ the following ClaimCenter-specific behavior and configuration.

REST endpoint generator variances for custom risk units

The following section details the abbreviated REST endpoint generator prompts when creating custom risk units.

After the first prompt for entering your risk unit entity name ( Which data model entity would you like to generate endpoints for?), the REST endpoint generator already understands the following:

  • Risk units inherently belong on the Claim API.
  • Policy entities always use the claim integration graph

Therefore, the REST endpoint generator does not prompt for the API name, if the entity is at the root of the path, or if the endpoint belongs to an integration graph.

Note: Inputting anything other than Policy or a descendant of Policy as a Parent resource presents an error during the script.

Configuring variances for glue and impl classes for risk units

Policy endpoints create and change the same series of files as standard endpoints but vary in logic for how the endpoint interacts with the application.

Risk units create and change the same series of files as standard endpoints but vary in logic for how the endpoint interacts with the application.

  • The risk unit schema, mapper, and updater files generate additional attributes of RUNumber, Description, and PolicySystemId. These attributes match the default schema for risk unit entities.
  • The risk unit schema, mapper, and updater files can include custom inline damageables for the policy coverage. See Inline damageable for details.
  • The modified apiconfig file generates extra entities for the verified and unverified policy resources.
  • The modified apiconfig file for the Risk unit collection resource includes a default ascending sort by RUNumber:
UnverifiedCRiskUnits2Ext:
  resource: gw.rest.ext.cc.claim.v1.claims.policy.criskunit2ext.UnverifiedCRiskUnits2ExtResource
  mapper: CRiskUnit2Ext
  updater: CRiskUnit2Ext
  defaultSort:
  - RUNumber

The default sort can be modified or added to as other endpoints.

  • There are four “impl” files that define implementation details for the verified and unverified Risk unit resources.
    • Two <collection>Resource.gs file Gosu files that defines required behaviors for working with collections for verified and unverified policy resources. For example:
      • <collectionResource>Resource.gs
      • Unverified<collectionResource>Resource.gs
    • Two <element>Resource.gs file Gosu files that define required behaviors for working with elements for verified and unverified policy resource. For example:
      • <elementResource>Resource.gs
      • Unverified<elementResource>Resource.gs

See respective sections below for variances and coding details.

Configuring variances for risk unit resource files

Risk unit endpoint impl files for verified and unverified policies variances are as follows:

Verified and unverified resource files

  • Verified and unverified risk unit element and collection resources do not include delete methods. You cannot delete verified risk units or child objects of a Risk unit on verified policies, and Guidewire does not offer deletion of unverified risk units at this time.

Verified resource files

  • Verified element resources do not include CanViewException as it inherently returns null.
  • Verified collection resources do not include CanViewException as it inherently returns null.

Unverified resource files

  • Unverified element resource files generate an additional operation finishCreate(data,batchUpdateMap) to reserve Ids for additional beans created by the Policy resource.
  • Unverified element resources do not include CanViewException, CanEditExcpetion, and CanDeleteException methods as they inherently return null.
  • Unverified collection resources do not include CanViewException and CanCreateException as it inherently returns null.
  • Unverified risk unit collection resource files generate an additional property getter get Policy(): Policy to connect the path from policy descendants to the Policy resource.
  • Unverified Risk unit collection resource generates the createMinimalChildElement. However, if the risk unit does not directly descend from Policy, you must set the parent foreign key to be set to the earliest parent (such as for using Policy as the immediate parent resource riskUnit.{{ChildOfPolicyFK}} = this.Parent.Element).

The policy getter

In the Unverified<collectionResource>Resource.gs file, the policy getter connects the path from the policy descendant to the policy.

For example, if your endpoint has a foreign key to of Grandchild_Ext, which then has a foreign key Child_Ext, to which has a foreign key to Policy with this.Parent.Element.Policy.

The following code illustrates this:

  private property get Policy() : Policy {
  return this.Parent.Element.Policy
  }
}

The finishCreate operation

In the Unverified<elementResource>Resource.gs ,the finishCreate operation reserves Ids for any additional objects resulting from the creation of the Policy endpoint.

Creating an unverified policy requires composite requests to execute subsrequests for claim and policy creation. Composite request reserve Id values so that these Ids can be provided in subresponses and committed to the database. For example, a subrequest of POST /claims returns a response for with a reserved Id.

However, the composite API does not reserve Ids for inline objects create in composite response payloads. For example, the framework API assigns an Id for the /unverified-policies/policyId/vehicleRiskUnits endpoint, but not the inline child object vehicle. Subrequests rely on the finishCreate operation to reserve Ids for an inline object.

If the updater or schema files for your risk unit endpoint contain custom inline objects of which you want to reserve an Id, implement the finishCreate operation.

For example, your risk unit schema or mapper contains the inline object framing, and you want to reserve an Id from the framing object in response payloads.

The following code illustrates this:

override function finishCreate(data : DataEnvelope, batchUpdateMap : BatchUpdateMap) {
  super.finishCreate(data, batchUpdateMap)
  var riskUnit = this.Element
  reserveIdsIfNecessary({riskUnit.framing})
}

Inline damageables

In the same way VehicleRiskUnits schema uses Vehicle as an inline variable to determine a damageable, you can associate the risk unit with a custom entity to represent the covered risk unit damageable.

Guidewire recommends extending the custom damageable entity to determine whether it belongs to the policy. Guidewire also recommends including on the entity a policySystemId attribute to populate when integrating with the PAS. See examples below.

Inline damageables in the schema file

The properties object defines values generated by the generator and customer specific values found on the custom policy risk unit. policyCustomDamageable provides other customer specific-values found on the custom damageable.

The following code illustrates inline damageables in the schema file:

claim_ext-1.0.schema.json
  "CustomPolicyEntityExt": {
    "title": "Custom policy entity ext",
    "description": "Custom policy entity ext"
    "type": "object",
    "properties": {
      "customDamageable_Ext": {
        "title": "Custom damageable",
        "description": "The custom Damageable that is covered",
        "$ref": "#/definitions/custom Damageable"
      }
    }
  }
  ...
"customDamageableExt": {
    "title": "customdamageableext",
    "description": "Custom damageable ext",
    "type": "object",
    "properties": {
      "displayName": {
        "title": "Display name",
        "description": "The formatted name of this custom damageable",
        "type": "string",
        "readOnly": true
      },
      "id": {
        "title": "ID",
        "description": "The unique identifier of this element",
        "type": "string"
      },
      "policyCustomDamageable": {
        "title": "Policy custom damageable",
        "description": "A `true` value indicates that this custom damageable is part of 
         the claim's policy and cannot be edited directly",
        "type": "boolean",
        "readOnly": true
      },
      "policySystemId": {
        "title": "Policy system ID",
        "description": "The unique identifier of this element within the policy system",
        "type": "string"
      },
    }
  },

Inline damageables in the mapping file

The properties object defines values generated by the generator and customer specific values found on the custom policy risk unit. policyCustomDamageable supplies other customer specific-values found on the custom damageable.

The following code illustrates inline damageables in the mapping file:

claim_ext-1.0.mapping.json
"CustomPolicyEntityExt": {
    "schemaDefinition": "CustomPolicyEntityExt",
    "root": "entity.CustomPolicyEntity_Ext",
    "properties": {        
      "fooBar_Ext": {
        "path": "FooBarRiskUnit_Ext.FooBar_Ext",
        "mapper": "#/mappers/FooBarExt"
      }
    }
  }
  ...
  "customDamageableExt": {
    "schemaDefinition": "Custom damageable ext",
    "root": "entity.customDamageable_Ext",
    "properties": {
      "displayName": {
        "path": "CustomDamageable_Ext.RestV1_SafeDisplayName"
      },
      "id": {
        "path": " customDamageable_Ext.RestId"
      },
      "policyCustomDamageable": {
        "path": "customDamageable_Ext.PolicyCustomDamageable_Ext"
      },
      "policySystemId": {
        "path": "customDamageable_Ext.PolicySystemId"
      },
    }
  },

Inline damageables in the updater file

The properties object defines values generated by the generator and customer specific values found on the custom policy risk unit. policyCustomDamageable supplies other customer specific-values found on the custom damageable.

The following code illustrates inline damageables in the updater file:

claim_ext-1.0.updater.json
  "CustomPolicyEntityExt": {
    "schemaDefinition": "CustomPolicyEntityExt",
    "root": "entity.CustomPolicyEntity_Ext",
    "properties": {         
      "CustomDamageable_Ext ": {
        "path": "customPolicyEntity_Ext.PolicyCustomDamageable_Ext ",
        "create": "{var fooBar = new Policy CustomDamageable_Ext (CustomDamageable_Ext); customDamageable. 
        policyCustomDamageable_Ext = true; return CustomDamageable}",
        "updaterRef": "#/updaters/customDamageableExt
      }
    }
  },
  ...
  "CustomDamageableExt": {
    "schemaDefinition": "CustomDamageableExt ",
    "root": "entity. CustomDamageable_Ext ",
    "properties": {
    }
  },