Download (all) Scripts from Maximo / ICD to your Eclipse Project

In one of my last blogs I showed a very nice way how to upload Jython scripts from Eclipse to your Maximo / ICD environment. Now what about the situation that you already have a Maximo / ICD environment with tons of scripts in it? In this blog I will show you a simple way how you can include all these scripts to your Eclipse project within 15 minutes. This will also include the first comment lines needed for the later upload.

To achieve our goal the following steps are needed:

  • Setup an application export in the Autoscript application
  • Download a XML File including all scripts
  • Run a Jython script to extract all the unique scripts

Setup an application export in the Autoscript application

The application export will be configured using the “Object Structures” application. Launch:

Go To > Integration > Object Structures

In the Object Structures application search for the “MXSCRIPT” Object Structure and open it.

Selection_018

After opening select an action:

Select Action > Add/Modify Application Export Support

 

Menu_020

In the dialog box create a new row in the table using the values shown here:

Selection_021

Press OK. The export support now has been created. Next step is to grant the security rights to the user group which should use the tool. In my example I will grant the rights to the maxadmin group. Goto the following Menu:

Go To > Security > Security Groups

Now perform the following steps:

  1. Search and open the security group you want to grant the rights to.
  2. Change to the “Applications” Tab.
  3. Filter for the Application “Automation Scripts” and select the record.
  4. In the Options for Automation Scripts section enable the option “Application Export”.Selection_022
  5. Save the Security Group.
  6. Logoff and Logon again to Maximo / ICD. Be sure that all your user sessions are successfully logged of – otherwise the settings will not be activated.

Download a XML File including all scripts

To download a XML File which includes all scripts in your system you have to go to the Automation Scripts application.

Go To > System Configuration > Plattform Configuration > Automation Scripts

If the previous step worked correctly you should now see a new Icon in the iconbar Selection_023for the application export. Before you press this button you have to search for the scripts to export. If all scripts should be exported just press enter in the search field. Now press the icon.

In the “Application Export” Dialog you just can take all settings and press “OK”.

Selection_024

The XML File now will be downloaded to the download directory of your browser on your local PC.

Run a Jython script to extract all the unique scripts

First of all you have to have a project setup in Eclipse where you would like to store your downloaded scripts. This chapter requires a complete project-setup using Eclipse, Jython and PyDev like described in this blog. Copy the downloaded XML file to this directory and name it scripts.xml.

Now create a Jython script with the following code:

#AUTOSCRIPT:EXPORTSCRIPTS
#DESCRIPTION:Script to export all Jython Scripts on a Server
#LOGLEVEL:ERROR

from java.io import File
from org.jdom.input import SAXBuilder

xmlFile = File("scripts.xml")
builder = SAXBuilder()

document = builder.build(xmlFile)
wrap = document.getRootElement()
ns = wrap.getNamespace()
rootNode = wrap.getChild("MXSCRIPTSet", ns)

liste = rootNode.getChildren("AUTOSCRIPT",ns)
for i in range(0,liste.size()):
    node = liste.get(i)
    scriptName = node.getChildText("AUTOSCRIPT",ns)
    scriptDesc = node.getChildText("DESCRIPTION",ns)
    scriptVersion = node.getChildText("VERSION",ns)
    scriptDebug = node.getChildText("LOGLEVEL",ns)
    scriptCode = node.getChildText("SOURCE",ns).encode('utf-8')
    
    scriptFile = open(scriptName + ".py","w")
    scriptFile.write("#AUTOSCRIPT: " + scriptName + "\n")
    scriptFile.write("#DESCRIPTION:" + scriptDesc + "\n")
    scriptFile.write("#VERSION:    " + scriptVersion + "\n")
    scriptFile.write("#LOGLEVEL:   " + scriptDebug + "\n")
    scriptFile.write(scriptCode)
    scriptFile.close()

This scripts requires the Java JDOM Class. Please ensure that the jdom.jar file is included in your PYTHONPATH. You can check this by right-click on your Eclipse project and select the “Properties” Menu. Check under “PyDev – PYTHONPATH” if jdom.jar is existent. If not use the “Add zip/jar/egg” Button to add it.

Selection_025

Remark: If you don’t have a local version of jdom.jar you can find one on your Maximo / ICD Server in the following directory: %WEBSPHERE _DIR%\AppServer\profiles\ctgAppSrv01\installedApps\ctgCell01\MAXIMO.ear\lib

Everything is prepared now. You can run the Script now from Eclipse using the Run Icon Arrow  Selection_009 and then the following menu:

Menu_026

Hopefully after a refresh of your project/folder (F5) you will see a bunch of new scripts! Congratulations!

TPAE Scripting customization points

In this blog I will shortly document the different ways a Jython script can be triggered in TPAE. The following launch points and invocation methods are available to start a script:

Launch points

A launch point is a configuration objects which triggers an automation script if a certain condition occurs. When a launch point is deactivated, the script associated with that launch point does not run. The The following launch point types can be defined in TPAE:

Object Launch Point

  • Execute scripts on MBO events such as init, add, update, or delete (TPAE 7.5)
  • Starting from TPAE 7.6 this kind of Launch Point has a much more fine granular configuration.
  • Execute the script on:
    • Initialize Value: executed when the MBO is initialized
    • Validate Application: executed when the MBO is validated against business rules, but is not yet saved in the Database
    • Allow Object Creation: Indicates whether Maximo business objects can be created.
    • Allow Object Deletion: Indicates whether Maximo business objects can be deleted.
    • Save: executed in the process of saving the MBO. In this case more fine granular specifications about the execution time (before Save, after Save, After Commit) can be made.

Attribute Launch Point

  • Execute scripts based on the change of an attribute. This type of launchpoint is used for field validations or other actions.
  • Starting from TPAE 7.6 this kind of Launch Point has a much more fine granular configuration.
  • Execute the script on:
    • Initialize access restriction: Sets the access level for the attribute’s field. (Example: Read/Write to Read only)
    • Initialize value: Sets the initial value for the attribute’s field.
    • Validate: Checks whether the value in the attribute’s field is valid.
    • Retrieve list: Retrieves a list of valid values for the attribute’s field. For example, in an invoice, you can set up the supplier field to return a list of approved vendors.
    • Run action: Runs an action that is based on the value that is in the field.
  • Example can be found here

Action Launch Point

  • Execute scripts in the context of workflow/escalation actions
  • Execute scripts in the context of a Menu or Button (Sample here)

Custom condition Launch Point

  • Workflow conditions and conditional expressions can be utilized by Custom condition launch point

Other Methods

Manually Run from Scripting Application

  • Run a script without any launchpoint defined. (Sample here)

Remote Method Invocation (RMI)

  • Runs scripts from outside TPAE. See here for further details.

Interfaces (starting from Maximo 7.6)

  • Runs in context of Integration Framework to convert data