The generateBoDefs() method does not return the actual generated business object definitions. For Business Object Wizard to be able to access the generated content, the ODA class must implement the content-retrieval method for business object definitions. Business Object Wizard uses the information in the content-metadata object (which generateBoDefs() does return) to determine whether to call the appropriate content-retrieval method. If generateBoDefs() has successfully generated business objects, Business Object Wizard calls the getBoDefs() method to retrieve the generated business object definitions.
To provide access to generated business object definitions, the ODA class must implement the getBoDefs() method. This method is defined as part of the IGeneratesBoDefs interface. The method accepts as an argument an index, which identifies the number of business object definitions to return. It access these business object definitions in the generated-content structure and returns an array of the retrieved business-object-definition (BusObjDef) objects. The number of business object definitions in this array depends on the value of the index argument, as Table 44 shows.
Table 44. Retrieving business object definitions
For the sample Roman Army ODA, the generateBoDefs() method (defined in the ArmyAgent3 class) populates the m_generatedBOs vector with its generated business object definitions. Therefore, the getBoDefs() method (also defined in ArmyAgent3) retrieves the specified number of business object definitions from this vector and copies them into its return array. The following code shows the getBoDefs() method for the sample Roman Army ODA:
public BusObjDef[] getBoDefs(long index) throws ODKException { BusObjDef[] bos = null;
if (index == ODKConstant.GET_ALL_OBJECTS) { bos = new BusObjDef[m_generatedBOs.size()] System.arraycopy(m_generatedBOs.toArray(), 0, bos, 0, m_generatedBOs.size()); }
else bos = new BusObjDef[] {(BusObjDef)m_generatedBOs.get((int)index)};
return bos; }