Jumat, 25 April 2014

Extending Maximo Business Objects

This entry is part of the Maximo Java Development series.

Sometimes it is necessary to override or extend the functionality in Maximo. This can be achieved by extending methods in the Maximo Business Objects.
This article outlines the process involved in extending the out-of-the-box psdi.app.item.Item class to initialize the description field to a specific value.

Create Java Classes
We will need to create two new files an Mbo and an MboSet. The cust.psdi.app.item.Item will extend the add() method in the psdi.app.item.Item class. It is a good common practice to use a well defined 1st level package name like 'cust' to group all the custom code.
Now open Eclipse and create a new Java class named cust.psdi.app.item.Item and paste the following code.
package cust.psdi.app.item;

import java.rmi.RemoteException;
import psdi.mbo.*;
import psdi.util.*;

public class Item extends psdi.app.item.Item implements psdi.app.item.ItemRemote
{
public Item(MboSet ms) throws MXException, RemoteException
{
super(ms);
}

public void add() throws MXException, RemoteException
{
setValue("description", "TEST");
super.add();
}
}
Note how we have overridden the add() method of the psdi.app.item.Item class to insert the initialization of the description field.
Every time you override a Maximo method remember to call the super() method to preserve any preexisting behavior.

The ItemSet class does not contain any logic. It simply returns the reference of our new object.
package cust.psdi.app.item;

import java.rmi.RemoteException;
import psdi.mbo.*;
import psdi.util.*;

public class ItemSet extends psdi.app.item.ItemSet implements psdi.app.item.ItemSetRemote
{
public ItemSet(MboServerInterface ms) throws MXException, RemoteException
{
super(ms);
}

protected Mbo getMboInstance(MboSet ms) throws MXException, RemoteException
{
return new Item(ms);
}
}

Deploy Maximo EAR
After having compiled the two Java classes (should be done automatically by Eclipse), go in bin\cust\psdi\app\item folder and copy those two .class files into [SMPDIR]\maximo\applications\maximo\businessobjects\classes\cust\psdi\app\item.
Now rebuild the Maximo EAR file, redeploy it and restart your server (or use this fast method).

Update database
Now we have to tell Maximo to use the new classes. Open the Database Configuration application, select the ITEM object and put cust.psdi.app.item.ItemSet into the Class field.


Test
Launch Maximo and open the Item Master application. When the application launches, select insert from the toolbar. You will notice that the application will insert a new record with the description field defaulting to the value 'TEST'.


Source:http://maximodev.blogspot.com/2012/05/maximo-extend-java-mbo.html

Tidak ada komentar:

Posting Komentar