IBM MAXIMO : EXTRACT AUTOSCRIPTS AND XMLS AS INDIVIDUAL FILES TO SYSTEM FOLDERS

Abstract

In the rapidly evolving field of developments and customizations in Maximo,

efficient management of automation scripts and XML files is crucial. This paper presents a simple solution designed to streamline this process by extracting

automation scripts and XML files into individual files with ease. The extracted 

files are stored in a predefined server folder, facilitating seamless version control,

efficient backups, and effortless deployments. 

By automating this process, developers can focus more on core development tasks, thereby increasing productivity and reducing the risk of errors. This approach represents a significant step forward in the management of automation scripts and XML files,

with potential wide-ranging benefits for the software development community.

The paper further explores the implementation details, performance metrics, and

potential future enhancements of this automation script.


Introduction

As a Maximo developer, the major areas we work on our day-to-day requirements are automation scripts and application XML’s. In a huge project with many developers and parallel development activities going on, it will be a tedious task to copy paste these automation scripts and XMLS to different files.We usually use these files to take local backups, for attaching to the work items, for deployments and to make use of version control tools. 
If it is single digit files, the task would be easier, what if the files are 100s in number? Copy pasting each individual code into a text editor and saving it with the required file format is not practical and is highly prone to errors.  
As a developer we should always move towards automated approach and hence I have worked on a simple solution to extract these files with just few clicks and with so little time and hence saves the time of developers so they can spend that time concentrating on the coding parts.


Methodology

To address this requirement, we leverage the out-of-the-box capabilities of

Maximo. Our approach involves the creation of a straightforward autoscript that

accepts a 'where' clause as input, provided by the developer. Based on this

input, Maximo queries the autoscript or maxpresentation objects and retrieves

the corresponding codes.

These codes are subsequently encapsulated into individual files, each bearing

the name of the original script or XML. We have the flexibility to designate an

existing folder within the autoscript as the destination for these files. Moreover,

we can enhance this flexibility by allowing the folder name to be specified as an

input, eliminating the need for the developer to modify the autoscript when

extracting files to a different folder.

The autoscript’ s inputs, namely the 'where' clause and the folder (if required),

can be captured using components from the app designer. We can incorporate

an action under 'more actions' which, when clicked, invokes a dialog box. This

dialog box serves as the interface for specifying these inputs. Upon submission,

the files are extracted accordingly, thereby streamlining the management of

automation scripts and XML files.


Implementation

1. Create a ‘sigoption’ using the application designer for the Autoscript Application as below and provide MAXADMIN security group access to the sigoption.


2. Then we will create a select action in more action as follows:



3. Then we need to have a non-persistent attribute to take where clause as input.

We can have one more to take the folder path as well. We can create these in

any object. (whereclause_np, directory_np)


4. We need to create a dialog box which will have these fields and a button to

extract the files as below. This button will invoke our action script.


<dialog id="EXPORT SCRIPT FILE" label="Extract Automation Scripts" mboname="EXTRACT_FILE"

whereclause="1=1">

<section id="autoscipt_extract_dialog_section">

<sectionrow id="autoscipt_extract_dialog_section_11">

<section id="autoscipt_extract_dialog_section_12">

<multilinetextbox columns="60" dataattribute="DIRECTORY_NP" id="autoscipt_extract_dialog_section_2_1" label="Extraction Directory" rows="1"/>

<multilinetextbox columns="60" dataattribute="WHERECLAUSE_NP" id="autoscipt_extract_dialog_section_2_2" label="Where Clause" rows="2"/>

</section>

</sectionrow>

</section>

<buttongroup id="autoscipt_extract_dialog_btgrp_3">

<pushbutton id="autoscipt_extract_dialog_bt_31" label="Extract"

mxevent="extract_file"/>

<pushbutton id="autoscipt_extract_dialog_bt_33" label="Close"

mxevent="dialogcancel"/>

</buttongroup>

</dialog>



5.
Create an action launch point script as below. The action name should match with the mxevent specified in the button properties.

# Import necessary libraries
from java.io import PrintWriter
from psdi.server import MXServer   
  
# Get the MXServer instance and the current web client session
mxServer = MXServer.getMXServer()
session = service.webclientsession() 
 
# Get the data bean for the export script dialog
databean = session.getDataBean("export_script_dialog")
dialogSet = databean.getMboSet()
if not dialogSet.notExist() :
dialogMbo = dialogSet.moveFirst()
# Get the where clause and directory from the dialog MBO
whereClause = dialogMbo.getString("WHERECLAUSE_NP")
directory = dialogMbo.getString("DIRECTORY_NP")
if whereClause is not None and directory is not None:
autoScriptSet=mxServer.getMboSet("AUTOSCRIPT",mxServer.getSystemUserInfo())
sqlErr = 0
try :
autoScriptSet.setWhere(whereClause)
autoScriptSet.reset()
except :
sqlErr = 1
if sqlErr == 1 :
service.error("SQLERROR", "Verify the where clause")
else :
if not autoScriptSet.notExist():
autoScript = autoScriptSet.moveFirst()
while (autoScript != None) :
source = autoScript.getString("SOURCE")
name = autoScript.getString("AUTOSCRIPT")
# Create a new PrintWriter for the auto script file
out = PrintWriter(directory + "/" + name + ".py")
# Write the source to the file
out.println(source)
# Flush and close the PrintWriter
out.flush()
out.close()
autoScript = autoScriptSet.moveNext()
# Clean up and close the auto script set
autoScriptSet.cleanup()
autoScriptSet.close()
else :
service.error("INVALID","Provide Both Directory and Where clause")


Execution

1.Goto Automation Script Application

2.Click on Extract Script File under More actions



3.Provide the folder path and where clause, then click on Extract Button




4.The files will be extracted to the specified folder

 

Conclusion


This approach is just a simple method to extract files by using Maximo interface.

In the methodology, I have mentioned about extraction of autoscripts, the same can be enabled for other files like XMLs. 

By implementing this small technique, developer time can be saved a lot. We can expand the autoscript if there is even a business use case where we need to extract certain files which are present in Database.







Comments

Popular Posts