Custom Java Class for Roles

This entry is part of the Maximo Java Development series.

This is just an example of a Maximo role defined with a custom Java class. In this example I have defined a role that can be used to send emails (Communication Template) to the workorder’s supervisor or to the owner group if the supervisor is not set.

This is the definition of the role.

And this is the Java code.

package cust.psdi.workflow;

import java.rmi.RemoteException;

import psdi.common.role.CustomRoleAdapter;
import psdi.common.role.CustomRoleInterface;
import psdi.common.role.MaxRole;
import psdi.mbo.MboRemote;
import psdi.util.MXApplicationException;
import psdi.util.MXException;

/**
* Returns the supervisor if set otherwise returns the owner group
*/
public class SupervisorOrOwnerGroup extends CustomRoleAdapter implements CustomRoleInterface
{
public MboRemote evaluateCustomRole(MaxRole roleMbo, MboRemote currentMbo)
throws MXException, RemoteException
{
// check if the current MBO is a WorkOrder
if (currentMbo instanceof psdi.app.workorder.WO)
{
throw new MXApplicationException("workflow", "WrongObject");
}

String sup = currentMbo.getString("SUPERVISOR");
if(sup.length()!=0)
{
// if the supervisor is set returns the corresponding person
MboRemote mbs = currentMbo.getMboSet("SUPERVISOR").getMbo(0);
return mbs.getMboSet("PERSON").getMbo(0);
}
// otherwise returns the corresponding owner group
return currentMbo.getMboSet("WORKORDERTOPERSONGROUP").getMbo(0);
}
}

Custom Java Class for Roles

3 thoughts on “Custom Java Class for Roles

  1. Hi,

    I have modified this code – i need to get only Owner group as the Role (it will be dynamic in Work order) and used in Work flow but this is not working.

  2. Hi Bruno,
    Great article! Can this be achieved through automation script?

  3. This was an outstanding blog post. I loved it. I’ll be back to read more. Thanks !
    Amazing post with lots of usefull information. Well done!. Keep Posting.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top