October 15, 2013

How to implement stateful MBOs

This entry is part of the Maximo Java Development series.

Many objects in Maximo has a STATUS attribute that can be changed using the status icon or the change status menu option. The STATUS attribute is always associated with a synonym domain that has the valid statuses for the object. Examples of these domains are:
  • POSTATUS for the PO (Purchase Order) object
  • WOSTATUS for the WORKORDER object


The objects with changes of status must inherit from the StatefulMbo class which provides the basic functionality to change the status. For example the WORKORDER object has the following class hierarchy:
  • Mbo > StatefulMbo > WORKORDER

The synonym domain is associated with the STATUS attribute, and this domain has an internal and external value. The value stored in the database and displayed on the screen is the external value for an attribute with a synonym domain.



The most important methods available in the StatefulMbo class are:
  • canChangeStatus(String changeToStatus, long accessModifier)
    Identifies whether the status of the object be changed to the specified value.
    If status change is not allowed, an exception is thrown.
  • changeStatus (String status, Date date, String memo)
    Changes the status of the object.
    This method compares the requested status and the current status by calling canChangeStatus before the change is performed. If the status change is allowed, the status change is performed and a status history record is written. If the status change is not allowed, an exception is thrown.
  • getInternalStatus()
    Returns the Internal value for the current status of the object
  • getStatusListName()
    Return the name of the domain associated with the status attribute.

Passing the NOACCESSCHECK flag in the accessModifier parameter can be used to indicate that the status can be changed even if it is invalid.
Two similar methods that can be used to manipulate internal status values are: canChangeMaxStatus and changeMaxStatus.

When the user selects the 'Change Status' option, the framework displays a dialog box that lists the valid statuses to which the object can change.



The list is the result of calls to the canChangeStatus method for each of the possible statuses from the synonym domain. If the canChangeStatus method throws an exception, the status is not listed.
When the user selects the new status, the framework calls the changeStatus method that first call the the canChangeStatus method (again) to validate the change and then update the status and status history.

2 comments:

  1. Thanks, I can implement change status on Custom App / Custom Object from Main Tab.
    But on List Tab , when I selected some rows, then click Change Status , I get error message : BMXAA4187E - The relationship WOCHANGESTATUS does not exist ... .What was I missing?

    ReplyDelete
  2. I'm learning Maximo and I don't understand what does getTranslator () mean ?

    ReplyDelete