May 26, 2012

Understanding Mbos and MboSets

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.

15 comments:

  1. Really healpful for people who were starting there career in maximo

    ReplyDelete
  2. Hi Bruno,

    I need to compare two fields ( both belongs to the different object in db2 ) and out of which one field belongs to the incident object and second belongs to the different object and if it's equal then we need to set some value ? What will be the best way to achieve this task ? Is it possible through the Java codes ?

    Thanks in Advance

    ReplyDelete
    Replies
    1. Yes, it is feasible with Java. Look at his post: http://maximodev.blogspot.com/2012/09/navigate-object-relationship-in-mbo-code.html

      I think it can also be done with some scripting if you are on 7.5.

      Delete
    2. Thanks Bruno...:) It seems script will not work for us. we are using TSRM 7.2.1 . You made all the thing very easy for the beginners...:) Super Awesome..:)

      Delete
  3. Excellent article. Simple and well written. Thanks a lot.

    ReplyDelete
  4. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    rpa training in bangalore
    best rpa training in bangalore
    RPA training in bangalore
    rpa course in bangalore
    rpa training in chennai
    rpa online training

    ReplyDelete
  5. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's. 
    best rpa training in bangalore
    rpa training in bangalore | rpa course in bangalore
    RPA training in bangalore
    rpa training in chennai
    rpa online training

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
    AWS Course Interview Questions and Answers for Freshers | AWS Interviews Questions and Answers for Devops
    AWS Tutorial – Besant Technologies
    AWS Interview questions and answers for Sysops |AWS Interview Question and Answers BlogSpot
    AWS Tutorial For Beginners | AWS Tutorial with AWS Training Videos

    ReplyDelete
  8. Thanks for the good words! Really appreciated. Great post. I’ve been commenting a lot on a few blogs recently, but I hadn’t thought about my approach until you brought it up. 
    Python training in bangalore
    Python course in pune
    Python training in bangalore

    ReplyDelete
  9. Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
    Really very nice blog information for this one and more technical skills are improve,i like that kind of post.

    ReplyDelete
  10. Awesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.
    AWS Training in Bangalore
    AWS training in sholinganallur
    AWS training in Tambaram
    AWS training in Velachery

    ReplyDelete
  11. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging.
    AWS Training in Bangalore

    AWS Training in pune

    ReplyDelete