2/28/2013

Sample Action Class

This entry is part of the Maximo Java Development
Sometimes you have to implement some complex logic in workflows or escalation and you feel limited by the out-of-the-box Maximo actions. In these cases you can unleash the Java power and code your algorithm in a custom action class.
In order to create a custom action class, you must extend the psdi.common.action.ActionCustomClass class.
package cust.actions;

import java.rmi.RemoteException;
import java.rmi.RemoteException;
import psdi.common.action.ActionCustomClass;
import psdi.mbo.MboRemote;
import psdi.util.MXException;

public class SampleAction implements ActionCustomClass
{
   public SampleAction()
   {
        super();
   }

   public void applyCustomAction(MboRemote mbo, Object[] params)
   {
        // Write custom code here
   }
}


2/27/2013

Maximo Developer 101: Lession 4 - Extending MBOs

One of the basic tasks in customizing Maximo is extending the MBOs. Remember, much of the business logic is placed in the MBOs so if you want to add custom business logic, you will need to extend the existing MBOs. 

First, let's talk about the path (package) naming for your custom MBOs.

Standard IBM proceedure is to use the same path, only changing the top level value. For example, the Maximo class path for Asset is: psdi.app.asset.Asset.class. So you would name your customization: myCompany.app.asset.Asset.class

Ok, now when you extend an MBO, you actually have to extend 6 class files. You have to extend the MBO class and the MBO Set class. Then there is a "remote" class for each. Finally the each has a "stub" file. I know this sounds like a lot but in truth, the most of your custom work will be in the MBO class and a maybe a little in the MBO Set file. The two "Remote" files will just be extensions of the base "remote" classes. And as for the two "Stub" files, you will use an XML file that will generate these for you.

At this point, I am going to strongly recommend you download and install the Maximo Developer for Eclipse. This tool will build the four files (MBO, MBO Set, and two remote files) for you. What makes build these files easier is that IBM uses a standing naming system for them. For example say you want to extend the Asset MBO. Well the four files are named as follows: Asset, AssetSet, AssetRemote, AssetSetRemote. (If you are using the Maximo Developer, then you will need to specify the MBO class file name and not the MBO set name.) 

The last step is you need to create an ANT file (this is just a special XML file). This file is a set of instructions that will create the two ";stub" files. The following will compile the stub files for extending the Asset MBO.

Maximo Developer 101: Lesson 3 - Working with Business Objects

The first step in programming Maximo is working with the Maximo Business Objects (MBOs). In this lesson, we will cover the basics of working with this class files
Although there are class files for different MBO in Maximo (one for Asset, WorkOrder, etc.), these all extend the same base object. This means you can use this based object to do 90% of what you need to do. When access an MBO, you first use what is called and MBO Set object. The main class you will use is called “MboSetRemote”. You get an MBO set object by using the MXServer object.
psdi.mbo.MboSetRemote myAssetSet = psdi.server.MXServer.getMXServer().getMboSet(“ASSET”, getUserInfo())
The above line of code creates an MBO Set object of the ASSET MBO. Of course at this point you have all of the records in the Asset table. You will most like want to narrow this down. To do this you use the .setWhere method on the MboSetRemote object. For example if we wanted just one asset, we could use something like this:
myAssetSet.setWhere(“ASSETNUM = ’12345′ and SITEID = ‘EAGLEA’”);
In the above line of code, our MboSet object would return just one record (assuming that asset/siteid existed). Now one note about the setWhere method. You can use it over and over on the same MboSet object (like in a loop), but you must call the .reset() method after each setWhere or the subsequent calls to setWhere will do nothing.
Now that we have our collection of records we want to work with, we now need to get each record. We do this by using the getMbo() method. Of course you need make sure you have any records to process and we can do that with the .count() method. This will return how many records match your “setWhere”.
Just like how all MBO Set objects extend the same object, so do each of the record objects. They extend the MboRemote object. Again, you can do 90% of what you need to do.
if (myAssetSet.count() > 0)
{
   for (int i=0; i < myAssetSet.count(); i++) {
      psdi.mbo.MboRemote currentAsset = myAssetSet.getMbo(i);
   }
}

Maximo Developer 101: Lesson 2- Maximo Fundamentals

Before you being working with Maximo, there are a couple of important concepts you need to know. These will affect your design options in creating solutions.
First thing to know is that when programming Maximo is that it is database agnostic. What I mean by this is that Maximo does know what database it is using. What does this mean to you? Well if you are trying to develop something in Maximo and hope to sell it, then you need to make sure that your enhancement is also database agnostic. If you are developing something in-house and will never change database platforms, then this is not that big of a programming concern, but it is a good practice to do it anyway.
Next thing to know is that Maximo is an Object Oriented database. Now you might be wondering how this can be since the physical database is a standard relational database (DB2, Oracle or SQL Server). Maximo does it the same way that the Java tool Hibernate does it, through a set of class files that manage all physical read/writes to the database. As a developer, you just would use the class files for accessing the database. IBM however did not use Hibernate for the Object Oriented interface. Instead, they created their own set of classes call Maximo Business Objects (MBOs) (pronounced M.B.Os or Maybows). Since Maximo is database agnostic, there is no guaranteed way to place business rules and all data integrity requirements in the database. As such, Maximo places almost all of this in the MBOs. In the database, the only data integrity you will find are unique indexes and required fields. None of the tables have primary keys, Foreign Keys or default values. This makes updating/adding data directly to the database tricky at best. It is entirely possible to enter data into the database and have it not show up in the front end because it does not meet Maximo’s data requirements. You are safe to query the database directly but all updated/inserts/deletes should be done in Java using the MBO objects. Another benefit of using the MBOs is that your code then becomes database agnostic too.

Maximo Developer 101 – Getting Started

So you want to be a Maximo developer. Well the first step is to setup your development environment. First you will need a Maximo development environment. This guide does not cover how to set that up. Although you can technically use any Java IDE, IBM recommends Eclipse IDE. All documentation from IBM is for Eclipse as well as an add-on or two are available for it. So the next question is always “What version?” Any version of 3.1 or above. You can download Eclipse here: http://www.eclipse.org/.

Next you will want to download the setup guides from IBM:

Maximo Eclipse Developer Setup Guide

Maximo Developer Remote Access Guide

Now these guides were created for Maximo 6 but they still work for Maximo 7 with the following changes

  1. The guide says Eclipse 3.1 but any newer version will work
  2. Step 1 of the Maximo Eclipse Developer Setup Guide says “Make sure that you have follow all the steps in the document MXES-Initial Eclipse 3.1.1 Setup”, this just means to make sure Eclipse is installed.
  3. Maximo 7 uses Java 1.5 while Maximo 6 uses Java 1.4

The setup guide talks about how to setup for doing MBO extension. This will also work for field classes and integration development. If you want to do screen development, then you will also need to add to your library the class folder %maximo%/maximouiweb/webmodule/WEB-INF/classes as this is where app beans and data beans are stored.

A couple of other useful tools are:

  • Maximo Developer : This is an Eclipse plug-in that helps automate the creation of Mbo Class extensions.
  • Maximo View Log : This is a web based tool for quickly viewing the Maximo Log

At this point, you should have a development environment for doing your Maximo work. So, what next? Here are some other resources available to you: