Merge "Issue #1614 Refactor data access framework to use single request. Change-Id: Id3ed7afcf79dfb2ddeca1d9c2b632f90cc44d798" into development

Former-commit-id: f748815e22 [formerly 55acd96d99a61170cbbc2b202e9562912b6fb0c3]
Former-commit-id: f79f7db348
This commit is contained in:
Nate Jensen 2013-02-15 11:56:11 -06:00 committed by Gerrit Code Review
commit a60cf277bc
41 changed files with 555 additions and 1033 deletions

View file

@ -40,6 +40,8 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 31, 2013 bkowal Initial creation * Jan 31, 2013 bkowal Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -47,7 +49,7 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
* @version 1.0 * @version 1.0
*/ */
public abstract class AbstractDataAccessResource<T extends AbstractDataAccessResourceData<?, ?>> public abstract class AbstractDataAccessResource<T extends AbstractDataAccessResourceData<?>>
extends AbstractVizResource<T, MapDescriptor> { extends AbstractVizResource<T, MapDescriptor> {
protected static final String _SPACE_ = " "; protected static final String _SPACE_ = " ";

View file

@ -22,10 +22,13 @@ package com.raytheon.viz.dataaccess.rsc;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.xml.bind.annotation.XmlElement;
import com.raytheon.uf.common.dataaccess.DataAccessLayer; import com.raytheon.uf.common.dataaccess.DataAccessLayer;
import com.raytheon.uf.common.dataaccess.IData; import com.raytheon.uf.common.dataaccess.IData;
import com.raytheon.uf.common.dataaccess.IDataRequest; import com.raytheon.uf.common.dataaccess.IDataRequest;
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException; 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.common.time.DataTime;
import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.exception.NoDataAvailableException; import com.raytheon.uf.viz.core.exception.NoDataAvailableException;
@ -44,6 +47,8 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 31, 2013 bkowal Initial creation * Jan 31, 2013 bkowal Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -51,8 +56,11 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
* @version 1.0 * @version 1.0
*/ */
public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>, X extends IData> public abstract class AbstractDataAccessResourceData<X extends IData> extends
extends AbstractResourceData { AbstractResourceData {
@XmlElement
private DefaultDataRequest request;
private DataTime[] dataTimes; private DataTime[] dataTimes;
@ -76,7 +84,7 @@ public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>,
@Override @Override
public AbstractVizResource<?, ?> construct(LoadProperties loadProperties, public AbstractVizResource<?, ?> construct(LoadProperties loadProperties,
IDescriptor descriptor) throws VizException { IDescriptor descriptor) throws VizException {
this.populateTimes(this.getRequest()); this.populateTimes(request);
return this.constructResource(loadProperties, descriptor); return this.constructResource(loadProperties, descriptor);
} }
@ -87,7 +95,8 @@ public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>,
* @param request * @param request
* the request * the request
*/ */
protected void populateTimes(T request) throws NoDataAvailableException { protected void populateTimes(IDataRequest request)
throws NoDataAvailableException {
dataTimes = null; dataTimes = null;
try { try {
dataTimes = DataAccessLayer.getAvailableTimes(request); dataTimes = DataAccessLayer.getAvailableTimes(request);
@ -97,7 +106,7 @@ public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>,
} catch (TimeAgnosticDataException e1) { } catch (TimeAgnosticDataException e1) {
// Make sure that time agnostic has data before continuing. // Make sure that time agnostic has data before continuing.
dataTimes = null; dataTimes = null;
X[] data = retreiveData(request, null); X[] data = retreiveData(request);
if (data == null || data.length == 0) { if (data == null || data.length == 0) {
throw new NoDataAvailableException(this.getClass()); 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 * the class that is requesting the data; will always be a
* subclass of AbstractDataAccessResourceData * subclass of AbstractDataAccessResourceData
*/ */
private X[] retreiveData(T request, DataTime dataTime) { protected abstract X[] retreiveData(IDataRequest request, DataTime... times);
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();
/** /**
* Constructs the resource * Constructs the resource
@ -147,7 +134,8 @@ public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>,
* @throws VizException * @throws VizException
*/ */
protected abstract AbstractVizResource<?, ?> constructResource( protected abstract AbstractVizResource<?, ?> constructResource(
LoadProperties loadProperties, IDescriptor descriptor) throws VizException; LoadProperties loadProperties, IDescriptor descriptor)
throws VizException;
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -187,13 +175,19 @@ public abstract class AbstractDataAccessResourceData<T extends IDataRequest<X>,
public X[] getData(DataTime time) { public X[] getData(DataTime time) {
if (data.containsKey(time)) { if (data.containsKey(time)) {
return data.get(time); return data.get(time);
} else { } else if (time != null) {
X[] data = retreiveData(getRequest(), time); X[] data = retreiveData(request, time);
this.data.put(time, data); this.data.put(time, data);
return data; return data;
} else if (dataTimes == null) {
X[] data = retreiveData(request);
this.data.put(time, data);
return data;
} else {
return null;
} }
} }
/** /**
* get the dataTimes * get the dataTimes
* *

View file

@ -21,14 +21,15 @@ package com.raytheon.viz.dataaccess.rsc.geometry;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; 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.drawables.IDescriptor;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties; 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; import com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData;
/** /**
@ -41,6 +42,8 @@ import com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 30, 2013 bkowal Initial creation * Jan 30, 2013 bkowal Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -50,9 +53,7 @@ import com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData;
@XmlAccessorType(XmlAccessType.NONE) @XmlAccessorType(XmlAccessType.NONE)
public class GenericGeometryResourceData extends public class GenericGeometryResourceData extends
AbstractDataAccessResourceData<DefaultGeometryRequest, IGeometryData> { AbstractDataAccessResourceData<IGeometryData> {
@XmlElement
private DefaultGeometryRequest request;
/** /**
* Constructor * Constructor
@ -74,15 +75,9 @@ public class GenericGeometryResourceData extends
return new GenericGeometryResource(this, loadProperties); return new GenericGeometryResource(this, loadProperties);
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData#getRequest
* ()
*/
@Override @Override
protected DefaultGeometryRequest getRequest() { protected IGeometryData[] retreiveData(IDataRequest request,
return this.request; DataTime... times) {
return DataAccessLayer.getGeometryData(request, times);
} }
} }

View file

@ -21,14 +21,15 @@ package com.raytheon.viz.dataaccess.rsc.grid;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; 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.drawables.IDescriptor;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties; 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; 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 8, 2013 bkowal Initial creation
* Jan 31, 2013 #1555 bkowal Refactor * Jan 31, 2013 #1555 bkowal Refactor
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -51,9 +54,7 @@ import com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData;
@XmlAccessorType(XmlAccessType.NONE) @XmlAccessorType(XmlAccessType.NONE)
public class GenericGridResourceData extends public class GenericGridResourceData extends
AbstractDataAccessResourceData<DefaultGridRequest, IGridData> { AbstractDataAccessResourceData<IGridData> {
@XmlElement
private DefaultGridRequest request;
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -69,15 +70,9 @@ public class GenericGridResourceData extends
return new GenericGridResource(this, loadProperties); return new GenericGridResource(this, loadProperties);
} }
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.dataaccess.rsc.AbstractDataAccessResourceData#getRequest
* ()
*/
@Override @Override
protected DefaultGridRequest getRequest() { protected IGridData[] retreiveData(IDataRequest request, DataTime... times) {
return this.request; return DataAccessLayer.getGridData(request, times);
} }
} }

View file

@ -28,6 +28,8 @@
# Date Ticket# Engineer Description # Date Ticket# Engineer Description
# ------------ ---------- ----------- -------------------------- # ------------ ---------- ----------- --------------------------
# 12/17/12 njensen Initial Creation. # 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)): for i in xrange(len(args)):
levels[i] = Level(str(args[i])) levels[i] = Level(str(args[i]))
self.jobj.setLevels(levels) self.jobj.setLevels(levels)
def getLocationNames(self): def setEnvelope(self, env):
return self.jobj.getLocationNames() 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): def getDatatype(self):
return self.jobj.getDatatype() return self.jobj.getDatatype()
@ -87,12 +99,16 @@ class JDataRequest(IDataRequest, JUtil.JavaWrapperClass):
levels.append(str(lev)) levels.append(str(lev))
return levels return levels
def setLocationNames(self, *args): def getEnvelope(self):
from java.lang import String as JavaString env = None
locs = jep.jarray(len(args), JavaString) jenv = self.jobj.getEnvelope()
for i in xrange(len(args)): if jenv:
locs[i] = str(args[i]) from com.vividsolutions.jts.geom import GeometryFactory
self.jobj.setLocationNames(locs) env = shapely.wkt.loads(GeometryFactory().toGeometry(jenv).toText())
return env
def getLocationNames(self):
return self.jobj.getLocationNames()
def toJavaObj(self): def toJavaObj(self):
return self.jobj return self.jobj

View file

@ -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)

View file

@ -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)

View file

@ -30,21 +30,23 @@
# Date Ticket# Engineer Description # Date Ticket# Engineer Description
# ------------ ---------- ----------- -------------------------- # ------------ ---------- ----------- --------------------------
# 12/10/12 njensen Initial Creation. # 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 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.time import DataTime as JavaDataTime
from com.raytheon.uf.common.geospatial import LatLonReprojection from com.raytheon.uf.common.geospatial import LatLonReprojection
from com.raytheon.uf.common.python import PythonNumpyFloatArray from com.raytheon.uf.common.python import PythonNumpyFloatArray
import jep import jep
import DataTime import DataTime
import JGeometryData, JGridData, JGridRequest, JGeometryRequest import JGeometryData, JGridData, JDataRequest
def getAvailableTimes(request): def getAvailableTimes(request):
@ -55,31 +57,41 @@ def getAvailableTimes(request):
return times return times
def getData(request, times): def getGridData(request, times):
if type(times) is list: if type(times) is list:
# presuming list of DataTimes # presuming list of DataTimes
jtimes = jep.jarray(len(times), JavaDataTime) jtimes = jep.jarray(len(times), JavaDataTime)
for i in xrange(len(times)): for i in xrange(len(times)):
jtimes[i] = times[i].toJavaObj() jtimes[i] = times[i].toJavaObj()
javaData = JavaDataAccessLayer.getData(request.toJavaObj(), jtimes) javaData = JavaDataAccessLayer.getGridData(request.toJavaObj(), jtimes)
else: else:
# presuming TimeRange # presuming TimeRange
javaData = JavaDataAccessLayer.getData(request.toJavaObj(), times.toJavaObj()) javaData = JavaDataAccessLayer.getGridData(request.toJavaObj(), times.toJavaObj())
wrapper = None
if isinstance(request, IGeometryRequest):
wrapper = JGeometryData.JGeometryData
elif isinstance(request, IGridRequest):
wrapper = JGridData.JGridData
data = [] data = []
for jd in javaData: for jd in javaData:
data.append(wrapper(jd)) data.append(JGridData.JGridData(jd))
return data 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 @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 : if gridGeometry is None :
return None return None
latlons = LatLonReprojection.getLatLons(gridGeometry) latlons = LatLonReprojection.getLatLons(gridGeometry)
@ -92,9 +104,6 @@ def getLatLonCoords(gridRequest):
def getAvailableLocationNames(request): def getAvailableLocationNames(request):
return JavaDataAccessLayer.getAvailableLocationNames(request.toJavaObj()) return JavaDataAccessLayer.getAvailableLocationNames(request.toJavaObj())
def newGeometryRequest(): def newDataRequest():
return JGeometryRequest.JGeometryRequest(DefaultGeometryRequest()) return JDataRequest.JDataRequest(DefaultDataRequest())
def newGridRequest():
return JGridRequest.JGridRequest(DefaultGridRequest())

View file

@ -19,12 +19,11 @@
**/ **/
package com.raytheon.uf.common.dataaccess; 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.DataFactoryNotFoundException;
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException; import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException;
import com.raytheon.uf.common.dataaccess.grid.IGridDataFactory; import com.raytheon.uf.common.dataaccess.exception.UnsupportedOutputTypeException;
import com.raytheon.uf.common.dataaccess.grid.IGridRequest; 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.BinOffset;
import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange; import com.raytheon.uf.common.time.TimeRange;
@ -48,6 +47,8 @@ import com.raytheon.uf.common.time.TimeRange;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 24, 2012 njensen Initial creation * Oct 24, 2012 njensen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -65,9 +66,8 @@ public class DataAccessLayer {
* @return the available times that match the request * @return the available times that match the request
* @throws TimeAgnosticDataException * @throws TimeAgnosticDataException
*/ */
public static <R extends IDataRequest<D>, D extends IData> DataTime[] getAvailableTimes( public static DataTime[] getAvailableTimes(IDataRequest request) {
R request) { IDataFactory factory = getFactory(request);
IDataFactory<R, D> factory = getFactory(request);
return factory.getAvailableTimes(request); return factory.getAvailableTimes(request);
} }
@ -82,27 +82,29 @@ public class DataAccessLayer {
* request * request
* @throws TimeAgnosticDataException * @throws TimeAgnosticDataException
*/ */
public static <R extends IDataRequest<D>, D extends IData> DataTime[] getAvailableTimes( public static DataTime[] getAvailableTimes(IDataRequest request,
R request, BinOffset binOffset) { BinOffset binOffset) {
IDataFactory<R, D> factory = getFactory(request); IDataFactory factory = getFactory(request);
return factory.getAvailableTimes(request, binOffset); return factory.getAvailableTimes(request, binOffset);
} }
/** /**
* Gets the data that matches the request at the specified times. If data is * 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 * time agnostic then simply don't pass in any DataTimes, for example
* DataAccessLayer.getData(R) * DataAccessLayer.getGridData(R)
* *
* @param request * @param request
* the request to get data for * the request to get data for
* @param times * @param times
* the times to get data for * the times to get data for
* @return the data that matches the request and times * @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( public static IGridData[] getGridData(IDataRequest request,
R request, DataTime... times) { DataTime... times) throws UnsupportedOutputTypeException {
IDataFactory<R, D> factory = getFactory(request); IDataFactory factory = getFactory(request);
return factory.getData(request, times); return factory.getGridData(request, times);
} }
/** /**
@ -113,25 +115,49 @@ public class DataAccessLayer {
* @param timeRange * @param timeRange
* the time range to get data for * the time range to get data for
* @return the data that matches the request and time range * @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( public static IGeometryData[] getGeometryData(IDataRequest request,
R request, TimeRange timeRange) { TimeRange timeRange) throws UnsupportedOutputTypeException {
IDataFactory<R, D> factory = getFactory(request); IDataFactory factory = getFactory(request);
return factory.getData(request, timeRange); return factory.getGeometryData(request, timeRange);
} }
/** /**
* Gets the grid geometry of the data matching the request without actually * Gets the data that matches the request at the specified times. If data is
* requesting the data. Useful for then making slab/subgrid/line requests by * time agnostic then simply don't pass in any DataTimes, for example
* setting the storage request parameter on an IGridRequest. * DataAccessLayer.getGeometryData(R)
* *
* @param request * @param request
* the request to get the grid geometry of the data for * the request to get data for
* @return the geometry of the data if the data was requested * @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) { public static IGeometryData[] getGeometryData(IDataRequest request,
IGridDataFactory factory = (IGridDataFactory) getFactory(request); DataTime... times) throws UnsupportedOutputTypeException {
return factory.getGeometry(request); 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 * @param request
* @return the available location names if the data was requested * @return the available location names if the data was requested
*/ */
public static <R extends IDataRequest<D>, D extends IData> String[] getAvailableLocationNames( public static String[] getAvailableLocationNames(IDataRequest request) {
R request) { IDataFactory factory = getFactory(request);
IDataFactory<R, D> factory = getFactory(request);
return factory.getAvailableLocationNames(request); return factory.getAvailableLocationNames(request);
} }
@ -156,8 +181,7 @@ public class DataAccessLayer {
* @return the factory that matches the request * @return the factory that matches the request
* @throws DataFactoryNotFoundException * @throws DataFactoryNotFoundException
*/ */
private static <R extends IDataRequest<D>, D extends IData> IDataFactory<R, D> getFactory( private static IDataFactory getFactory(IDataRequest request) {
R request) {
return DataFactoryRegistry.getInstance().getFactory(request); return DataFactoryRegistry.getInstance().getFactory(request);
} }

View file

@ -21,7 +21,6 @@ package com.raytheon.uf.common.dataaccess;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException; import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException;
@ -38,6 +37,8 @@ import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 10, 2012 njensen Initial creation * Oct 10, 2012 njensen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -47,7 +48,7 @@ import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException;
public class DataFactoryRegistry { public class DataFactoryRegistry {
private Map<String, Map<Class<IDataRequest<?>>, IDataFactory<?, ?>>> datatypeMap; private Map<String, IDataFactory> datatypeMap;
private static DataFactoryRegistry instance; private static DataFactoryRegistry instance;
@ -55,7 +56,7 @@ public class DataFactoryRegistry {
* Constructor * Constructor
*/ */
private DataFactoryRegistry() { 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 * the factory that will support requests of this datatype and
* type * type
*/ */
public IDataFactory<?, ?> register(String datatype, public IDataFactory register(String datatype, IDataFactory factory) {
Class<IDataRequest<?>> requestType, IDataFactory<?, ?> factory) {
datatype = datatype.toLowerCase(); datatype = datatype.toLowerCase();
Map<Class<IDataRequest<?>>, IDataFactory<?, ?>> requestTypeMap = datatypeMap datatypeMap.put(datatype, factory);
.get(datatype);
if (requestTypeMap == null) {
requestTypeMap = new HashMap<Class<IDataRequest<?>>, IDataFactory<?, ?>>();
datatypeMap.put(datatype, requestTypeMap);
}
requestTypeMap.put(requestType, factory);
return factory; return factory;
} }
@ -107,30 +101,13 @@ public class DataFactoryRegistry {
* @throws DataFactoryNotFoundException * @throws DataFactoryNotFoundException
* @throws IllegalArgumentException * @throws IllegalArgumentException
*/ */
@SuppressWarnings("unchecked") public IDataFactory getFactory(IDataRequest request) {
public <R extends IDataRequest<D>, D extends IData> IDataFactory<R, D> getFactory(
R request) {
String datatype = request.getDatatype().toLowerCase(); String datatype = request.getDatatype().toLowerCase();
if (datatype != null) { if (datatype != null) {
Map<Class<IDataRequest<?>>, IDataFactory<?, ?>> requestTypeMap = datatypeMap IDataFactory factory = datatypeMap
.get(datatype); .get(datatype);
if (requestTypeMap != null) { if (factory != null) {
IDataFactory<?, ?> factory = null; return factory;
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());
}
} else { } else {
throw new DataFactoryNotFoundException( throw new DataFactoryNotFoundException(
"No data access support registered to datatype key: " "No data access support registered to datatype key: "

View file

@ -20,6 +20,9 @@
package com.raytheon.uf.common.dataaccess; package com.raytheon.uf.common.dataaccess;
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException; 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.BinOffset;
import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange; import com.raytheon.uf.common.time.TimeRange;
@ -49,6 +52,8 @@ import com.raytheon.uf.common.time.TimeRange;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 10, 2012 njensen Initial creation * Oct 10, 2012 njensen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -57,7 +62,7 @@ import com.raytheon.uf.common.time.TimeRange;
* @param <D> * @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 * 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 * @return the times that have data available for this request
* @throws TimeAgnosticDataException * @throws TimeAgnosticDataException
*/ */
public DataTime[] getAvailableTimes(R request) public DataTime[] getAvailableTimes(IDataRequest request)
throws TimeAgnosticDataException; throws TimeAgnosticDataException;
/** /**
@ -84,7 +89,8 @@ public interface IDataFactory<R extends IDataRequest<D>, D extends IData> {
* for this request * for this request
* @throws TimeAgnosticDataException * @throws TimeAgnosticDataException
*/ */
public DataTime[] getAvailableTimes(R request, BinOffset binOffset) public DataTime[] getAvailableTimes(IDataRequest request,
BinOffset binOffset)
throws TimeAgnosticDataException; 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 * the times to get data for. If data is time agnostic, use
* getData(R) * getData(R)
* @return the data that matches the request at the specified times * @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 * 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, * the time range to return data for. If data is time agnostic,
* use getData(R). * use getData(R).
* @return the data that matches the request within the time range * @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 * Gets the available location names that match the request. Implementations
* should throw LocationNameUnsupportedException if location names do not * should throw IncompatibleRequestException if location names do not apply
* apply to their datatype. * to their datatype.
* *
* @param request * @param request
* the request to find matching location names for * the request to find matching location names for
* @return the available location names that match the request * @return the available location names that match the request
*/ */
public String[] getAvailableLocationNames(R request); public String[] getAvailableLocationNames(IDataRequest request);
} }

View file

@ -22,6 +22,7 @@ package com.raytheon.uf.common.dataaccess;
import java.util.Map; import java.util.Map;
import com.raytheon.uf.common.dataplugin.level.Level; 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 * 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 * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 10, 2012 njensen Initial creation * Oct 10, 2012 njensen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -41,7 +44,7 @@ import com.raytheon.uf.common.dataplugin.level.Level;
* @version 1.0 * @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 * 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 * radar name, etc). Possible location names can be retrieved by using the
* method getAvailableLocationNames(IGeometryRequest) on the DataAccessLayer * method getAvailableLocationNames(IGeometryRequest) on the DataAccessLayer
* or IGeometryDataFactory. Note that not all factories may support requests * or IGeometryDataFactory. Note that not all factories may support requests
* by location names and instead may throw a * by location names and instead may throw a IncompatibleRequestException or
* LocationNameUnsupportedException or ignore the location names. * ignore the location names.
* *
* @param locationNames * @param locationNames
*/ */
@ -102,6 +105,17 @@ public interface IDataRequest<D extends IData> {
*/ */
public String getDatatype(); 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. * Returns the identifiers added to the request.
* *
@ -130,4 +144,11 @@ public interface IDataRequest<D extends IData> {
*/ */
public String[] getLocationNames(); public String[] getLocationNames();
/**
* Returns the envelope set on the request.
*
* @return the envelope set on the request
*/
public Envelope getEnvelope();
} }

View file

@ -17,13 +17,10 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information. * further licensing information.
**/ **/
package com.raytheon.uf.common.dataaccess.geom; package com.raytheon.uf.common.dataaccess.exception;
import com.raytheon.uf.common.dataaccess.IDataFactory;
/** /**
* IDataFactory for any data that is non-gridded, for example points or * TODO Add Description
* polygons.
* *
* <pre> * <pre>
* *
@ -31,15 +28,38 @@ import com.raytheon.uf.common.dataaccess.IDataFactory;
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 10, 2012 njensen Initial creation * Feb 15, 2013 1614 bsteffen Initial creation
* *
* </pre> * </pre>
* *
* @author njensen * @author bsteffen
* @version 1.0 * @version 1.0
*/ */
public interface IGeometryDataFactory extends public class UnsupportedOutputTypeException extends DataAccessException {
IDataFactory<IGeometryRequest, IGeometryData> {
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;
}
} }

View file

@ -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();
}

View file

@ -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);
}

View file

@ -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();
}

View file

@ -40,6 +40,8 @@ import com.raytheon.uf.common.dataaccess.exception.InvalidIdentifiersException;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 13, 2012 njensen Initial creation * Nov 13, 2012 njensen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -75,7 +77,7 @@ public abstract class AbstractDataFactory {
* @param request * @param request
* the request to validate * the request to validate
*/ */
public void validateRequest(IDataRequest<?> request) { public void validateRequest(IDataRequest request) {
String[] required = getRequiredIdentifiers(); String[] required = getRequiredIdentifiers();
Collection<String> missing = Collections.emptySet(); Collection<String> missing = Collections.emptySet();
Collection<String> invalid = Collections.emptySet(); Collection<String> invalid = Collections.emptySet();
@ -99,4 +101,5 @@ public abstract class AbstractDataFactory {
invalid); invalid);
} }
} }
} }

View file

@ -24,10 +24,11 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.raytheon.uf.common.dataaccess.IData;
import com.raytheon.uf.common.dataaccess.IDataRequest; import com.raytheon.uf.common.dataaccess.IDataRequest;
import com.raytheon.uf.common.dataaccess.exception.DataRetrievalException; import com.raytheon.uf.common.dataaccess.exception.DataRetrievalException;
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException; 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.DbQueryRequest;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
@ -49,6 +50,8 @@ import com.raytheon.uf.common.time.TimeRange;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 17, 2013 bsteffen Initial creation * Jan 17, 2013 bsteffen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -56,20 +59,20 @@ import com.raytheon.uf.common.time.TimeRange;
* @version 1.0 * @version 1.0
*/ */
public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D extends IData> public abstract class AbstractDataPluginFactory
extends AbstractDataFactory { extends AbstractDataFactory {
protected static final String FIELD_DATATIME = "dataTime"; protected static final String FIELD_DATATIME = "dataTime";
protected static final String DBQUERY_PLUGIN_NAME_KEY = "pluginName"; protected static final String DBQUERY_PLUGIN_NAME_KEY = "pluginName";
public DataTime[] getAvailableTimes(R request) public DataTime[] getAvailableTimes(IDataRequest request)
throws TimeAgnosticDataException { throws TimeAgnosticDataException {
return this.getAvailableTimes(request, null); return this.getAvailableTimes(request, null);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public DataTime[] getAvailableTimes(R request, public DataTime[] getAvailableTimes(IDataRequest request,
BinOffset binOffset) throws TimeAgnosticDataException { BinOffset binOffset) throws TimeAgnosticDataException {
validateRequest(request); validateRequest(request);
TimeQueryRequest timeQueryRequest = this.buildTimeQueryRequest(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()]); return dataTimes.toArray(new DataTime[dataTimes.size()]);
} }
/** public IGeometryData[] getGeometryData(IDataRequest request,
* Builds a TimeQueryRequest that will be used to retrieve Data Times. DataTime... times) {
* validateRequest(request);
* @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) {
DbQueryRequest dbQueryRequest = this DbQueryRequest dbQueryRequest = this
.buildDbQueryRequest(request, times); .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, DbQueryResponse dbQueryResponse = executeDbQueryRequest(dbQueryRequest,
request.toString()); 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 dbQueryRequest = buildDbQueryRequest(request);
dbQueryRequest.setDistinct(Boolean.TRUE); dbQueryRequest.setDistinct(Boolean.TRUE);
dbQueryRequest.addRequestField(locationColumn); dbQueryRequest.addRequestField(locationColumn);
@ -144,6 +153,22 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
return locationNames.toArray(new String[0]); 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 * 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) * the data times to include in the request (if any)
* @return a DbQueryRequest to execute * @return a DbQueryRequest to execute
*/ */
protected DbQueryRequest buildDbQueryRequest(R request, DataTime[] dataTimes) { protected DbQueryRequest buildDbQueryRequest(IDataRequest request,
DataTime[] dataTimes) {
DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request); DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request);
if (dataTimes.length <= 0) { if (dataTimes.length <= 0) {
return dbQueryRequest; return dbQueryRequest;
@ -207,7 +233,8 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
* the time range to include in the request * the time range to include in the request
* @return a DbQueryRequest to execute * @return a DbQueryRequest to execute
*/ */
protected DbQueryRequest buildDbQueryRequest(R request, TimeRange timeRange) { protected DbQueryRequest buildDbQueryRequest(IDataRequest request,
TimeRange timeRange) {
DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request); DbQueryRequest dbQueryRequest = this.buildDbQueryRequest(request);
/* Add the TimeRange Constraint */ /* Add the TimeRange Constraint */
RequestConstraint requestConstraint = new RequestConstraint(); RequestConstraint requestConstraint = new RequestConstraint();
@ -215,7 +242,6 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
String[] dateTimeStrings = new String[] { String[] dateTimeStrings = new String[] {
timeRange.getStart().toString(), timeRange.getEnd().toString() }; timeRange.getStart().toString(), timeRange.getEnd().toString() };
requestConstraint.setBetweenValueList(dateTimeStrings); requestConstraint.setBetweenValueList(dateTimeStrings);
// TODO what should this do with forecast products?
dbQueryRequest.addConstraint(FIELD_DATATIME, requestConstraint); dbQueryRequest.addConstraint(FIELD_DATATIME, requestConstraint);
return dbQueryRequest; return dbQueryRequest;
@ -228,7 +254,7 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
* the original grid request * the original grid request
* @return the base DbQueryRequest * @return the base DbQueryRequest
*/ */
protected DbQueryRequest buildDbQueryRequest(R request) { protected DbQueryRequest buildDbQueryRequest(IDataRequest request) {
DbQueryRequest dbQueryRequest = new DbQueryRequest(); DbQueryRequest dbQueryRequest = new DbQueryRequest();
Map<String, RequestConstraint> constraints = this Map<String, RequestConstraint> constraints = this
.buildConstraintsFromRequest(request); .buildConstraintsFromRequest(request);
@ -239,9 +265,15 @@ public abstract class AbstractDataPluginFactory<R extends IDataRequest<D>, D ext
return dbQueryRequest; return dbQueryRequest;
} }
protected abstract Map<String, RequestConstraint> buildConstraintsFromRequest( protected abstract IGridData[] getGridData(IDataRequest request,
R 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);
} }

View file

@ -19,17 +19,19 @@
**/ **/
package com.raytheon.uf.common.dataaccess.impl; package com.raytheon.uf.common.dataaccess.impl;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.ArrayList;
import java.util.Map; 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.DataRetrievalException;
import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException; 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.IGeometryData;
import com.raytheon.uf.common.dataaccess.geom.IGeometryDataFactory; import com.raytheon.uf.common.dataaccess.grid.IGridData;
import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest;
import com.raytheon.uf.common.dataaccess.util.DatabaseQueryUtil; import com.raytheon.uf.common.dataaccess.util.DatabaseQueryUtil;
import com.raytheon.uf.common.dataaccess.util.DatabaseQueryUtil.QUERY_MODE; import com.raytheon.uf.common.dataaccess.util.DatabaseQueryUtil.QUERY_MODE;
import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.Level;
@ -50,6 +52,8 @@ import com.vividsolutions.jts.geom.Geometry;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 29, 2013 bkowal Initial creation * Jan 29, 2013 bkowal Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -58,7 +62,7 @@ import com.vividsolutions.jts.geom.Geometry;
*/ */
public abstract class AbstractGeometryDatabaseFactory extends 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 * 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) * raytheon.uf.common.dataaccess.IDataRequest)
*/ */
@Override @Override
public DataTime[] getAvailableTimes(IGeometryRequest request) public DataTime[] getAvailableTimes(IDataRequest request)
throws TimeAgnosticDataException { throws TimeAgnosticDataException {
this.validateRequest(request); this.validateRequest(request);
return this.executeTimeQuery(this.assembleGetTimes(request), request); return this.executeTimeQuery(this.assembleGetTimes(request), request);
@ -110,7 +114,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
* com.raytheon.uf.common.time.BinOffset) * com.raytheon.uf.common.time.BinOffset)
*/ */
@Override @Override
public DataTime[] getAvailableTimes(IGeometryRequest request, public DataTime[] getAvailableTimes(IDataRequest request,
BinOffset binOffset) throws TimeAgnosticDataException { BinOffset binOffset) throws TimeAgnosticDataException {
this.validateRequest(request); this.validateRequest(request);
return this.executeTimeQuery(this.assembleGetTimes(request, binOffset), 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[]) * .common.dataaccess.IDataRequest, com.raytheon.uf.common.time.DataTime[])
*/ */
@Override @Override
public IGeometryData[] getData(IGeometryRequest request, DataTime... times) { public IGeometryData[] getGeometryData(IDataRequest request,
DataTime... times) {
this.validateRequest(request); this.validateRequest(request);
return this.executeDataQuery(this.assembleGetData(request, times), return this.executeDataQuery(this.assembleGetData(request, times),
request); request);
@ -139,12 +144,23 @@ public abstract class AbstractGeometryDatabaseFactory extends
* .common.dataaccess.IDataRequest, com.raytheon.uf.common.time.TimeRange) * .common.dataaccess.IDataRequest, com.raytheon.uf.common.time.TimeRange)
*/ */
@Override @Override
public IGeometryData[] getData(IGeometryRequest request, TimeRange timeRange) { public IGeometryData[] getGeometryData(IDataRequest request,
TimeRange timeRange) {
this.validateRequest(request); this.validateRequest(request);
return this.executeDataQuery(this.assembleGetData(request, timeRange), return this.executeDataQuery(this.assembleGetData(request, timeRange),
request); 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. * Runs a query to retrieve Data Times from the database.
* *
@ -155,7 +171,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
* @return an array of DataTimes * @return an array of DataTimes
*/ */
protected final DataTime[] executeTimeQuery(String query, protected final DataTime[] executeTimeQuery(String query,
IGeometryRequest request) { IDataRequest request) {
List<Object[]> results = this.executeQuery(query, request); List<Object[]> results = this.executeQuery(query, request);
List<DataTime> dataTimes = new ArrayList<DataTime>(); List<DataTime> dataTimes = new ArrayList<DataTime>();
for (Object[] objects : results) { for (Object[] objects : results) {
@ -187,7 +203,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
* @return an array of IGeometryData * @return an array of IGeometryData
*/ */
protected final IGeometryData[] executeDataQuery(String query, protected final IGeometryData[] executeDataQuery(String query,
IGeometryRequest request) { IDataRequest request) {
List<Object[]> results = this.executeQuery(query, request); List<Object[]> results = this.executeQuery(query, request);
return this.makeGeometries(results, request.getParameters(), return this.makeGeometries(results, request.getParameters(),
request.getIdentifiers()); request.getIdentifiers());
@ -203,7 +219,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
* @return the raw data retrieved from the database * @return the raw data retrieved from the database
*/ */
protected final List<Object[]> executeQuery(String query, protected final List<Object[]> executeQuery(String query,
IGeometryRequest request) { IDataRequest request) {
return DatabaseQueryUtil.executeDatabaseQuery(queryMode, query, return DatabaseQueryUtil.executeDatabaseQuery(queryMode, query,
this.databaseName, request.getDatatype()); this.databaseName, request.getDatatype());
} }
@ -213,10 +229,10 @@ public abstract class AbstractGeometryDatabaseFactory extends
* *
* @see com.raytheon.uf.common.dataaccess.geom.IGeometryDataFactory# * @see com.raytheon.uf.common.dataaccess.geom.IGeometryDataFactory#
* getAvailableLocationNames * getAvailableLocationNames
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest) * (com.raytheon.uf.common.dataaccess.geom.IDataRequest)
*/ */
@Override @Override
public String[] getAvailableLocationNames(IGeometryRequest request) { public String[] getAvailableLocationNames(IDataRequest request) {
this.validateRequest(request); this.validateRequest(request);
List<Object[]> results = this.executeQuery( List<Object[]> results = this.executeQuery(
this.assembleGetAvailableLocationNames(request), request); this.assembleGetAvailableLocationNames(request), request);
@ -252,7 +268,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
* the original request that we are processing * the original request that we are processing
* @return the query * @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 * 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 * the BinOffset to apply to the retrieved DataTimes
* @return the query * @return the query
*/ */
protected abstract String assembleGetTimes(IGeometryRequest request, protected abstract String assembleGetTimes(IDataRequest request,
BinOffset binOffset); BinOffset binOffset);
/** /**
@ -278,7 +294,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
* manifest as constraints * manifest as constraints
* @return the query * @return the query
*/ */
protected abstract String assembleGetData(IGeometryRequest request, protected abstract String assembleGetData(IDataRequest request,
DataTime... times); DataTime... times);
/** /**
@ -292,7 +308,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
* manifest as a BETWEEN constraint * manifest as a BETWEEN constraint
* @return the query * @return the query
*/ */
protected abstract String assembleGetData(IGeometryRequest request, protected abstract String assembleGetData(IDataRequest request,
TimeRange timeRange); TimeRange timeRange);
/** /**
@ -304,7 +320,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
* @return the query * @return the query
*/ */
protected abstract String assembleGetAvailableLocationNames( protected abstract String assembleGetAvailableLocationNames(
IGeometryRequest request); IDataRequest request);
/** /**
* Builds the data objects that will be returned by calls to getData() on * 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 * the raw data associated with a single row retrieved from the
* database * database
* @param paramNames * @param paramNames
* the parameters specified in the original IGeometryRequest * the parameters specified in the original IDataRequest
* @param attrs * @param attrs
* the identifiers specified in the original IGeometryRequest * the identifiers specified in the original IDataRequest
* @return the constructed IGeometryData * @return the constructed IGeometryData
*/ */
protected abstract IGeometryData makeGeometry(Object[] data, protected abstract IGeometryData makeGeometry(Object[] data,
@ -358,9 +374,9 @@ public abstract class AbstractGeometryDatabaseFactory extends
* @param locationName * @param locationName
* the provided Location * the provided Location
* @param attributes * @param attributes
* the identifiers specified in the original IGeometryRequest * the identifiers specified in the original IDataRequest
* @param paramNames * @param paramNames
* the parameters specified in the original IGeometryRequest * the parameters specified in the original IDataRequest
* @return the constructed DefaultGeometryData * @return the constructed DefaultGeometryData
*/ */
protected DefaultGeometryData buildGeometryData(DataTime time, Level level, protected DefaultGeometryData buildGeometryData(DataTime time, Level level,
@ -382,7 +398,7 @@ public abstract class AbstractGeometryDatabaseFactory extends
* @param locationName * @param locationName
* the provided Location * the provided Location
* @param attributes * @param attributes
* identifiers specified in the original IGeometryRequest * identifiers specified in the original IDataRequest
* @param dataIndex * @param dataIndex
* a numerical index indicating where user-specified parameters * a numerical index indicating where user-specified parameters
* may start in the provided row of raw data * 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 * user-specified parameters are extracted from it and added to
* the DefaultGeometryData using the addData method * the DefaultGeometryData using the addData method
* @param paramNames * @param paramNames
* the parameters specified in the original IGeometryRequest * the parameters specified in the original IDataRequest
* @return the constructed DefaultGeometryData * @return the constructed DefaultGeometryData
*/ */
protected DefaultGeometryData buildGeometryData(DataTime time, Level level, protected DefaultGeometryData buildGeometryData(DataTime time, Level level,

View file

@ -19,9 +19,9 @@
**/ **/
package com.raytheon.uf.common.dataaccess.impl; 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.exception.TimeAgnosticDataException;
import com.raytheon.uf.common.dataaccess.geom.IGeometryData; 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.BinOffset;
import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange; import com.raytheon.uf.common.time.TimeRange;
@ -37,6 +37,8 @@ import com.raytheon.uf.common.time.TimeRange;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 29, 2013 bkowal Initial creation * Jan 29, 2013 bkowal Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -69,7 +71,7 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
* raytheon.uf.common.dataaccess.IDataRequest) * raytheon.uf.common.dataaccess.IDataRequest)
*/ */
@Override @Override
public DataTime[] getAvailableTimes(IGeometryRequest request) public DataTime[] getAvailableTimes(IDataRequest request)
throws TimeAgnosticDataException { throws TimeAgnosticDataException {
throw new TimeAgnosticDataException(this.buildExceptionMessage(request)); throw new TimeAgnosticDataException(this.buildExceptionMessage(request));
} }
@ -82,7 +84,8 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
* .common.dataaccess.IDataRequest, com.raytheon.uf.common.time.DataTime[]) * .common.dataaccess.IDataRequest, com.raytheon.uf.common.time.DataTime[])
*/ */
@Override @Override
public IGeometryData[] getData(IGeometryRequest request, DataTime... times) { public IGeometryData[] getGeometryData(IDataRequest request,
DataTime... times) {
return this.getData(request); return this.getData(request);
} }
@ -94,7 +97,8 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
* .common.dataaccess.IDataRequest, com.raytheon.uf.common.time.TimeRange) * .common.dataaccess.IDataRequest, com.raytheon.uf.common.time.TimeRange)
*/ */
@Override @Override
public IGeometryData[] getData(IGeometryRequest request, TimeRange timeRange) { public IGeometryData[] getGeometryData(IDataRequest request,
TimeRange timeRange) {
return this.getData(request); return this.getData(request);
} }
@ -104,7 +108,7 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
* @param request the original request that we are processing * @param request the original request that we are processing
* @return an array of IGeometryData * @return an array of IGeometryData
*/ */
protected IGeometryData[] getData(IGeometryRequest request) { protected IGeometryData[] getData(IDataRequest request) {
return super.executeDataQuery(this.assembleGetData(request), request); return super.executeDataQuery(this.assembleGetData(request), request);
} }
@ -117,7 +121,7 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
* com.raytheon.uf.common.time.BinOffset) * com.raytheon.uf.common.time.BinOffset)
*/ */
@Override @Override
public DataTime[] getAvailableTimes(IGeometryRequest request, public DataTime[] getAvailableTimes(IDataRequest request,
BinOffset binOffset) throws TimeAgnosticDataException { BinOffset binOffset) throws TimeAgnosticDataException {
throw new TimeAgnosticDataException(this.buildExceptionMessage(request)); throw new TimeAgnosticDataException(this.buildExceptionMessage(request));
} }
@ -128,7 +132,7 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
* @param request the original request that we are processing * @param request the original request that we are processing
* @return the constructed exception message * @return the constructed exception message
*/ */
private String buildExceptionMessage(IGeometryRequest request) { private String buildExceptionMessage(IDataRequest request) {
StringBuilder stringBuilder = new StringBuilder( StringBuilder stringBuilder = new StringBuilder(
"This operation is unsupported for data type: "); "This operation is unsupported for data type: ");
stringBuilder.append(request.getDatatype()); stringBuilder.append(request.getDatatype());
@ -142,7 +146,7 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
* @param request the original request that we are processing * @param request the original request that we are processing
* @return the query * @return the query
*/ */
protected abstract String assembleGetData(IGeometryRequest request); protected abstract String assembleGetData(IDataRequest request);
/** /**
* The following methods are no longer applicable to us. * The following methods are no longer applicable to us.
@ -150,24 +154,24 @@ public abstract class AbstractGeometryTimeAgnosticDatabaseFactory extends
* Should we be throwing an exception * Should we be throwing an exception
*/ */
@Override @Override
protected String assembleGetTimes(IGeometryRequest request) { protected String assembleGetTimes(IDataRequest request) {
return null; return null;
} }
@Override @Override
protected String assembleGetTimes(IGeometryRequest request, protected String assembleGetTimes(IDataRequest request,
BinOffset binOffset) { BinOffset binOffset) {
return null; return null;
} }
@Override @Override
protected String assembleGetData(IGeometryRequest request, protected String assembleGetData(IDataRequest request,
DataTime... times) { DataTime... times) {
return null; return null;
} }
@Override @Override
protected String assembleGetData(IGeometryRequest request, protected String assembleGetData(IDataRequest request,
TimeRange timeRange) { TimeRange timeRange) {
return null; return null;
} }

View file

@ -23,19 +23,17 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.geotools.coverage.grid.GridEnvelope2D;
import org.geotools.coverage.grid.GridGeometry2D; 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.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.IGridData;
import com.raytheon.uf.common.dataaccess.grid.IGridRequest;
import com.raytheon.uf.common.dataaccess.util.PDOUtil; import com.raytheon.uf.common.dataaccess.util.PDOUtil;
import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse; import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
import com.raytheon.uf.common.datastorage.Request; import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.Request.Type;
import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord;
/** /**
@ -49,6 +47,8 @@ import com.raytheon.uf.common.datastorage.records.IDataRecord;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 17, 2013 bsteffen Initial creation * Jan 17, 2013 bsteffen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -57,7 +57,7 @@ import com.raytheon.uf.common.datastorage.records.IDataRecord;
*/ */
public abstract class AbstractGridDataPluginFactory extends public abstract class AbstractGridDataPluginFactory extends
AbstractDataPluginFactory<IGridRequest, IGridData> { AbstractDataPluginFactory {
/** /**
* Executes the provided DbQueryRequest and returns an array of IGridData * 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 * the db query request to execute
* @return an array of IGridData * @return an array of IGridData
*/ */
protected IGridData[] getData(IGridRequest request, protected IGridData[] getGridData(IDataRequest request,
DbQueryResponse dbQueryResponse) { DbQueryResponse dbQueryResponse) {
List<IGridData> gridData = new ArrayList<IGridData>(); List<IGridData> gridData = new ArrayList<IGridData>();
@ -85,17 +85,13 @@ public abstract class AbstractGridDataPluginFactory extends
PluginDataObject pdo = (PluginDataObject) resultMap PluginDataObject pdo = (PluginDataObject) resultMap
.get(null); .get(null);
IDataRecord dataRecord = getDataRecord(pdo, IDataRecord dataRecord = getDataRecord(pdo);
request.getStorageRequest());
/* /*
* Extract the grid geometry. * Extract the grid geometry.
*/ */
GridGeometry2D gridGeometry = getGridGeometry(pdo); GridGeometry2D gridGeometry = getGridGeometry(pdo);
gridGeometry = trimGridGeometryToRequest(gridGeometry,
request.getStorageRequest());
IGridData defaultGridData = null; IGridData defaultGridData = null;
defaultGridData = this.constructGridDataResponse(request, pdo, defaultGridData = this.constructGridDataResponse(request, pdo,
gridGeometry, dataRecord); gridGeometry, dataRecord);
@ -106,10 +102,17 @@ public abstract class AbstractGridDataPluginFactory extends
return gridData.toArray(new IGridData[gridData.size()]); return gridData.toArray(new IGridData[gridData.size()]);
} }
protected IDataRecord getDataRecord(PluginDataObject pdo, protected IGeometryData[] getGeometryData(IDataRequest request,
Request storageRequest) { 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 { try {
return PDOUtil.getDataRecord(pdo, "Data", storageRequest); return PDOUtil.getDataRecord(pdo, "Data", Request.ALL);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new DataRetrievalException( throw new DataRetrievalException(
@ -136,47 +139,8 @@ public abstract class AbstractGridDataPluginFactory extends
* @return the IGridData that was constructed * @return the IGridData that was constructed
*/ */
protected abstract IGridData constructGridDataResponse( protected abstract IGridData constructGridDataResponse(
IGridRequest request, PluginDataObject pdo, IDataRequest request, PluginDataObject pdo,
GridGeometry2D gridGeometry, IDataRecord dataRecord); 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;
}
}
} }

View file

@ -27,12 +27,15 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 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.dataplugin.level.Level;
import com.raytheon.uf.common.serialization.XmlGenericMapAdapter; 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> * <pre>
* *
@ -41,6 +44,8 @@ import com.raytheon.uf.common.serialization.XmlGenericMapAdapter;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 6, 2012 njensen Initial creation * Nov 6, 2012 njensen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -49,7 +54,7 @@ import com.raytheon.uf.common.serialization.XmlGenericMapAdapter;
*/ */
@XmlAccessorType(XmlAccessType.NONE) @XmlAccessorType(XmlAccessType.NONE)
public abstract class AbstractDataRequest { public class DefaultDataRequest implements IDataRequest {
@XmlElement @XmlElement
protected String datatype; protected String datatype;
@ -57,14 +62,17 @@ public abstract class AbstractDataRequest {
@XmlJavaTypeAdapter(value = XmlGenericMapAdapter.class) @XmlJavaTypeAdapter(value = XmlGenericMapAdapter.class)
protected Map<String, Object> identifiers; protected Map<String, Object> identifiers;
@XmlElement @XmlElement(name = "parameter")
protected String[] parameters; protected String[] parameters;
@XmlElement @XmlElement(name = "level")
protected Level[] levels; protected Level[] levels;
@XmlElement(name = "locationName") @XmlElement(name = "locationName")
protected String[] locationNames; protected String[] locationNames;
@XmlJavaTypeAdapter(value = JTSEnvelopeAdapter.class)
protected Envelope envelope;
public void setDatatype(String datatype) { public void setDatatype(String datatype) {
this.datatype = datatype; this.datatype = datatype;
@ -84,6 +92,15 @@ public abstract class AbstractDataRequest {
public void setLevels(Level... levels) { public void setLevels(Level... levels) {
this.levels = levels; this.levels = levels;
} }
public void setLocationNames(String... locationNames) {
this.locationNames = locationNames;
}
public void setEnvelope(Envelope env) {
this.envelope = env;
}
public String getDatatype() { public String getDatatype() {
return datatype; return datatype;
@ -101,13 +118,13 @@ public abstract class AbstractDataRequest {
return levels; return levels;
} }
public void setLocationNames(String... locationNames) {
this.locationNames = locationNames;
}
public String[] getLocationNames() { public String[] getLocationNames() {
return locationNames; return locationNames;
} }
public Envelope getEnvelope() {
return envelope;
}
} }

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -21,7 +21,6 @@ package com.raytheon.uf.common.dataaccess.impl;
import java.util.Set; import java.util.Set;
import com.raytheon.uf.common.dataaccess.IData;
import com.raytheon.uf.common.dataaccess.IDataFactory; import com.raytheon.uf.common.dataaccess.IDataFactory;
import com.raytheon.uf.common.dataaccess.IDataRequest; import com.raytheon.uf.common.dataaccess.IDataRequest;
import com.raytheon.uf.common.time.BinOffset; import com.raytheon.uf.common.time.BinOffset;
@ -37,6 +36,8 @@ import com.raytheon.uf.common.time.DataTime;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 14, 2012 njensen Initial creation * Nov 14, 2012 njensen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -59,8 +60,8 @@ public class FactoryUtil {
* the bin offset to apply * the bin offset to apply
* @return the binned times * @return the binned times
*/ */
public static <R extends IDataRequest<D>, D extends IData> DataTime[] getAvailableTimes( public static DataTime[] getAvailableTimes(IDataFactory factory,
IDataFactory<R, D> factory, R request, BinOffset binOffset) { IDataRequest request, BinOffset binOffset) {
DataTime[] actualTimes = factory.getAvailableTimes(request); DataTime[] actualTimes = factory.getAvailableTimes(request);
if (binOffset != null) { if (binOffset != null) {
Set<DataTime> normalized = binOffset Set<DataTime> normalized = binOffset

View file

@ -6,7 +6,6 @@
<bean factory-bean="dataAccessRegistry" factory-method="register"> <bean factory-bean="dataAccessRegistry" factory-method="register">
<constructor-arg value="gfe"/> <constructor-arg value="gfe"/>
<constructor-arg value="com.raytheon.uf.common.dataaccess.grid.IGridRequest"/>
<constructor-arg ref="gfeGridFactory"/> <constructor-arg ref="gfeGridFactory"/>
</bean> </bean>

View file

@ -28,10 +28,10 @@ import java.util.Set;
import org.geotools.coverage.grid.GridGeometry2D; 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.exception.DataRetrievalException;
import com.raytheon.uf.common.dataaccess.grid.IGridData; 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.AbstractGridDataPluginFactory;
import com.raytheon.uf.common.dataaccess.impl.DefaultGridData; import com.raytheon.uf.common.dataaccess.impl.DefaultGridData;
import com.raytheon.uf.common.dataaccess.util.DataWrapperUtil; 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;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse; 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.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.geospatial.MapUtil; import com.raytheon.uf.common.geospatial.MapUtil;
@ -65,6 +64,8 @@ import com.raytheon.uf.common.geospatial.MapUtil;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Feb 4, 2013 bsteffen Initial creation * Feb 4, 2013 bsteffen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -73,7 +74,7 @@ import com.raytheon.uf.common.geospatial.MapUtil;
*/ */
public class GFEGridFactory extends AbstractGridDataPluginFactory implements public class GFEGridFactory extends AbstractGridDataPluginFactory implements
IGridDataFactory { IDataFactory {
private static final String[] VALID_IDENTIFIERS = { GFEDataAccessUtil.MODEL_NAME, private static final String[] VALID_IDENTIFIERS = { GFEDataAccessUtil.MODEL_NAME,
GFEDataAccessUtil.MODEL_TIME, GFEDataAccessUtil.SITE_ID }; GFEDataAccessUtil.MODEL_TIME, GFEDataAccessUtil.SITE_ID };
@ -84,7 +85,7 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
} }
@Override @Override
protected IGridData constructGridDataResponse(IGridRequest request, protected IGridData constructGridDataResponse(IDataRequest request,
PluginDataObject pdo, GridGeometry2D gridGeometry, PluginDataObject pdo, GridGeometry2D gridGeometry,
IDataRecord dataRecord) { IDataRecord dataRecord) {
GFERecord gfeRecord = asGFERecord(pdo); GFERecord gfeRecord = asGFERecord(pdo);
@ -114,7 +115,7 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
@Override @Override
protected Map<String, RequestConstraint> buildConstraintsFromRequest( protected Map<String, RequestConstraint> buildConstraintsFromRequest(
IGridRequest request) { IDataRequest request) {
HashMap<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>(); HashMap<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
Map<String, String> parmIdComponents = new HashMap<String, String>(); 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; return constraints;
} }
@Override @Override
protected IDataRecord getDataRecord(PluginDataObject pdo, protected IDataRecord getDataRecord(PluginDataObject pdo) {
Request storageRequest) {
GFERecord gfeRecord = asGFERecord(pdo); GFERecord gfeRecord = asGFERecord(pdo);
try { try {
@ -226,20 +229,7 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
} }
@Override @Override
public GridGeometry2D getGeometry(IGridRequest request) { public String[] getAvailableLocationNames(IDataRequest 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) {
DbQueryRequest dbRequest = buildDbQueryRequest(request); DbQueryRequest dbRequest = buildDbQueryRequest(request);
dbRequest.addRequestField(GFEDataAccessUtil.DB_ID); dbRequest.addRequestField(GFEDataAccessUtil.DB_ID);
dbRequest.setDistinct(true); dbRequest.setDistinct(true);

View file

@ -6,7 +6,6 @@
<bean factory-bean="dataAccessRegistry" factory-method="register"> <bean factory-bean="dataAccessRegistry" factory-method="register">
<constructor-arg value="grid"/> <constructor-arg value="grid"/>
<constructor-arg value="com.raytheon.uf.common.dataaccess.grid.IGridRequest"/>
<constructor-arg ref="gridDataAccessFactory"/> <constructor-arg ref="gridDataAccessFactory"/>
</bean> </bean>

View file

@ -32,10 +32,10 @@ import javax.measure.unit.Unit;
import org.geotools.coverage.grid.GridGeometry2D; import org.geotools.coverage.grid.GridGeometry2D;
import com.raytheon.uf.common.comm.CommunicationException; 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.exception.DataRetrievalException;
import com.raytheon.uf.common.dataaccess.grid.IGridData; 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.AbstractGridDataPluginFactory;
import com.raytheon.uf.common.dataaccess.impl.DefaultGridData; import com.raytheon.uf.common.dataaccess.impl.DefaultGridData;
import com.raytheon.uf.common.dataaccess.util.DataWrapperUtil; 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.grid.mapping.DatasetIdMapper;
import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapper; 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;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; 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.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.parameter.mapping.ParameterMapper;
import com.raytheon.uf.common.util.mapping.Mapper; import com.raytheon.uf.common.util.mapping.Mapper;
@ -66,6 +62,8 @@ import com.raytheon.uf.common.util.mapping.Mapper;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 17, 2013 bsteffen Initial creation * Jan 17, 2013 bsteffen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -74,7 +72,7 @@ import com.raytheon.uf.common.util.mapping.Mapper;
*/ */
public class GridDataAccessFactory extends AbstractGridDataPluginFactory public class GridDataAccessFactory extends AbstractGridDataPluginFactory
implements IGridDataFactory { implements IDataFactory {
private static final String NAMESPACE = "namespace"; private static final String NAMESPACE = "namespace";
@ -87,41 +85,9 @@ public class GridDataAccessFactory extends AbstractGridDataPluginFactory
return VALID_IDENTIFIERS; 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 @Override
protected Map<String, RequestConstraint> buildConstraintsFromRequest( protected Map<String, RequestConstraint> buildConstraintsFromRequest(
IGridRequest request) { IDataRequest request) {
Map<String, RequestConstraint> result = new HashMap<String, RequestConstraint>(); Map<String, RequestConstraint> result = new HashMap<String, RequestConstraint>();
Map<String, Object> identifiers = request.getIdentifiers(); Map<String, Object> identifiers = request.getIdentifiers();
@ -219,7 +185,7 @@ public class GridDataAccessFactory extends AbstractGridDataPluginFactory
} }
@Override @Override
protected IGridData constructGridDataResponse(IGridRequest request, protected IGridData constructGridDataResponse(IDataRequest request,
PluginDataObject pdo, GridGeometry2D gridGeometry, PluginDataObject pdo, GridGeometry2D gridGeometry,
IDataRecord dataRecord) { IDataRecord dataRecord) {
if (pdo instanceof GridRecord == false) { if (pdo instanceof GridRecord == false) {
@ -305,7 +271,7 @@ public class GridDataAccessFactory extends AbstractGridDataPluginFactory
} }
@Override @Override
public String[] getAvailableLocationNames(IGridRequest request) { public String[] getAvailableLocationNames(IDataRequest request) {
return getAvailableLocationNames(request, GridConstants.DATASET_ID); return getAvailableLocationNames(request, GridConstants.DATASET_ID);
} }

View file

@ -11,7 +11,6 @@
<bean factory-bean="dataAccessRegistry" factory-method="register" <bean factory-bean="dataAccessRegistry" factory-method="register"
depends-on="mapsPluginName, mapsDataFactory"> depends-on="mapsPluginName, mapsDataFactory">
<constructor-arg ref="mapsPluginName"/> <constructor-arg ref="mapsPluginName"/>
<constructor-arg value="com.raytheon.uf.common.dataaccess.geom.IGeometryRequest"/>
<constructor-arg ref="mapsDataFactory"/> <constructor-arg ref="mapsDataFactory"/>
</bean> </bean>

View file

@ -21,12 +21,11 @@ package com.raytheon.uf.common.dataplugin.maps.dataaccess;
import java.util.Map; 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.exception.DataRetrievalException;
import com.raytheon.uf.common.dataaccess.geom.IGeometryData; 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.raytheon.uf.common.dataaccess.impl.AbstractGeometryTimeAgnosticDatabaseFactory;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKBReader; import com.vividsolutions.jts.io.WKBReader;
@ -42,6 +41,8 @@ import com.vividsolutions.jts.io.WKBReader;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 28, 2013 bkowal Initial creation * Jan 28, 2013 bkowal Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -106,10 +107,10 @@ public class MapsGeometryFactory extends
* *
* @see com.raytheon.uf.common.dataaccess.impl. * @see com.raytheon.uf.common.dataaccess.impl.
* AbstractGeometryTimeAgnosticDatabaseFactory * AbstractGeometryTimeAgnosticDatabaseFactory
* #assembleGetData(com.raytheon.uf.common.dataaccess.geom.IGeometryRequest) * #assembleGetData(com.raytheon.uf.common.dataaccess.geom.IDataRequest)
*/ */
@Override @Override
protected String assembleGetData(IGeometryRequest request) { protected String assembleGetData(IDataRequest request) {
return MapsQueryAssembler.assembleGetData(request); return MapsQueryAssembler.assembleGetData(request);
} }
@ -119,10 +120,10 @@ public class MapsGeometryFactory extends
* @see * @see
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory * com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
* #assembleGetAvailableLocationNames * #assembleGetAvailableLocationNames
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest) * (com.raytheon.uf.common.dataaccess.geom.IDataRequest)
*/ */
@Override @Override
protected String assembleGetAvailableLocationNames(IGeometryRequest request) { protected String assembleGetAvailableLocationNames(IDataRequest request) {
return MapsQueryAssembler.assembleGetAvailableLocationNames(request); return MapsQueryAssembler.assembleGetAvailableLocationNames(request);
} }
} }

View file

@ -21,12 +21,12 @@ package com.raytheon.uf.common.dataplugin.maps.dataaccess;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang.BooleanUtils; 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.raytheon.uf.common.dataplugin.maps.dataaccess.util.MapsQueryUtil;
import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Envelope;
@ -41,6 +41,8 @@ import com.vividsolutions.jts.geom.Envelope;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 28, 2013 bkowal Initial creation * Jan 28, 2013 bkowal Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -104,7 +106,7 @@ public class MapsQueryAssembler {
* the name of the identifier to extract * the name of the identifier to extract
* @return the identifier * @return the identifier
*/ */
public static String extractIdentifier(IGeometryRequest request, public static String extractIdentifier(IDataRequest request,
String identifierName) { String identifierName) {
return request.getIdentifiers().get(identifierName).toString(); return request.getIdentifiers().get(identifierName).toString();
} }
@ -116,7 +118,7 @@ public class MapsQueryAssembler {
* the original request that we are processing * the original request that we are processing
* @return the table identifier * @return the table identifier
*/ */
public static String extractTable(IGeometryRequest request) { public static String extractTable(IDataRequest request) {
return extractIdentifier(request, REQUIRED_IDENTIFIERS.IDENTIFIER_TABLE); return extractIdentifier(request, REQUIRED_IDENTIFIERS.IDENTIFIER_TABLE);
} }
@ -127,7 +129,7 @@ public class MapsQueryAssembler {
* the original request that we are processing * the original request that we are processing
* @return the geometry identifier * @return the geometry identifier
*/ */
public static String extractGeomField(IGeometryRequest request) { public static String extractGeomField(IDataRequest request) {
return extractIdentifier(request, return extractIdentifier(request,
REQUIRED_IDENTIFIERS.IDENTIFIER_GEOM_FIELD); REQUIRED_IDENTIFIERS.IDENTIFIER_GEOM_FIELD);
} }
@ -139,7 +141,7 @@ public class MapsQueryAssembler {
* the original request that we are processing * the original request that we are processing
* @return the query * @return the query
*/ */
public static String assembleGetData(IGeometryRequest request) { public static String assembleGetData(IDataRequest request) {
return assembleQuery(request, Boolean.FALSE); return assembleQuery(request, Boolean.FALSE);
} }
@ -151,7 +153,7 @@ public class MapsQueryAssembler {
* @return the query * @return the query
*/ */
public static String assembleGetAvailableLocationNames( public static String assembleGetAvailableLocationNames(
IGeometryRequest request) { IDataRequest request) {
return assembleQuery(request, Boolean.TRUE); return assembleQuery(request, Boolean.TRUE);
} }
@ -165,7 +167,7 @@ public class MapsQueryAssembler {
* location information * location information
* @return the query * @return the query
*/ */
private static String assembleQuery(IGeometryRequest request, private static String assembleQuery(IDataRequest request,
boolean locationQuery) { boolean locationQuery) {
Envelope envelope = request.getEnvelope(); Envelope envelope = request.getEnvelope();
String table = extractTable(request); String table = extractTable(request);

View file

@ -16,7 +16,6 @@
<bean factory-bean="dataAccessRegistry" factory-method="register"> <bean factory-bean="dataAccessRegistry" factory-method="register">
<constructor-arg value="radar"/> <constructor-arg value="radar"/>
<constructor-arg value="com.raytheon.uf.common.dataaccess.grid.IGridRequest"/>
<constructor-arg ref="radarGridFactory"/> <constructor-arg ref="radarGridFactory"/>
</bean> </bean>

View file

@ -30,11 +30,10 @@ import java.util.Set;
import org.geotools.coverage.grid.GridGeometry2D; import org.geotools.coverage.grid.GridGeometry2D;
import org.opengis.referencing.FactoryException; 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.DataRetrievalException;
import com.raytheon.uf.common.dataaccess.exception.IncompatibleRequestException;
import com.raytheon.uf.common.dataaccess.grid.IGridData; 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.AbstractGridDataPluginFactory;
import com.raytheon.uf.common.dataaccess.impl.DefaultGridData; import com.raytheon.uf.common.dataaccess.impl.DefaultGridData;
import com.raytheon.uf.common.dataaccess.util.DataWrapperUtil; 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.RadarInfo;
import com.raytheon.uf.common.dataplugin.radar.util.RadarInfoDict; import com.raytheon.uf.common.dataplugin.radar.util.RadarInfoDict;
import com.raytheon.uf.common.dataplugin.radar.util.RadarUtil; 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;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; 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.ByteDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.geospatial.interpolation.data.DataSource; import com.raytheon.uf.common.geospatial.interpolation.data.DataSource;
@ -73,6 +69,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 23, 2013 bsteffen Initial creation * Jan 23, 2013 bsteffen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -80,7 +78,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* @version 1.0 * @version 1.0
*/ */
public class RadarGridFactory extends AbstractGridDataPluginFactory implements public class RadarGridFactory extends AbstractGridDataPluginFactory implements
IGridDataFactory { IDataFactory {
private static final String PRODUCT_CODE = "productCode"; private static final String PRODUCT_CODE = "productCode";
@ -106,43 +104,7 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
} }
@Override @Override
public GridGeometry2D getGeometry(IGridRequest request) { protected IGridData constructGridDataResponse(IDataRequest 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,
PluginDataObject pdo, GridGeometry2D gridGeometry, PluginDataObject pdo, GridGeometry2D gridGeometry,
IDataRecord dataRecord) { IDataRecord dataRecord) {
RadarRecord radarRecord = asRadarRecord(pdo); RadarRecord radarRecord = asRadarRecord(pdo);
@ -226,8 +188,7 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
} }
@Override @Override
protected IDataRecord getDataRecord(PluginDataObject pdo, protected IDataRecord getDataRecord(PluginDataObject pdo) {
Request storageRequest) {
RadarRecord radarRecord = asRadarRecord(pdo); RadarRecord radarRecord = asRadarRecord(pdo);
try { try {
RadarDataRetriever.populateRadarRecord(PDOUtil.getDataStore(pdo), RadarDataRetriever.populateRadarRecord(PDOUtil.getDataStore(pdo),
@ -244,7 +205,7 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
@Override @Override
protected Map<String, RequestConstraint> buildConstraintsFromRequest( protected Map<String, RequestConstraint> buildConstraintsFromRequest(
IGridRequest request) { IDataRequest request) {
Map<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>(); Map<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
if (request.getParameters() != null) { if (request.getParameters() != null) {
Set<Integer> codes = new HashSet<Integer>(); Set<Integer> codes = new HashSet<Integer>();
@ -338,7 +299,7 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
} }
@Override @Override
public String[] getAvailableLocationNames(IGridRequest request) { public String[] getAvailableLocationNames(IDataRequest request) {
return getAvailableLocationNames(request, ICAO); return getAvailableLocationNames(request, ICAO);
} }
@ -353,6 +314,8 @@ public class RadarGridFactory extends AbstractGridDataPluginFactory implements
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jan 25, 2013 bsteffen Initial creation * Jan 25, 2013 bsteffen Initial creation
* Feb 14, 2013 1614 bsteffen refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *

View file

@ -11,7 +11,6 @@
<bean factory-bean="dataAccessRegistry" factory-method="register" <bean factory-bean="dataAccessRegistry" factory-method="register"
depends-on="satellitePluginName, satelliteDataFactory"> depends-on="satellitePluginName, satelliteDataFactory">
<constructor-arg ref="satellitePluginName"/> <constructor-arg ref="satellitePluginName"/>
<constructor-arg value="com.raytheon.uf.common.dataaccess.grid.IGridRequest"/>
<constructor-arg ref="satelliteDataFactory"/> <constructor-arg ref="satelliteDataFactory"/>
</bean> </bean>

View file

@ -30,22 +30,18 @@ import javax.measure.unit.UnitFormat;
import org.geotools.coverage.grid.GridGeometry2D; 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.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.AbstractGridDataPluginFactory;
import com.raytheon.uf.common.dataaccess.impl.DefaultGridData; import com.raytheon.uf.common.dataaccess.impl.DefaultGridData;
import com.raytheon.uf.common.dataaccess.util.DataWrapperUtil; import com.raytheon.uf.common.dataaccess.util.DataWrapperUtil;
import com.raytheon.uf.common.dataplugin.PluginDataObject; import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord; import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
import com.raytheon.uf.common.dataplugin.satellite.units.SatelliteUnits; 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;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; 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.datastorage.records.IDataRecord;
import com.raytheon.uf.common.time.DataTime;
/** /**
* A data factory for getting satellite data from the metadata database. There * 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 02, 2012 bkowal Initial creation
* Jan 22, 2012 bsteffen Extract common functionality to AbstractGridDataPluginFactory * Jan 22, 2012 bsteffen Extract common functionality to AbstractGridDataPluginFactory
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -66,7 +64,7 @@ import com.raytheon.uf.common.time.DataTime;
* @version 1.0 * @version 1.0
*/ */
public class SatelliteGridFactory extends AbstractGridDataPluginFactory public class SatelliteGridFactory extends AbstractGridDataPluginFactory
implements IGridDataFactory { implements IDataFactory {
private static final String FIELD_PYHSICAL_ELEMENT = "physicalElement"; private static final String FIELD_PYHSICAL_ELEMENT = "physicalElement";
@ -75,118 +73,16 @@ public class SatelliteGridFactory extends AbstractGridDataPluginFactory
private static final String[] VALID_IDENTIFIERS = { "source", private static final String[] VALID_IDENTIFIERS = { "source",
"creatingEntity", FIELD_SECTOR_ID, FIELD_PYHSICAL_ELEMENT }; "creatingEntity", FIELD_SECTOR_ID, FIELD_PYHSICAL_ELEMENT };
private Map<String, GridGeometry2D> sectorGeometryMapCache;
public SatelliteGridFactory() { public SatelliteGridFactory() {
this.sectorGeometryMapCache = new HashMap<String, GridGeometry2D>();
SatelliteUnits.register(); 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 @Override
public String[] getValidIdentifiers() { public String[] getValidIdentifiers() {
return VALID_IDENTIFIERS; return VALID_IDENTIFIERS;
} }
protected DefaultGridData constructGridDataResponse(IGridRequest request, protected DefaultGridData constructGridDataResponse(IDataRequest request,
PluginDataObject pdo, GridGeometry2D gridGeometry, PluginDataObject pdo, GridGeometry2D gridGeometry,
IDataRecord dataRecord) { IDataRecord dataRecord) {
if(pdo instanceof SatelliteRecord == false){ if(pdo instanceof SatelliteRecord == false){
@ -232,7 +128,7 @@ public class SatelliteGridFactory extends AbstractGridDataPluginFactory
* technique * technique
*/ */
protected Map<String, RequestConstraint> buildConstraintsFromRequest( protected Map<String, RequestConstraint> buildConstraintsFromRequest(
IGridRequest request) { IDataRequest request) {
Map<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>(); Map<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
if ((request.getIdentifiers() == null) == false) { if ((request.getIdentifiers() == null) == false) {
Iterator<String> identifiersIterator = request.getIdentifiers() Iterator<String> identifiersIterator = request.getIdentifiers()
@ -264,7 +160,7 @@ public class SatelliteGridFactory extends AbstractGridDataPluginFactory
} }
@Override @Override
public String[] getAvailableLocationNames(IGridRequest request) { public String[] getAvailableLocationNames(IDataRequest request) {
return getAvailableLocationNames(request, FIELD_SECTOR_ID); return getAvailableLocationNames(request, FIELD_SECTOR_ID);
} }

View file

@ -6,7 +6,6 @@
<bean factory-bean="dataAccessRegistry" factory-method="register"> <bean factory-bean="dataAccessRegistry" factory-method="register">
<constructor-arg value="ihfsData"/> <constructor-arg value="ihfsData"/>
<constructor-arg value="com.raytheon.uf.common.dataaccess.geom.IGeometryRequest"/>
<constructor-arg ref="hydroDataFactory"/> <constructor-arg ref="hydroDataFactory"/>
</bean> </bean>

View file

@ -22,9 +22,9 @@ package com.raytheon.uf.common.hydro.dataaccess;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Map; 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.exception.TimeAgnosticDataException;
import com.raytheon.uf.common.dataaccess.geom.IGeometryData; 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.AbstractGeometryDatabaseFactory;
import com.raytheon.uf.common.dataaccess.impl.FactoryUtil; import com.raytheon.uf.common.dataaccess.impl.FactoryUtil;
import com.raytheon.uf.common.time.BinOffset; import com.raytheon.uf.common.time.BinOffset;
@ -48,6 +48,8 @@ import com.vividsolutions.jts.geom.GeometryFactory;
* Nov 13, 2012 njensen Initial creation * Nov 13, 2012 njensen Initial creation
* Jan 30, 2012 1551 bkowal Refactored * Jan 30, 2012 1551 bkowal Refactored
* Jan 31, 2012 1555 bkowal Modification based on existing hydro code * 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> * </pre>
* *
@ -79,8 +81,7 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
* *
* @see * @see
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory * com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
* #getAvailableTimes * #getAvailableTimes (com.raytheon.uf.common.dataaccess.geom.IDataRequest,
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest,
* com.raytheon.uf.common.time.BinOffset) * com.raytheon.uf.common.time.BinOffset)
*/ */
/* /*
@ -89,7 +90,7 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
* accessed directly? * accessed directly?
*/ */
@Override @Override
public DataTime[] getAvailableTimes(IGeometryRequest request, public DataTime[] getAvailableTimes(IDataRequest request,
BinOffset binOffset) throws TimeAgnosticDataException { BinOffset binOffset) throws TimeAgnosticDataException {
return FactoryUtil.getAvailableTimes(this, request, binOffset); return FactoryUtil.getAvailableTimes(this, request, binOffset);
} }
@ -131,11 +132,10 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
* *
* @see * @see
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory * com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
* #assembleGetTimes * #assembleGetTimes (com.raytheon.uf.common.dataaccess.geom.IDataRequest)
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest)
*/ */
@Override @Override
protected String assembleGetTimes(IGeometryRequest request) { protected String assembleGetTimes(IDataRequest request) {
return HydroQueryAssembler.assembleGetTimes(request); return HydroQueryAssembler.assembleGetTimes(request);
} }
@ -144,12 +144,11 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
* *
* @see * @see
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory * com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
* #assembleGetTimes * #assembleGetTimes (com.raytheon.uf.common.dataaccess.geom.IDataRequest,
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest,
* com.raytheon.uf.common.time.BinOffset) * com.raytheon.uf.common.time.BinOffset)
*/ */
@Override @Override
protected String assembleGetTimes(IGeometryRequest request, protected String assembleGetTimes(IDataRequest request,
BinOffset binOffset) { BinOffset binOffset) {
return null; return null;
} }
@ -159,11 +158,11 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
* *
* @see * @see
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory * 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[]) * com.raytheon.uf.common.time.DataTime[])
*/ */
@Override @Override
protected String assembleGetData(IGeometryRequest request, protected String assembleGetData(IDataRequest request,
DataTime... times) { DataTime... times) {
return HydroQueryAssembler.assembleGetData(request, times); return HydroQueryAssembler.assembleGetData(request, times);
} }
@ -173,11 +172,11 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
* *
* @see * @see
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory * 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) * com.raytheon.uf.common.time.TimeRange)
*/ */
@Override @Override
protected String assembleGetData(IGeometryRequest request, protected String assembleGetData(IDataRequest request,
TimeRange timeRange) { TimeRange timeRange) {
return HydroQueryAssembler.assembleGetData(request, timeRange); return HydroQueryAssembler.assembleGetData(request, timeRange);
} }
@ -188,10 +187,10 @@ public class HydroGeometryFactory extends AbstractGeometryDatabaseFactory {
* @see * @see
* com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory * com.raytheon.uf.common.dataaccess.impl.AbstractGeometryDatabaseFactory
* #assembleGetAvailableLocationNames * #assembleGetAvailableLocationNames
* (com.raytheon.uf.common.dataaccess.geom.IGeometryRequest) * (com.raytheon.uf.common.dataaccess.geom.IDataRequest)
*/ */
@Override @Override
protected String assembleGetAvailableLocationNames(IGeometryRequest request) { protected String assembleGetAvailableLocationNames(IDataRequest request) {
return "select lid from location;"; return "select lid from location;";
} }
} }

View file

@ -24,14 +24,14 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; 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.exception.IncompatibleRequestException;
import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest;
import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange; import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.common.time.util.TimeUtil; 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> * <pre>
* *
@ -40,6 +40,8 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 15, 2012 njensen Initial creation * Nov 15, 2012 njensen Initial creation
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
* single request.
* *
* </pre> * </pre>
* *
@ -71,7 +73,7 @@ public class HydroQueryAssembler {
* the times of data to request * the times of data to request
* @return the SQL query * @return the SQL query
*/ */
public static String assembleGetData(IGeometryRequest request, public static String assembleGetData(IDataRequest request,
DataTime[] times) { DataTime[] times) {
return assembleGetData(request, buildTimeConstraint(times)).toString(); return assembleGetData(request, buildTimeConstraint(times)).toString();
} }
@ -85,7 +87,7 @@ public class HydroQueryAssembler {
* the time range of data to request * the time range of data to request
* @return the SQL query * @return the SQL query
*/ */
public static String assembleGetData(IGeometryRequest request, public static String assembleGetData(IDataRequest request,
TimeRange timeRange) { TimeRange timeRange) {
return assembleGetData(request, buildTimeConstraint(timeRange)) return assembleGetData(request, buildTimeConstraint(timeRange))
.toString(); .toString();
@ -101,7 +103,7 @@ public class HydroQueryAssembler {
* May be null. * May be null.
* @return a SQL string that corresponds to the request * @return a SQL string that corresponds to the request
*/ */
private static CharSequence assembleGetData(IGeometryRequest request, private static CharSequence assembleGetData(IDataRequest request,
CharSequence timeConstraint) { CharSequence timeConstraint) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// this method assembles a sql string such as: // this method assembles a sql string such as:
@ -139,7 +141,7 @@ public class HydroQueryAssembler {
* the request to find available times for * the request to find available times for
* @return the SQL query * @return the SQL query
*/ */
public static String assembleGetTimes(IGeometryRequest request) { public static String assembleGetTimes(IDataRequest request) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// select // select
@ -168,7 +170,7 @@ public class HydroQueryAssembler {
* the request to form a select statement on * the request to form a select statement on
* @return the select statement * @return the select statement
*/ */
private static CharSequence buildSelectParams(IGeometryRequest request) { private static CharSequence buildSelectParams(IDataRequest request) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// always want the location name and time even if they didn't request it // always want the location name and time even if they didn't request it
// so that returned objects will have that information // so that returned objects will have that information
@ -195,7 +197,7 @@ public class HydroQueryAssembler {
* the request to determine the tablename from * the request to determine the tablename from
* @return the from statement * @return the from statement
*/ */
private static CharSequence buildFrom(IGeometryRequest request) { private static CharSequence buildFrom(IDataRequest request) {
return " from " + request.getIdentifiers().get(TABLE); return " from " + request.getIdentifiers().get(TABLE);
} }
@ -207,7 +209,7 @@ public class HydroQueryAssembler {
* the request to determine the tablename from * the request to determine the tablename from
* @return the from statement * @return the from statement
*/ */
private static CharSequence buildFromWithLocation(IGeometryRequest request) { private static CharSequence buildFromWithLocation(IDataRequest request) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(buildFrom(request)); sb.append(buildFrom(request));
sb.append(" d, location l"); sb.append(" d, location l");
@ -224,7 +226,7 @@ public class HydroQueryAssembler {
* buildTimeConstraint(), or null * buildTimeConstraint(), or null
* @return the where clause * @return the where clause
*/ */
private static CharSequence buildWhere(IGeometryRequest request, private static CharSequence buildWhere(IDataRequest request,
CharSequence timeConstraint) { CharSequence timeConstraint) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
CharSequence locationConstraint = buildLocationConstraint(request CharSequence locationConstraint = buildLocationConstraint(request

View file

@ -28,6 +28,8 @@
# Date Ticket# Engineer Description # Date Ticket# Engineer Description
# ------------ ---------- ----------- -------------------------- # ------------ ---------- ----------- --------------------------
# 12/10/12 njensen Initial Creation. # 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): def getAvailableTimes(request):
return router.getAvailableTimes(request) return router.getAvailableTimes(request)
def getData(request, times): def getGridData(request, times):
return router.getData(request, times) return router.getGridData(request, times)
def getLatLonCoords(gridRequest): def getGeometryData(request, times):
return router.getLatLonCoords(gridRequest) return router.getGeometryData(request, times)
def getLatLonCoords(gridData):
return router.getLatLonCoords(gridData)
def getAvailableLocationNames(request): def getAvailableLocationNames(request):
return router.getAvailableLocationNames(request) return router.getAvailableLocationNames(request)
def newGeometryRequest(): def newDataRequest():
return router.newGeometryRequest() return router.newDataRequest()
def newGridRequest():
return router.newGridRequest()

View file

@ -28,6 +28,8 @@
# Date Ticket# Engineer Description # Date Ticket# Engineer Description
# ------------ ---------- ----------- -------------------------- # ------------ ---------- ----------- --------------------------
# 12/10/12 njensen Initial Creation. # 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): def setLevels(self, levels):
return return
@abc.abstractmethod
def setEnvelope(self, env):
return
@abc.abstractmethod @abc.abstractmethod
def setLocationNames(self, locationNames): def setLocationNames(self, locationNames):
return return
@ -69,10 +75,6 @@ class IDataRequest(object):
def getIdentifiers(self): def getIdentifiers(self):
return return
@abc.abstractmethod
def getParameters(self):
return
@abc.abstractmethod @abc.abstractmethod
def getLevels(self): def getLevels(self):
return return
@ -80,21 +82,11 @@ class IDataRequest(object):
@abc.abstractmethod @abc.abstractmethod
def getLocationNames(self): def getLocationNames(self):
return return
class IGridRequest(IDataRequest):
__metaclass__ = abc.ABCMeta
class IGeometryRequest(IDataRequest):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def getEnvelope(self): def getEnvelope(self):
return return
@abc.abstractmethod
def setEnvelope(self, env):
return
class IData(object): class IData(object):
@ -119,7 +111,6 @@ class IData(object):
class IGridData(IData): class IGridData(IData):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def getParameter(self): def getParameter(self):
@ -136,7 +127,6 @@ class IGridData(IData):
class IGeometryData(IData): class IGeometryData(IData):
#__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def getGeometry(self): def getGeometry(self):