Omaha #3185 harden using DAF through jep, implement new DAF methods for
JepRouter Change-Id: Id923a9267eee1242ef826414c037c1391f2effd6 Former-commit-id:dbf12d7973
[formerlya85f1054f3
] [formerly94ad041a46
] [formerlyb9caab11c9
[formerly94ad041a46
[formerly de69306f1d3804b5c4cb09736aec3fa9a889646c]]] Former-commit-id:b9caab11c9
Former-commit-id: 93caed802f88824b4a1961a2072cff78eeb31896 [formerly0db0812d68
] Former-commit-id:a2d2677a25
This commit is contained in:
parent
657035460b
commit
3912fdfd43
3 changed files with 39 additions and 33 deletions
|
@ -27,9 +27,10 @@
|
|||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 12/17/12 njensen Initial Creation.
|
||||
# Feb 14, 2013 1614 bsteffen refactor data access framework
|
||||
# Dec 17, 2012 njensen Initial Creation.
|
||||
# Feb 14, 2013 1614 bsteffen Refactor data access framework
|
||||
# to use single request.
|
||||
# Jul 22, 2014 3185 njensen Fix getters to return python objs
|
||||
#
|
||||
#
|
||||
#
|
||||
|
@ -85,15 +86,10 @@ class JDataRequest(IDataRequest, JUtil.JavaWrapperClass):
|
|||
def getIdentifiers(self):
|
||||
ids = {}
|
||||
jmap = self.jobj.getIdentifiers()
|
||||
itr = jmap.keySet().iterator()
|
||||
while itr.hasNext():
|
||||
key = itr.next()
|
||||
value = JUtil.javaObjToPyVal(jmap.get(key))
|
||||
ids[key] = value
|
||||
return ids
|
||||
return JUtil.javaObjToPyVal(jmap)
|
||||
|
||||
def getParameters(self):
|
||||
return self.jobj.getParameters()
|
||||
return JUtil.javaObjToPyVal(self.jobj.getParameters())
|
||||
|
||||
def getLevels(self):
|
||||
levels = []
|
||||
|
@ -111,7 +107,7 @@ class JDataRequest(IDataRequest, JUtil.JavaWrapperClass):
|
|||
return env
|
||||
|
||||
def getLocationNames(self):
|
||||
return self.jobj.getLocationNames()
|
||||
return JUtil.javaObjToPyVal(self.jobj.getLocationNames())
|
||||
|
||||
def toJavaObj(self):
|
||||
return self.jobj
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
# to use single request.
|
||||
# 03/03/14 2673 bsteffen Add ability to query only ref times.
|
||||
# 07/22/14 3185 njensen Added optional/default args to newDataRequest
|
||||
# and added new methods
|
||||
#
|
||||
#
|
||||
#
|
||||
|
@ -49,6 +50,7 @@ from com.raytheon.uf.common.python import PythonNumpyFloatArray
|
|||
import jep
|
||||
import DataTime
|
||||
import JGeometryData, JGridData, JDataRequest
|
||||
import JUtil
|
||||
|
||||
|
||||
def getAvailableTimes(request, refTimeOnly):
|
||||
|
@ -90,23 +92,27 @@ def getGeometryData(request, times):
|
|||
return data
|
||||
|
||||
def getAvailableLocationNames(request):
|
||||
return JavaDataAccessLayer.getAvailableLocationNames(request.toJavaObj())
|
||||
jlocs = JavaDataAccessLayer.getAvailableLocationNames(request.toJavaObj())
|
||||
return JUtil.javaObjToPyVal(jlocs)
|
||||
|
||||
def getAvailableParameters(request):
|
||||
# TODO
|
||||
raise Exception('Not implemented yet')
|
||||
jparams = JavaDataAccessLayer.getAvailableParameters(request.toJavaObj())
|
||||
return JUtil.javaObjToPyVal(jparams)
|
||||
|
||||
def getAvailableLevels(request):
|
||||
# TODO
|
||||
raise Exception('Not implemented yet')
|
||||
jlevels = JavaDataAccessLayer.getAvailableLevels(request.toJavaObj())
|
||||
pylevs = []
|
||||
for jlev in jlevels:
|
||||
pylevs.append(str(jlev))
|
||||
return pylevs
|
||||
|
||||
def getRequiredIdentifiers(datatype):
|
||||
# TODO
|
||||
raise Exception('Not implemented yet')
|
||||
jids = JavaDataAccessLayer.getRequiredIdentifiers(datatype)
|
||||
return JUtil.javaObjToPyVal(jids)
|
||||
|
||||
def getValidIdentifiers(datatype):
|
||||
# TODO
|
||||
raise Exception('Not implemented yet')
|
||||
jids = JavaDataAccessLayer.getValidIdentifiers(datatype)
|
||||
return JUtil.javaObjToPyVal(jids)
|
||||
|
||||
def newDataRequest(datatype, parameters=[], levels=[], locationNames = [], envelope=None, **kwargs):
|
||||
req = JDataRequest.JDataRequest(DefaultDataRequest())
|
||||
|
@ -127,6 +133,6 @@ def newDataRequest(datatype, parameters=[], levels=[], locationNames = [], envel
|
|||
return req
|
||||
|
||||
def getSupportedDatatypes():
|
||||
# TODO
|
||||
raise Exception('Not implemented yet')
|
||||
jsupported = JavaDataAccessLayer.getSupportedDatatypes()
|
||||
return JUtil.javaObjToPyVal(jsupported)
|
||||
|
||||
|
|
|
@ -47,10 +47,13 @@ THRIFT_HOST = subprocess.check_output(
|
|||
shell=True).strip()
|
||||
USING_NATIVE_THRIFT = False
|
||||
|
||||
try:
|
||||
if sys.modules.has_key('JavaImporter'):
|
||||
# intentionally do not catch if this fails to import, we want it to
|
||||
# be obvious that something is configured wrong when running from within
|
||||
# Java instead of allowing false confidence and fallback behavior
|
||||
import JepRouter
|
||||
router = JepRouter
|
||||
except ImportError:
|
||||
else:
|
||||
from ufpy.dataaccess import ThriftClientRouter
|
||||
router = ThriftClientRouter.ThriftClientRouter(THRIFT_HOST)
|
||||
USING_NATIVE_THRIFT = True
|
||||
|
@ -62,10 +65,9 @@ def getAvailableTimes(request, refTimeOnly=False):
|
|||
|
||||
Args:
|
||||
request: the IDataRequest to get data for
|
||||
|
||||
Args:
|
||||
refTimeOnly: True if only unique refTimes should be returned(without
|
||||
a forecastHr)
|
||||
refTimeOnly: optional, use True if only unique refTimes should be
|
||||
returned (without a forecastHr)
|
||||
|
||||
Returns:
|
||||
a list of DataTimes
|
||||
"""
|
||||
|
@ -165,14 +167,13 @@ def getValidIdentifiers(datatype):
|
|||
Returns:
|
||||
a list of strings of valid identifiers
|
||||
"""
|
||||
return router.getRequiredIdentifiers(datatype)
|
||||
return router.getValidIdentifiers(datatype)
|
||||
|
||||
def newDataRequest(datatype=None, **kwargs):
|
||||
""""
|
||||
Creates a new instance of IDataRequest suitable for the runtime environment.
|
||||
|
||||
Args:
|
||||
|
||||
All args are optional and exist solely for convenience.
|
||||
|
||||
Args:
|
||||
datatype: the datatype to create a request for
|
||||
parameters: a list of parameters to set on the request
|
||||
|
@ -197,10 +198,13 @@ def getSupportedDatatypes():
|
|||
|
||||
|
||||
def changeEDEXHost(newHostName):
|
||||
""""
|
||||
"""
|
||||
Changes the EDEX host the Data Access Framework is communicating with. Only
|
||||
works if using the native Python client implemenation, otherwise, this
|
||||
works if using the native Python client implementation, otherwise, this
|
||||
method will throw a TypeError.
|
||||
|
||||
Args:
|
||||
newHostHame: the EDEX host to connect to
|
||||
"""
|
||||
if USING_NATIVE_THRIFT:
|
||||
global THRIFT_HOST
|
||||
|
|
Loading…
Add table
Reference in a new issue