def getDeployableSoftwareTaskMbo(self, iemswdMbo): tloamsoftwareId = iemswdMbo.getInt("TLOAMSOFTWAREID") sqlFormat = SqlFormat(self.mbo.getUserInfo(), "tloamsoftwareid = :1") sqlFormat.setObject(1, "TLOAMSOFTWARE", "TLOAMSOFTWAREID", str(tloamsoftwareId)) swMboSet = MXServer.getMXServer().getMboSet("TLOAMSOFTWARE", self.mbo.getUserInfo()) swMboSet.setWhere(sqlFormat.format()) swMboSet.reset() swMbo = swMboSet.getMbo(0) if (swMbo != None): # we need to get install as the task type exists for a given software package deployableSoftwareSet = swMbo.getMboSet("TAMITDEPLOYSWTASK") taskType = MXServer.getMXServer().getMaximoDD().getTranslator().toExternalList("DPASWTASKTYPE", "INSTALL") deployableSoftwareSet.setWhere("tasktype in (" + taskType + ")"); deployableSoftwareSet.reset() if (deployableSoftwareSet.isEmpty()): swName = iemswdMbo.getString("SWNAME") print self.scriptName + "Unable to find deployable software of type Install for the software : " + swName self.addToSRWorkLog("iem_swctg_missing_deploytask_sum", "iem_swctg_missing_deploytask_desc") self.addErrorToWorkLog("iem_swctg_missing_deploytask_sum", "Unable to find deployable software of type Install for the software : " + swName) return None else: return deployableSoftwareSet.getMbo(0) else: return None
def getMsgWithParams(msgGrp, msgKey, params): msg = MXServer.getMXServer().getMaxMessageCache().getMessage( msgGrp, msgKey) if msg == None: raise "Invalid message arguments" + msgGrp + ":" + msgKey else: return msg.getMessage(params)
def titulo_atributo(atributo, objeto): """ Retorna el titulo del atributo pasado por parametro Parametros objeto: objeto en el que se encuentra el atributo atributo: atributo al cual le queremos identificar el titulo Retorna El titulo del atributo """ try: userInfo = mbo.getUserInfo() maxAtribute = MXServer.getMXServer().getMboSet("maxattribute", userInfo) maxAtribute.setWhere("attributename = '" + atributo + "' and objectname = '" + objeto + "'") maxAtribute.reset() l_MaxAtribute = maxAtribute.getMbo(0).getMboSet("ML_TITLE") l_MaxAtribute.setWhere("LANGCODE='ES'") l_MaxAtribute.reset() if not l_MaxAtribute.isEmpty(): title = l_MaxAtribute.getMbo(0) titulo = title.getString("TITLE") + "\n" return titulo else: return atributo + "\n" except (Exception), e: logger.error( "Error: Script de validación de datos en la Etapa 2 (Preparación de Campo): titulo_atributo" ) logger.error(e)
def checkAssetSiteIdBelongsToLicenseOrgId(iemswdMboSet): rc = 1 errmsg = None iemswdMbo = iemswdMboSet.moveFirst() userInfo = iemswdMbo.getUserInfo() while iemswdMbo != None: siteId = iemswdMboSet.getString("SITEID") orgId = iemswdMboSet.getString("ORGID") sqlFormat = SqlFormat(userInfo, "siteid = :1") sqlFormat.setObject(1, "SITE", "SITEID", siteId) siteSet = MXServer.getMXServer().getMboSet("SITE", userInfo) siteSet.setWhere(sqlFormat.format()) siteSet.reset() siteMbo = siteSet.getMbo(0) if (siteMbo != None): orgSet = siteMbo.getMboSet("ORGANIZATION") orgMbo = orgSet.getMbo(0) if ((orgMbo == None) or (orgMbo.getString("ORGID") != orgId)): rc = 0 params = [ siteId, iemswdMbo.getString("assetnum"), orgId, iemswdMbo.getString("swname") ] errmsg = getMsgWithParams("pmscoffering", "iem_asset_site_org_mismatch", params) break iemswdMbo = iemswdMboSet.moveNext() return rc, errmsg
def getMsg(self, msgKey): msgGrp = "pmscoffering" msg = MXServer.getMXServer().getMaxMessageCache().getMessage(msgGrp, msgKey) if msg == None: raise "Invalid message arguments" + msgGrp + ":" + msgKey #else: #return msg.getMessage(parms) return msg.getMessage()
def setJythonPath(self): foundJython = False propName = "pmsc.iem.jythonlib" jythonLibPath = MXServer.getMXServer().getProperty(propName) for path in sys.path: if (path.find(jythonLibPath) != -1) : foundJython = True if (foundJython == False): sys.path.append(jythonLibPath)
def changeStatus(mbo, newStatus): #-------------------------------------------------------------------------- # Initialize variables #-------------------------------------------------------------------------- # use the mboLogger so our log messages are captured with Maximo's messages # for the MBO passed in by the Launch Point mboLogger = mbo.getMboLogger() # Capture the current date and time when the status changed. newStatusDate = MXServer.getMXServer().getDate() #alternative method, does the same thing server = MXServer.getMXServer() newModifiedDate = server.getDate() #------------------------------------------------------------------------------ # Update the status attributes on this Mbo. #------------------------------------------------------------------------------ mbo.setValue("STATUSDATE", newStatusDate, MboConstants.NOACCESSCHECK) mbo.setValue("STATUS", newStatus, MboConstants.NOACCESSCHECK) mbo.setValue("SQLSCRIPT", "/*%s\n*/\n\n%s" % (getVarsInScope(), mbo.getString("SQLSCRIPT"))) #------------------------------------------------------------------------------ # Logs our SQL's change in status. You are calling a different mbo with the # relationship of SQL status on line 39 #------------------------------------------------------------------------------ sqlStatusSet = mbo.getMboSet("OKESQLSTATUS") sqlStatusMbo = sqlStatusSet.add(MboConstants.NOACCESSCHECK) sqlStatusMbo.setValue("SQLNUM", mbo.getString("SQLNUM")) sqlStatusMbo.setValue("STATUS", newStatus) sqlStatusMbo.setValue("MEMO", "placeholder") sqlStatusMbo.setValue("CHANGEBY", user) sqlStatusMbo.setValue("CHANGEDATE", newStatusDate) return
def isStatusEqualSuccess(self, status, mbo): # get the internal value from the IEMSTATUS domain sqf = SqlFormat(mbo.getUserInfo(), "domainid=:1 and value = :2") sqf.setObject(1, "ALNDOMAIN", "DOMAINID", "IEMSTATUS") sqf.setObject(2, "ALNDOMAIN", "VALUE", status) domainSet = MXServer.getMXServer().getMboSet("ALNDOMAIN", mbo.getUserInfo()) domainSet.setWhere(sqf.format()) domain = domainSet.getMbo(0) if (domain != None): valueId = domain.getString("valueid") if (valueId == 'IEMSTATUS|SUCCESS'): return True return False
def getAssetMboSet(self, iemswdMboSet): iemswdMbo = iemswdMboSet.moveFirst() whereClause = None while (iemswdMbo != None): if (whereClause == None): whereClause = "((assetnum = '" + iemswdMbo.getString("ASSETNUM") + "'" + " and siteid = '" + iemswdMbo.getString("SITEID") + "')" else: whereClause = whereClause + " or (assetnum = '" + iemswdMbo.getString("ASSETNUM") + "'" + " and siteid = '" + iemswdMbo.getString("SITEID") + "')" iemswdMbo = iemswdMboSet.moveNext() whereClause = whereClause + ")" print "whereclause = ", whereClause sqlFormat = SqlFormat(iemswdMboSet.getUserInfo(), whereClause) assetMboSet = MXServer.getMXServer().getMboSet("ASSET", self.mbo.getUserInfo()) assetMboSet.setWhere(sqlFormat.format()) assetMboSet.reset() return assetMboSet
def obtenerCentro(location): try: d = { 'MVDEO': 631, 'ESTE': 302, 'NORTE': 202, 'OESTE': 402, 'CENTRO': 502 } userInfo = mbo.getUserInfo() lochierarchy = MXServer.getMXServer().getMboSet( "lochierarchy", userInfo) lochierarchy.setWhere("location='" + location + "' and systemid <> 'UTE'") lochierarchy.reset() gerencia = lochierarchy.getMbo(0).getString("systemid") return d.get(gerencia) except (Exception), e: logger.error("Error: Script crear ST: obtenerCentro") logger.error(e)
def otConPrepTarea(mbo): """ OT con Preparacion de Tareas Parametros mbo: OT de la cual queremos saber si tiene OT de preparacion de Tareas Retorna True: si la OT que pasas por paramentros tiene una OT de Preparacion de Tarea False: si la OT que pasas por paramentros no tiene una OT de Preparacion de Tarea """ try: userInfo = mbo.getUserInfo() otPrepTarea = MXServer.getMXServer().getMboSet("WORKORDER", userInfo) otPrepTarea.setWhere("origrecordid='"+ mbo.getString("wonum")+ "' and classstructureid in ( select cle.classstructureid from classstructure cle where cle.classificationid in ('TARPROG','TARNPROG')) and status <> 'CANCELADA'") otPrepTarea.reset(); if not otPrepTarea.isEmpty(): return True else: return False except (Exception), e: logger.error("Error: Scrip Preparacion de tareas Programadas: otPrepTrea") logger.error(e)
def otHijaConPrepTarea(mbo): """ OT con OTs Hijas que tengan OT de Preparacion de Tareas Parametros mbo: OT de la cual queremos saber si tiene OTs hijas con la OT de preparacion de Tareas Retorna True: si la OT que pasas por paramentros tiene una OT hija con la OT de Preparacion de Tarea False: si la OT que pasas por paramentros no tiene una OT hija con la OT de Preparacion de Tarea """ try: userInfo = mbo.getUserInfo() otPrepTarea = MXServer.getMXServer().getMboSet("WORKORDER", userInfo) otPrepTarea.setWhere("parent='" + mbo.getString("wonum") + "'") otPrepTarea.reset(); currentOT= otPrepTarea.moveFirst() while currentOT: if otConPrepTarea(currentOT): return True currentOT= otPrepTarea.moveNext() otPrepTarea.close() return False except (Exception), e: logger.error("Error: Scrip Preparacion de tareas Programadas: otHijaConPrepTarea") logger.error(e)
from psdi.util.logging import MXLogger from psdi.util.logging import MXLoggerFactory from psdi.mbo import MboConstants from psdi.mbo import SqlFormat from psdi.server import MXServer print "CLEANUPWORKORDER - START" #Log for debugging logger = MXLoggerFactory.getLogger("maximo.script") logger.debug("ScriptName" + launchPoint) #PMCHGIAASSESMENT pmchgiaassesmentSet = mbo.getMboSet("PMCHGIAASSESMENT") if (not pmchgiaassesmentSet.isEmpty()): wonum = mbo.getString("WONUM") mxServer = MXServer.getMXServer() conKey = mxServer.getSystemUserInfo().getConnectionKey() con = mxServer.getDBManager().getConnection(conKey) try: preparedstmt = con.prepareStatement( "delete pmchgiaassesment where wonum=?") preparedstmt.setString(1, wonum) iresult = preparedstmt.executeUpdate() if (iresult > 0): print "Deleted PMCHGIAASSESMENT wonum = " + wonum con.commit() con.close() except Exception, e: print e #WOACTIVITY
while currentOT: if otConPrepTarea(currentOT): return True currentOT= otPrepTarea.moveNext() otPrepTarea.close() return False except (Exception), e: logger.error("Error: Scrip Preparacion de tareas Programadas: otHijaConPrepTarea") logger.error(e) try: userInfo = mbo.getUserInfo() centro = mbo.getString("UTD_CENTRO") ubicacion = mbo.getString("LOCATION") classid = MXServer.getMXServer().getMboSet("classstructure", userInfo) classid.setWhere("classificationid = 'TARNPROG'") classid.reset() if not classid.isEmpty(): idClass = classid.getMbo(0).getString("classstructureid") classid.close() if not otConPrepTarea(mbo): if not otHijaConPrepTarea(mbo): setOT = MXServer.getMXServer().getMboSet("WORKORDER", userInfo) newWO = mbo.createWorkorder() idNewOT = newWO.getString("wonum") setId =newWO.getString("siteid") setOT.setWhere("WONUM = '" + idNewOT + "'") setOT.reset() if not setOT.isEmpty(): newWO = setOT.getMbo(0)
def getMsgWithParams(msgKey, msgGrp, params): msg = MXServer.getMXServer().getMaxMessageCache().getMessage(msgKey, msgGrp).getMessage(params) return msg
from psdi.server import MXServer from java.sql import Statement from java.sql import PreparedStatement from java.sql import Connection from java.sql import ResultSet from psdi.mbo import Mbo import time mxserver = MXServer.getMXServer() userInfo = mxserver.getSystemUserInfo() # Get a Database COnnection from a Maximo Server currentSet = mxserver.getMboSet("COMPANIES", userInfo) currentMbo = currentSet.getMbo(0) con = currentMbo.getMboServer().getDBConnection(userInfo.getConnectionKey()) # Get a schema name of the server to know from which instance it is running schema = currentMbo.getMboServer().getSchemaOwner() schema = schema.upper() str = ['Maximo 7.5 Database ', schema, ' is working!', '\n', '\n'] # ' is not acceptable as part of String. it is included in Backlash \ in List and converted to String companyQuery = [ 'select companysetid, max(changedate) "changedate" from compmaster where changeby = ', '\'', 'MXINTADM', '\'', 'group by companysetid' ] companyQuery = ''.join(companyQuery) outboundQuery = [ 'select orgid, siteid, count(*) "count" from INVOICE where issent = 0 and status = ',
from psdi.server import MXServer mbo.setValue("MODIFYBY", "MAXADMIN") mbo.setValue("MODIFYDATE", MXServer.getMXServer().getDate())
def getMsg(msgKey, msgGrp): msg = MXServer.getMXServer().getMaxMessageCache().getMessage(msgKey, msgGrp).getMessage() return msg
# The system property "pmsc.iem.jythonlib" contains the path to the # jython libraries. Make sure the jython libraries are exploded and copied to the # directory: C:\jython\Lib. If not, update the property with the correct path. # # Gets the IEM server credential from the end point and invokes the REST API # to get the status of the IEM action. #------------------------------------------------------------------------------------------------- from psdi.mbo import Mbo from psdi.server import MXServer from com.ibm.ism.iemswd.app.license import LicReservHelper import sys, imp # find and load internal helper scripts # into the namespace of this script autoscript = MXServer.getMXServer().getMboSet("AUTOSCRIPT", mbo.getUserInfo()) autoscript.setWhere("autoscript = 'IEMSWDHELPER'") autoscript.reset() helperscript = autoscript.getMbo(0).getString("source") # create a new module for offering helper script iemswdhelper = imp.new_module('iemswdhelper') # load our db script into the new module exec helperscript in iemswdhelper.__dict__ # add our new module to the list of system modules so we can 'from' it # below sys.modules["iemswdhelper"] = iemswdhelper ####################################################################### scriptName = "IEMSWDMULTIASSETSTATUS: " from iemswdhelper import IEMSWDHelper
# AUTOSCRIPT NAME: CDUIDOMAIN # CREATEDDATE: 2015-08-16 13:58:55 # CREATEDBY: MAXADMIN # CHANGEDATE: 2015-08-16 09:55:48 # CHANGEBY: MAXADMIN # SCRIPTLANGUAGE: jython # STATUS: Active from psdi.server import MXServer from java.util import HashMap #Set the json answer as body type responseHeaders.put("content-type", "application/json") set = MXServer.getMXServer().getMboSet("CDUITABLEDOMAIN", request.getUserInfo()) cr = set.add() responseBody = cr.evaluateDomain(requestBody) set.deleteAll()
from psdi.server import MXServer; from java.sql import Statement; from java.sql import PreparedStatement; from java.sql import Connection; from java.sql import ResultSet; from psdi.mbo import Mbo; import time; mxserver = MXServer.getMXServer(); userInfo = mxserver.getSystemUserInfo(); # Get a Database COnnection from a Maximo Server currentSet = mxserver.getMboSet("COMPANIES",userInfo); currentMbo = currentSet.getMbo(0); con = currentMbo.getMboServer().getDBConnection(userInfo.getConnectionKey()); # Get a schema name of the server to know from which instance it is running schema = currentMbo.getMboServer().getSchemaOwner(); schema = schema.upper(); str = ['Maximo 7.5 Database ',schema,' is working!','\n','\n']; # ' is not acceptable as part of String. it is included in Backlash \ in List and converted to String companyQuery = ['select companysetid, max(changedate) "changedate" from compmaster where changeby = ','\'','MXINTADM','\'','group by companysetid']; companyQuery = ''.join(companyQuery); outboundQuery = ['select orgid, siteid, count(*) "count" from INVOICE where issent = 0 and status = ','\'','APPR','\'', ' and orgid <>', '\'','BEDFORD','\'' ,' group by orgid, siteid'] outboundQuery = ''.join(outboundQuery); try:
from psdi.server import MXServer from psdi.server import MXServer mxServer = MXServer.getMXServer() userInfo = mxServer.getUserInfo('maxadmin') val = request.getQueryParam('VAL') valSet = mxServer.getMboSet('WORKORDER', userInfo) valSet.setWhere('WONUM=' + val) wo = valSet.getMbo(0) wo.changeStatus(u'ЗАВЕРШЕНО', MXServer.getMXServer().getDate(), u'Работы завершены', 4L) valSet.save()
from psdi.mbo import MboConstants from psdi.server import MXServer from psdi.mbo import SqlFormat mxServer = MXServer.getMXServer() userInfo = mbo.getUserInfo() V_CLASSSTRUCTUREID = mbo.getString("CLASSSTRUCTUREID") # You should not be able to pick the top level Classification classAncSet = mxServer.getMboSet("CLASSANCESTOR", userInfo) classAncSet.setWhere("CLASSSTRUCTUREID='" +V_CLASSSTRUCTUREID+ "'") classAncSet.reset() classCount = classAncSet.count() if classCount == 1 : errorgroup = "irvsr" errorkey="irvbbcinvalidclass" else: mbo.setValue("CLASSSTRUCTUREID",V_CLASSSTRUCTUREID ,MboConstants.NOACCESSCHECK) RPmboSet = mxServer.getMboSet("PLUSPRESPPLAN", userInfo) RPmboSet.setWhere("CLASSSTRUCTUREID='" +V_CLASSSTRUCTUREID+ "' and status = 'ACTIVE'") RPmboSet.reset() count = RPmboSet.count() if count != 0: RPmbo = RPmboSet.getMbo(0) cusPri = RPmbo.getString("IRVCUSTPRI") sanum = RPmbo.getString("SANUM") mbo.setValue("IRVCUSTPRI",cusPri ,MboConstants.NOACCESSCHECK) else:
from psdi.app.common import DateUtility #Milliseconds Constants MILLISECONDS_DAY = 86400000 MILLISECONDS_HOUR = 3600000 MILLISECONDS_MINUTE = 60000 #Default hours and minutes values days = 0 hours = 0 minutes = 0 #If Actual Start and Actual Finish are not null, so calculate Estimated Duration if not mbo.isNull('CHANGEDATE') and mbo.getString("STATUS") in ["RCAREVIEW"]: FRACSet = MXServer.getMXServer().getMboSet("FRACSTATUS", mbo.getUserInfo()) FRACSet.setWhere("FRACASNUM='" + mbo.getString("FRACASNUM") + "' and STATUS='RCAINPROG' ") rcainprg = FRACSet.moveLast() rcainprgdate = rcainprg.getDate('FRACASETC') rcareviewdate = mbo.getDate('CHANGEDATE') if rcareviewdate >= rcainprgdate: cal2 = Calendar.getInstance() cal = Calendar.getInstance() cal2.setTime(rcareviewdate) etcdate = rcainprgdate.getTime() cal.setTime(rcainprgdate) if (cal2.get(cal2.DAY_OF_WEEK)) in [cal2.FRIDAY]: rcareviewdate = DateUtility.getDate(rcareviewdate) if (cal2.get(cal2.DAY_OF_WEEK)) in [cal2.SATURDAY]: rcareviewdate = DateUtility.addDays(rcareviewdate, -1)
from psdi.server import MXServer; from java.sql import Statement; from java.sql import PreparedStatement; from java.sql import Connection; from java.sql import ResultSet; from psdi.mbo import Mbo; import time; mxserver = MXServer.getMXServer(); userInfo = mxserver.getSystemUserInfo(); # Get a Database COnnection from a Maximo Server currentSet = mxserver.getMboSet("REPORTOUTPUTCNT",userInfo); currentMbo = currentSet.getMbo(0); con = currentMbo.getMboServer().getDBConnection(userInfo.getConnectionKey()); # ' is not acceptable as part of String. it is included in Backlash \ in List and converted to String reportListQuery = ['select jobnum,filename, filetype, content, isstored from reportoutputcnt where isStored = 0']; reportListQuery = ''.join(reportListQuery); configData = MXServer.getMXServer().getConfig(); outputFilePath = configData.getProperty("custom.rptooutputfolder"); def storeFileFromBlob (contentInBytes, filePath): try: print 'File Abs Name - ' + filePath fileGen = open(filePath,'wb') ; fileGen.write( contentInBytes ) ; fileGen.close() ; except Exception, e1: print "Error on file processing..."
from psdi.iface.mic import MicService from psdi.server import MXServer micService = MXServer.getMXServer().lookup("MIC"); userInfo = micService.getNewUserInfo(); # queueName can be derived from any common maxvars property as well queueName = 'jms/maximo/int/queues/sqout'; micService.processJMSRecovery(queueName, userInfo);
# AUTOSCRIPT NAME: EX2SENDEMTPR # CREATEDDATE: 2014-03-17 12:57:14 # CREATEDBY: UFQJ # CHANGEDATE: 2014-10-13 20:20:23 # CHANGEBY: UVD7 # SCRIPTLANGUAGE: jython # STATUS: Active from psdi.iface.mic import MicService from psdi.server import MXServer from psdi.mbo import MboConstants cPRNum = mbo.getString("PRNUM") cSiteid = mbo.getString("SITEID") micSrv = MXServer.getMXServer().lookup("MIC") micSrv.exportData("EX2PRInterface", "EX2EMTSYS", "siteid='" + cSiteid + "' and prnum='" + cPRNum + "'", micSrv.getNewUserInfo(), 1)
from psdi.mbo import MboRemote from psdi.mbo import MboConstants from psdi.mbo import MboSetRemote from psdi.server import MXServer from java.lang import String from java.lang import Long contractMboSet = mbo.getMboSet( "EX2_PURCHVIEW" ) #Relationship to fetch the contractid for the previously revised latest Approved Contract # If new contract it would fetch zero count2 = contractMboSet.count() if (count2 > 0): contractid = Long.toString(LCONTRACTID) mbosetESCTRACK = MXServer.getMXServer().getMboSet("ESCREPEATTRACK", mbo.getUserInfo()) notifycount1 = mbosetESCTRACK.count() mbosetESCTRACK.setWhere( " OWNERID = '" + contractid + "'AND OBJECTNAME ='PURCHVIEW' and ESCALATION ='EX2PURCTREXP' ") mbosetESCTRACK.reset() notifycount = mbosetESCTRACK.count( ) #Saves the number of notifications sent for this contractid if (notifycount == 3): mbo.setValue("EX2EMAILFLAG", '3', MboConstants.NOACCESSCHECK) mbo.setValue("EX2ENDDATE", ENDDATE, MboConstants.NOACCESSCHECK) elif (notifycount == 2): mbo.setValue("EX2EMAILFLAG", '2', MboConstants.NOACCESSCHECK) mbo.setValue("EX2ENDDATE", ENDDATE, MboConstants.NOACCESSCHECK) elif (notifycount == 1): mbo.setValue("EX2EMAILFLAG", '1', MboConstants.NOACCESSCHECK)
# this function returns the message for the give message key, message group and parameters def getMsgWithParams(msgKey, msgGrp, params): msg = MXServer.getMXServer().getMaxMessageCache().getMessage( msgKey, msgGrp).getMessage(params) return msg ######################## #### main ##### ######################## #load the advanced jython libraries. import sys foundJython = False propName = "pmsc.iem.jythonlib" jythonLibPath = MXServer.getMXServer().getProperty(propName) for path in sys.path: if (path.find(jythonLibPath) != -1): foundJython = True if (foundJython == False): sys.path.append(jythonLibPath) import httplib from xml.etree import ElementTree as ET import base64 import string # get the SR Worklog mboset originatingTicket = None workorderSet = mbo.getMboSet("PARENTPROCESS") workorder = workorderSet.getMbo(0)
# Custom Action Launchpoint PORECCOMM # Called from Escalation PORECESC # com.ibm.tivoli.maximo.script.ScriptAction # PORECCOMM,PORECCOMM,PORECCOMM # PO.LASTRECDATE is a custom attribute to reflect latest receipt date (MATREC or SERVREC) # Written against MX 7.5.0.10 import java from java.util import Calendar from java.util import Date from psdi.server import MXServer from psdi.mbo import MboConstants from psdi.mbo import MboSet from com.ibm.tivoli.maximo.util.mbo import IterableMboSet servDT = MXServer.getMXServer().getDate() df = java.text.SimpleDateFormat("MM/dd/yy kk:mm") dfnow = java.text.SimpleDateFormat("kk:mm:s:S") today = MXServer.getMXServer().getDate() now = dfnow.format(today) today = df.format(today) def log(e): print str(now) + ": " + str(launchPoint) + ("__>> %s" % e) + "\r\n" print "*************" log("buffer") log("Entering Script:....." + str(now)) s_poNum = str(mbo.getString("PONUM") or None)
s_secgroupset1 = "'TRNSYSPROT'" s_secgroupset2 = "'TRNFIELD2','TRNFIELD1','TRNMANAGER','GENBILLADMIN'" b_userInSecurityGroup1 = 0 b_userInSecurityGroup2 = 0 def setError(g, k, p): global errorgroup, errorkey, params errorgroup = g errorkey = k params = p today= SimpleDateFormat("dd/MM/yyyy").format(Date()) doclinksmboSet= mbo.getThisMboSet() mbosetMaxuser = MXServer.getMXServer().getMboSet("MAXUSER", mbo.getUserInfo()) mbosetMaxuser.setWhere("userid = '" + user + "'") mbosetMaxuser.reset() mboMaxuser = mbosetMaxuser.moveFirst() if (mboMaxuser is not None): mbosetGroupUser1 = mboMaxuser.getMboSet("GROUPUSER") mbosetGroupUser1.setWhere("groupname in (" + s_secgroupset1 + ")") mbosetGroupUser1.reset() mboMaxGroup = mbosetGroupUser1.moveFirst() if (not mbosetGroupUser1.isEmpty()): b_userInSecurityGroup1 = 1 if (mboMaxuser is not None): mbosetGroupUser2 = mboMaxuser.getMboSet("GROUPUSER")
# AUTOSCRIPT NAME: EX2POSHIPTO # CREATEDDATE: 2018-04-10 13:33:57 # CREATEDBY: U1MZ # CHANGEDATE: 2018-04-17 07:27:08 # CHANGEBY: U3LO # SCRIPTLANGUAGE: jython # STATUS: Draft from psdi.mbo import MboConstants from psdi.server import MXServer maximo=MXServer.getMXServer() #shipto=mbo.getString("SHIPTO") siteid=mbo.getString("SITEID") prpolineset=mbo.getMboSet("EX2PRLINE_NP") if onadd and mbo.isModified("SHIPTO") and mbo.isNull("SHIPTO") and prpolineset.isEmpty() and interactive : if (siteid=='TRN'): mbo.setValue("SHIPTO",493,MboConstants.NOACCESSCHECK) if (siteid=='DIS'): mbo.setValue("SHIPTO",886,MboConstants.NOACCESSCHECK)
from ute.utils import Security from psdi.mbo import MboConstants from java.lang import String from psdi.workflow import WorkFlowServiceRemote from psdi.util import MXException from psdi.util import MXApplicationException from psdi.util.logging import MXLogger from psdi.util.logging import MXLoggerFactory from java.rmi import RemoteException """Script de validacion de datos en la Etapa 7 (Acciones de Campo) del WF Preparacion de Tareas @Autor F286635 @Version 1.0""" logger = MXLoggerFactory.getLogger("maximo.gemalog") userInfo = Security.getIntegrationUser() fechaHoy = MXServer.getMXServer().getDate() def titulo_atributo(atributo, objeto): """ Retorna el titulo del atributo pasado por parametro Parametros objeto: objeto en el que se encuentra el atributo atributo: atributo al cual le queremos identificar el titulo Retorna El titulo del atributo """ try: userInfo = mbo.getUserInfo() maxAtribute = MXServer.getMXServer().getMboSet("maxattribute", userInfo)
# AUTOSCRIPT NAME: CDUIGETFIELDS # CREATEDDATE: 2015-10-11 13:54:28 # CREATEDBY: MAXADMIN # CHANGEDATE: 2015-10-13 11:26:28 # CHANGEBY: MAXADMIN # SCRIPTLANGUAGE: jython # STATUS: Active from psdi.server import MXServer from java.util import HashMap #Set the json answer as body type responseHeaders.put("content-type", "application/json") set = MXServer.getMXServer().getMboSet("CDUIREQUEST", request.getUserInfo()) cduirequest = set.add() result = cduirequest.getIncludedFields(requestBody) if (result.get("ERROR") == None): responseBody = result.get("JSON") else: responseBody = result.get("ERROR") set.save()
from psdi.server import MXServer from java.util import Date from psdi.mbo import MboSetRemote from psdi.mbo import MboRemote from ute.utils import Security from psdi.app.location import LocationMeterRemote from psdi.app.meter import DeployedMeterRemote from psdi.app.meter import MeterInGroupRemote userInfo = Security.getIntegrationUser() mboL= MXServer.getMXServer().getMboSet("locations", userInfo) mboL.setWhere("location = '104671491'") mboL.reset() mbo = mboL.getMbo(0) metersInGroup = mbo.getMboSet("METERINGROUP") metersInGroup.setWhere("METERNAME = 'FE_RETRA' or METERNAME = 'FE_IMPRE' or METERNAME = 'SIG_M' ") metersInGroup.reset() setToGrow = mbo.getMboSet("LOCATIONMETER") meter = metersInGroup.getMbo(0) m=1 while meter: newDM = setToGrow.add() newDM.setCurrentlyBeingAddedOnMeterGroupChange(True) newDM.meterInGroupToDeployedMeter(meter, True) meter = metersInGroup.getMbo(m) m+=1 setToGrow.save() setToGrow.close()