def getParmID(self, parmNameAndLevel, databaseID): index = string.find(parmNameAndLevel, "_") if index == -1: name = parmNameAndLevel level = "SFC" parm = ParmID(name, databaseID, level) else: name = parmNameAndLevel[0:index] level = parmNameAndLevel[index + 1:] parm = ParmID(name, databaseID, level) return parm
def initParms(self): dm = self.dm btext = self.getConfig('Png_parms', []) if len(btext) == 0: LogStream.logProblem("Png_parms missing or empty") raise UserWarning, "Png_parms missing or empty" if "Topo" in btext: self._topo = 1 btext.remove("Topo") ip = self.getConfig('Png_image', None) if ip == "Topo": self._topo = 1 # Attempt to decode pseudo parms in the config file from com.raytheon.uf.common.dataplugin.gfe.db.objects import ParmID from com.raytheon.uf.common.dataplugin.gfe.weatherelement import WEItem, WEGroup wegroup = WEGroup() wegroup.setName('png') weItems = jep.jarray(len(btext), WEItem) for i in range(len(btext)): text = btext[i].split(' ') parmid = text[0] + '_00000000_0000' parmid = string.replace(parmid, ':', ':SITE_GRID_') cycles = text[1] p = ParmID(parmid) weItems[i] = WEItem(p, int(cycles)) wegroup.setWeItems(weItems) # make the text file # id = AFPS.TextFileID("png",'BUNDLE') # txtfile = AFPS.TextFile(id, ctext) # process the bundle dbIDs = dm.getParmManager().getAvailableDbs() availableParmIDs = [] for i in range(dbIDs.size()): dbID = dbIDs.get(i) nextAvailable = dm.getParmManager().getAvailableParms(dbID) for next in nextAvailable: availableParmIDs.append(next) size = len(availableParmIDs) jparmIds = jep.jarray(size, ParmID) for i in range(size): jparmIds[i] = availableParmIDs[i] vv = dm.getWEGroupManager().getParmIDs(wegroup, jparmIds) if len(vv) == 0: LogStream.logProblem("Png_parms contains no valid weather " + "elements") raise UserWarning, "Png_parms contains no valid weather elements" return vv
def __init__(self, histoSampler): self._histoSampler = histoSampler if type(histoSampler) is types.DictionaryType: try: sampler = histoSampler[histoSampler.keys()[0]] except IndexError: sampler = None else: sampler = histoSampler self.__parmID = sampler.getParmID() if self.__parmID.equals(ParmID()): self.__parmID = None
def __convertJavaObjToPyWrapper(self, javaObj): objtype = javaObj.java_name if objtype == "com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID": retVal = DatabaseID.DatabaseID(javaObj) elif objtype == "com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID": retVal = ParmID.ParmID(javaObj) elif objtype == "com.raytheon.uf.common.time.TimeRange": retVal = TimeRange.TimeRange(javaObj) else: retVal = None return retVal
def __init__(self, name=None, model=None, dbid=None, level=None, jParmId=None): if jParmId is not None: self.__pid = jParmId elif name is None: if model is None and dbid is None and level is None: self.__pid = JavaParmId() else: raise ValueError, '"name" must be given if any arguments are supplied.' else: if dbid is None and model is None and level is None: # name is an ident string self.__pid = JavaParmID(name) elif dbid is None and model is None: raise ValueError, '"level" cannot be specified without "dbid" or "model".' elif dbid is not None and model is not None: raise ValueError, '"model" and "dbid" cannot both be specified.' elif dbid is not None: # assume it is a DatabaseID.DatabaseID dbid = dbid.toJavaObj() if level is None: self.__pid = JavaParmID(name, dbid) else: self.__pid = JavaParmID(name, dbid, level) else: if level is None: self.__pid = JavaParmID(name, model) else: self.__pid = JavaParmID(name, model, level)
def defaultLevel(): return JavaParmID.defaultLevel()
class ParmID(JUtil.JavaWrapperClass): "Wrapper class for com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID" def __init__(self, name=None, model=None, dbid=None, level=None, jParmId=None): if jParmId is not None: self.__pid = jParmId elif name is None: if model is None and dbid is None and level is None: self.__pid = JavaParmId() else: raise ValueError, '"name" must be given if any arguments are supplied.' else: if dbid is None and model is None and level is None: # name is an ident string self.__pid = JavaParmID(name) elif dbid is None and model is None: raise ValueError, '"level" cannot be specified without "dbid" or "model".' elif dbid is not None and model is not None: raise ValueError, '"model" and "dbid" cannot both be specified.' elif dbid is not None: # assume it is a DatabaseID.DatabaseID dbid = dbid.toJavaObj() if level is None: self.__pid = JavaParmID(name, dbid) else: self.__pid = JavaParmID(name, dbid, level) else: if level is None: self.__pid = JavaParmID(name, model) else: self.__pid = JavaParmID(name, model, level) def __str__(self): return str(self.__pid.toString()) @staticmethod def defaultLevel(): return JavaParmID.defaultLevel() def toJavaObj(self): return self.__pid def compositeNameUI(self): return self.__pid.compositeNameUI() def parmNameAndLevel(self, composite): retval = self.__pid.parmNameAndLevel(composite) retval = JUtil.javaStringListToPylist(retval) return retval def expressionName(self, topoID, mutableID, includeTime): return self.__pid.expressionName(topoID.toJavaObj(), mutableID.toJavaObj(), includeTime) def isValid(self): return self.__pid.isValid() def getParmName(self): return self.__pid.getParmName() def getParmLevel(self): return self.__pid.getParmLevel() def getDbId(self): return DatabaseID.DatabaseID(self.__pid.getDbId()) def getCompositeName(self): return self.__pid.getCompositeName() def getShortParmId(self): return self.__pid.getShortParmId() def getParmId(self): return self.__pid.getParmId() @staticmethod def shortSerializer(parmID): return JavaParmID.shortSerializer(parmID.javaParmId()) @staticmethod def shortDeserializer(parmIDasString): return ParmID(parmIDasString) def getUIFormattedString(self): return self.__pid.getUIFormattedString()
def shortSerializer(parmID): return JavaParmID.shortSerializer(parmID.javaParmId())
def __getitem__(self, key): #pid = AFPS.ParmID_string(key + ":" + str(self._dbid)) pid = ParmID(key + ":" + str(self._dbid)) return DBSSWE(self._pmgr.getParm(pid))