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 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 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 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
#WOACTIVITY woactivitySet = mbo.getMboSet("WOACTIVITY") if (not woactivitySet.isEmpty()): i = 0 woactivityMbo = woactivitySet.getMbo(i) while (woactivityMbo is not None): #WOACTIVITY - CHILDREN wochildrenSet = woactivityMbo.getMboSet("CHILDREN") if (not wochildrenSet.isEmpty()): wochildrenSet.deleteAll(MboConstants.NOACCESSCHECK) #WOACTIVITY - WFINSTANCE strownertable = woactivityMbo.getString("WOCLASS") strownerid = woactivityMbo.getString("WORKORDERID") sqlf = SqlFormat("ownertable=:1 and ownerid=:2") sqlf.setObject(1, "WOACTIVITY", "WOCLASS", strownertable) sqlf.setObject(2, "WOACTIVITY", "WORKORDERID", strownerid) wfinstanceSet = woactivityMbo.getMboSet("$wfinstance", "WFINSTANCE", sqlf.format()) if (not wfinstanceSet.isEmpty()): wfinstanceSet.deleteAll(MboConstants.NOACCESSCHECK) #WOACTIVITY - WORKLOG worklogSet = woactivityMbo.getMboSet("MODIFYWORKLOG") if (not worklogSet.isEmpty()): worklogSet.deleteAll(MboConstants.NOACCESSCHECK) #WOACTIVITY - COMMLOG commlogSet = woactivityMbo.getMboSet("COMMLOG") if (not commlogSet.isEmpty()):
from psdi.util.logging import MXLogger from psdi.util.logging import MXLoggerFactory from psdi.mbo import MboConstants from psdi.mbo import SqlFormat print "CLEANUPTICKET - START" #Log for debugging logger = MXLoggerFactory.getLogger("maximo.script"); logger.debug("ScriptName" + launchPoint) #WFINSTANCE strownertable = mbo.getString("CLASS") strownerid = mbo.getString("TICKETUID") sqlf = SqlFormat("ownertable=:1 and ownerid=:2") sqlf.setObject(1, "TICKET","CLASS", strownertable) sqlf.setObject(2, "TICKET", "TICKETUID", strownerid) wfinstanceSet = mbo.getMboSet("$wfinstance", "WFINSTANCE", sqlf.format()) #wfinstanceMbo = commTemplateSet.getMbo(0) if (not wfinstanceSet.isEmpty()): wfinstanceSet.deleteAll(MboConstants.NOACCESSCHECK) #WORKLOG worklogSet = mbo.getMboSet("MODIFYWORKLOG") if (not worklogSet.isEmpty()): worklogSet.deleteAll(MboConstants.NOACCESSCHECK) #COMMLOG commlogSet = mbo.getMboSet("COMMLOG") if (not commlogSet.isEmpty()): commlogSet.deleteAll(MboConstants.NOACCESSCHECK)
from psdi.mbo import MboSetRemote from psdi.mbo import SqlFormat from java.util import GregorianCalendar WEEKDAYS = ["ZONDAG","MAANDAG", "DINSDAG", "WOENSDAG", "DONDERDAG", "VRIJDAG", "ZATERDAG"] cal=Calendar.getInstance() cal.setTime(mbo.getDate('STARTDATE')) destMboSet = mbo.getMboSet("NTPLANARRIVAL") if not destMboSet.isEmpty(): destMboSet.deleteAll() for x in range(7): if x>0: cal.add(Calendar.DATE,1) weekday=WEEKDAYS[ cal.get( Calendar.DAY_OF_WEEK )-1] headerMboSet = mbo.getMboSet("NTPLANHEADER") sqf = SqlFormat("ntday = :1 and ntvalidfrom <= :2 and :2 <= ntvalidto") sqf.setObject(1, "NTPLANHEADER", "NTDAY", weekday) sqf.setDate(2, cal.getTime()) headerMboSet.setWhere(sqf.format()) headerMboSet.reset() if not headerMboSet.isEmpty(): headerMbo = headerMboSet.moveFirst() sourceMboSet = headerMbo.getMboSet("NTPLANSCHEDULE"); if not sourceMboSet.isEmpty(): sourceMbo=sourceMboSet.moveFirst() while sourceMbo: destMbo = destMboSet.add() destMbo.setValue("LOCATION", sourceMbo.getString("LOCATION")) destMbo.setValue("NTARRTRACK", sourceMbo.getString("NTARRTRACK")) destMbo.setValue("NTDEPTRACK", sourceMbo.getString("NTDEPTRACK"))
#Get the user Id as header parameter userID = request.getQueryParam("userid") print "CDUIRESETPSW: userid from request userID:", userID if (userID == None): responseHeaders.put("OPCODE", "1") responseHeaders.put("OPMSG", "Missing user ID") print "CDUIRESETPSW: missing userID" elif (sigService == None): responseHeaders.put("OPCODE", "2") responseHeaders.put("OPMSG", "Internal error") print "CDUIRESETPSW: missing signature service" else: uInfo = MXServer.getMXServer().getUserInfo(userID) set = MXServer.getMXServer().getMboSet("MAXUSER", uInfo) s = SqlFormat(uInfo, "userid = :1") s.setObject(1, "MAXUSER", "userid", userID) set.setWhere(s.format()) set.reset() if (set.isEmpty()): responseHeaders.put("OPCODE", "3") responseHeaders.put("OPMSG", "User does not exist") print "CDUIRESETPSW: userid not matching any entry" else: user = set.getMbo(0) setPSW = user.getMboSet("MYPROFILECHANGEPASSWORDS") pswMbo = setPSW.add() newPassword = sigService.generatePassword(userID, uInfo) print "CDUIRESETPSW: password generated" user.setValue( "passwordinput", newPassword,
# AUTOSCRIPT NAME: EX2LCCTRLACCT # CREATEDDATE: 2014-04-30 10:00:54 # CREATEDBY: UFQJ # CHANGEDATE: 2014-10-13 20:18:59 # CHANGEBY: UVD7 # SCRIPTLANGUAGE: jython # STATUS: Active from psdi.mbo import MboConstants from psdi.mbo import SqlFormat sqf = SqlFormat("orgid=:1 and DFLTGROUP=:2 and GROUPVALUE=:3") sqf.setObject(1, "ACCOUNTDEFAULTS", "ORGID", mbo.getString("orgid")) sqf.setObject(2, "ACCOUNTDEFAULTS", "DFLTGROUP", "LABORREC") sqf.setObject(3, "ACCOUNTDEFAULTS", "GROUPVALUE", "LABORRECACCT") accountDefaultsSet = mbo.getMboSet("$ACCOUNTDEFAULS", "ACCOUNTDEFAULTS", sqf.format()) if accountDefaultsSet.count() > 0: accLContAccMbo = accountDefaultsSet.getMbo(0) mbo.setValue("controlaccount", accLContAccMbo.getString("GLDefault"), MboConstants.NOACCESSCHECK)
def setError(): global errorkey, errorgroup, params errorkey = 'invalidStatusForThisMove' errorgroup = 'asset' if interactive: prevloc = mbo.getString("LOCATION") prevloc1 = mbo.getMboValue("LOCATION").getPreviousValue().asString() if prevloc != prevloc1: loc = mbo.getMboSet("NEWLOCATION").getMbo(0) if (loc != "" or loc is not None) and mbo.getString("SITEID") == "MS": assetnum = mbo.getString("ASSETNUM") sqf = SqlFormat("location=:1 and siteid=:2") sqf.setObject( 1, "LOCATIONS", "LOCATION", mbo.getMboValue("LOCATION").getPreviousValue().asString()) sqf.setObject(2, "LOCATIONS", "SITEID", mbo.getString("SITEID")) fromLoc = mbo.getMboSet("$newlocation", "LOCATIONS", sqf.format()).getMbo(0) fromlocation = fromLoc.getString("LOCATION") fromlocationtype = fromLoc.getString("TYPE") loclocation = loc.getString("LOCATION") loclocationtype1 = loc.getString("TYPE") sqlfmt = SqlFormat(
crontaskinst.setValue( "HASLD", 0, MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION) crontaskinst.setValue( "AUTOREMOVAL", True, MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION) print "have set all cron task instance values for REPORTSCHEDULE cron task" reportsched.setValue( "CRONTASKNAME", crontaskinst.getString("CRONTASKNAME")) reportsched.setValue( "INSTANCENAME", crontaskinst.getString("INSTANCENAME")) print "Now going to work with Cron task PARAMETERS" cronparamset = crontaskinst.getMboSet("PARAMETER") if cronparamset is not None: sqf = SqlFormat(cronparamset.getUserInfo(), "reportname=:1") sqf.setObject(1, "REPORTPARAM", "REPORTNAME", reportname) reportparamset = MXServer.getMXServer().getMboSet( "REPORTPARAM", cronparamset.getUserInfo()) if reportparamset is not None: print "working with REPORTPARAM mbo set" reportparamset.setWhere(sqf.format()) reportparamset.reset() i = reportparamset.count() reportparammbo = None for j in range(i): reportparam = reportparamset.getMbo(j) cronparam = cronparamset.add( MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION)