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