Obtaining configuration properties

To begin ODA initialization, Business Object Wizard calls the getAgentProperties() method of the ODA class. The getAgentProperties() method is part of the low-level ODA base class, ODKAgentBase. It is inherited by the ODA base class, ODKAgentBase2, then inherited in turn by your ODA class.

Important:
As part of the implementation of your ODA class, you must implement an getAgentProperties() method.

The getAgentProperties() method performs the following tasks:

Obtaining the handle to the ODKUtility object

Because getAgentProperties() is the first ODA method that Business Object Wizard calls, it is a good place to instantiate the ODKUtility object, which provides the ODA code with access to the following:

To obtain access to an ODKUtility object, use the getODKUtility() method. This method, defined in the ODKUtility class, returns a handle to the ODKUtility object.

odkUtil = ODKUtility.getODKUtility()
 

If you declare the handle to the ODKUtility object as global to the entire ODA class, all methods within this class can access the utility methods.

Note:
Instead of instantiating the ODKUtility object in its getAgentProperties() method, the sample Roman Army ODA provides a member variable named m_utility in its ODA class and initializes it as follows:
final ODKUtility m_utility = ODKUtility.getODKUtility();
 

Initializing the configuration-property array

As Obtaining ODA configuration properties describes, Business Object Wizard uses the configuration-property array that getAgentProperties() returns to initialize the Configure Agent dialog box (Step 2). This dialog box displays all ODA configuration properties and allows users to enter or change their values. The configuration-property array is an array of AgentProperty objects. The AgentProperty class provides support for the configuration property to have the following features:

Note:
For more information, see Working with agent properties.

The purpose of getAgentProperties() is to send to Business Object Wizard an array of AgentProperty objects that describe the ODA configuration properties. To initialize the configuration-property array in getAgentProperties(), take the following steps:

  1. Instantiate an AgentProperty object for a configuration property, initializing it with the appropriate property information.

    The implementation of the getAgentProperties() method must instantiate agent-property objects for each configuration property that the Business Object Wizard is to display to users. When you instantiate the agent-property object, you initialize some or all of its member variables (shown in Table 49).

  2. Store the initialized AgentProperty object in the configuration-property array.
  3. Return the initialized configuration-property array from the getAgentProperties() method.

Figure 55 shows the implementation of the getAgentProperties() method (defined in the ArmyAgent2 class of the sample Roman Army ODA).

Figure 55. Initializing the configuration-property array

public AgentProperties[] getAgentProperties()
    throws com.crossworlds.ODK.ODKException
 {
    AgentProperty general = new AgentProperty("Army general", 
       AgentProperty.TYPE_STRING, true, false, false,
       "A general is a soldier at least 45 years old", true,
       ODKConstant.SINGLE_CARD, m_generals.toArray(), null);
 
   AgentProperty recAdop = new AgentProperty("Allow adoption", 
       AgentProperty.TYPE_BOOLEAN, true, false, false,
       "Select \"yes\" if adopted children can be business objects", true,
       ODKConstant.SINGLE_CARD, new Object[]{"true", "false"}, null);
 
   AgentProperty minAge = new AgentProperty("Minimum age for drafting", 
       AgentProperty.TYPE_INTEGER, true, false, false,
       "Drafted soldiers will be generable nodes", false,
       ODKConstant.SINGLE_CARD, null, new Object[] {"15"});
 
   AgentProperty maxAge = new AgentProperty("Maximum age for drafting", 
       AgentProperty.TYPE_INTEGER, true, false, false,
       "Drafted soldiers will be generable nodes", false,
       ODKConstant.SINGLE_CARD, null, new Object[] {"55"});
 
   AgentProperty minAdo = new AgentProperty("Minimum age for adopting", 
       AgentProperty.TYPE_INTEGER, true, false, true,
       "Drafted soldiers will be generable nodes", false,
       ODKConstant.SINGLE_CARD, null, new Object[] {"" + m_minAdoptionAge});
 
   AgentProperty[] props = new AgentProperty[]
       {general, minAge, maxAge, recAdop, minAdo});
 
   return props;
 }
 

Figure 55 initializes the five ODA configuration properties for the sample Roman Army ODA. The actual properties you define depend on the specific data source your ODA is accessing.

After values are specified for the configuration properties, Business Object Wizard saves these properties in the memory of the ODA runtime. The ODA can access these properties through methods such as the getAgentProperty() method in the ODKUtility class. For more information, see Retrieving ODA configuration properties.

Copyright IBM Corp. 1997, 2004