# Java Source: gov.bart.maximo.plust.webclient.beans.plustwo.PlusAWOAppBean.java # Replace the function: removevirtualasset # App design: # By Eric. DR 2193 from psdi.app.workorder import WORemote; from psdi.mbo import MboConstants; from psdi.mbo import MboRemote; from psdi.mbo import MboSetRemote; from psdi.plust.app.workorder import PlusTWOCommonInterface; from psdi.plust.webclient.beans.plustwo import PlusTRecentnRepeatRepairsUtil; from psdi.plust.webclient.beans.plustwo import PlustRecentnRepeatRepairsHolder; from psdi.server import MXServer; from psdi.util import CommonUtil; from psdi.util import MXException; from psdi.util.logging import FixedLoggers; from psdi.util.logging import MXLogger; from psdi.webclient.system.beans import DataBean; from psdi.webclient.system.controller import ControlInstance; from psdi.webclient.system.controller import Utility, SessionContext, WebClientEvent; from psdi.plusa.webclient.beans.workorder import PlusAWOAppBean; from psdi.common.context import UIContext; import sys def setError(p0,p1,p2): global errorkey,errorgroup,params errorkey ='InfoParameters3'; errorgroup='AutoScript'; params=[p0,p1,p2]; teststr="0"; wonum = ""; problemCode=""; failureCode=""; newMbo = None; logSet = None; thisMbo = None; woRemote = None; thisService = None; virAsstNbr = ""; OrigWonum = ""; try: teststr="1"; thisService = service; # @UndefinedVariable tag thisMbo = mbo; # @UndefinedVariable tag #thisMbo.setFieldFlag("REMVRASTNUM", 128L, True); #thisMbo.setFieldFlag("VRSERIALNUM", 128L, True); #thisMbo.setFieldFlag("VRSERIALNUMI", 128L, True); #thisMbo.setFieldFlag("REMREASON", 128L, True); #thisMbo.setFieldFlag("COMP_RM_DRVR_NP", 128L, True); #thisMbo.setFieldFlag("PLUSTREASON_NP", 128L, True); teststr="1.1"; UIContext.getCurrentContext().getWebClientSession().getCurrentApp().getResultsBean().checkESigAuthenticated("REMOVEVASST"); teststr="1.2"; woRemote = UIContext.getCurrentContext().getWebClientSession().getCurrentApp().getResultsBean().getMbo(); wonum = thisMbo.getString("wonum"); teststr = "1.5"; mxserver1 = UIContext.getCurrentContext().getWebClientSession().getCurrentApp().getResultsBean().getMXSession().getMXServerRemote(); teststr = "1.6"; repairFacilityEnabled = CommonUtil.isRepairFacilityEnabled(woRemote, mxserver1); teststr="2"; virAsstNbr = thisMbo.getString("REMVRASTNUM"); teststr="2.1"; if (virAsstNbr is not None): remReason = thisMbo.getString("REMREASON"); teststr="2.2"; assetDesc = thisMbo.getMboSet("VIRASSET").getMbo(0).getString("DESCRIPTION"); teststr="2.3"; remDriver = thisMbo.getString("COMP_RM_DRVR_NP"); teststr="2.4"; plustRsn = thisMbo.getString("PLUSTREASON_NP"); virAstSerNbr = thisMbo.getString("VRSERIALNUM"); virAstSerNbrI = thisMbo.getString("VRSERIALNUMI"); parentLocation = thisMbo.getString("LOCATION"); teststr="3"; teststr="4"; if (repairFacilityEnabled and woRemote is not None and ( woRemote.isNull("repairfacility") or woRemote.isNull("repfacsiteid") ) ) : teststr="4.11"; UIContext.getCurrentContext().getWebClientSession().loadDialog("createWOWithRepFacility"); teststr="4.12" ; else : teststr="4.21"; newMbo = woRemote.createWorkorder(woRemote.getThisMboSet(),None, False); teststr="5"; OrigWonum = woRemote.getString("WONUM"); origWOSet = newMbo.getMboSet("ORIGWO"); whereStr = "wonum='"+ OrigWonum +"' "; origWOSet.setWhere(whereStr); origWOSet.reset(); teststr="5.6" ; origWo = origWOSet.getMbo(0); teststr="5.61" ; problemCode = origWo.getString("PROBLEMCODE"); teststr="5.62" ; failureCode = origWo.getString("FAILURECODE"); teststr="5.63" ; origAssetnum = origWo.getString("ASSETNUM"); teststr="6"; #woRemote.setValue("PROBLEMCODE", problemCode,MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION ); #woRemote.setValue("FAILURECODE", failureCode,MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION_AND_NOACTION ); teststr="7"; # Set Values to follow up WO newMbo.setValue("ASSETNUM",virAsstNbr, MboConstants.NOVALIDATION_AND_NOACTION_ALLOWCROSSOVER); newMbo.setValue("SERIALNUM2", virAstSerNbr); newMbo.setValue("WORKTYPE", "CM"); newMbo.setValue("DESCRIPTION", remReason); newMbo.setValue("COMP_RM_DRVR", remDriver, MboConstants.NOACCESSCHECK); newMbo.setValue("PLUSTREASON", plustRsn, MboConstants.NOACCESSCHECK); newMbo.setValue("SERIALNUM", virAstSerNbrI); newMbo.setValue("PROBLEMCODE", "", MboConstants.NOVALIDATION | MboConstants.NOVALIDATION_AND_NOACTION); newMbo.setValue("FAILURECODE", "", MboConstants.NOVALIDATION | MboConstants.NOVALIDATION_AND_NOACTION); # Redmin: Feature #2339, the following line is originally dupllcated, replace it for priority = 9. newMbo.setValue("WOPRIORITY", 9); teststr="9"; # newMbo.setValue("WORKLOCATION", moveToLoc); # Set Harvest Location based on parent location if location is RSS if (parentLocation== "RSS"): teststr="9.1"; newMbo.setValue("LOCATION", "OHY-HRVST",11L); teststr="9.5"; # Set the functional department of new workorder to Asset's department newMbo.setValue("BARTDEPT",newMbo.getMboSet("ASSET").getMbo(0).getString("BARTDEPT") ); teststr="A"; # Reset the mandatory flags thisMbo.setFieldFlag("REMVRASTNUM", 128L, False); thisMbo.setFieldFlag("VRSERIALNUM", 128L, False); thisMbo.setFieldFlag("VRSERIALNUMI", 128L, False); thisMbo.setFieldFlag("REMREASON", 128L, False); thisMbo.setFieldFlag("COMP_RM_DRVR_NP", 128L, False); thisMbo.setFieldFlag("PLUSTREASON_NP", 128L, False); teststr="B"; newMbo.getThisMboSet().save(); teststr="B.1"; woRemote.getThisMboSet().save(); UIContext.getCurrentContext().getWebClientSession().getCurrentApp().getResultsBean().save(); #UIContext.getCurrentContext().getWebClientSession().getCurrentApp().save(); teststr="B.2"; #if (logSet is not None and not logSet.isEmpty()): # logSet.close(); teststr="C"; context = UIContext.getCurrentContext(); if context: teststr="C2"; wcs = context.getWebClientSession(); teststr="C3"; Utility().sendEvent(WebClientEvent("dialogclose", wcs.getCurrentPageId(), None, SessionContext(wcs))); else: teststr="D.2"; context = UIContext.getCurrentContext(); if context: wcs = context.getWebClientSession(); Utility().sendEvent(WebClientEvent("dialogclose", wcs.getCurrentPageId(), None, SessionContext(wcs))); #Utility.sendEvent( WebClientEvent("dialogclose", thisMbo.app.getCurrentPageId(), None, thisMbo.sessionContext)); except Exception, e: setError("Error after: "+ teststr , sys.exc_info()[0], ", wonum=" + wonum +", OrigMO: "+ OrigWonum);