June 26, 2012

Retrieve JDBC connection to Maximo database

In some cases you need a JDBC connection to directly access Maximo database in order to perform some job. This is not common since all Maximo data can be accessed through standard MboSets. However, you may need to access non-Maximo tables, perform specific SQL statements or bypass Mbos for performance reasons. The two main approaches to use issue standard SQL code through Java JDBC are described here.

JDBC Connection
Here is a sample that shows how to get a JDBC connection from Maximo connection pool (and correctly release it).

public int countAssets() throws RemoteException, MXException
{
  MXServer mxServer = MXServer.getMXServer();
  ConnectionKey conKey = mxServer.getSystemUserInfo().getConnectionKey();
  Connection con = mxServer.getDBManager().getConnection(conKey);

  int c = 0;
  try
  {
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("select count(*) from asset");
    while (rs.next())
      c = rs.getInt(1);
    rs.close();
    stmt.close();
    con.commit();
  }
  catch (SQLException e )
  {
    throw new MXApplicationException("SQLException caught", e.getMessage());
  }
  finally
  {
    mxServer.getDBManager().freeConnection(conKey);
  }
  return c;
}

DBShortcut class
A quick easy way to get a java.sql.ResultSet object is to use DBShortcut class. This object comes in the psdi.mbo package and is designed to quickly retrieve result-sets or run update statements against the database.
public int countAssets() throws RemoteException, MXException
{
  MXServer mxServer = MXServer.getMXServer();
  ConnectionKey conKey = mxServer.getSystemUserInfo().getConnectionKey();
  DBShortcut dbs = new DBShortcut();
  dbs.connect(conKey);

  int c = 0;
  try
  {
    ResultSet rs = dbs.executeQuery("select count(*) from asset");
    while (rs.next())
      c = rs.getInt(1);
    rs.close();
    dbs.commit();
  }
  catch (SQLException e )
  {
    throw new MXApplicationException("SQLException caught", e.getMessage());
  }
  finally
  {
    dbs.close();
  }
  return c;
}

Alternative methods
In both the described methods the connection is retrieved through a static reference to MXServer object and a system psdi.security.ConnectionKey object.
A better approach could be to use some methods defined in the psdi.mbo.Mbo class as follows.
ConnectionKey conKey = getUserInfo().getConnectionKey();
Connection con = getMboServer().getDBConnection(conKey);

June 19, 2012

Maximo Everyplace on Motorola ET1 tablet

Maximo Everyplace is a great addon to enable mobile capabilities in IBM products based on Maximo/TPAE without dealing with complex setup and configuration required by the more advanced Maximo Mobile solutions. The great advantage of Maximo Everyplace over Maximo Mobile is its simplicity.
Basically speaking, with Maximo Everyplace you can build small-screen-friendly TPAE applications that are tailored to fulfill specific user scenarios. The process of creating a custom application is well described in the product documentation and is easy if you are familiar with the Application Designer.

The current supported platform for Maximo Everyplace are iOS (Apple), Android and Blackberry. I found iOS and Blackberry very limited because they have proprietary hardware platforms. On the other hand, many hardware manufacturers are starting to produce industrial rugged devices based on the Android platform.
When I was asked for some advice by one of my customers I performed a market research based on the following requirements.
  • Well known manaufacturer to provide excellent and durable support.
  • 7 inches screen. I think that 3.5 or 4 screens are to small to effectly use Everyplace in a real working environment. Tablets with 10-inches screen seems to big to be handled with one hand.
  • Good CPU running at at least 1GHz to deliver a smooth browsing user experience.
  • Built in barcode scanner with dedicated button to activate the scan.

7-inch Android rugged tablets are not yet very common (June 2012). In particular I have found two interesting devices that seems to fit my requirements. Motorola ET1 and Panasonic Toughpad A1 Since the Panasonic is not yet available I ended up with choosing Motorola ET1 tablet. Even if Motorola seems to fit all my needs I want to be sure it works well with Maximo Everyplace so I have asked Motorola to send me a device to perform a hands on test.
After few days of testing I have to say that I really like the Motorola's tablet. Here are my favorite characteristics.

Stylish and robust hardware

Looking at ET1 you wan't believe that you are looking at a MIL STD 810G certified 'rugged' device.



Dedicated buttons for barcode scanning

The ET1 is equipped with two buttons on the back that can trigger barcode scanning through the rear camera. Considering that it is not a laser scanner, I found it quite fast and powerful. It takes around 1 second to start the camera and recognize a wide variety of barcode types.


Soft-buttons on the front

There are three customizable buttons on the lower left corner of the screen. I have assigned one of these to type a TAB character so i can quickly move across Maximo field without having to play too much with the touchscreen.



Hand strap
The optional hand strap accessory allows you to steadily hold the ET1 with the left hand while leaving your right hand free to type and swype on the display or hold and move items and tools in your storeroom.


June 18, 2012

Maximo for beginners

Checkout these three articles on IBM Asset Management blog if you are a Maximo newbie.



June 12, 2012

Do you like MaximoDev?

If you like this blog please give me a little token by clicking on this button

Thanks for your cooperation and don't forget subscribe to one of my channels.

June 11, 2012

How to enable barcode scanning for Maximo Everyplace on Android

With this post I will start a small set of articles on Maximo Everyplace which is a feature that provides the ability to use Maximo on mobile devices through the device web browser.

An interesting article on IBM Asset Management blog describes how to use a bluetooth barcode scanner paired with an iPhone or an iPad to enable barcode scanning capabilities for Maximo Everyplace. On Android you have two options to achieve the same result.

The first option is to install the Android App for IBM Maximo Everyplace from ISM Library. This little app addresses some of the limitations of Maximo Everyplace and displays a dedicated button to scan barcodes through the built-in camera.

The second solution is based on the Barcodescanner Keyboard Free app that is available on the Google Android market. There is also a paid version of the app but the free version works perfectly on my phone. This custom keyboard provides a custom button close to the spacebar that allows to scan a barcode through the built-in camera and send the output to the currently selected field. Here is how the keyboard looks.


After having installed it, run the app and follow the instructions to configure it. Otherwise go in Settings - Language and input - Keyboard and set the Barcode Key as the default keyboard.
Now launch an application and you should be able to scan the following barcode directly into any text field using the new keyboard.


June 7, 2012

Skip field copy when duplicating object

On almost every application Maximo provides a useful entry in the action menu to duplicate the selected record. When this action is performed, some of the field are intentionally wiped from Maximo. For example if you try to dupicate an Asset you will notice that Maximo resets some fields like ASSETNUM, LOCATION and SERIALNUM.
It may happen that you have added some custom fields on a Maximo object and you want to be cleaned when a record is duplicated. In such case, all you have to do is to override the skipCopyField(MboValueInfo mvi) method of the object's data bean.
Extend the object's class handler as described here and put the following method in the Mbo class.

@Override
protected boolean skipCopyField(MboValueInfo mvi) throws RemoteException, MXException
{
  if(mvi.getName().equals("MYCUSTOMFIELD"))
    return true;

  return super.skipCopyField(mvi);
}

Add all the fields to be skipped during the object cloning in the if statement.
Simple and straightforward as long as you know it...

TPAE 7.5

The Database Configuration Application has been enhanced in Maximo 7.5.0.3 with a new object definition menu called ‘Exclude Attribute Data’. Here you can specify the attributes that you do not want included in your new object during the duplication process. You can also control what records are excluded using an SQL condition.

June 6, 2012

Creating a custom dialog box to send a report via email

An outstanding tutorial from Daniel Ng explaining how to create a custom dialog box to send a report via email.
The tutorial is very detailed and explains a lot of Maximo/TPAE stuff including:
  • Create a custom XML dialog box
  • Attach the dialog box to an application
  • Associate a signature option to the dialog box
  • Associate the custom dialog box to a custom toolbar button
  • Create a custom AppBean class
  • Create a custom message box
  • Turn on debugging mode for the logger
  • Deployment and testing.
Many compliments Daniel!

June 5, 2012

I'm now a Certified Solution Designer for MAM 7.1

Few weeks ago I have achieved the IBM Certified Solution Designer certification for Maximo Asset Management V7.1.
It's now time for a little self-celebration.


I strongly encourage you all to take a look at IBM Certify website and search for Maximo under Tivoli Software professional certifications.

June 4, 2012

Sample Action Class

This entry is part of the Maximo Java Development series.

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 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)
      throws MXException, RemoteException
  {
    // Write custom code here
  }
}

As usual... compile, rebuild EAR and redeploy. For a full example of a custom action class look here.

To call this action from a workflow or escalation you have to register the new Maximo action. Go in System Configuration - Platform Configuration - Actions and create a new action. Choose Custom Class as Type, select the object for which the custom applies and provide the full class name (cust.actions.SampleAction) in the value field. Here is how the new Action should look.


June 2, 2012

Grant access to an action menu or toolbar button conditionally

This entry is part of the Conditional Expressions HowTo.

In Maximo/TPAE menu items are granted per security group in the Security Groups application. Every option available for an application has a corresponding signature option (aka sigoption) record in the SIGOPTION table. Those SigOptions can be configured in the Application Designer.

In this article I will show how is it possible to hide an action menu or a toolbar button conditionally for a specific security group using a conditional expression and a signature option.
As an example I will demonstrate how to hide the 'View History' action menu entry for all purchase orders that have a total cost higher than 100.
Note that the same procedure can be used to show or hide a toolbar button.

Define conditional expression

First of all we need to define conditional expression to implement our business rule. Open Conditional Expression Manager application and Create the following conditional expression.
  • Condition: COST100
  • Description: Total cost is less than 100
  • Expression: totalcost<100

Identify the Signature Option

Understand what SigOption is associated with the action menu entry or toolbar button we want to control. Launch Application Designer and open the PO application. From the action menu select the Add/Modify Select Action Menu and locate the correct row. This could be a little tricky however keep in mind that these rows are listed in the same order as the menu entries. The View History' action menu entry is the second from the list and has a Key Value: VIEWHIST.


If you now close this dialog and open the Add/Modify Signature Options menu entry and locate the SigOption named VIEWHIST. Tate note of the description (View History) and ensure that Visible flag is selected.


Assign the Signature Option to Security Groups

Now is the time to tell Maximo what are the groups that have access to the 'View History' action menu entry in the PO application and what is the business rule that must be satisfied to enable it.
For this example we will apply this rule on MAXADMIN group that typically has access to all applications and options.
Open the Security Groups applications, choose MAXADMIN group, go under Applications tab and search for Purchase Orders application. In the Options for Purchase Orders sections search for 'View History' than set the condition to COST100.


In this way we are telling that the VIEWHIST sigoption must be granted to MAXADMIN group only if the PO cost is less than 100.
Signout of Maximo and login back to force the reload of security settings for MAXADMIN user. Launch the Purchase Orders application and open a PO with a total cost higher than 100 and you will see that the 'View History' action menu entry is not visible.

June 1, 2012

How to make a field readonly using conditional expressions

This entry is part of the Conditional Expressions HowTo.

One of the most common Maximo customization scenarios is to make a textbox readonly based on some business rules.
This could be easily achieved using Maximo/TPAE Conditional UI.
As an example, I will describe how to make readonly the Priority in the Asset application when the asset is in 'OPERATING' status.

Define conditional expression

Open Administration - Conditional Expression Manager application and Create the following conditional expression.
  • Condition: OPERSTATUS
  • Description: Status is 'OPERATING'
  • Expression: status='OPERATING'
  • Always Evaluate: True



Configure ASSET application

Open System Configuration - Platform Configuration - Application Designer application and edit the ASSET application. Select the Priority field of the Details section of Asset tab and open the properties window. Click on Configure Conditional Properties button (on TPAE 7.5 it is in the Advanced tab) and configure it as follows.
  • Signature Option: READ
  • Security Group: EVERYONE
  • Property: inputmode
  • Value: readonly



Now open the Asset application and select and OPERATING asset and you should see the Priority field marked as readonly.