Create a JSON value resolver for the damageable
A value resolver is a class used in updaters to return the resource that a foreign key property points to. Within the context of a foreign key property:
- The root (or the root resource) is the resource that has the foreign key property.
- The resolved value is the resource that the foreign key points to.
For general information on value resolvers, see Adding foreign keys.
In the "damageable" data model design, the incident entity has a foreign key to the damageable entity. Therefore, the incident updater has a foreign key property that uses a value resolver whose resolved value is the damageable.
For custom entities, you must declare a custom value resolver. If the custom entity must
provide support for reference by policySystemId
, then the value
resolver must extend the PolicyDescendantJsonValueResolver
class.
Syntax for a custom risk unit value resolver
Guidewire recommends declaring the custom risk unit value resolver in the
gw.rest.ext.cc.claim.v1.claims.policy
package in a sub-package
whose name is the custom damageable.
package gw.rest.ext.cc.claim.v1.claims.policy.<customdamageable>
uses gw.rest.core.cc.claim.v1.claims.policy.PolicyDescendantJsonValueResolver
uses org.jetbrains.annotations.NotNull
class <CustomDamageable>JsonValueResolver extends
PolicyDescendantJsonValueResolver<<CustomDamageable>, Policy> {
@NotNull
protected override property get ResolvedValueType() :
Class<<CustomDamageable>> {
return <CustomDamageable>
}
@NotNull
protected override property get AncestorType() : Class<Policy> {
return Policy
}
protected override function getPossibleResolvedValues(ancestor : Policy) :
<CustomDamageable>[] {
return ancestor.RiskUnits.cast(<CustomRiskUnit>).map(\elt ->
elt?.<CustomDamageable>)
}
}
Example custom damageable value resolver
Towable_Ext
.package gw.rest.ext.cc.claim.v1.claims.policy.towableext
uses gw.rest.core.cc.claim.v1.claims.policy.PolicyDescendantJsonValueResolver
uses org.jetbrains.annotations.NotNull
class TowableExtJsonValueResolver extends
PolicyDescendantJsonValueResolver<Towable_Ext, Policy> {
@NotNull
protected override property get ResolvedValueType() :
Class<Towable_Ext> {
return Towable_Ext
}
@NotNull
protected override property get AncestorType() : Class<Policy> {
return Policy
}
protected override function getPossibleResolvedValues(ancestor : Policy) :
Towable_Ext[] {
return ancestor.RiskUnits.cast(TowableRU_Ext).map(\elt ->
elt?.Towable_Ext)
}
}