Subtype mapping associative arrays
Use subtype mapping to access array elements based on their subtype. This type of associative array divides the elements of the array into multiple partitions. Each of these partitions contains array elements of only a particular object subtype.
JobTypes on the Policy object. In the
Policy definition file (), you can add the <array> element from the
following example XML:
<entity xmlns="http://guidewire.com/datamodel"
entity="Policy"
table="policy"
type="retireable">
...
<array arrayentity="Job"
desc="Types of jobs pertaining to a policy."
exportable="false"
ignoreforevents="true"
name="JobTypes">
<link-association>
<subtype-map/>
</link-association>
</array>
...
</entity>
The JobTypes array contains a number of objects. Each of these objects
is a subtype of a Job object. The data model defines the associative
array using the <link-association> element. A link association
returns at most one element. The return type is an object of the type of the array. In
this case, the return type is an object of type Job or, more
specifically, one of its subtypes.AuditCancellationIssuancePolicyChange- Reinstatement
- Renewal
- Rewrite
- RewriteNewAccount
- Submission
To determine the complete list of subtypes on an object, consult the PolicyCenter Data Dictionary. The dictionary organizes the subtypes into a table at the top of the dictionary page with active links to sections that describe each subtype in greater detail.
Working with array values by using subtype mapping
To retrieve an array value through subtype mapping, use the following syntax:
base-entity.subtype-map.propertyEach field has the following meanings:
Field |
Description |
|---|---|
|
The base object on which the associative array exists. For example, consider the
Claim entity for the
|
|
The array entity subtype,
for example, |
|
A field or property on the array object. For example, the AllEscalatedActivitiesClaimMetric object contains the following properties (among others):
|
The following table lists the attributes associated with the
<subtype-map> element.
|
Description |
Default |
|---|---|---|
|
Internal. Do not use. | None |
|
Optional attribute that specifies a prefix for every property that an array association generates. This attribute is useful when you have two or more array associations with overlapping keys. For example, suppose that you have two array associations that both have a subtype map on the same field. In this case, you need to use the propertyPrefix attribute on at least one of the subtype maps. Providing a value for the attribute avoids the two array associations having the same set of property names. | None |
Example 1
The following example code uses the sample data in the Guidewire ClaimCenter base configuration. It first retrieves a specific claim object using a query builder and then uses that object as the base entity from which to retrieve array member properties.
uses gw.transaction.Transaction
uses gw.api.database.Query
var clm = gw.api.database.Query.make(Claim).compare("Claim#ClaimNumber", Equals,
"235-53-365870").select().getAtMostOneRow()
print("AllEscalatedActivitiesClaimMetric\tClaim Metric Category = "
+ clm.AllEscalatedActivitiesClaimMetric.ClaimMetricCategory.DisplayName)
print("AllEscalatedActivitiesClaimMetric\tDisplay Value = "
+ clm.AllEscalatedActivitiesClaimMetric.DisplayValue)
print("AllEscalatedActivitiesClaimMetric\tReach Yellow Time = "
+ clm.AllEscalatedActivitiesClaimMetric.ReachYellowTime)
The output of running this code in the Gosu Scratchpad looks similar to the following:
AllEscalatedActivitiesClaimMetric Claim Metric Category = Claim Activity
AllEscalatedActivitiesClaimMetric Display Value = 0
AllEscalatedActivitiesClaimMetric Reach Yellow Time = nullExample 2
The following sample code:
- Retrieves a read-only claim object.
- Adds the claim object to transaction bundle to make it writable.
- Sets a specific property on the AllEscalatedActivitiesClaimMetric object (a subtype of the ClaimMetric object) associated with the claim.
In the definition of the claim object, ClaimCenter associates an array of
ClaimMetric objects—the ClaimMetrics
array—with the Claim object. The metadata definition file also
defines the ClaimMetrics array as being of type
<link-association> using subtypes. Thus, you can access
array member properties by first accessing the array member of the proper
subtype.
uses gw.api.database.Query
uses gw.transaction.Transaction
var todaysDate = java.util.Date.CurrentDate
var clm = gw.api.database.Query.make(Claim).compare(Claim#ClaimNumber, Equals,
"235-53-365870").select().AtMostOneRow
//Query result is read-only, need to get current bundle and add object to bundle
Transaction.runWithNewBundle(\bundle -> {
if (clm != null) {
clm = bundle.add(clm)
print("AllEscalatedActivitiesClaimMetric\tReach Yellow Time = "
+ clm.AllEscalatedActivitiesClaimMetric.ReachYellowTime)
clm.AllEscalatedActivitiesClaimMetric.ReachYellowTime = todaysDate
print("\nAfter modifying the ReachYellowTime value...\n")
print("AllEscalatedActivitiesClaimMetric\tReach Yellow Time = "
+ clm.AllEscalatedActivitiesClaimMetric.ReachYellowTime)
}
}, "su")
The output of running this code in the Gosu Scratchpad looks similar to the following:
AllEscalatedActivitiesClaimMetric Reach Yellow Time = null
After modifying the ReachYellowTime value...
AllEscalatedActivitiesClaimMetric Reach Yellow Time = 2018-03-08
See also
