Fixed ID keys link a cost data object to another object

Each cost data object contains cost-related properties defined by its corresponding cost entity. For example, the PersonalAutoTaxCostData class has equivalent properties for each cost-related property of the PersonalAutoTaxCost entity.

A cost data object might contain the following types of properties.

  • Properties in common to all costs in the line
  • Properties unique to a specific cost entity

Generally speaking, cost properties that are in a cost object also exist also in the corresponding cost data class. For example, PersonalAutoTaxCost properties are on the PersonalAutoTaxCostData class.

There is an important difference between costs and cost data objects you must be aware of. In normal entities, links to entities typically take the form of real foreign key links in memory to other entities. For example, the property PACost.Coverage links to a coverage.

In contrast, CostData classes link to other objects using the fixed ID of any entity it references. The fixed ID is a unique identifier that identifies one object across effective time and also across multiple revisions.

In the database column itself, a fixed ID is just a numeric value. PolicyCenter encapsulates the fixed ID numeric value and the entity type for the object into a Key object. Think of the Key object as a simple container for foreign keys. In the context of rating, a fixed ID Key object is the most important usage of the Key class.

This difference in handling links simplifies rating code, particularly with external rating engines. You can easily send entity links as fixed IDs and the entity type to an external system. With results from the external system, you can assemble cost data objects from that information. Let the default rating engine merge related cost data objects and handle the complex revisioning code to create and update the actual Cost entities.

As you design your cost data object, add any line-specific properties that the equivalent cost object contains. Declare these as private properties whose names begin with an underscore. However, remember to declare properties that link to an entity instance as the data type Key. For example, the PersonalVehicleCovCostData class declares a link to the coverage as a private variable of type Key.

class PersonalVehicleCovCostData extends PACostData<PersonalVehicleCovCost> {
  var _covID : Key

//...

}

To get the fixed ID Key object from an entity, simply access its FixedID property.

var fixedIDKey = myPersonalVehicleCov.FixedID

You can convert a fixed ID Key object to a standard direct link using the cost object method setFieldValue. Typical code uses this method to implement the cost data object method setSpecificFieldsOnCost, which copies line-specific (non-core) properties to the cost entity instance.

A critical difference between cost entity instances and cost data objects is how they treat links to other objects. Cost data objects store a fixed ID Key, which encapsulates a numeric fixed ID value and the entity type of the object. Other Gosu code in PolicyCenter use a Key object to track other types of foreign keys, but in rating-related code a Key typically contains a fixed ID.