Externalizable Business Objects 1-to-1 References

Introduction

This page describes how to create 1-to-1 relationships to externalizable business objects. In the example used on this page, the Account business object (the parent object) (in the COA module) has a 1-to-1 relationship with the Cfda business object (the child object) (in the CG module).

Define the EBO interface, implementation

(see parent page)

Configure module service

(see parent page)

Define a data dictionary-based relationship

A DD-based relationship will need to be defined, similar to UniversalUser relationships.

In Account.xml
    <property name="relationships" >
      <list>
        <dd:relationship objectAttribute="cfda">
            <dd:primitiveAttribute source="accountCfdaNumber" target="cfdaNumber" />
        </dd:relationship>
      </list>
    </property>

The above <dd:relationship> tag defines a foreign-key like relationship between the Account BO and the "cfda" reference object.

Define getter methods in the parent table to retrieve the child object

The getter method will return an instance of the ExternalizableBusinessObject sub-interface. For our example, the method will return an instance of ContractsAndGrantsCfda.

public class Account extends PersistableBusinessObjectBase implements AccountIntf, Inactivateable {
    private ContractsAndGrantsCfda cfda;

    public ContractsAndGrantsCfda getCfda() {
        return cfda = (ContractsAndGrantsCfda)SpringContext.getBean(KualiModuleService.class)
                    .getResponsibleModuleService(ContractsAndGrantsCfda.class)
                    .retrieveExternalizableBusinessObjectIfNecessary(this, cfda, "cfda");
    }
}

This method will use the responsible module service to retrieve the externalizable business objects. However, if the primary key values of the child table match the foreign key values of the parent table, then the reference does not need to be re-retrieved since we know we already have the right record.

Use business object attribute metadata from the child record in the parent business business object data dictionary file

The data dictionary allows for the dynamic generation of BusinessObjectEntry objects for externalizable business objects. A new data dictionary bean has been added to support the dynamic referencing of such dynamically generated data dictionary metadata.

In Account.xml
  <bean id="Account-accountCfdaNumber" parent="Account-accountCfdaNumber-parentBean" />

  <bean id="Account-accountCfdaNumber-parentBean" abstract="true" parent="ExternalizableAttributeDefinitionProxy"
  	p:sourceExternalizableBusinessObjectInterface="org.kuali.kfs.integration.businessobject.cg.ContractsAndGrantsCfda"
	p:sourceAttributeName="cfdaNumber"> 
	<property name="name" value="accountCfdaNumber"></property>
    <property name="label" value="Catalog of Federal Domestic Assistance Number" /> 
    <property name="shortLabel" value="FedDomAssisNum" /> 
    <property name="required" value="false" />
  </bean>

In the Account-accountCfdaNumber-parentBean bean definition, we are declaring that the metadata for this attribute will be the same as the attribute metadata for the ContractsAndGrantsCfda class's "cfdaNumber" attribute.