Enterprise service scripts
Enterprise services provide the inbound integration foundation of IBM® Maximo® Manage. They represent the internal implementation for all the services that the Maximo integration framework offers, for example, XML, HTTP, SOAP, flat files, and interface tables. Enterprise services can optionally use the queues.
Enterprise services are also used to import data from the user interface and cron jobs. If the
service is asynchronous, the enterprise service starts running after the messages is picked up from
those queues and is pushed downstream. Similar to its outbound equivalent publish channel,
enterprise services are used to transform data from the external format to the internal format,
JSON, or XML. Enterprise services support the following script points.
Script point | Purpose |
---|---|
External exits | Used for data transformation of inbound messages from the external format
erData to the internal format irData |
User exit before external exit | Used for data modification before it reaches the external exit
erData . |
User exit after external exit | Used for data transformation from the output of the external exit to the target internal format. |
The following table lists the available variables.
Variable | Purpose |
---|---|
erData | An instance of psdi.iface.mic.StructureData that is used to hold the external document. Available for all three exits. |
irData | An instance of psdi.iface.mic.StructureData that is used to hold the internal document. This
variable is set to null as input for the external exit and before the 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 such as Sync, Create, Update, and Delete. |
extSystem | The external system name. |
userInfo | The UserInfo object that represents the authenticated user who started this service. |
conn | The JDBC connection object. |
The following script is an example of an after user exit script that sets the wopriority to an
inbound work order
transaction:
if irData.getCurrentData("vendor")=="A0001" and irData.isCurrentDataNull("wopriority")==True:
irData.setCurrentDataAsInt("wopriority",1)
The after user exit for enterprise service works with the
irData
internal format
data as the inbound external exit mapped the external format to an internal format. In the following
example that shows a before user exit, the script skips the transaction when a certain condition is
met.from org.jdom import Namespace
doc = 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 only to 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(). For a JSON document, you need
to use a different API to get the JSON data. The following script is an example of this
situation:from com.ibm.tivoli.maximo.oslc import OslcUtils
jsonData = OslcUtils.bytesToJSON(erData.getOriginalByteData())
orgname = jsonData.get("orgname")
if orgname=="somevalue":
service.raiseSkipTransaction()
The following example shows an external exit script that creates a company by mapping external
data to the MXVENDOR object
structure:
from psdi.iface.mic import EnterpriseServiceCache
from psdi.server import MXServer
from org.jdom import Namespace
doc = 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")