Special handling in ContactMapper for core applications
In some cases, it is not possible to use ContactMapper code to handle the transfer of contact data. In those cases, the core application uses methods that handle more complex cases, like related contacts and addresses.
Special handling in one direction
Address handling is an example of special handling of data sent from ContactManager. Addresses sent from ContactManager require special handling in core applications to support scenarios like swapping a primary address for a secondary address. Turning address data into XML does not require any special handling, so addresses being sent to ContactManager use the normal ContactMapper code. For these reasons, the following foreign key and array references are defined as one-way, from the core application to ContactManager:
fkMapping(Contact#PrimaryAddress)
.withMappingDirection(TO_XML),
arrayMapping(Contact#ContactAddresses)
.withMappingDirection(TO_XML),
When a change to a primary or secondary address for
a contact comes in from a core application, the core application calls
populateAddresses instead
of the regular mapping code. The method is defined in ContactIntegrationXMLMapperAppBase.
This method call is explicit in ClaimCenter:
arrayMapping(Contact#ContactAddresses)
.withMappingDirection(TO_BEAN)
.withArrayBeanBlock( \ am, bp ->
populateAddresses(bp.Bean as Contact, bp.XmlBackedInstance)),
PolicyCenter and BillingCenter also call populateAddresses for incoming
addresses, but the method call is not explicit in ContactMapper.
While the address foreign key and address array reference require special handling, the fields of an address do not. You can add or delete address fields as needed by using the fieldMapping method.
Special handling in both directions
In ClaimCenter, related contacts use a parameter of the withMappingDirection method not discussed so far:
.withMappingDirection(BOTH)
You can use this method to specify one behavior for a field when it is sent to ContactManager and another behavior when the field is received from ContactManager. For example:
fkMapping(ContactContact#RelatedContact)
.withMappingDirection(BOTH)
.withABName("RelABContact")
.withEntityXMLBlock( \ lm, xp -> populateContactXmlForRelatedContact(lm, xp))
.withEntityBeanBlock( \ lm, bp -> populateBeanFromXml(bp)),