Support form multiplicity

You use a subtype of FormAssociation and an inference class that extends AbstractMultipleCopiesForm to provide form multiplicity on a policy.

Procedure

  1. In the data model, create a subtype of FormAssociation.
    For a personal auto form associated with single personal vehicle, create a new subtype of FormAssociation called PAVehicleFormAssociation.
  2. On that entity, add property with a foreign key link to the desired type, such as a personal vehicle.
    Suppose the property is called Vehicle.
  3. In your inference class, extend the AbstractMultipleCopiesForm class instead of the extending the FormData class. This class uses Gosu generics features to abstract this class for your linked-to type.
    Use the following syntax to define the inference class.
    class MyPAVehicleForm extends AbstractMultipleCopiesForm<PersonalVehicle>
  4. To support form multiplicity, add the getEntities method to your inference class. This method must return a list containing one or more entities of your desired type. If there is more than one entity returned, PolicyCenter knows that there are multiple instances of the form, each linked to one of the items in this list.
    getEntities returns a list of all personal vehicles on the policy.
    Do not implement the populateInferenceData method. That method is used only if you do not use form multiplicity.
  5. Add to your inference class the FormAssociationPropertyName method, which returns the name of the property in your FormAssociation subtype, as a String.
    Pass the String value "Vehicle" because the property name is Vehicle.
  6. In your inference class XML generation method addDataForComparisonOrExport, export the data for only one entity in your generated list of entities. Your code refers to the current entity by using the private variable called _entity, which is set up by the AbstractMultipleCopiesForm.
    The _entity variable contains one PersonalVehicle from the list returned in your getEntities method. Your addDataForComparisonOrExport would add child XML nodes for that vehicle only.
  7. In your inference class, create the createFormAssociation method to instantiate one version of your form association subtype.

    This method can use simple code, such as the following example.

    override protected function createFormAssociation( form : Form) : FormAssociation {
      return new PAVehicleFormAssociation(form.Branch)
    }

What to do next

In your messaging code, you must access Form.FormAssociations to get form associations that link to the associated entity.