This entry is part of the Maximo Java Development series.
Maximo Business Objects (MBOs) are a set of Java classes that implements the data persistence layer and business rules in Maximo/TPAE infrastructure. Those Java class files are stored in the [SMPDIR]\maximo\applications\maximo\businessobjects directory and are packaged in the businessobjects.jar file.
Roughly speaking there are two types of objects Mbo and MboSet.
- An Mbo represents a record in a table. It has business intelligence and persistence methods. It can be compared to a session/entity bean in J2EE.
- An MboSet is a collection of Mbo objects. It has methods to manipulate, iterate and query data.
To access data (Mbo) you first have to access the table (MboSet). The following example shows how to retrieve all the assets located in BEDFORD site.
MboSetRemote assetSet = getMboSet("ASSET");
assetSet.setWhere("LOCATION='BEDFORD'");
MboRemote asset=null;
for(int i=0; (asset=assetSet.getMbo(i))!=null; i++)
{
...
}
- The getMboSet method gets a reference the ASSET table.
- The setWhere method specifies the SQL where clause that must be applied to filter data. If the setWhere is not invoked, the entire table will be fetched.
- The getMbo method returns a specific element of the MboSet collection. The first invocation of getMbo method automatically fetches data and initialize the MboSet.
Now that you have an Mbo object it is possible to read field values using the getXxxx methods.
String assetnum = asset.getString("ASSETNUM");
int assetid = asset.getInt("ASSETID");
To modify the value of a field the setValue methods can be used.
asset.setValue("DESCRIPTION", "New description");
In the previous examples we have used the basic psdi.mbo.Mbo and psdi.mbo.MboSet classes. However many Maximo objects have a specific handler class that is specified in the Class field of the object definition in the Database Configuration application. For the ASSET object it is psdi.app.asset.AssetSet and it extends psdi.mbo.MboSet class. Associated to psdi.app.asset.AssetSet there is psdi.app.asset.Asset that extends psdi.mbo.Mbo class. Those two specialized classes provides specific methods and logic to manage assets.
The following code snippet shows how to fetch an asset from Maximo database and understand if it is a rotating asset or not using the isRotating() method.
AssetSetRemote assetSet = (AssetSetRemote)getMboSet("ASSET");
assetSet.setWhere("ASSETNUM='1000'");
AssetRemote asset = (AssetRemote)assetSet.getMbo(0);
System.out.println("Is rotating: " + asset.isRotating());
You have just walked the first step in the long journey of the Maximo/TPAE developer...
For more articles look at Maximo MBO Java Development page.
Labels: intermediate, java, mbo, tpae