Window mode API overview

To view objects across all effective time, you can view the policy objects (or a whole branch) in window mode. Typically you do this with a version list for an object. A version list represents all versions of that one object within one policy period. For example, a version list for a car represents all versions of that car during the entire policy period.

Important: For important overview information about window mode and version lists, see Slice mode and window mode overview.

In general, you get a version list from a revisioned object by getting its VersionList property. The result has the type specific to that object with the VersionList suffix, for example a Building version list has type BuildingVersionList. In the unusual case that you write general purpose code that operates on multiple revisioned entity types, declare variables as the base type EffDated or EffDatedBase. For those types, instead of getting the VersionList property, get the property VersionListUntyped.

If you have a version list, you can get various information about the object. For example, get all versions of the object, or navigate up or down the hierarchy to other entity instances or version lists.

The most important APIs on a version list are as follows. All results are in window mode unless otherwise noted.

  • The versionList.AllVersions property gets all versions of this object. All results are in window mode. The order in the list (the sort order) is the effective date for each version.
  • The versionList.asOf(date) method gets the one version of this object on that date, or null if none were effective on that date.
  • If an entity property contains an array of entity instances, Gosu generates two version list properties related to that original entity property:
    • Gosu generates a version list property whose name exactly matches the property name on the original object. It contains a list of all unique objects that are ever in that array at any effective time in the period. For example, a personal vehicle object contains its drivers in the vehicle.Drivers property. Thus, a vehicle’s version list also has a Drivers property. It contains a list that contains one version list for each unique driver for that vehicle. The items in this list have no defined order. Do not rely on the order.
    • Gosu generates a version list method whose name matches the property name on the original object but with the suffix AsOf. This method takes a date argument, which is an effective date. The AsOf method returns a snapshot of that array property as of that effective date. The AsOf method converts and returns the results to a list, which is typically easier to code with than arrays. For example, a personal vehicle object contains its drivers in the vehicle.Drivers property. Thus, a vehicle version list has a DriverAsOf(date) method. This method returns a list of that vehicle’s drivers on that date. The entities are returned in window mode. The items in this list have no defined order. Do not rely on the order.
    Note: Generated methods like DriverAsOf are a rare exemption to the normal Gosu coding rule that method names always begin with a lowercase character. PolicyCenter capitalizes the first character in this case to improve Gosu code readability because these methods mirror the original property names with an initial capital letter.

The following subtopics describe real-world tasks with a version list by using as an example a car (a PersonalVehicle) and its version list. For code examples, assume that the variable vehicleVL contains a version list for the car (vehicle.VersionList). There are three versions of this car in this period, each with a different color. The car’s version list represents exactly three versions of this car.

Get all versions of a particular car

To get all versions of this particular car in the policy period, use the following Gosu code:

var val = vehicleVL.AllVersions

If the car changed twice during the period, such as a color change, the result is a list with three entity instances. Each represents a different version of this car.

Get the car version that is effective at specified date in window mode

To determine which version of this car (if any) was effective at a specific effective date, and return it in window mode, use the following Gosu code:

var vehOnDate = vehicleVL.asOf(date)

The result is a single car object returned in window mode, or null if no version of the car is effective at that date.

Get the car version that is effective at specified date in slice mode

To get this car’s version that was effective at a specific effective date, and return it ready to make slice mode changes at that date, use the following Gosu code:

var vehSlicedOnDate = vehicleVL.asOf(date).getSlice(date)

The result is a single car object returned in slice mode, assuming a car is effective at that date. If no car is effective at that date, it throws a null pointer exception, since asOf returns null. Because the code calls the getSlice method of the result of asOf, that is a method invocation on a null value.

Note: For more information about null-safety of properties but not methods, see Property paths are null tolerant.

Get the set of all drivers who were ever drivers of this car

To get the list of all drivers who were ever drivers of this car during this period, use the following Gosu code:

var drivers = vehicleVL.Drivers

The result is a list. The list contains one version list for each unique driver of this particular car. Each version list represents a single driver. From each version list, you can get all entity instance versions of that unique driver by getting the version list’s AllVersions property.

Get the set of all drivers who were ever drivers of this car at specified date

To get the list of all drivers who were drivers at a specific date, use the following Gosu code:

var theDate = new Date() // a date object, in this case "today"
var drivers = vehicleVL.DriversAsOf(theDate)

The result is a list containing one or more VehicleDriver objects in window mode. Think of this as a snapshot of the entity array on that effective date, with all other entities hidden. The type of the result is java.util.List<VehicleDriver>.

Get the drivers of this car at specified date and return their contact public IDs

To get the list of all drivers who were drivers at a specific date, then get the public IDs for their contacts, use the following Gosu code:

var arrayOfPID = vehicleVL.DriversAsOf(date)*.PolicyDriver*.PublicID

The DriversAsOf method returns a list of VehicleDriver objects. Each one of those objects links to the actual contact for that driver through its vehicleDriver.PolicyDriver property. That is the object that contains the driver name and drivers license number. The Gosu array expansion operator *. extracts data from each item in an array or list, then returns results in a single-dimension array. Similarly, if you pass it a list, it return returns a list. For details, see List expansion (*.).