Custom condition Java class

Sometimes standard Conditional Expressions are not enough. Sometimes the logic to implement is too complex to be implemented using an SQL expression. In such cases Maximo allows to implement the condition logic in a custom condition class using Java.

To implement a condition class you must extend psdi.common.condition.CustomCondition and override evaluateCondition and toWhereClause methods. Here is a sample class.

public class IsIssueProblem implements CustomCondition
{
  public boolean evaluateCondition(MboRemote mbo, Object obj)
         throws MXException, RemoteException
  {
    if (mbo.getString("ISSUETYPE").equalsIgnoreCase("PROBLEM"))
    {
      return false;
    }
    else
    {
      return false;
    }
  }

  public String toWhereClause(Object obj, MboSetRemote mbs)
         throws MXException, RemoteException
  {
    // ensure this method is not called by throwing an Exception
    throw new MXApplicationException("", "");
  }
}

The provided snippet works for all Conditional Expression usages except for QUALIFIED security restrictions. In this cases you have to implement the toWhereClause method to return a valid SQL clause.

The Maximo JavaDocs for the two methods better explain how the two methods should be implemented.


evaluateCondition

Evaluate the condition.
For data restrictions having a condition (SecurityRestrict other than object Qualified), the object framework will call this method for each Mbo and set the Mbo and MboValue flags appropriately.

Parameters:
Returns:


toWhereClause

Convert the condition to a where clause. If the condition class will be used for "QUALIFIED" object security type, this method should return a where clause. If the condition should NOT be used for "QUALIFIED", it should throw an exception to indicate it is an error when attempted to be used. This method has to be thread safe. For qualified object data restrictions (SecurityRestrict) having a condition type of Class, the object framework (MboSet) will call this method to construct the Where clause.

Parameters:

Returns:

Labels: , ,