Issue #1614 Refactor data access framework to use single request.
Change-Id: Id3ed7afcf79dfb2ddeca1d9c2b632f90cc44d798 Former-commit-id:e771076275
[formerly1393f3e3cf
] [formerlye771076275
[formerly1393f3e3cf
] [formerly0933a5f596
[formerly 5a9ae7df15633492b0d9fb648876cfb2bb2946b6]]] Former-commit-id:0933a5f596
Former-commit-id:91bbdc3337
[formerlyf0f3c71d50
] Former-commit-id:f868f66f76
This commit is contained in:
parent
498c622823
commit
e6fc131343
41 changed files with 555 additions and 1033 deletions
|
@ -40,6 +40,8 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 31, 2013 bkowal Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,7 +49,7 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class AbstractDataAccessResource<T extends AbstractDataAccessResourceData<?, ?>>
|
||||
public abstract class AbstractDataAccessResource<T extends AbstractDataAccessResourceData<?>>
|
||||
extends AbstractVizResource<T, MapDescriptor> {
|
||||
|
||||
protected static final String _SPACE_ = " ";
|
||||
|
|
|
@ -22,10 +22,13 @@ package com.raytheon.viz.dataaccess.rsc;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.DataAccessLayer;
|
||||
import com.raytheon.uf.common.dataaccess.IData;
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException;
|
||||
import com.raytheon.uf.common.dataaccess.impl.DefaultDataRequest;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.exception.NoDataAvailableException;
|
||||
|
@ -44,6 +47,8 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 31, 2013 bkowal Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -51,8 +56,11 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>, X extends IData>
|
||||
extends AbstractResourceData {
|
||||
public abstract class AbstractDataAccessResourceData<X extends IData> extends
|
||||
AbstractResourceData {
|
||||
|
||||
@XmlElement
|
||||
private DefaultDataRequest request;
|
||||
|
||||
private DataTime[] dataTimes;
|
||||
|
||||
|
@ -76,7 +84,7 @@ public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>,
|
|||
@Override
|
||||
public AbstractVizResource<?, ?> construct(LoadProperties loadProperties,
|
||||
IDescriptor descriptor) throws VizException {
|
||||
this.populateTimes(this.getRequest());
|
||||
this.populateTimes(request);
|
||||
return this.constructResource(loadProperties, descriptor);
|
||||
}
|
||||
|
||||
|
@ -87,7 +95,8 @@ public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>,
|
|||
* @param request
|
||||
* the request
|
||||
*/
|
||||
protected void populateTimes(T request) throws NoDataAvailableException {
|
||||
protected void populateTimes(IDataRequest request)
|
||||
throws NoDataAvailableException {
|
||||
dataTimes = null;
|
||||
try {
|
||||
dataTimes = DataAccessLayer.getAvailableTimes(request);
|
||||
|
@ -97,7 +106,7 @@ public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>,
|
|||
} catch (TimeAgnosticDataException e1) {
|
||||
// Make sure that time agnostic has data before continuing.
|
||||
dataTimes = null;
|
||||
X[] data = retreiveData(request, null);
|
||||
X[] data = retreiveData(request);
|
||||
if (data == null || data.length == 0) {
|
||||
throw new NoDataAvailableException(this.getClass());
|
||||
}
|
||||
|
@ -114,29 +123,7 @@ public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>,
|
|||
* the class that is requesting the data; will always be a
|
||||
* subclass of AbstractDataAccessResourceData
|
||||
*/
|
||||
private X[] retreiveData(T request, DataTime dataTime) {
|
||||
X[] data = null;
|
||||
if (dataTime == null && dataTimes == null) {
|
||||
/*
|
||||
* If we were a legitimate resource, we would want to cache time
|
||||
* agnostic data that was retrieved. The cache could be a simple Map
|
||||
* or even the cache provided by GOOG in the guava library.
|
||||
*/
|
||||
data = DataAccessLayer.getData(request);
|
||||
} else if (dataTime != null) {
|
||||
/* Just use the latest time since this is a sample / test resource */
|
||||
data = DataAccessLayer.getData(request, dataTime);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the data access framework request associated with the resource data
|
||||
*
|
||||
* @return the data access framework request to execute
|
||||
*/
|
||||
protected abstract T getRequest();
|
||||
protected abstract X[] retreiveData(IDataRequest request, DataTime... times);
|
||||
|
||||
/**
|
||||
* Constructs the resource
|
||||
|
@ -147,7 +134,8 @@ public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>,
|
|||
* @throws VizException
|
||||
*/
|
||||
protected abstract AbstractVizResource<?, ?> constructResource(
|
||||
LoadProperties loadProperties, IDescriptor descriptor) throws VizException;
|
||||
LoadProperties loadProperties, IDescriptor descriptor)
|
||||
throws VizException;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -187,13 +175,19 @@ public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>,
|
|||
public X[] getData(DataTime time) {
|
||||
if (data.containsKey(time)) {
|
||||
return data.get(time);
|
||||
} else {
|
||||
X[] data = retreiveData(getRequest(), time);
|
||||
} else if (time != null) {
|
||||
X[] data = retreiveData(request, time);
|
||||
this.data.put(time, data);
|
||||
return data;
|
||||
} else if (dataTimes == null) {
|
||||
X[] data = retreiveData(request);
|
||||
this.data.put(time, data);
|
||||
return data;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the dataTimes
|
||||
*
|
||||
|
|
|
@ -21,14 +21,15 @@ package com.raytheon.viz.dataaccess.rsc.geometry;
|
|||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.DataAccessLayer;
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryData;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.common.dataaccess.impl.DefaultGeometryRequest;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryData;
|
||||
import com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData;
|
||||
|
||||
/**
|
||||
|
@ -41,6 +42,8 @@ import com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 30, 2013 bkowal Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -50,9 +53,7 @@ import com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData;
|
|||
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class GenericGeometryResourceData extends
|
||||
AbstractDataAccessResourceData<DefaultGeometryRequest, IGeometryData> {
|
||||
@XmlElement
|
||||
private DefaultGeometryRequest request;
|
||||
AbstractDataAccessResourceData<IGeometryData> {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -74,15 +75,9 @@ public class GenericGeometryResourceData extends
|
|||
return new GenericGeometryResource(this, loadProperties);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData#getRequest
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
protected DefaultGeometryRequest getRequest() {
|
||||
return this.request;
|
||||
protected IGeometryData[] retreiveData(IDataRequest request,
|
||||
DataTime... times) {
|
||||
return DataAccessLayer.getGeometryData(request, times);
|
||||
}
|
||||
}
|
|
@ -21,14 +21,15 @@ package com.raytheon.viz.dataaccess.rsc.grid;
|
|||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.DataAccessLayer;
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.common.dataaccess.impl.DefaultGridRequest;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData;
|
||||
|
||||
/**
|
||||
|
@ -42,6 +43,8 @@ import com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 8, 2013 bkowal Initial creation
|
||||
* Jan 31, 2013 #1555 bkowal Refactor
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -51,9 +54,7 @@ import com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData;
|
|||
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class GenericGridResourceData extends
|
||||
AbstractDataAccessResourceData<DefaultGridRequest, IGridData> {
|
||||
@XmlElement
|
||||
private DefaultGridRequest request;
|
||||
AbstractDataAccessResourceData<IGridData> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -69,15 +70,9 @@ public class GenericGridResourceData extends
|
|||
return new GenericGridResource(this, loadProperties);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData#getRequest
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
protected DefaultGridRequest getRequest() {
|
||||
return this.request;
|
||||
protected IGridData[] retreiveData(IDataRequest request, DataTime... times) {
|
||||
return DataAccessLayer.getGridData(request, times);
|
||||
}
|
||||
|
||||
}
|
|
@ -28,6 +28,8 @@
|
|||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 12/17/12 njensen Initial Creation.
|
||||
# Feb 14, 2013 1614 bsteffen refactor data access framework
|
||||
# to use single request.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
@ -60,9 +62,19 @@ class JDataRequest(IDataRequest, JUtil.JavaWrapperClass):
|
|||
for i in xrange(len(args)):
|
||||
levels[i] = Level(str(args[i]))
|
||||
self.jobj.setLevels(levels)
|
||||
|
||||
def getLocationNames(self):
|
||||
return self.jobj.getLocationNames()
|
||||
|
||||
def setEnvelope(self, env):
|
||||
from com.vividsolutions.jts.geom import Envelope
|
||||
bounds = env.bounds
|
||||
jenv = Envelope(bounds[0], bounds[2], bounds[1], bounds[3])
|
||||
self.jobj.setEnvelope(bounds)
|
||||
|
||||
def setLocationNames(self, *args):
|
||||
from java.lang import String as JavaString
|
||||
locs = jep.jarray(len(args), JavaString)
|
||||
for i in xrange(len(args)):
|
||||
locs[i] = JavaString(str(args[i]))
|
||||
self.jobj.setLocationNames(locs)
|
||||
|
||||
def getDatatype(self):
|
||||
return self.jobj.getDatatype()
|
||||
|
@ -87,12 +99,16 @@ class JDataRequest(IDataRequest, JUtil.JavaWrapperClass):
|
|||
levels.append(str(lev))
|
||||
return levels
|
||||
|
||||
def setLocationNames(self, *args):
|
||||
from java.lang import String as JavaString
|
||||
locs = jep.jarray(len(args), JavaString)
|
||||
for i in xrange(len(args)):
|
||||
locs[i] = str(args[i])
|
||||
self.jobj.setLocationNames(locs)
|
||||
def getEnvelope(self):
|
||||
env = None
|
||||
jenv = self.jobj.getEnvelope()
|
||||
if jenv:
|
||||
from com.vividsolutions.jts.geom import GeometryFactory
|
||||
env = shapely.wkt.loads(GeometryFactory().toGeometry(jenv).toText())
|
||||
return env
|
||||
|
||||
def getLocationNames(self):
|
||||
return self.jobj.getLocationNames()
|
||||
|
||||
def toJavaObj(self):
|
||||
return self.jobj
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
##
|
||||
# This software was developed and / or modified by Raytheon Company,
|
||||
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
#
|
||||
# U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
# This software product contains export-restricted data whose
|
||||
# export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
# to non-U.S. persons whether in the United States or abroad requires
|
||||
# an export license or other authorization.
|
||||
#
|
||||
# Contractor Name: Raytheon Company
|
||||
# Contractor Address: 6825 Pine Street, Suite 340
|
||||
# Mail Stop B8
|
||||
# Omaha, NE 68106
|
||||
# 402.291.0100
|
||||
#
|
||||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
# further licensing information.
|
||||
##
|
||||
|
||||
|
||||
#
|
||||
# Implements IGeometryRequest and wraps around a Java IGeometryRequest.
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 12/18/12 njensen Initial Creation.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
from ufpy.dataaccess import IGeometryRequest
|
||||
import JUtil, JDataRequest
|
||||
import jep
|
||||
import shapely.wkt
|
||||
|
||||
class JGeometryRequest(IGeometryRequest, JDataRequest.JDataRequest):
|
||||
|
||||
def __init__(self, wrappedObject):
|
||||
JDataRequest.JDataRequest.__init__(self, wrappedObject)
|
||||
|
||||
def getEnvelope(self):
|
||||
env = None
|
||||
jenv = self.jobj.getEnvelope()
|
||||
if jenv:
|
||||
from com.vividsolutions.jts.geom import GeometryFactory
|
||||
env = shapely.wkt.loads(GeometryFactory().toGeometry(jenv).toText())
|
||||
return env
|
||||
|
||||
def setEnvelope(self, env):
|
||||
from com.vividsolutions.jts.geom import Envelope
|
||||
bounds = env.bounds
|
||||
jenv = Envelope(bounds[0], bounds[2], bounds[1], bounds[3])
|
||||
self.jobj.setEnvelope(bounds)
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
##
|
||||
# This software was developed and / or modified by Raytheon Company,
|
||||
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
#
|
||||
# U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
# This software product contains export-restricted data whose
|
||||
# export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
# to non-U.S. persons whether in the United States or abroad requires
|
||||
# an export license or other authorization.
|
||||
#
|
||||
# Contractor Name: Raytheon Company
|
||||
# Contractor Address: 6825 Pine Street, Suite 340
|
||||
# Mail Stop B8
|
||||
# Omaha, NE 68106
|
||||
# 402.291.0100
|
||||
#
|
||||
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
# further licensing information.
|
||||
##
|
||||
|
||||
|
||||
#
|
||||
# Implements IGridRequest and wraps around a Java IGridRequest.
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 12/18/12 njensen Initial Creation.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
from ufpy.dataaccess import IGridRequest
|
||||
import JUtil, JDataRequest
|
||||
import jep
|
||||
|
||||
class JGridRequest(IGridRequest, JDataRequest.JDataRequest):
|
||||
|
||||
def __init__(self, wrappedObject):
|
||||
JDataRequest.JDataRequest.__init__(self, wrappedObject)
|
||||
|
||||
|
||||
|
||||
|
|
@ -30,21 +30,23 @@
|
|||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 12/10/12 njensen Initial Creation.
|
||||
# Feb 14, 2013 1614 bsteffen refactor data access framework
|
||||
# to use single request.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
from ufpy.dataaccess import IGeometryRequest, IGridRequest
|
||||
from ufpy.dataaccess import IDataRequest
|
||||
|
||||
from com.raytheon.uf.common.dataaccess import DataAccessLayer as JavaDataAccessLayer
|
||||
from com.raytheon.uf.common.dataaccess.impl import DefaultGridRequest, DefaultGeometryRequest
|
||||
from com.raytheon.uf.common.dataaccess.impl import DefaultDataRequest
|
||||
from com.raytheon.uf.common.time import DataTime as JavaDataTime
|
||||
from com.raytheon.uf.common.geospatial import LatLonReprojection
|
||||
from com.raytheon.uf.common.python import PythonNumpyFloatArray
|
||||
|
||||
import jep
|
||||
import DataTime
|
||||
import JGeometryData, JGridData, JGridRequest, JGeometryRequest
|
||||
import JGeometryData, JGridData, JDataRequest
|
||||
|
||||
|
||||
def getAvailableTimes(request):
|
||||
|
@ -55,31 +57,41 @@ def getAvailableTimes(request):
|
|||
return times
|
||||
|
||||
|
||||
def getData(request, times):
|
||||
def getGridData(request, times):
|
||||
if type(times) is list:
|
||||
# presuming list of DataTimes
|
||||
jtimes = jep.jarray(len(times), JavaDataTime)
|
||||
for i in xrange(len(times)):
|
||||
jtimes[i] = times[i].toJavaObj()
|
||||
javaData = JavaDataAccessLayer.getData(request.toJavaObj(), jtimes)
|
||||
javaData = JavaDataAccessLayer.getGridData(request.toJavaObj(), jtimes)
|
||||
else:
|
||||
# presuming TimeRange
|
||||
javaData = JavaDataAccessLayer.getData(request.toJavaObj(), times.toJavaObj())
|
||||
wrapper = None
|
||||
if isinstance(request, IGeometryRequest):
|
||||
wrapper = JGeometryData.JGeometryData
|
||||
elif isinstance(request, IGridRequest):
|
||||
wrapper = JGridData.JGridData
|
||||
javaData = JavaDataAccessLayer.getGridData(request.toJavaObj(), times.toJavaObj())
|
||||
data = []
|
||||
for jd in javaData:
|
||||
data.append(wrapper(jd))
|
||||
data.append(JGridData.JGridData(jd))
|
||||
return data
|
||||
|
||||
def getLatLonCoords(gridRequest):
|
||||
def getGeometryData(request, times):
|
||||
if type(times) is list:
|
||||
# presuming list of DataTimes
|
||||
jtimes = jep.jarray(len(times), JavaDataTime)
|
||||
for i in xrange(len(times)):
|
||||
jtimes[i] = times[i].toJavaObj()
|
||||
javaData = JavaDataAccessLayer.getGeometryData(request.toJavaObj(), jtimes)
|
||||
else:
|
||||
# presuming TimeRange
|
||||
javaData = JavaDataAccessLayer.getGeometryData(request.toJavaObj(), times.toJavaObj())
|
||||
data = []
|
||||
for jd in javaData:
|
||||
data.append(JGeometryData.JGeometryData(jd))
|
||||
return data
|
||||
|
||||
def getLatLonCoords(gridData):
|
||||
'''
|
||||
@return: a tuple where the first element is a numpy array of lons, and the second element is a numpy array of lats
|
||||
'''
|
||||
gridGeometry = JavaDataAccessLayer.getGridGeometry(gridRequest.toJavaObj())
|
||||
gridGeometry = gridData.toJavaObj().getGridGeometry()
|
||||
if gridGeometry is None :
|
||||
return None
|
||||
latlons = LatLonReprojection.getLatLons(gridGeometry)
|
||||
|
@ -92,9 +104,6 @@ def getLatLonCoords(gridRequest):
|
|||
def getAvailableLocationNames(request):
|
||||
return JavaDataAccessLayer.getAvailableLocationNames(request.toJavaObj())
|
||||
|
||||
def newGeometryRequest():
|
||||
return JGeometryRequest.JGeometryRequest(DefaultGeometryRequest())
|
||||
|
||||
def newGridRequest():
|
||||
return JGridRequest.JGridRequest(DefaultGridRequest())
|
||||
def newDataRequest():
|
||||
return JDataRequest.JDataRequest(DefaultDataRequest())
|
||||
|
||||
|
|
|
@ -19,12 +19,11 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.dataaccess;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException;
|
||||
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.UnsupportedOutputTypeException;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryData;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.time.BinOffset;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
|
@ -48,6 +47,8 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 24, 2012 njensen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -65,9 +66,8 @@ public class DataAccessLayer {
|
|||
* @return the available times that match the request
|
||||
* @throws TimeAgnosticDataException
|
||||
*/
|
||||
public static <R extends IDataRequest<D>, D extends IData> DataTime[] getAvailableTimes(
|
||||
R request) {
|
||||
IDataFactory<R, D> factory = getFactory(request);
|
||||
public static DataTime[] getAvailableTimes(IDataRequest request) {
|
||||
IDataFactory factory = getFactory(request);
|
||||
return factory.getAvailableTimes(request);
|
||||
}
|
||||
|
||||
|
@ -82,27 +82,29 @@ public class DataAccessLayer {
|
|||
* request
|
||||
* @throws TimeAgnosticDataException
|
||||
*/
|
||||
public static <R extends IDataRequest<D>, D extends IData> DataTime[] getAvailableTimes(
|
||||
R request, BinOffset binOffset) {
|
||||
IDataFactory<R, D> factory = getFactory(request);
|
||||
public static DataTime[] getAvailableTimes(IDataRequest request,
|
||||
BinOffset binOffset) {
|
||||
IDataFactory factory = getFactory(request);
|
||||
return factory.getAvailableTimes(request, binOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data that matches the request at the specified times. If data is
|
||||
* time agnostic then simply don't pass in any DataTimes, for example
|
||||
* DataAccessLayer.getData(R)
|
||||
* DataAccessLayer.getGridData(R)
|
||||
*
|
||||
* @param request
|
||||
* the request to get data for
|
||||
* @param times
|
||||
* the times to get data for
|
||||
* @return the data that matches the request and times
|
||||
* @throws UnsupportedOutputTypeException
|
||||
* if the factory for this datatype cannot produce IGridData
|
||||
*/
|
||||
public static <R extends IDataRequest<D>, D extends IData> D[] getData(
|
||||
R request, DataTime... times) {
|
||||
IDataFactory<R, D> factory = getFactory(request);
|
||||
return factory.getData(request, times);
|
||||
public static IGridData[] getGridData(IDataRequest request,
|
||||
DataTime... times) throws UnsupportedOutputTypeException {
|
||||
IDataFactory factory = getFactory(request);
|
||||
return factory.getGridData(request, times);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,25 +115,49 @@ public class DataAccessLayer {
|
|||
* @param timeRange
|
||||
* the time range to get data for
|
||||
* @return the data that matches the request and time range
|
||||
* @throws UnsupportedOutputTypeException
|
||||
* if the factory for this datatype cannot produce IGeometryData
|
||||
*/
|
||||
public static <R extends IDataRequest<D>, D extends IData> D[] getData(
|
||||
R request, TimeRange timeRange) {
|
||||
IDataFactory<R, D> factory = getFactory(request);
|
||||
return factory.getData(request, timeRange);
|
||||
public static IGeometryData[] getGeometryData(IDataRequest request,
|
||||
TimeRange timeRange) throws UnsupportedOutputTypeException {
|
||||
IDataFactory factory = getFactory(request);
|
||||
return factory.getGeometryData(request, timeRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the grid geometry of the data matching the request without actually
|
||||
* requesting the data. Useful for then making slab/subgrid/line requests by
|
||||
* setting the storage request parameter on an IGridRequest.
|
||||
* Gets the data that matches the request at the specified times. If data is
|
||||
* time agnostic then simply don't pass in any DataTimes, for example
|
||||
* DataAccessLayer.getGeometryData(R)
|
||||
*
|
||||
* @param request
|
||||
* the request to get the grid geometry of the data for
|
||||
* @return the geometry of the data if the data was requested
|
||||
* the request to get data for
|
||||
* @param times
|
||||
* the times to get data for
|
||||
* @return the data that matches the request and times
|
||||
* @throws UnsupportedOutputTypeException
|
||||
* if the factory for this datatype cannot produce IGeometryData
|
||||
*/
|
||||
public static GridGeometry2D getGridGeometry(IGridRequest request) {
|
||||
IGridDataFactory factory = (IGridDataFactory) getFactory(request);
|
||||
return factory.getGeometry(request);
|
||||
public static IGeometryData[] getGeometryData(IDataRequest request,
|
||||
DataTime... times) throws UnsupportedOutputTypeException {
|
||||
IDataFactory factory = getFactory(request);
|
||||
return factory.getGeometryData(request, times);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data that matches the request within the time range
|
||||
*
|
||||
* @param request
|
||||
* the request to get data for
|
||||
* @param timeRange
|
||||
* the time range to get data for
|
||||
* @return the data that matches the request and time range
|
||||
* @throws UnsupportedOutputTypeException
|
||||
* if the factory for this datatype cannot produce IGridData
|
||||
*/
|
||||
public static IGridData[] getGridData(IDataRequest request,
|
||||
TimeRange timeRange) throws UnsupportedOutputTypeException {
|
||||
IDataFactory factory = getFactory(request);
|
||||
return factory.getGridData(request, timeRange);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,9 +167,8 @@ public class DataAccessLayer {
|
|||
* @param request
|
||||
* @return the available location names if the data was requested
|
||||
*/
|
||||
public static <R extends IDataRequest<D>, D extends IData> String[] getAvailableLocationNames(
|
||||
R request) {
|
||||
IDataFactory<R, D> factory = getFactory(request);
|
||||
public static String[] getAvailableLocationNames(IDataRequest request) {
|
||||
IDataFactory factory = getFactory(request);
|
||||
return factory.getAvailableLocationNames(request);
|
||||
}
|
||||
|
||||
|
@ -156,8 +181,7 @@ public class DataAccessLayer {
|
|||
* @return the factory that matches the request
|
||||
* @throws DataFactoryNotFoundException
|
||||
*/
|
||||
private static <R extends IDataRequest<D>, D extends IData> IDataFactory<R, D> getFactory(
|
||||
R request) {
|
||||
private static IDataFactory getFactory(IDataRequest request) {
|
||||
return DataFactoryRegistry.getInstance().getFactory(request);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ package com.raytheon.uf.common.dataaccess;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException;
|
||||
|
||||
|
@ -38,6 +37,8 @@ import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,7 +48,7 @@ import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException;
|
|||
|
||||
public class DataFactoryRegistry {
|
||||
|
||||
private Map<String, Map<Class<IDataRequest<?>>, IDataFactory<?, ?>>> datatypeMap;
|
||||
private Map<String, IDataFactory> datatypeMap;
|
||||
|
||||
private static DataFactoryRegistry instance;
|
||||
|
||||
|
@ -55,7 +56,7 @@ public class DataFactoryRegistry {
|
|||
* Constructor
|
||||
*/
|
||||
private DataFactoryRegistry() {
|
||||
datatypeMap = new HashMap<String, Map<Class<IDataRequest<?>>, IDataFactory<?, ?>>>();
|
||||
datatypeMap = new HashMap<String, IDataFactory>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,16 +84,9 @@ public class DataFactoryRegistry {
|
|||
* the factory that will support requests of this datatype and
|
||||
* type
|
||||
*/
|
||||
public IDataFactory<?, ?> register(String datatype,
|
||||
Class<IDataRequest<?>> requestType, IDataFactory<?, ?> factory) {
|
||||
public IDataFactory register(String datatype, IDataFactory factory) {
|
||||
datatype = datatype.toLowerCase();
|
||||
Map<Class<IDataRequest<?>>, IDataFactory<?, ?>> requestTypeMap = datatypeMap
|
||||
.get(datatype);
|
||||
if (requestTypeMap == null) {
|
||||
requestTypeMap = new HashMap<Class<IDataRequest<?>>, IDataFactory<?, ?>>();
|
||||
datatypeMap.put(datatype, requestTypeMap);
|
||||
}
|
||||
requestTypeMap.put(requestType, factory);
|
||||
datatypeMap.put(datatype, factory);
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
@ -107,30 +101,13 @@ public class DataFactoryRegistry {
|
|||
* @throws DataFactoryNotFoundException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <R extends IDataRequest<D>, D extends IData> IDataFactory<R, D> getFactory(
|
||||
R request) {
|
||||
public IDataFactory getFactory(IDataRequest request) {
|
||||
String datatype = request.getDatatype().toLowerCase();
|
||||
if (datatype != null) {
|
||||
Map<Class<IDataRequest<?>>, IDataFactory<?, ?>> requestTypeMap = datatypeMap
|
||||
IDataFactory factory = datatypeMap
|
||||
.get(datatype);
|
||||
if (requestTypeMap != null) {
|
||||
IDataFactory<?, ?> factory = null;
|
||||
for (Entry<Class<IDataRequest<?>>, IDataFactory<?, ?>> entry : requestTypeMap
|
||||
.entrySet()) {
|
||||
if (entry.getKey().isInstance(request)) {
|
||||
factory = entry.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (factory != null) {
|
||||
return (IDataFactory<R, D>) factory;
|
||||
} else {
|
||||
throw new DataFactoryNotFoundException(
|
||||
"No data access support for requests of datatype "
|
||||
+ datatype + " and type "
|
||||
+ request.getClass());
|
||||
}
|
||||
if (factory != null) {
|
||||
return factory;
|
||||
} else {
|
||||
throw new DataFactoryNotFoundException(
|
||||
"No data access support registered to datatype key: "
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
package com.raytheon.uf.common.dataaccess;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException;
|
||||
import com.raytheon.uf.common.dataaccess.exception.UnsupportedOutputTypeException;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryData;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.time.BinOffset;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
|
@ -49,6 +52,8 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -57,7 +62,7 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* @param <D>
|
||||
*/
|
||||
|
||||
public interface IDataFactory<R extends IDataRequest<D>, D extends IData> {
|
||||
public interface IDataFactory {
|
||||
|
||||
/**
|
||||
* Gets the available times that match the request. Implementations should
|
||||
|
@ -68,7 +73,7 @@ public interface IDataFactory<R extends IDataRequest<D>, D extends IData> {
|
|||
* @return the times that have data available for this request
|
||||
* @throws TimeAgnosticDataException
|
||||
*/
|
||||
public DataTime[] getAvailableTimes(R request)
|
||||
public DataTime[] getAvailableTimes(IDataRequest request)
|
||||
throws TimeAgnosticDataException;
|
||||
|
||||
/**
|
||||
|
@ -84,7 +89,8 @@ public interface IDataFactory<R extends IDataRequest<D>, D extends IData> {
|
|||
* for this request
|
||||
* @throws TimeAgnosticDataException
|
||||
*/
|
||||
public DataTime[] getAvailableTimes(R request, BinOffset binOffset)
|
||||
public DataTime[] getAvailableTimes(IDataRequest request,
|
||||
BinOffset binOffset)
|
||||
throws TimeAgnosticDataException;
|
||||
|
||||
/**
|
||||
|
@ -97,8 +103,10 @@ public interface IDataFactory<R extends IDataRequest<D>, D extends IData> {
|
|||
* the times to get data for. If data is time agnostic, use
|
||||
* getData(R)
|
||||
* @return the data that matches the request at the specified times
|
||||
* @throws UnsupportedOutputTypeException
|
||||
* if this factory cannot produce IGridData
|
||||
*/
|
||||
public D[] getData(R request, DataTime... times);
|
||||
public IGridData[] getGridData(IDataRequest request, DataTime... times);
|
||||
|
||||
/**
|
||||
* Gets the available data that matches the request and is within the time
|
||||
|
@ -110,18 +118,52 @@ public interface IDataFactory<R extends IDataRequest<D>, D extends IData> {
|
|||
* the time range to return data for. If data is time agnostic,
|
||||
* use getData(R).
|
||||
* @return the data that matches the request within the time range
|
||||
* @throws UnsupportedOutputTypeException
|
||||
* if this factory cannot produce IGridData
|
||||
*/
|
||||
public D[] getData(R request, TimeRange timeRange);
|
||||
public IGridData[] getGridData(IDataRequest request, TimeRange timeRange);
|
||||
|
||||
/**
|
||||
* Gets the available data that matches the request at the specified times.
|
||||
* If data is time agnostic, use getData(R).
|
||||
*
|
||||
* @param request
|
||||
* the request to get matching data for
|
||||
* @param times
|
||||
* the times to get data for. If data is time agnostic, use
|
||||
* getData(R)
|
||||
* @return the data that matches the request at the specified times
|
||||
* @throws UnsupportedOutputTypeException
|
||||
* if this factory cannot produce IGeometryData
|
||||
*/
|
||||
public IGeometryData[] getGeometryData(IDataRequest request,
|
||||
DataTime... times);
|
||||
|
||||
/**
|
||||
* Gets the available data that matches the request and is within the time
|
||||
* range. If data is time agnostic, use getData(R).
|
||||
*
|
||||
* @param request
|
||||
* the request to get matching data for
|
||||
* @param timeRange
|
||||
* the time range to return data for. If data is time agnostic,
|
||||
* use getData(R).
|
||||
* @return the data that matches the request within the time range
|
||||
* @throws UnsupportedOutputTypeException
|
||||
* if this factory cannot produce IGeometryData
|
||||
*/
|
||||
public IGeometryData[] getGeometryData(IDataRequest request,
|
||||
TimeRange timeRange);
|
||||
|
||||
/**
|
||||
* Gets the available location names that match the request. Implementations
|
||||
* should throw LocationNameUnsupportedException if location names do not
|
||||
* apply to their datatype.
|
||||
* should throw IncompatibleRequestException if location names do not apply
|
||||
* to their datatype.
|
||||
*
|
||||
* @param request
|
||||
* the request to find matching location names for
|
||||
* @return the available location names that match the request
|
||||
*/
|
||||
public String[] getAvailableLocationNames(R request);
|
||||
public String[] getAvailableLocationNames(IDataRequest request);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package com.raytheon.uf.common.dataaccess;
|
|||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
/**
|
||||
* A generic request for geospatial data to the Data Access Framework. All
|
||||
|
@ -34,6 +35,8 @@ import com.raytheon.uf.common.dataplugin.level.Level;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -41,7 +44,7 @@ import com.raytheon.uf.common.dataplugin.level.Level;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IDataRequest<D extends IData> {
|
||||
public interface IDataRequest {
|
||||
|
||||
/**
|
||||
* The datatype of the data, usually the pluginName. This value will be used
|
||||
|
@ -88,8 +91,8 @@ public interface IDataRequest<D extends IData> {
|
|||
* radar name, etc). Possible location names can be retrieved by using the
|
||||
* method getAvailableLocationNames(IGeometryRequest) on the DataAccessLayer
|
||||
* or IGeometryDataFactory. Note that not all factories may support requests
|
||||
* by location names and instead may throw a
|
||||
* LocationNameUnsupportedException or ignore the location names.
|
||||
* by location names and instead may throw a IncompatibleRequestException or
|
||||
* ignore the location names.
|
||||
*
|
||||
* @param locationNames
|
||||
*/
|
||||
|
@ -102,6 +105,17 @@ public interface IDataRequest<D extends IData> {
|
|||
*/
|
||||
public String getDatatype();
|
||||
|
||||
/**
|
||||
* Sets a bounding box on the request to limit the area of the request. The
|
||||
* envelope coordinates should be in Lat/Lon space. Note that not all
|
||||
* factories may support the envelope and instead may throw an
|
||||
* IncompatibleRequestException or ignore the envelope.
|
||||
*
|
||||
* @param env
|
||||
* the envelope to constrain the request
|
||||
*/
|
||||
public void setEnvelope(Envelope env);
|
||||
|
||||
/**
|
||||
* Returns the identifiers added to the request.
|
||||
*
|
||||
|
@ -130,4 +144,11 @@ public interface IDataRequest<D extends IData> {
|
|||
*/
|
||||
public String[] getLocationNames();
|
||||
|
||||
/**
|
||||
* Returns the envelope set on the request.
|
||||
*
|
||||
* @return the envelope set on the request
|
||||
*/
|
||||
public Envelope getEnvelope();
|
||||
|
||||
}
|
||||
|
|
|
@ -17,13 +17,10 @@
|
|||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.dataaccess.geom;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataFactory;
|
||||
package com.raytheon.uf.common.dataaccess.exception;
|
||||
|
||||
/**
|
||||
* IDataFactory for any data that is non-gridded, for example points or
|
||||
* polygons.
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -31,15 +28,38 @@ import com.raytheon.uf.common.dataaccess.IDataFactory;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
* Feb 15, 2013 1614 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IGeometryDataFactory extends
|
||||
IDataFactory<IGeometryRequest, IGeometryData> {
|
||||
public class UnsupportedOutputTypeException extends DataAccessException {
|
||||
|
||||
private final String dataType;
|
||||
|
||||
private final String outputType;
|
||||
|
||||
public UnsupportedOutputTypeException(String dataType, String outputType) {
|
||||
super(dataType + " does not support " + outputType + " data");
|
||||
this.dataType = dataType;
|
||||
this.outputType = outputType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dataType
|
||||
*/
|
||||
public String getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the outputType
|
||||
*/
|
||||
public String getOutputType() {
|
||||
return outputType;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.dataaccess.geom;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
/**
|
||||
* A request for any data type that is non-gridded and can be represented by a
|
||||
* geometry.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IGeometryRequest extends IDataRequest<IGeometryData> {
|
||||
|
||||
/**
|
||||
* Sets a bounding box on the request to limit the area of the request. The
|
||||
* envelope coordinates should be in Lat/Lon space. Note that not all
|
||||
* factories may support the envelope and instead may throw an
|
||||
* EnvelopeUnsupportedException or ignore the envelope.
|
||||
*
|
||||
* @param env
|
||||
* the envelope to constrain the request
|
||||
*/
|
||||
public void setEnvelope(Envelope env);
|
||||
|
||||
/**
|
||||
* Returns the envelope set on the request.
|
||||
*
|
||||
* @return the envelope set on the request
|
||||
*/
|
||||
public Envelope getEnvelope();
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.dataaccess.grid;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataFactory;
|
||||
|
||||
/**
|
||||
* IDataFactory interface for two dimensional gridded data. Note that IGridData
|
||||
* has the populateData() methods, therefore the implementations of this
|
||||
* interface can choose to either retrieve the raw data when factory.getData()
|
||||
* is called, or have the implementation of IGridData retrieve the raw data when
|
||||
* populateData() is called.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 9, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IGridDataFactory extends IDataFactory<IGridRequest, IGridData> {
|
||||
|
||||
/**
|
||||
* Gets the GridGeometry2D that matches the request. Useful for determining
|
||||
* the area before requesting the data.
|
||||
*
|
||||
* @param request
|
||||
* the request to get the geometry for
|
||||
* @return the grid geometry of the data that would be returned from this
|
||||
* request
|
||||
*/
|
||||
public GridGeometry2D getGeometry(IGridRequest request);
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.dataaccess.grid;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
|
||||
/**
|
||||
* A request for gridded data.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 9, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IGridRequest extends IDataRequest<IGridData> {
|
||||
|
||||
/**
|
||||
* Sets a storage request as part of the request. If null, the entire
|
||||
* dataset will be retrieved. Useful for slab requests to avoid retrieving
|
||||
* the entire dataset and boost performance in some scenarios.
|
||||
*
|
||||
* @param request
|
||||
* the {@link Request} to limit the data returned
|
||||
*/
|
||||
public void setStorageRequest(Request request);
|
||||
|
||||
/**
|
||||
* Gets the storage request set on the request.
|
||||
*
|
||||
* @return the {@link Request} set on the IGridRequest
|
||||
*/
|
||||
public Request getStorageRequest();
|
||||
|
||||
}
|
|
@ -40,6 +40,8 @@ import com.raytheon.uf.common.dataaccess.exception.InvalidIdentifiersException;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 13, 2012 njensen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -75,7 +77,7 @@ public abstract class AbstractDataFactory {
|
|||
* @param request
|
||||
* the request to validate
|
||||
*/
|
||||
public void validateRequest(IDataRequest<?> request) {
|
||||
public void validateRequest(IDataRequest request) {
|
||||
String[] required = getRequiredIdentifiers();
|
||||
Collection<String> missing = Collections.emptySet();
|
||||
Collection<String> invalid = Collections.emptySet();
|
||||
|
@ -99,4 +101,5 @@ public abstract class AbstractDataFactory {
|
|||
invalid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,10 +24,11 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IData;
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataRetrievalException;
|
||||
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryData;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
|
@ -49,6 +50,8 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 17, 2013 bsteffen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -56,20 +59,20 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D extends IData>
|
||||
public abstract class AbstractDataPluginFactory
|
||||
extends AbstractDataFactory {
|
||||
|
||||
protected static final String FIELD_DATATIME = "dataTime";
|
||||
|
||||
protected static final String DBQUERY_PLUGIN_NAME_KEY = "pluginName";
|
||||
|
||||
public DataTime[] getAvailableTimes(R request)
|
||||
public DataTime[] getAvailableTimes(IDataRequest request)
|
||||
throws TimeAgnosticDataException {
|
||||
return this.getAvailableTimes(request, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public DataTime[] getAvailableTimes(R request,
|
||||
public DataTime[] getAvailableTimes(IDataRequest request,
|
||||
BinOffset binOffset) throws TimeAgnosticDataException {
|
||||
validateRequest(request);
|
||||
TimeQueryRequest timeQueryRequest = this.buildTimeQueryRequest(request);
|
||||
|
@ -96,41 +99,47 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
|
|||
return dataTimes.toArray(new DataTime[dataTimes.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a TimeQueryRequest that will be used to retrieve Data Times.
|
||||
*
|
||||
* @param request
|
||||
* the original grid request
|
||||
* @return a TimeQueryRequest to execute
|
||||
*/
|
||||
protected TimeQueryRequest buildTimeQueryRequest(R request) {
|
||||
TimeQueryRequest timeQueryRequest = new TimeQueryRequest();
|
||||
timeQueryRequest.setPluginName(request.getDatatype());
|
||||
timeQueryRequest.setQueryTerms(this
|
||||
.buildConstraintsFromRequest(request));
|
||||
|
||||
return timeQueryRequest;
|
||||
}
|
||||
|
||||
public D[] getData(R request, DataTime... times) {
|
||||
public IGeometryData[] getGeometryData(IDataRequest request,
|
||||
DataTime... times) {
|
||||
validateRequest(request);
|
||||
DbQueryRequest dbQueryRequest = this
|
||||
.buildDbQueryRequest(request, times);
|
||||
return this.getData(request, dbQueryRequest);
|
||||
}
|
||||
|
||||
public D[] getData(R request, TimeRange timeRange) {
|
||||
DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request,
|
||||
timeRange);
|
||||
return this.getData(request, dbQueryRequest);
|
||||
}
|
||||
|
||||
protected D[] getData(R request, DbQueryRequest dbQueryRequest) {
|
||||
DbQueryResponse dbQueryResponse = executeDbQueryRequest(dbQueryRequest,
|
||||
request.toString());
|
||||
return getData(request, dbQueryResponse);
|
||||
return getGeometryData(request, dbQueryResponse);
|
||||
}
|
||||
|
||||
public String[] getAvailableLocationNames(R request, String locationColumn) {
|
||||
public IGeometryData[] getGeometryData(IDataRequest request,
|
||||
TimeRange timeRange) {
|
||||
validateRequest(request);
|
||||
DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request,
|
||||
timeRange);
|
||||
DbQueryResponse dbQueryResponse = executeDbQueryRequest(dbQueryRequest,
|
||||
request.toString());
|
||||
return getGeometryData(request, dbQueryResponse);
|
||||
}
|
||||
|
||||
public IGridData[] getGridData(IDataRequest request, DataTime... times) {
|
||||
validateRequest(request);
|
||||
DbQueryRequest dbQueryRequest = this
|
||||
.buildDbQueryRequest(request, times);
|
||||
DbQueryResponse dbQueryResponse = executeDbQueryRequest(dbQueryRequest,
|
||||
request.toString());
|
||||
return getGridData(request, dbQueryResponse);
|
||||
}
|
||||
|
||||
public IGridData[] getGridData(IDataRequest request, TimeRange timeRange) {
|
||||
validateRequest(request);
|
||||
DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request,
|
||||
timeRange);
|
||||
DbQueryResponse dbQueryResponse = executeDbQueryRequest(dbQueryRequest,
|
||||
request.toString());
|
||||
return getGridData(request, dbQueryResponse);
|
||||
}
|
||||
|
||||
public String[] getAvailableLocationNames(IDataRequest request,
|
||||
String locationColumn) {
|
||||
validateRequest(request);
|
||||
DbQueryRequest dbQueryRequest = buildDbQueryRequest(request);
|
||||
dbQueryRequest.setDistinct(Boolean.TRUE);
|
||||
dbQueryRequest.addRequestField(locationColumn);
|
||||
|
@ -144,6 +153,22 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
|
|||
return locationNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a TimeQueryRequest that will be used to retrieve Data Times.
|
||||
*
|
||||
* @param request
|
||||
* the original grid request
|
||||
* @return a TimeQueryRequest to execute
|
||||
*/
|
||||
protected TimeQueryRequest buildTimeQueryRequest(IDataRequest request) {
|
||||
TimeQueryRequest timeQueryRequest = new TimeQueryRequest();
|
||||
timeQueryRequest.setPluginName(request.getDatatype());
|
||||
timeQueryRequest.setQueryTerms(this
|
||||
.buildConstraintsFromRequest(request));
|
||||
|
||||
return timeQueryRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the provided DbQueryRequest and returns a DbQueryResponse
|
||||
*
|
||||
|
@ -178,7 +203,8 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
|
|||
* the data times to include in the request (if any)
|
||||
* @return a DbQueryRequest to execute
|
||||
*/
|
||||
protected DbQueryRequest buildDbQueryRequest(R request, DataTime[] dataTimes) {
|
||||
protected DbQueryRequest buildDbQueryRequest(IDataRequest request,
|
||||
DataTime[] dataTimes) {
|
||||
DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request);
|
||||
if (dataTimes.length <= 0) {
|
||||
return dbQueryRequest;
|
||||
|
@ -207,7 +233,8 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
|
|||
* the time range to include in the request
|
||||
* @return a DbQueryRequest to execute
|
||||
*/
|
||||
protected DbQueryRequest buildDbQueryRequest(R request, TimeRange timeRange) {
|
||||
protected DbQueryRequest buildDbQueryRequest(IDataRequest request,
|
||||
TimeRange timeRange) {
|
||||
DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request);
|
||||
/* Add the TimeRange Constraint */
|
||||
RequestConstraint requestConstraint = new RequestConstraint();
|
||||
|
@ -215,7 +242,6 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
|
|||
String[] dateTimeStrings = new String[] {
|
||||
timeRange.getStart().toString(), timeRange.getEnd().toString() };
|
||||
requestConstraint.setBetweenValueList(dateTimeStrings);
|
||||
// TODO what should this do with forecast products?
|
||||
dbQueryRequest.addConstraint(FIELD_DATATIME, requestConstraint);
|
||||
|
||||
return dbQueryRequest;
|
||||
|
@ -228,7 +254,7 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
|
|||
* the original grid request
|
||||
* @return the base DbQueryRequest
|
||||
*/
|
||||
protected DbQueryRequest buildDbQueryRequest(R request) {
|
||||
protected DbQueryRequest buildDbQueryRequest(IDataRequest request) {
|
||||
DbQueryRequest dbQueryRequest = new DbQueryRequest();
|
||||
Map<String, RequestConstraint> constraints = this
|
||||
.buildConstraintsFromRequest(request);
|
||||
|
@ -239,9 +265,15 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
|
|||
return dbQueryRequest;
|
||||
}
|
||||
|
||||
protected abstract Map<String, RequestConstraint> buildConstraintsFromRequest(
|
||||
R request);
|
||||
protected abstract IGridData[] getGridData(IDataRequest request,
|
||||
DbQueryResponse dbQueryResponse);
|
||||
|
||||
protected abstract IGeometryData[] getGeometryData(IDataRequest request,
|
||||
DbQueryResponse dbQueryResponse);
|
||||
|
||||
protected abstract Map<String, RequestConstraint> buildConstraintsFromRequest(
|
||||
IDataRequest request);
|
||||
|
||||
|
||||
protected abstract D[] getData(R request, DbQueryResponse dbQueryResponse);
|
||||
|
||||
}
|
||||
|
|
|
@ -19,17 +19,19 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.dataaccess.impl;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataRetrievalException;
|
||||
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException;
|
||||
import com.raytheon.uf.common.dataaccess.exception.UnsupportedOutputTypeException;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryData;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.dataaccess.util.DatabaseQueryUtil;
|
||||
import com.raytheon.uf.common.dataaccess.util.DatabaseQueryUtil.QUERY_MODE;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
|
@ -50,6 +52,8 @@ import com.vividsolutions.jts.geom.Geometry;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 29, 2013 bkowal Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -58,7 +62,7 @@ import com.vividsolutions.jts.geom.Geometry;
|
|||
*/
|
||||
|
||||
public abstract class AbstractGeometryDatabaseFactory extends
|
||||
AbstractDataFactory implements IGeometryDataFactory {
|
||||
AbstractDataFactory implements IDataFactory {
|
||||
|
||||
/*
|
||||
* for now, we will assume that we will always be executing sql queries. If
|
||||
|
@ -95,7 +99,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* raytheon.uf.common.dataaccess.IDataRequest)
|
||||
*/
|
||||
@Override
|
||||
public DataTime[] getAvailableTimes(IGeometryRequest request)
|
||||
public DataTime[] getAvailableTimes(IDataRequest request)
|
||||
throws TimeAgnosticDataException {
|
||||
this.validateRequest(request);
|
||||
return this.executeTimeQuery(this.assembleGetTimes(request), request);
|
||||
|
@ -110,7 +114,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* com.raytheon.uf.common.time.BinOffset)
|
||||
*/
|
||||
@Override
|
||||
public DataTime[] getAvailableTimes(IGeometryRequest request,
|
||||
public DataTime[] getAvailableTimes(IDataRequest request,
|
||||
BinOffset binOffset) throws TimeAgnosticDataException {
|
||||
this.validateRequest(request);
|
||||
return this.executeTimeQuery(this.assembleGetTimes(request, binOffset),
|
||||
|
@ -125,7 +129,8 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* .common.dataaccess.IDataRequest, com.raytheon.uf.common.time.DataTime[])
|
||||
*/
|
||||
@Override
|
||||
public IGeometryData[] getData(IGeometryRequest request, DataTime... times) {
|
||||
public IGeometryData[] getGeometryData(IDataRequest request,
|
||||
DataTime... times) {
|
||||
this.validateRequest(request);
|
||||
return this.executeDataQuery(this.assembleGetData(request, times),
|
||||
request);
|
||||
|
@ -139,12 +144,23 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* .common.dataaccess.IDataRequest, com.raytheon.uf.common.time.TimeRange)
|
||||
*/
|
||||
@Override
|
||||
public IGeometryData[] getData(IGeometryRequest request, TimeRange timeRange) {
|
||||
public IGeometryData[] getGeometryData(IDataRequest request,
|
||||
TimeRange timeRange) {
|
||||
this.validateRequest(request);
|
||||
return this.executeDataQuery(this.assembleGetData(request, timeRange),
|
||||
request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridData[] getGridData(IDataRequest request, DataTime... times) {
|
||||
throw new UnsupportedOutputTypeException(request.getDatatype(), "grid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridData[] getGridData(IDataRequest request, TimeRange timeRange) {
|
||||
throw new UnsupportedOutputTypeException(request.getDatatype(), "grid");
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a query to retrieve Data Times from the database.
|
||||
*
|
||||
|
@ -155,7 +171,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* @return an array of DataTimes
|
||||
*/
|
||||
protected final DataTime[] executeTimeQuery(String query,
|
||||
IGeometryRequest request) {
|
||||
IDataRequest request) {
|
||||
List<Object[]> results = this.executeQuery(query, request);
|
||||
List<DataTime> dataTimes = new ArrayList<DataTime>();
|
||||
for (Object[] objects : results) {
|
||||
|
@ -187,7 +203,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* @return an array of IGeometryData
|
||||
*/
|
||||
protected final IGeometryData[] executeDataQuery(String query,
|
||||
IGeometryRequest request) {
|
||||
IDataRequest request) {
|
||||
List<Object[]> results = this.executeQuery(query, request);
|
||||
return this.makeGeometries(results, request.getParameters(),
|
||||
request.getIdentifiers());
|
||||
|
@ -203,7 +219,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* @return the raw data retrieved from the database
|
||||
*/
|
||||
protected final List<Object[]> executeQuery(String query,
|
||||
IGeometryRequest request) {
|
||||
IDataRequest request) {
|
||||
return DatabaseQueryUtil.executeDatabaseQuery(queryMode, query,
|
||||
this.databaseName, request.getDatatype());
|
||||
}
|
||||
|
@ -213,10 +229,10 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
*
|
||||
* @see com.raytheon.uf.common.dataaccess.geom.IGeometryDataFactory#
|
||||
* getAvailableLocationNames
|
||||
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest)
|
||||
* (com.raytheon.uf.common.dataaccess.geom.IDataRequest)
|
||||
*/
|
||||
@Override
|
||||
public String[] getAvailableLocationNames(IGeometryRequest request) {
|
||||
public String[] getAvailableLocationNames(IDataRequest request) {
|
||||
this.validateRequest(request);
|
||||
List<Object[]> results = this.executeQuery(
|
||||
this.assembleGetAvailableLocationNames(request), request);
|
||||
|
@ -252,7 +268,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* the original request that we are processing
|
||||
* @return the query
|
||||
*/
|
||||
protected abstract String assembleGetTimes(IGeometryRequest request);
|
||||
protected abstract String assembleGetTimes(IDataRequest request);
|
||||
|
||||
/**
|
||||
* Builds a query that will be used to retrieve time from the database based
|
||||
|
@ -264,7 +280,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* the BinOffset to apply to the retrieved DataTimes
|
||||
* @return the query
|
||||
*/
|
||||
protected abstract String assembleGetTimes(IGeometryRequest request,
|
||||
protected abstract String assembleGetTimes(IDataRequest request,
|
||||
BinOffset binOffset);
|
||||
|
||||
/**
|
||||
|
@ -278,7 +294,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* manifest as constraints
|
||||
* @return the query
|
||||
*/
|
||||
protected abstract String assembleGetData(IGeometryRequest request,
|
||||
protected abstract String assembleGetData(IDataRequest request,
|
||||
DataTime... times);
|
||||
|
||||
/**
|
||||
|
@ -292,7 +308,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* manifest as a BETWEEN constraint
|
||||
* @return the query
|
||||
*/
|
||||
protected abstract String assembleGetData(IGeometryRequest request,
|
||||
protected abstract String assembleGetData(IDataRequest request,
|
||||
TimeRange timeRange);
|
||||
|
||||
/**
|
||||
|
@ -304,7 +320,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* @return the query
|
||||
*/
|
||||
protected abstract String assembleGetAvailableLocationNames(
|
||||
IGeometryRequest request);
|
||||
IDataRequest request);
|
||||
|
||||
/**
|
||||
* Builds the data objects that will be returned by calls to getData() on
|
||||
|
@ -338,9 +354,9 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* the raw data associated with a single row retrieved from the
|
||||
* database
|
||||
* @param paramNames
|
||||
* the parameters specified in the original IGeometryRequest
|
||||
* the parameters specified in the original IDataRequest
|
||||
* @param attrs
|
||||
* the identifiers specified in the original IGeometryRequest
|
||||
* the identifiers specified in the original IDataRequest
|
||||
* @return the constructed IGeometryData
|
||||
*/
|
||||
protected abstract IGeometryData makeGeometry(Object[] data,
|
||||
|
@ -358,9 +374,9 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* @param locationName
|
||||
* the provided Location
|
||||
* @param attributes
|
||||
* the identifiers specified in the original IGeometryRequest
|
||||
* the identifiers specified in the original IDataRequest
|
||||
* @param paramNames
|
||||
* the parameters specified in the original IGeometryRequest
|
||||
* the parameters specified in the original IDataRequest
|
||||
* @return the constructed DefaultGeometryData
|
||||
*/
|
||||
protected DefaultGeometryData buildGeometryData(DataTime time, Level level,
|
||||
|
@ -382,7 +398,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* @param locationName
|
||||
* the provided Location
|
||||
* @param attributes
|
||||
* identifiers specified in the original IGeometryRequest
|
||||
* identifiers specified in the original IDataRequest
|
||||
* @param dataIndex
|
||||
* a numerical index indicating where user-specified parameters
|
||||
* may start in the provided row of raw data
|
||||
|
@ -391,7 +407,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
|
|||
* user-specified parameters are extracted from it and added to
|
||||
* the DefaultGeometryData using the addData method
|
||||
* @param paramNames
|
||||
* the parameters specified in the original IGeometryRequest
|
||||
* the parameters specified in the original IDataRequest
|
||||
* @return the constructed DefaultGeometryData
|
||||
*/
|
||||
protected DefaultGeometryData buildGeometryData(DataTime time, Level level,
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.dataaccess.impl;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryData;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest;
|
||||
import com.raytheon.uf.common.time.BinOffset;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
|
@ -37,6 +37,8 @@ import com.raytheon.uf.common.time.TimeRange;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 29, 2013 bkowal Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -69,7 +71,7 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
|
|||
* raytheon.uf.common.dataaccess.IDataRequest)
|
||||
*/
|
||||
@Override
|
||||
public DataTime[] getAvailableTimes(IGeometryRequest request)
|
||||
public DataTime[] getAvailableTimes(IDataRequest request)
|
||||
throws TimeAgnosticDataException {
|
||||
throw new TimeAgnosticDataException(this.buildExceptionMessage(request));
|
||||
}
|
||||
|
@ -82,7 +84,8 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
|
|||
* .common.dataaccess.IDataRequest, com.raytheon.uf.common.time.DataTime[])
|
||||
*/
|
||||
@Override
|
||||
public IGeometryData[] getData(IGeometryRequest request, DataTime... times) {
|
||||
public IGeometryData[] getGeometryData(IDataRequest request,
|
||||
DataTime... times) {
|
||||
return this.getData(request);
|
||||
}
|
||||
|
||||
|
@ -94,7 +97,8 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
|
|||
* .common.dataaccess.IDataRequest, com.raytheon.uf.common.time.TimeRange)
|
||||
*/
|
||||
@Override
|
||||
public IGeometryData[] getData(IGeometryRequest request, TimeRange timeRange) {
|
||||
public IGeometryData[] getGeometryData(IDataRequest request,
|
||||
TimeRange timeRange) {
|
||||
return this.getData(request);
|
||||
}
|
||||
|
||||
|
@ -104,7 +108,7 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
|
|||
* @param request the original request that we are processing
|
||||
* @return an array of IGeometryData
|
||||
*/
|
||||
protected IGeometryData[] getData(IGeometryRequest request) {
|
||||
protected IGeometryData[] getData(IDataRequest request) {
|
||||
return super.executeDataQuery(this.assembleGetData(request), request);
|
||||
}
|
||||
|
||||
|
@ -117,7 +121,7 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
|
|||
* com.raytheon.uf.common.time.BinOffset)
|
||||
*/
|
||||
@Override
|
||||
public DataTime[] getAvailableTimes(IGeometryRequest request,
|
||||
public DataTime[] getAvailableTimes(IDataRequest request,
|
||||
BinOffset binOffset) throws TimeAgnosticDataException {
|
||||
throw new TimeAgnosticDataException(this.buildExceptionMessage(request));
|
||||
}
|
||||
|
@ -128,7 +132,7 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
|
|||
* @param request the original request that we are processing
|
||||
* @return the constructed exception message
|
||||
*/
|
||||
private String buildExceptionMessage(IGeometryRequest request) {
|
||||
private String buildExceptionMessage(IDataRequest request) {
|
||||
StringBuilder stringBuilder = new StringBuilder(
|
||||
"This operation is unsupported for data type: ");
|
||||
stringBuilder.append(request.getDatatype());
|
||||
|
@ -142,7 +146,7 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
|
|||
* @param request the original request that we are processing
|
||||
* @return the query
|
||||
*/
|
||||
protected abstract String assembleGetData(IGeometryRequest request);
|
||||
protected abstract String assembleGetData(IDataRequest request);
|
||||
|
||||
/**
|
||||
* The following methods are no longer applicable to us.
|
||||
|
@ -150,24 +154,24 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
|
|||
* Should we be throwing an exception
|
||||
*/
|
||||
@Override
|
||||
protected String assembleGetTimes(IGeometryRequest request) {
|
||||
protected String assembleGetTimes(IDataRequest request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String assembleGetTimes(IGeometryRequest request,
|
||||
protected String assembleGetTimes(IDataRequest request,
|
||||
BinOffset binOffset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String assembleGetData(IGeometryRequest request,
|
||||
protected String assembleGetData(IDataRequest request,
|
||||
DataTime... times) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String assembleGetData(IGeometryRequest request,
|
||||
protected String assembleGetData(IDataRequest request,
|
||||
TimeRange timeRange) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -23,19 +23,17 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.geotools.coverage.grid.GridEnvelope2D;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.opengis.geometry.Envelope;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataRetrievalException;
|
||||
import com.raytheon.uf.common.dataaccess.exception.UnsupportedOutputTypeException;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryData;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridRequest;
|
||||
import com.raytheon.uf.common.dataaccess.util.PDOUtil;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.Request.Type;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
|
||||
/**
|
||||
|
@ -49,6 +47,8 @@ import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 17, 2013 bsteffen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -57,7 +57,7 @@ import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
|||
*/
|
||||
|
||||
public abstract class AbstractGridDataPluginFactory extends
|
||||
AbstractDataPluginFactory<IGridRequest, IGridData> {
|
||||
AbstractDataPluginFactory {
|
||||
|
||||
/**
|
||||
* Executes the provided DbQueryRequest and returns an array of IGridData
|
||||
|
@ -68,7 +68,7 @@ public abstract class AbstractGridDataPluginFactory extends
|
|||
* the db query request to execute
|
||||
* @return an array of IGridData
|
||||
*/
|
||||
protected IGridData[] getData(IGridRequest request,
|
||||
protected IGridData[] getGridData(IDataRequest request,
|
||||
DbQueryResponse dbQueryResponse) {
|
||||
|
||||
List<IGridData> gridData = new ArrayList<IGridData>();
|
||||
|
@ -85,17 +85,13 @@ public abstract class AbstractGridDataPluginFactory extends
|
|||
PluginDataObject pdo = (PluginDataObject) resultMap
|
||||
.get(null);
|
||||
|
||||
IDataRecord dataRecord = getDataRecord(pdo,
|
||||
request.getStorageRequest());
|
||||
IDataRecord dataRecord = getDataRecord(pdo);
|
||||
|
||||
/*
|
||||
* Extract the grid geometry.
|
||||
*/
|
||||
GridGeometry2D gridGeometry = getGridGeometry(pdo);
|
||||
|
||||
gridGeometry = trimGridGeometryToRequest(gridGeometry,
|
||||
request.getStorageRequest());
|
||||
|
||||
IGridData defaultGridData = null;
|
||||
defaultGridData = this.constructGridDataResponse(request, pdo,
|
||||
gridGeometry, dataRecord);
|
||||
|
@ -106,10 +102,17 @@ public abstract class AbstractGridDataPluginFactory extends
|
|||
return gridData.toArray(new IGridData[gridData.size()]);
|
||||
}
|
||||
|
||||
protected IDataRecord getDataRecord(PluginDataObject pdo,
|
||||
Request storageRequest) {
|
||||
protected IGeometryData[] getGeometryData(IDataRequest request,
|
||||
DbQueryResponse dbQueryResponse) {
|
||||
// Subtypes can optionally support geometry by overriding this, default
|
||||
// is to not support geometry data.
|
||||
throw new UnsupportedOutputTypeException(request.getDatatype(),
|
||||
"geometry");
|
||||
}
|
||||
|
||||
protected IDataRecord getDataRecord(PluginDataObject pdo) {
|
||||
try {
|
||||
return PDOUtil.getDataRecord(pdo, "Data", storageRequest);
|
||||
return PDOUtil.getDataRecord(pdo, "Data", Request.ALL);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new DataRetrievalException(
|
||||
|
@ -136,47 +139,8 @@ public abstract class AbstractGridDataPluginFactory extends
|
|||
* @return the IGridData that was constructed
|
||||
*/
|
||||
protected abstract IGridData constructGridDataResponse(
|
||||
IGridRequest request, PluginDataObject pdo,
|
||||
IDataRequest request, PluginDataObject pdo,
|
||||
GridGeometry2D gridGeometry, IDataRecord dataRecord);
|
||||
|
||||
/**
|
||||
* Given a full PDO grid geometry and the request used this will determine
|
||||
* the geometry that describes the requested area. For null or ALL this
|
||||
* returns the full geometry, for SLAB requests this will create a subset
|
||||
* geometry describing the slab and for all other types of requests this
|
||||
* returns null.
|
||||
*
|
||||
* @param gridGeom
|
||||
* - full dataset geometry
|
||||
* @param storageRequest
|
||||
* @return for null or ALL this returns the full geometry, for SLAB requests
|
||||
* this will create a subset geometry describing the slab and for
|
||||
* all other types of requests this returns null.
|
||||
*/
|
||||
protected static GridGeometry2D trimGridGeometryToRequest(
|
||||
GridGeometry2D gridGeom,
|
||||
Request storageRequest) {
|
||||
if (storageRequest == null || storageRequest.getType() == Type.ALL) {
|
||||
return gridGeom;
|
||||
} else if (storageRequest.getType() == Type.SLAB) {
|
||||
int[] min = storageRequest.getMinIndexForSlab();
|
||||
int[] max = storageRequest.getMaxIndexForSlab();
|
||||
GridEnvelope2D range = new GridEnvelope2D(min[0], min[1], max[0]
|
||||
- min[0], max[1] - min[1]);
|
||||
try {
|
||||
Envelope env = gridGeom.gridToWorld(range);
|
||||
return new GridGeometry2D(range, env);
|
||||
} catch (TransformException e) {
|
||||
throw new DataRetrievalException(e);
|
||||
}
|
||||
} else {
|
||||
// point, and line requests can't easily be described by a grid
|
||||
// geometry. Theoretically if there is one point or if the lines are
|
||||
// evenly spaced it might be possible or lines could be described by
|
||||
// a nonlinear geometry, but as of now there are no plans to use the
|
||||
// api for anything this exciting.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,12 +27,15 @@ import javax.xml.bind.annotation.XmlAccessorType;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.serialization.XmlGenericMapAdapter;
|
||||
import com.raytheon.uf.common.serialization.adapters.JTSEnvelopeAdapter;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
/**
|
||||
*
|
||||
* An abstract request for requesting data through the Data Access Framework.
|
||||
* An default request for requesting data through the Data Access Framework.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -41,6 +44,8 @@ import com.raytheon.uf.common.serialization.XmlGenericMapAdapter;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 6, 2012 njensen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -49,7 +54,7 @@ import com.raytheon.uf.common.serialization.XmlGenericMapAdapter;
|
|||
*/
|
||||
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public abstract class AbstractDataRequest {
|
||||
public class DefaultDataRequest implements IDataRequest {
|
||||
|
||||
@XmlElement
|
||||
protected String datatype;
|
||||
|
@ -57,14 +62,17 @@ public abstract class AbstractDataRequest {
|
|||
@XmlJavaTypeAdapter(value = XmlGenericMapAdapter.class)
|
||||
protected Map<String, Object> identifiers;
|
||||
|
||||
@XmlElement
|
||||
@XmlElement(name = "parameter")
|
||||
protected String[] parameters;
|
||||
|
||||
@XmlElement
|
||||
@XmlElement(name = "level")
|
||||
protected Level[] levels;
|
||||
|
||||
@XmlElement(name = "locationName")
|
||||
protected String[] locationNames;
|
||||
|
||||
@XmlJavaTypeAdapter(value = JTSEnvelopeAdapter.class)
|
||||
protected Envelope envelope;
|
||||
|
||||
public void setDatatype(String datatype) {
|
||||
this.datatype = datatype;
|
||||
|
@ -84,6 +92,15 @@ public abstract class AbstractDataRequest {
|
|||
public void setLevels(Level... levels) {
|
||||
this.levels = levels;
|
||||
}
|
||||
|
||||
public void setLocationNames(String... locationNames) {
|
||||
this.locationNames = locationNames;
|
||||
|
||||
}
|
||||
|
||||
public void setEnvelope(Envelope env) {
|
||||
this.envelope = env;
|
||||
}
|
||||
|
||||
public String getDatatype() {
|
||||
return datatype;
|
||||
|
@ -101,13 +118,13 @@ public abstract class AbstractDataRequest {
|
|||
return levels;
|
||||
}
|
||||
|
||||
public void setLocationNames(String... locationNames) {
|
||||
this.locationNames = locationNames;
|
||||
|
||||
}
|
||||
|
||||
public String[] getLocationNames() {
|
||||
return locationNames;
|
||||
}
|
||||
|
||||
public Envelope getEnvelope() {
|
||||
return envelope;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.dataaccess.impl;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest;
|
||||
import com.raytheon.uf.common.serialization.adapters.JTSEnvelopeAdapter;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
/**
|
||||
* A default IGeometryRequest that can be used for most IGeometryRequests.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 5, 2012 njensen Initial creation
|
||||
* Jan 30, 2013 #1555 bkowal Added XML Annotations
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class DefaultGeometryRequest extends AbstractDataRequest implements
|
||||
IGeometryRequest {
|
||||
|
||||
@XmlJavaTypeAdapter(value = JTSEnvelopeAdapter.class)
|
||||
protected Envelope envelope;
|
||||
|
||||
@Override
|
||||
public void setEnvelope(Envelope env) {
|
||||
this.envelope = env;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Envelope getEnvelope() {
|
||||
return envelope;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.dataaccess.impl;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridRequest;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
|
||||
/**
|
||||
* A default IGridRequest that can be used for most IGridRequests.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 5, 2012 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class DefaultGridRequest extends AbstractDataRequest implements
|
||||
IGridRequest {
|
||||
|
||||
@XmlElement
|
||||
protected Request storageRequest;
|
||||
|
||||
@Override
|
||||
public void setStorageRequest(Request request) {
|
||||
this.storageRequest = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Request getStorageRequest() {
|
||||
return this.storageRequest;
|
||||
}
|
||||
|
||||
}
|
|
@ -21,7 +21,6 @@ package com.raytheon.uf.common.dataaccess.impl;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IData;
|
||||
import com.raytheon.uf.common.dataaccess.IDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.time.BinOffset;
|
||||
|
@ -37,6 +36,8 @@ import com.raytheon.uf.common.time.DataTime;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 14, 2012 njensen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -59,8 +60,8 @@ public class FactoryUtil {
|
|||
* the bin offset to apply
|
||||
* @return the binned times
|
||||
*/
|
||||
public static <R extends IDataRequest<D>, D extends IData> DataTime[] getAvailableTimes(
|
||||
IDataFactory<R, D> factory, R request, BinOffset binOffset) {
|
||||
public static DataTime[] getAvailableTimes(IDataFactory factory,
|
||||
IDataRequest request, BinOffset binOffset) {
|
||||
DataTime[] actualTimes = factory.getAvailableTimes(request);
|
||||
if (binOffset != null) {
|
||||
Set<DataTime> normalized = binOffset
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
<bean factory-bean="dataAccessRegistry" factory-method="register">
|
||||
<constructor-arg value="gfe"/>
|
||||
<constructor-arg value="com.raytheon.uf.common.dataaccess.grid.IGridRequest"/>
|
||||
<constructor-arg ref="gfeGridFactory"/>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -28,10 +28,10 @@ import java.util.Set;
|
|||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataRetrievalException;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridRequest;
|
||||
import com.raytheon.uf.common.dataaccess.impl.AbstractGridDataPluginFactory;
|
||||
import com.raytheon.uf.common.dataaccess.impl.DefaultGridData;
|
||||
import com.raytheon.uf.common.dataaccess.util.DataWrapperUtil;
|
||||
|
@ -49,7 +49,6 @@ import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
|||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
|
@ -65,6 +64,8 @@ import com.raytheon.uf.common.geospatial.MapUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 4, 2013 bsteffen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -73,7 +74,7 @@ import com.raytheon.uf.common.geospatial.MapUtil;
|
|||
*/
|
||||
|
||||
public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
||||
IGridDataFactory {
|
||||
IDataFactory {
|
||||
|
||||
private static final String[] VALID_IDENTIFIERS = { GFEDataAccessUtil.MODEL_NAME,
|
||||
GFEDataAccessUtil.MODEL_TIME, GFEDataAccessUtil.SITE_ID };
|
||||
|
@ -84,7 +85,7 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IGridData constructGridDataResponse(IGridRequest request,
|
||||
protected IGridData constructGridDataResponse(IDataRequest request,
|
||||
PluginDataObject pdo, GridGeometry2D gridGeometry,
|
||||
IDataRecord dataRecord) {
|
||||
GFERecord gfeRecord = asGFERecord(pdo);
|
||||
|
@ -114,7 +115,7 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
|||
|
||||
@Override
|
||||
protected Map<String, RequestConstraint> buildConstraintsFromRequest(
|
||||
IGridRequest request) {
|
||||
IDataRequest request) {
|
||||
HashMap<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
|
||||
|
||||
Map<String, String> parmIdComponents = new HashMap<String, String>();
|
||||
|
@ -182,12 +183,14 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
|||
}
|
||||
}
|
||||
|
||||
constraints.put(GFEDataAccessUtil.PARM_ID,
|
||||
GFEDataAccessUtil.createParmIdConstraint(parmIdComponents));
|
||||
|
||||
return constraints;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IDataRecord getDataRecord(PluginDataObject pdo,
|
||||
Request storageRequest) {
|
||||
protected IDataRecord getDataRecord(PluginDataObject pdo) {
|
||||
GFERecord gfeRecord = asGFERecord(pdo);
|
||||
|
||||
try {
|
||||
|
@ -226,20 +229,7 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public GridGeometry2D getGeometry(IGridRequest request) {
|
||||
DbQueryRequest dbRequest = buildDbQueryRequest(request);
|
||||
dbRequest.setLimit(1);
|
||||
DbQueryResponse dbResonse = executeDbQueryRequest(dbRequest,
|
||||
request.toString());
|
||||
for (Map<String, Object> resultMap : dbResonse.getResults()) {
|
||||
GFERecord gfeRecord = asGFERecord(resultMap.get(null));
|
||||
return getGridGeometry(gfeRecord);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAvailableLocationNames(IGridRequest request) {
|
||||
public String[] getAvailableLocationNames(IDataRequest request) {
|
||||
DbQueryRequest dbRequest = buildDbQueryRequest(request);
|
||||
dbRequest.addRequestField(GFEDataAccessUtil.DB_ID);
|
||||
dbRequest.setDistinct(true);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
<bean factory-bean="dataAccessRegistry" factory-method="register">
|
||||
<constructor-arg value="grid"/>
|
||||
<constructor-arg value="com.raytheon.uf.common.dataaccess.grid.IGridRequest"/>
|
||||
<constructor-arg ref="gridDataAccessFactory"/>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ import javax.measure.unit.Unit;
|
|||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.comm.CommunicationException;
|
||||
import com.raytheon.uf.common.dataaccess.IDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataRetrievalException;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridRequest;
|
||||
import com.raytheon.uf.common.dataaccess.impl.AbstractGridDataPluginFactory;
|
||||
import com.raytheon.uf.common.dataaccess.impl.DefaultGridData;
|
||||
import com.raytheon.uf.common.dataaccess.util.DataWrapperUtil;
|
||||
|
@ -46,13 +46,9 @@ import com.raytheon.uf.common.dataplugin.grid.dataquery.GridQueryAssembler;
|
|||
import com.raytheon.uf.common.dataplugin.grid.mapping.DatasetIdMapper;
|
||||
import com.raytheon.uf.common.dataplugin.level.Level;
|
||||
import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapper;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.gridcoverage.GridCoverage;
|
||||
import com.raytheon.uf.common.gridcoverage.lookup.GridCoverageLookup;
|
||||
import com.raytheon.uf.common.parameter.mapping.ParameterMapper;
|
||||
import com.raytheon.uf.common.util.mapping.Mapper;
|
||||
|
||||
|
@ -66,6 +62,8 @@ import com.raytheon.uf.common.util.mapping.Mapper;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 17, 2013 bsteffen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -74,7 +72,7 @@ import com.raytheon.uf.common.util.mapping.Mapper;
|
|||
*/
|
||||
|
||||
public class GridDataAccessFactory extends AbstractGridDataPluginFactory
|
||||
implements IGridDataFactory {
|
||||
implements IDataFactory {
|
||||
|
||||
private static final String NAMESPACE = "namespace";
|
||||
|
||||
|
@ -87,41 +85,9 @@ public class GridDataAccessFactory extends AbstractGridDataPluginFactory
|
|||
return VALID_IDENTIFIERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GridGeometry2D getGeometry(IGridRequest request) {
|
||||
Object locationId = null;
|
||||
DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request);
|
||||
dbQueryRequest.setDistinct(Boolean.TRUE);
|
||||
dbQueryRequest.addRequestField(GridConstants.LOCATION_ID);
|
||||
|
||||
DbQueryResponse dbQueryResponse = this.executeDbQueryRequest(
|
||||
dbQueryRequest, request.toString());
|
||||
|
||||
if (dbQueryResponse.getResults().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (dbQueryResponse.getResults().size() > 1) {
|
||||
throw new DataRetrievalException(
|
||||
"The provided request parameters refer to more than one geographical location.");
|
||||
}
|
||||
|
||||
locationId = dbQueryResponse.getResults().get(0)
|
||||
.get(GridConstants.LOCATION_ID);
|
||||
GridCoverage cov = GridCoverageLookup.getInstance().getCoverage(
|
||||
Integer.parseInt(locationId.toString()));
|
||||
if (cov != null) {
|
||||
return trimGridGeometryToRequest(cov.getGridGeometry(),
|
||||
request.getStorageRequest());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Map<String, RequestConstraint> buildConstraintsFromRequest(
|
||||
IGridRequest request) {
|
||||
IDataRequest request) {
|
||||
Map<String, RequestConstraint> result = new HashMap<String, RequestConstraint>();
|
||||
|
||||
Map<String, Object> identifiers = request.getIdentifiers();
|
||||
|
@ -219,7 +185,7 @@ public class GridDataAccessFactory extends AbstractGridDataPluginFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IGridData constructGridDataResponse(IGridRequest request,
|
||||
protected IGridData constructGridDataResponse(IDataRequest request,
|
||||
PluginDataObject pdo, GridGeometry2D gridGeometry,
|
||||
IDataRecord dataRecord) {
|
||||
if (pdo instanceof GridRecord == false) {
|
||||
|
@ -305,7 +271,7 @@ public class GridDataAccessFactory extends AbstractGridDataPluginFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
public String[] getAvailableLocationNames(IGridRequest request) {
|
||||
public String[] getAvailableLocationNames(IDataRequest request) {
|
||||
return getAvailableLocationNames(request, GridConstants.DATASET_ID);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
<bean factory-bean="dataAccessRegistry" factory-method="register"
|
||||
depends-on="mapsPluginName, mapsDataFactory">
|
||||
<constructor-arg ref="mapsPluginName"/>
|
||||
<constructor-arg value="com.raytheon.uf.common.dataaccess.geom.IGeometryRequest"/>
|
||||
<constructor-arg ref="mapsDataFactory"/>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -21,12 +21,11 @@ package com.raytheon.uf.common.dataplugin.maps.dataaccess;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataRetrievalException;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryData;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest;
|
||||
import com.raytheon.uf.common.dataaccess.impl.AbstractGeometryTimeAgnosticDatabaseFactory;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.io.ParseException;
|
||||
import com.vividsolutions.jts.io.WKBReader;
|
||||
|
||||
|
@ -42,6 +41,8 @@ import com.vividsolutions.jts.io.WKBReader;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 28, 2013 bkowal Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -106,10 +107,10 @@ public class MapsGeometryFactory extends
|
|||
*
|
||||
* @see com.raytheon.uf.common.dataaccess.impl.
|
||||
* AbstractGeometryTimeAgnosticDatabaseFactory
|
||||
* #assembleGetData(com.raytheon.uf.common.dataaccess.geom.IGeometryRequest)
|
||||
* #assembleGetData(com.raytheon.uf.common.dataaccess.geom.IDataRequest)
|
||||
*/
|
||||
@Override
|
||||
protected String assembleGetData(IGeometryRequest request) {
|
||||
protected String assembleGetData(IDataRequest request) {
|
||||
return MapsQueryAssembler.assembleGetData(request);
|
||||
}
|
||||
|
||||
|
@ -119,10 +120,10 @@ public class MapsGeometryFactory extends
|
|||
* @see
|
||||
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
|
||||
* #assembleGetAvailableLocationNames
|
||||
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest)
|
||||
* (com.raytheon.uf.common.dataaccess.geom.IDataRequest)
|
||||
*/
|
||||
@Override
|
||||
protected String assembleGetAvailableLocationNames(IGeometryRequest request) {
|
||||
protected String assembleGetAvailableLocationNames(IDataRequest request) {
|
||||
return MapsQueryAssembler.assembleGetAvailableLocationNames(request);
|
||||
}
|
||||
}
|
|
@ -21,12 +21,12 @@ package com.raytheon.uf.common.dataplugin.maps.dataaccess;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest;
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataplugin.maps.dataaccess.util.MapsQueryUtil;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
|
||||
|
@ -41,6 +41,8 @@ import com.vividsolutions.jts.geom.Envelope;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 28, 2013 bkowal Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -104,7 +106,7 @@ public class MapsQueryAssembler {
|
|||
* the name of the identifier to extract
|
||||
* @return the identifier
|
||||
*/
|
||||
public static String extractIdentifier(IGeometryRequest request,
|
||||
public static String extractIdentifier(IDataRequest request,
|
||||
String identifierName) {
|
||||
return request.getIdentifiers().get(identifierName).toString();
|
||||
}
|
||||
|
@ -116,7 +118,7 @@ public class MapsQueryAssembler {
|
|||
* the original request that we are processing
|
||||
* @return the table identifier
|
||||
*/
|
||||
public static String extractTable(IGeometryRequest request) {
|
||||
public static String extractTable(IDataRequest request) {
|
||||
return extractIdentifier(request, REQUIRED_IDENTIFIERS.IDENTIFIER_TABLE);
|
||||
}
|
||||
|
||||
|
@ -127,7 +129,7 @@ public class MapsQueryAssembler {
|
|||
* the original request that we are processing
|
||||
* @return the geometry identifier
|
||||
*/
|
||||
public static String extractGeomField(IGeometryRequest request) {
|
||||
public static String extractGeomField(IDataRequest request) {
|
||||
return extractIdentifier(request,
|
||||
REQUIRED_IDENTIFIERS.IDENTIFIER_GEOM_FIELD);
|
||||
}
|
||||
|
@ -139,7 +141,7 @@ public class MapsQueryAssembler {
|
|||
* the original request that we are processing
|
||||
* @return the query
|
||||
*/
|
||||
public static String assembleGetData(IGeometryRequest request) {
|
||||
public static String assembleGetData(IDataRequest request) {
|
||||
return assembleQuery(request, Boolean.FALSE);
|
||||
}
|
||||
|
||||
|
@ -151,7 +153,7 @@ public class MapsQueryAssembler {
|
|||
* @return the query
|
||||
*/
|
||||
public static String assembleGetAvailableLocationNames(
|
||||
IGeometryRequest request) {
|
||||
IDataRequest request) {
|
||||
return assembleQuery(request, Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
@ -165,7 +167,7 @@ public class MapsQueryAssembler {
|
|||
* location information
|
||||
* @return the query
|
||||
*/
|
||||
private static String assembleQuery(IGeometryRequest request,
|
||||
private static String assembleQuery(IDataRequest request,
|
||||
boolean locationQuery) {
|
||||
Envelope envelope = request.getEnvelope();
|
||||
String table = extractTable(request);
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
<bean factory-bean="dataAccessRegistry" factory-method="register">
|
||||
<constructor-arg value="radar"/>
|
||||
<constructor-arg value="com.raytheon.uf.common.dataaccess.grid.IGridRequest"/>
|
||||
<constructor-arg ref="radarGridFactory"/>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -30,11 +30,10 @@ import java.util.Set;
|
|||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataRetrievalException;
|
||||
import com.raytheon.uf.common.dataaccess.exception.IncompatibleRequestException;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridRequest;
|
||||
import com.raytheon.uf.common.dataaccess.impl.AbstractGridDataPluginFactory;
|
||||
import com.raytheon.uf.common.dataaccess.impl.DefaultGridData;
|
||||
import com.raytheon.uf.common.dataaccess.util.DataWrapperUtil;
|
||||
|
@ -49,11 +48,8 @@ import com.raytheon.uf.common.dataplugin.radar.util.RadarDataRetriever;
|
|||
import com.raytheon.uf.common.dataplugin.radar.util.RadarInfo;
|
||||
import com.raytheon.uf.common.dataplugin.radar.util.RadarInfoDict;
|
||||
import com.raytheon.uf.common.dataplugin.radar.util.RadarUtil;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
import com.raytheon.uf.common.datastorage.Request;
|
||||
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.geospatial.interpolation.data.DataSource;
|
||||
|
@ -73,6 +69,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 23, 2013 bsteffen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -80,7 +78,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class RadarGridFactory extends AbstractGridDataPluginFactory implements
|
||||
IGridDataFactory {
|
||||
IDataFactory {
|
||||
|
||||
private static final String PRODUCT_CODE = "productCode";
|
||||
|
||||
|
@ -106,43 +104,7 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public GridGeometry2D getGeometry(IGridRequest request) {
|
||||
// Radial will almost always throw an exception for radial data since
|
||||
// every volume scan starts at a different angle. Raster will work as
|
||||
// long as only one product is requested.
|
||||
GridGeometry2D gridGeom = null;
|
||||
DbQueryRequest dbRequest = buildDbQueryRequest(request);
|
||||
DbQueryResponse dbResonse = executeDbQueryRequest(dbRequest,
|
||||
request.toString());
|
||||
for (Map<String, Object> resultMap : dbResonse.getResults()) {
|
||||
|
||||
if ((resultMap.get(null) instanceof RadarRecord) == false) {
|
||||
throw new DataRetrievalException(
|
||||
"The PluginDataObject objects returned by the DbQueryRequest are not of type PluginDataObject as expected.");
|
||||
}
|
||||
|
||||
RadarRecord radarRecod = (RadarRecord) resultMap.get(null);
|
||||
if (radarRecod.getFormat().equals(RADIAL_FORMAT)) {
|
||||
// TODO need angle data but avoid requesting the rest? Or at
|
||||
// least cache it?
|
||||
getDataRecord(radarRecod, request.getStorageRequest());
|
||||
}
|
||||
GridGeometry2D potentialGridGeom = getGridGeometry(radarRecod);
|
||||
if (gridGeom == null) {
|
||||
gridGeom = potentialGridGeom;
|
||||
} else if (!gridGeom.equals(potentialGridGeom)) {
|
||||
// It would have been nice to throw this before requesting all
|
||||
// the data
|
||||
throw new IncompatibleRequestException(
|
||||
"Multiple radar geometries match the given request().");
|
||||
}
|
||||
}
|
||||
return gridGeom;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IGridData constructGridDataResponse(IGridRequest request,
|
||||
protected IGridData constructGridDataResponse(IDataRequest request,
|
||||
PluginDataObject pdo, GridGeometry2D gridGeometry,
|
||||
IDataRecord dataRecord) {
|
||||
RadarRecord radarRecord = asRadarRecord(pdo);
|
||||
|
@ -226,8 +188,7 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
|
|||
}
|
||||
|
||||
@Override
|
||||
protected IDataRecord getDataRecord(PluginDataObject pdo,
|
||||
Request storageRequest) {
|
||||
protected IDataRecord getDataRecord(PluginDataObject pdo) {
|
||||
RadarRecord radarRecord = asRadarRecord(pdo);
|
||||
try {
|
||||
RadarDataRetriever.populateRadarRecord(PDOUtil.getDataStore(pdo),
|
||||
|
@ -244,7 +205,7 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
|
|||
|
||||
@Override
|
||||
protected Map<String, RequestConstraint> buildConstraintsFromRequest(
|
||||
IGridRequest request) {
|
||||
IDataRequest request) {
|
||||
Map<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
|
||||
if (request.getParameters() != null) {
|
||||
Set<Integer> codes = new HashSet<Integer>();
|
||||
|
@ -338,7 +299,7 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public String[] getAvailableLocationNames(IGridRequest request) {
|
||||
public String[] getAvailableLocationNames(IDataRequest request) {
|
||||
return getAvailableLocationNames(request, ICAO);
|
||||
}
|
||||
|
||||
|
@ -353,6 +314,8 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 25, 2013 bsteffen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
<bean factory-bean="dataAccessRegistry" factory-method="register"
|
||||
depends-on="satellitePluginName, satelliteDataFactory">
|
||||
<constructor-arg ref="satellitePluginName"/>
|
||||
<constructor-arg value="com.raytheon.uf.common.dataaccess.grid.IGridRequest"/>
|
||||
<constructor-arg ref="satelliteDataFactory"/>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -30,22 +30,18 @@ import javax.measure.unit.UnitFormat;
|
|||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.DataRetrievalException;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridData;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridDataFactory;
|
||||
import com.raytheon.uf.common.dataaccess.grid.IGridRequest;
|
||||
import com.raytheon.uf.common.dataaccess.impl.AbstractGridDataPluginFactory;
|
||||
import com.raytheon.uf.common.dataaccess.impl.DefaultGridData;
|
||||
import com.raytheon.uf.common.dataaccess.util.DataWrapperUtil;
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
|
||||
import com.raytheon.uf.common.dataplugin.satellite.units.SatelliteUnits;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
|
||||
/**
|
||||
* A data factory for getting satellite data from the metadata database. There
|
||||
|
@ -59,6 +55,8 @@ import com.raytheon.uf.common.time.DataTime;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 02, 2012 bkowal Initial creation
|
||||
* Jan 22, 2012 bsteffen Extract common functionality to AbstractGridDataPluginFactory
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -66,7 +64,7 @@ import com.raytheon.uf.common.time.DataTime;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class SatelliteGridFactory extends AbstractGridDataPluginFactory
|
||||
implements IGridDataFactory {
|
||||
implements IDataFactory {
|
||||
|
||||
private static final String FIELD_PYHSICAL_ELEMENT = "physicalElement";
|
||||
|
||||
|
@ -75,118 +73,16 @@ public class SatelliteGridFactory extends AbstractGridDataPluginFactory
|
|||
private static final String[] VALID_IDENTIFIERS = { "source",
|
||||
"creatingEntity", FIELD_SECTOR_ID, FIELD_PYHSICAL_ELEMENT };
|
||||
|
||||
private Map<String, GridGeometry2D> sectorGeometryMapCache;
|
||||
|
||||
public SatelliteGridFactory() {
|
||||
this.sectorGeometryMapCache = new HashMap<String, GridGeometry2D>();
|
||||
SatelliteUnits.register();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.dataaccess.grid.IGridDataFactory#getGeometry(com
|
||||
* .raytheon.uf.common.dataaccess.grid.IGridRequest)
|
||||
*/
|
||||
@Override
|
||||
public GridGeometry2D getGeometry(IGridRequest request) {
|
||||
String satelliteSectorID = this.retrieveSectorID(request);
|
||||
|
||||
if (satelliteSectorID == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GridGeometry2D geometry = null;
|
||||
|
||||
/*
|
||||
* Has the Geometry for the sector id already been cached?
|
||||
*/
|
||||
synchronized (this.sectorGeometryMapCache) {
|
||||
if (this.sectorGeometryMapCache.containsKey(satelliteSectorID)) {
|
||||
/*
|
||||
* Return the Geometry from cache.
|
||||
*/
|
||||
geometry = this.sectorGeometryMapCache.get(satelliteSectorID);
|
||||
}
|
||||
}
|
||||
|
||||
if (geometry == null) {
|
||||
/*
|
||||
* Retrieve the Geometry.
|
||||
*/
|
||||
IGridData[] records = this.getData(request, new DataTime[] {});
|
||||
if (records.length <= 0) {
|
||||
// No records were found
|
||||
return null;
|
||||
}
|
||||
geometry = records[0].getGridGeometry();
|
||||
|
||||
/*
|
||||
* Cache the Geometry.
|
||||
*/
|
||||
synchronized (this.sectorGeometryMapCache) {
|
||||
this.sectorGeometryMapCache.put(satelliteSectorID, geometry);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the Geometry.
|
||||
*/
|
||||
return trimGridGeometryToRequest(geometry, request.getStorageRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Will either extract the satellite sector id from the request if it has
|
||||
* been provided or execute a database query utilizing the information in
|
||||
* the request to retrieve the sector id.
|
||||
*
|
||||
* @param request
|
||||
* the original grid request
|
||||
* @return the satellite sector id
|
||||
*/
|
||||
private String retrieveSectorID(IGridRequest request) {
|
||||
/*
|
||||
* Determine if the sector id has been included in the request.
|
||||
*/
|
||||
if (request.getIdentifiers().containsKey(FIELD_SECTOR_ID)) {
|
||||
return request.getIdentifiers().get(FIELD_SECTOR_ID).toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* First, retrieve the unique sector id(s) associated with the request.
|
||||
* Ideally, there will only be one.
|
||||
*/
|
||||
DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request);
|
||||
dbQueryRequest.setDistinct(Boolean.TRUE);
|
||||
dbQueryRequest.addRequestField(FIELD_SECTOR_ID);
|
||||
|
||||
DbQueryResponse dbQueryResponse = this.executeDbQueryRequest(
|
||||
dbQueryRequest, request.toString());
|
||||
|
||||
// Check for no results returned?
|
||||
|
||||
/*
|
||||
* Verify that only one sector id has been returned.
|
||||
*/
|
||||
if (dbQueryResponse.getResults().size() > 1) {
|
||||
throw new DataRetrievalException(
|
||||
"The provided request parameters refer to more than one geographical location.");
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the sector id from the results.
|
||||
*/
|
||||
return dbQueryResponse.getResults().get(0).get(FIELD_SECTOR_ID)
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getValidIdentifiers() {
|
||||
return VALID_IDENTIFIERS;
|
||||
}
|
||||
|
||||
protected DefaultGridData constructGridDataResponse(IGridRequest request,
|
||||
protected DefaultGridData constructGridDataResponse(IDataRequest request,
|
||||
PluginDataObject pdo, GridGeometry2D gridGeometry,
|
||||
IDataRecord dataRecord) {
|
||||
if(pdo instanceof SatelliteRecord == false){
|
||||
|
@ -232,7 +128,7 @@ public class SatelliteGridFactory extends AbstractGridDataPluginFactory
|
|||
* technique
|
||||
*/
|
||||
protected Map<String, RequestConstraint> buildConstraintsFromRequest(
|
||||
IGridRequest request) {
|
||||
IDataRequest request) {
|
||||
Map<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
|
||||
if ((request.getIdentifiers() == null) == false) {
|
||||
Iterator<String> identifiersIterator = request.getIdentifiers()
|
||||
|
@ -264,7 +160,7 @@ public class SatelliteGridFactory extends AbstractGridDataPluginFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
public String[] getAvailableLocationNames(IGridRequest request) {
|
||||
public String[] getAvailableLocationNames(IDataRequest request) {
|
||||
return getAvailableLocationNames(request, FIELD_SECTOR_ID);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
<bean factory-bean="dataAccessRegistry" factory-method="register">
|
||||
<constructor-arg value="ihfsData"/>
|
||||
<constructor-arg value="com.raytheon.uf.common.dataaccess.geom.IGeometryRequest"/>
|
||||
<constructor-arg ref="hydroDataFactory"/>
|
||||
</bean>
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ package com.raytheon.uf.common.hydro.dataaccess;
|
|||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryData;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest;
|
||||
import com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory;
|
||||
import com.raytheon.uf.common.dataaccess.impl.FactoryUtil;
|
||||
import com.raytheon.uf.common.time.BinOffset;
|
||||
|
@ -48,6 +48,8 @@ import com.vividsolutions.jts.geom.GeometryFactory;
|
|||
* Nov 13, 2012 njensen Initial creation
|
||||
* Jan 30, 2012 1551 bkowal Refactored
|
||||
* Jan 31, 2012 1555 bkowal Modification based on existing hydro code
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -79,8 +81,7 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
|
|||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
|
||||
* #getAvailableTimes
|
||||
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest,
|
||||
* #getAvailableTimes (com.raytheon.uf.common.dataaccess.geom.IDataRequest,
|
||||
* com.raytheon.uf.common.time.BinOffset)
|
||||
*/
|
||||
/*
|
||||
|
@ -89,7 +90,7 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
|
|||
* accessed directly?
|
||||
*/
|
||||
@Override
|
||||
public DataTime[] getAvailableTimes(IGeometryRequest request,
|
||||
public DataTime[] getAvailableTimes(IDataRequest request,
|
||||
BinOffset binOffset) throws TimeAgnosticDataException {
|
||||
return FactoryUtil.getAvailableTimes(this, request, binOffset);
|
||||
}
|
||||
|
@ -131,11 +132,10 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
|
|||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
|
||||
* #assembleGetTimes
|
||||
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest)
|
||||
* #assembleGetTimes (com.raytheon.uf.common.dataaccess.geom.IDataRequest)
|
||||
*/
|
||||
@Override
|
||||
protected String assembleGetTimes(IGeometryRequest request) {
|
||||
protected String assembleGetTimes(IDataRequest request) {
|
||||
return HydroQueryAssembler.assembleGetTimes(request);
|
||||
}
|
||||
|
||||
|
@ -144,12 +144,11 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
|
|||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
|
||||
* #assembleGetTimes
|
||||
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest,
|
||||
* #assembleGetTimes (com.raytheon.uf.common.dataaccess.geom.IDataRequest,
|
||||
* com.raytheon.uf.common.time.BinOffset)
|
||||
*/
|
||||
@Override
|
||||
protected String assembleGetTimes(IGeometryRequest request,
|
||||
protected String assembleGetTimes(IDataRequest request,
|
||||
BinOffset binOffset) {
|
||||
return null;
|
||||
}
|
||||
|
@ -159,11 +158,11 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
|
|||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
|
||||
* #assembleGetData(com.raytheon.uf.common.dataaccess.geom.IGeometryRequest,
|
||||
* #assembleGetData(com.raytheon.uf.common.dataaccess.geom.IDataRequest,
|
||||
* com.raytheon.uf.common.time.DataTime[])
|
||||
*/
|
||||
@Override
|
||||
protected String assembleGetData(IGeometryRequest request,
|
||||
protected String assembleGetData(IDataRequest request,
|
||||
DataTime... times) {
|
||||
return HydroQueryAssembler.assembleGetData(request, times);
|
||||
}
|
||||
|
@ -173,11 +172,11 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
|
|||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
|
||||
* #assembleGetData(com.raytheon.uf.common.dataaccess.geom.IGeometryRequest,
|
||||
* #assembleGetData(com.raytheon.uf.common.dataaccess.geom.IDataRequest,
|
||||
* com.raytheon.uf.common.time.TimeRange)
|
||||
*/
|
||||
@Override
|
||||
protected String assembleGetData(IGeometryRequest request,
|
||||
protected String assembleGetData(IDataRequest request,
|
||||
TimeRange timeRange) {
|
||||
return HydroQueryAssembler.assembleGetData(request, timeRange);
|
||||
}
|
||||
|
@ -188,10 +187,10 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
|
|||
* @see
|
||||
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
|
||||
* #assembleGetAvailableLocationNames
|
||||
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest)
|
||||
* (com.raytheon.uf.common.dataaccess.geom.IDataRequest)
|
||||
*/
|
||||
@Override
|
||||
protected String assembleGetAvailableLocationNames(IGeometryRequest request) {
|
||||
protected String assembleGetAvailableLocationNames(IDataRequest request) {
|
||||
return "select lid from location;";
|
||||
}
|
||||
}
|
|
@ -24,14 +24,14 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataaccess.IDataRequest;
|
||||
import com.raytheon.uf.common.dataaccess.exception.IncompatibleRequestException;
|
||||
import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.common.time.TimeRange;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
|
||||
/**
|
||||
* Utilities for assembling a SQL query based on an IGeometryRequest
|
||||
* Utilities for assembling a SQL query based on an IDataRequest
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -40,6 +40,8 @@ import com.raytheon.uf.common.time.util.TimeUtil;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 15, 2012 njensen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -71,7 +73,7 @@ public class HydroQueryAssembler {
|
|||
* the times of data to request
|
||||
* @return the SQL query
|
||||
*/
|
||||
public static String assembleGetData(IGeometryRequest request,
|
||||
public static String assembleGetData(IDataRequest request,
|
||||
DataTime[] times) {
|
||||
return assembleGetData(request, buildTimeConstraint(times)).toString();
|
||||
}
|
||||
|
@ -85,7 +87,7 @@ public class HydroQueryAssembler {
|
|||
* the time range of data to request
|
||||
* @return the SQL query
|
||||
*/
|
||||
public static String assembleGetData(IGeometryRequest request,
|
||||
public static String assembleGetData(IDataRequest request,
|
||||
TimeRange timeRange) {
|
||||
return assembleGetData(request, buildTimeConstraint(timeRange))
|
||||
.toString();
|
||||
|
@ -101,7 +103,7 @@ public class HydroQueryAssembler {
|
|||
* May be null.
|
||||
* @return a SQL string that corresponds to the request
|
||||
*/
|
||||
private static CharSequence assembleGetData(IGeometryRequest request,
|
||||
private static CharSequence assembleGetData(IDataRequest request,
|
||||
CharSequence timeConstraint) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// this method assembles a sql string such as:
|
||||
|
@ -139,7 +141,7 @@ public class HydroQueryAssembler {
|
|||
* the request to find available times for
|
||||
* @return the SQL query
|
||||
*/
|
||||
public static String assembleGetTimes(IGeometryRequest request) {
|
||||
public static String assembleGetTimes(IDataRequest request) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
// select
|
||||
|
@ -168,7 +170,7 @@ public class HydroQueryAssembler {
|
|||
* the request to form a select statement on
|
||||
* @return the select statement
|
||||
*/
|
||||
private static CharSequence buildSelectParams(IGeometryRequest request) {
|
||||
private static CharSequence buildSelectParams(IDataRequest request) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// always want the location name and time even if they didn't request it
|
||||
// so that returned objects will have that information
|
||||
|
@ -195,7 +197,7 @@ public class HydroQueryAssembler {
|
|||
* the request to determine the tablename from
|
||||
* @return the from statement
|
||||
*/
|
||||
private static CharSequence buildFrom(IGeometryRequest request) {
|
||||
private static CharSequence buildFrom(IDataRequest request) {
|
||||
return " from " + request.getIdentifiers().get(TABLE);
|
||||
}
|
||||
|
||||
|
@ -207,7 +209,7 @@ public class HydroQueryAssembler {
|
|||
* the request to determine the tablename from
|
||||
* @return the from statement
|
||||
*/
|
||||
private static CharSequence buildFromWithLocation(IGeometryRequest request) {
|
||||
private static CharSequence buildFromWithLocation(IDataRequest request) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(buildFrom(request));
|
||||
sb.append(" d, location l");
|
||||
|
@ -224,7 +226,7 @@ public class HydroQueryAssembler {
|
|||
* buildTimeConstraint(), or null
|
||||
* @return the where clause
|
||||
*/
|
||||
private static CharSequence buildWhere(IGeometryRequest request,
|
||||
private static CharSequence buildWhere(IDataRequest request,
|
||||
CharSequence timeConstraint) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
CharSequence locationConstraint = buildLocationConstraint(request
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 12/10/12 njensen Initial Creation.
|
||||
# Feb 14, 2013 1614 bsteffen refactor data access framework
|
||||
# to use single request.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
@ -47,20 +49,20 @@ else:
|
|||
def getAvailableTimes(request):
|
||||
return router.getAvailableTimes(request)
|
||||
|
||||
def getData(request, times):
|
||||
return router.getData(request, times)
|
||||
def getGridData(request, times):
|
||||
return router.getGridData(request, times)
|
||||
|
||||
def getLatLonCoords(gridRequest):
|
||||
return router.getLatLonCoords(gridRequest)
|
||||
def getGeometryData(request, times):
|
||||
return router.getGeometryData(request, times)
|
||||
|
||||
def getLatLonCoords(gridData):
|
||||
return router.getLatLonCoords(gridData)
|
||||
|
||||
def getAvailableLocationNames(request):
|
||||
return router.getAvailableLocationNames(request)
|
||||
|
||||
def newGeometryRequest():
|
||||
return router.newGeometryRequest()
|
||||
|
||||
def newGridRequest():
|
||||
return router.newGridRequest()
|
||||
def newDataRequest():
|
||||
return router.newDataRequest()
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 12/10/12 njensen Initial Creation.
|
||||
# Feb 14, 2013 1614 bsteffen refactor data access framework
|
||||
# to use single request.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
@ -57,6 +59,10 @@ class IDataRequest(object):
|
|||
def setLevels(self, levels):
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def setEnvelope(self, env):
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def setLocationNames(self, locationNames):
|
||||
return
|
||||
|
@ -69,10 +75,6 @@ class IDataRequest(object):
|
|||
def getIdentifiers(self):
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getParameters(self):
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getLevels(self):
|
||||
return
|
||||
|
@ -80,21 +82,11 @@ class IDataRequest(object):
|
|||
@abc.abstractmethod
|
||||
def getLocationNames(self):
|
||||
return
|
||||
|
||||
class IGridRequest(IDataRequest):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
|
||||
class IGeometryRequest(IDataRequest):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def getEnvelope(self):
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def setEnvelope(self, env):
|
||||
return
|
||||
|
||||
|
||||
|
||||
class IData(object):
|
||||
|
@ -119,7 +111,6 @@ class IData(object):
|
|||
|
||||
|
||||
class IGridData(IData):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def getParameter(self):
|
||||
|
@ -136,7 +127,6 @@ class IGridData(IData):
|
|||
|
||||
|
||||
class IGeometryData(IData):
|
||||
#__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def getGeometry(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue