Enterprise service script
Enterprise Services provide the inbound integration backbone of Maximo. They represent the internal implementation for all kinds of services that Maximo Integration Framework (MIF) offers,
XML/HTTP, SOAP, Flat Files, Interface tables to name a few. Enterprise services can optionally leverage the queues as it is async.
Enterprise services are also used for Data import from UI as well as cron jobs (File, Interface Tables).
If the service is async, the Enterprise service execution starts after the messages get picked up from those queues and
get pushed downstream. Like its outbound equivalent (Publish Channel), Enterprise Services are used to transform data from external format to Maximo format, json or xml.
Enterprise Services support the following script points:
Script Point | Purpose |
---|---|
External Exits | Used for data transformation of inbound messages from External format (erData ) to internal Maximo format irData |
User Exit (Before External Exit) | Used for data modification before it reaches the External Exit (erData ). |
User Exit (After External Exit) | Used data transformation from the output of the External Exit to target Maximo format. |
The following table lists the available variables:
Variable | Purpose |
---|---|
erData | An instance of psdi.iface.mic.StructureData used to hold the external document. Available for all three exits. |
irData | An instance of psdi.iface.mic.StructureData used to hold the internal (Maximo format) document. This is set to null (as input) for External Exit and Before User Exit. External exits are expected to set the irData by transforming the erData . |
ifaceType | The interface type name. |
ifaceName | The channel name. |
osName | The Object Structure name. |
messageType | The message type which can have values like Sync/Create/Update/Delete. |
extSystem | The external system name. |
userInfo | The UserInfo object representing the authenticated user that invoked this service. |
conn | The jdbc Connection object. |
The following example is of an after user exit script that sets the wopriority to an inbound WO transaction:
if irData.getCurrentData("vendor")=="A0001" and irData.isCurrentDataNull("wopriority")==True:irData.setCurrentDataAsInt("wopriority",1)
The “After User Exit” for Enterprise service would work with the irData
(internal Maximo format data)
as the inbound External exit would have mapped the external format to an internal format.
The following example is of a before user exit. In this example, the script decides to skip the transaction when a certain condition is met.
from org.jdom import Namespacedoc = erData.getData()extXMLRoot = doc.getRootElement()orgname = extXMLRoot.getChildText("orgname", Namespace.getNamespace("http://some_ns.org"))if orgname=="somevalue":service.raiseSkipTransaction()
The Before User Exit has access to only the erData
variable that contains the external document.
In this case the external document is XML and the API to access that as a JDOM document is erData.getData()
.
If this was a json document, you would need to use a different API to get the json data. The following script is an example of that:
from com.ibm.tivoli.maximo.oslc import OslcUtilsjsonData = OslcUtils.bytesToJSON(erData.getOriginalByteData())orgname = jsonData.get("orgname")if orgname=="somevalue":service.raiseSkipTransaction()
The following example shows how to map a MAS User sync json with extension attributes (conforming to SCIM specification) to custom attributes for person record. We will use an “after” User Exit script for the enterprise service MASPERUSER.
from com.ibm.tivoli.maximo.oslc import OslcUtilsfrom com.ibm.tivoli.maximo.oslc.provider import OslcJSONStructureDatabyteData = irData.getDataAsBytes()peruserJo = OslcUtils.bytesToJSONObject()extJo = peruserJo.get("extension")empNum = ""if extJo is not None:empNum = extJo.get("employeeNumber")
The following example is of an External Exit Script that creates a Maximo company by mapping external data to to MXVENDOR Object Structure:
from psdi.iface.mic import EnterpriseServiceCachefrom psdi.server import MXServerfrom org.jdom import Namespacedoc = erData.getData()extXMLRoot = doc.getRootElement()vendor = extXMLRoot.getChildText("vendor", Namespace.getNamespace("http://some_ns.org"))organization = extXMLRoot.getChildText("organization", Namespace.getNamespace("http://some_ns.org"))srv = EnterpriseServiceCache.getInstance().getEnterpriseServiceInfo("MXVENDORInterface")