Providing access to generated business object definitions

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.

Note:
In this release, Business Object Wizard always calls the generateBoDefs() method to initiate generation of business object definitions because the ODA must support the on-request content protocol. The ODA should not support the callback content protocol for generation of business object definitions. For more information on content protocols, see Choosing the ODA content protocol.

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

Value of index Description Number of elements in array that getBoDefs() returns
In the range 0 to count - 1, where count is the total number of business object definitions in the generated-content structure Specifies the index position into the generated-content structure of the business object definition to retrieve One business object definition

 ODKConstant.GET_ALL_OBJECTS
 
Special constant to indicate the return of all business object definitions in the generated-content structure All business object definitions in the generated-content structure (count)

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;
 } 
 

Copyright IBM Corp. 1997, 2003