From f34751122a5388601890b75162dd93dc45fc8f2f Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Wed, 6 Feb 2013 11:53:33 -0600 Subject: [PATCH] Issue #1554 initial implementation of GFE grid factory. Change-Id: Id2ae308c0c13822dd6e5dd0195f7920df82ff994 Former-commit-id: 0b350f62b26c9f2154a1d7bd6ba9d18475012495 --- .../META-INF/MANIFEST.MF | 10 +- .../d2d/gfe/browser/GFEDataDefinition.java | 69 ++---- .../viz/d2d/gfe/browser/GFEVbDataCatalog.java | 36 +-- .../uf/viz/d2d/gfe/rsc/GFEGridResource.java | 37 ++- .../viz/d2d/gfe/xy/GfeTimeSeriesAdapter.java | 9 +- .../META-INF/MANIFEST.MF | 6 +- .../res/spring/gfe-dataplugin-common.xml | 13 ++ .../gfe/dataaccess/GFEDataAccessUtil.java | 127 ++++++---- .../gfe/dataaccess/GFEGridFactory.java | 220 ++++++++++++++++++ 9 files changed, 407 insertions(+), 120 deletions(-) create mode 100644 edexOsgi/com.raytheon.uf.common.dataplugin.gfe/res/spring/gfe-dataplugin-common.xml rename cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/GFEUtil.java => edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/dataaccess/GFEDataAccessUtil.java (50%) create mode 100644 edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/dataaccess/GFEGridFactory.java diff --git a/cave/com.raytheon.uf.viz.d2d.gfe/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.d2d.gfe/META-INF/MANIFEST.MF index 98e598814e..6b78a3d1d3 100644 --- a/cave/com.raytheon.uf.viz.d2d.gfe/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.d2d.gfe/META-INF/MANIFEST.MF @@ -7,17 +7,11 @@ Bundle-Activator: com.raytheon.uf.viz.d2d.gfe.Activator Bundle-Vendor: RAYTHEON Eclipse-RegisterBuddy: com.raytheon.viz.core, com.raytheon.uf.viz.core Require-Bundle: org.eclipse.core.runtime, - com.raytheon.uf.common.serialization;bundle-version="1.12.1174" + com.raytheon.uf.common.serialization;bundle-version="1.12.1174", + com.raytheon.uf.common.dataplugin.gfe;bundle-version="1.12.1174" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Import-Package: com.raytheon.uf.common.dataplugin, - com.raytheon.uf.common.dataplugin.gfe, - com.raytheon.uf.common.dataplugin.gfe.db.objects, - com.raytheon.uf.common.dataplugin.gfe.grid, - com.raytheon.uf.common.dataplugin.gfe.request, - com.raytheon.uf.common.dataplugin.gfe.server.message, - com.raytheon.uf.common.dataplugin.gfe.server.request, - com.raytheon.uf.common.dataplugin.gfe.slice, com.raytheon.uf.common.dataquery.requests, com.raytheon.uf.common.dataquery.responses, com.raytheon.uf.common.datastorage.records, diff --git a/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/browser/GFEDataDefinition.java b/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/browser/GFEDataDefinition.java index c3f6bbac7d..c811026afd 100644 --- a/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/browser/GFEDataDefinition.java +++ b/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/browser/GFEDataDefinition.java @@ -27,13 +27,12 @@ import java.util.List; import java.util.Map; import java.util.Set; +import com.raytheon.uf.common.dataplugin.gfe.dataaccess.GFEDataAccessUtil; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; -import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.viz.core.rsc.DisplayType; import com.raytheon.uf.viz.core.rsc.ResourceType; import com.raytheon.uf.viz.core.rsc.capabilities.DisplayTypeCapability; -import com.raytheon.uf.viz.d2d.gfe.GFEUtil; import com.raytheon.uf.viz.d2d.gfe.rsc.GFEGridResourceData; import com.raytheon.uf.viz.productbrowser.AbstractRequestableProductBrowserDataDefinition; import com.raytheon.uf.viz.productbrowser.ProductBrowserLabel; @@ -60,22 +59,11 @@ import com.raytheon.viz.grid.rsc.GridLoadProperties; public class GFEDataDefinition extends AbstractRequestableProductBrowserDataDefinition { - public static final String SITE_ID = "siteId"; - - public static final String DB_TYPE = "dbType"; - - public static final String MODEL_NAME = "modelName"; - - public static final String MODEL_TIME = "modelTime"; - - public static final String PARM_NAME = "parmName"; - - public static final String PARM_LEVEL = "parmLevel"; - public GFEDataDefinition() { productName = "gfe"; displayName = "GFE"; - order = new String[] { SITE_ID, MODEL_NAME, PARM_NAME, PARM_LEVEL }; + order = new String[] { GFEDataAccessUtil.SITE_ID, GFEDataAccessUtil.MODEL_NAME, + GFEDataAccessUtil.PARM_NAME, GFEDataAccessUtil.PARM_LEVEL }; order = getOrder(); loadProperties = new GridLoadProperties(); loadProperties.setResourceType(getResourceType()); @@ -111,7 +99,7 @@ public class GFEDataDefinition extends */ @Override public List buildProductList(List historyList) { - String[] parameters = queryData(GFEUtil.PARM_ID, + String[] parameters = queryData(GFEDataAccessUtil.PARM_ID, getProductParameters(new String[0], null)); List result = new ArrayList(); for (String orderString : order) { @@ -131,7 +119,7 @@ public class GFEDataDefinition extends if (!isEnabled()) { return null; } - String[] parameters = queryData(GFEUtil.PARM_ID, + String[] parameters = queryData(GFEDataAccessUtil.PARM_ID, getProductParameters(new String[0], null)); if (parameters != null) { @@ -149,7 +137,7 @@ public class GFEDataDefinition extends @Override protected String[] queryData(String param, HashMap queryList) { - return super.queryData(GFEUtil.PARM_ID, queryList); + return super.queryData(GFEDataAccessUtil.PARM_ID, queryList); } @Override @@ -160,17 +148,17 @@ public class GFEDataDefinition extends String label = value; try { ParmID parmId = new ParmID(value); - if (param.equals(SITE_ID)) { + if (param.equals(GFEDataAccessUtil.SITE_ID)) { label = parmId.getDbId().getSiteId(); - } else if (param.equals(MODEL_NAME)) { + } else if (param.equals(GFEDataAccessUtil.MODEL_NAME)) { label = parmId.getDbId().getModelName(); - } else if (param.equals(MODEL_TIME)) { + } else if (param.equals(GFEDataAccessUtil.MODEL_TIME)) { label = parmId.getDbId().getModelTime(); - } else if (param.equals(DB_TYPE)) { + } else if (param.equals(GFEDataAccessUtil.DB_TYPE)) { label = parmId.getDbId().getDbType(); - } else if (param.equals(PARM_NAME)) { + } else if (param.equals(GFEDataAccessUtil.PARM_NAME)) { label = parmId.getParmName(); - } else if (param.equals(PARM_LEVEL)) { + } else if (param.equals(GFEDataAccessUtil.PARM_LEVEL)) { label = parmId.getParmLevel(); } } catch (Exception e) { @@ -190,37 +178,20 @@ public class GFEDataDefinition extends if (order == null) { order = this.order; } - String siteId = "%"; - String modelName = "%"; - String modelTime = "%"; - String dbType = "%"; - String parmName = "%"; - String parmLevel = "%"; - HashMap queryList = new HashMap(); - queryList.put(PLUGIN_NAME, new RequestConstraint(productName)); + Map parmIdComponents = new HashMap(); if (selection.length > 1) { String[] usedSelection = realignSelection(selection); for (int i = 0; i < usedSelection.length; i++) { - if (order[i].equals(SITE_ID)) { - siteId = usedSelection[i]; - } else if (order[i].equals(MODEL_NAME)) { - modelName = usedSelection[i]; - } else if (order[i].equals(MODEL_TIME)) { - modelTime = usedSelection[i]; - } else if (order[i].equals(DB_TYPE)) { - dbType = usedSelection[i]; - } else if (order[i].equals(PARM_NAME)) { - parmName = usedSelection[i]; - } else if (order[i - 1].equals(PARM_LEVEL)) { - parmLevel = usedSelection[i]; - } + parmIdComponents.put(order[i], usedSelection[i]); } } - String parmId = String.format(GFEUtil.PARM_ID_FORMAT, parmName, - parmLevel, siteId, dbType, modelName, modelTime); - queryList.put(GFEUtil.PARM_ID, new RequestConstraint(parmId, - ConstraintType.LIKE)); + + HashMap queryList = new HashMap(); + queryList.put(PLUGIN_NAME, new RequestConstraint(productName)); + + queryList.put(GFEDataAccessUtil.PARM_ID, + GFEDataAccessUtil.createParmIdConstraint(parmIdComponents)); return queryList; } diff --git a/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/browser/GFEVbDataCatalog.java b/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/browser/GFEVbDataCatalog.java index 550ab19471..40df6f91b5 100644 --- a/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/browser/GFEVbDataCatalog.java +++ b/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/browser/GFEVbDataCatalog.java @@ -23,12 +23,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.measure.unit.UnitFormat; +import com.raytheon.uf.common.dataplugin.gfe.dataaccess.GFEDataAccessUtil; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.dataquery.requests.RequestConstraint; -import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; @@ -43,7 +44,7 @@ import com.raytheon.uf.viz.core.style.ParamLevelMatchCriteria; import com.raytheon.uf.viz.core.style.StyleManager; import com.raytheon.uf.viz.core.style.StyleRule; import com.raytheon.uf.viz.core.style.VizStyleException; -import com.raytheon.uf.viz.d2d.gfe.GFEUtil; +import com.raytheon.uf.viz.d2d.gfe.rsc.GFEGridResource; import com.raytheon.uf.viz.d2d.gfe.rsc.GFEGridResourceData; import com.raytheon.viz.volumebrowser.datacatalog.AbstractDataCatalog; import com.raytheon.viz.volumebrowser.datacatalog.AvailableDataRequest; @@ -54,7 +55,9 @@ import com.raytheon.viz.volumebrowser.vbui.VBMenuBarItemsMgr.ViewMenu; /** * - * TODO Add Description + * Data Catalog for using gfe data in the volume browser. This works by using + * selected model, field, and plane to create ParmId LIKE constraints that can + * be used to narrow down the selection. * *
  * 
@@ -76,10 +79,10 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
     @Override
     public IDataCatalogEntry getCatalogEntry(SelectedData selectedData) {
         HashMap queryList = new HashMap();
-        queryList.put(GFEUtil.PLUGIN_NAME, new RequestConstraint("gfe"));
-        queryList.put(GFEUtil.PARM_ID, getParmIdConstraint(selectedData));
+        queryList.put(GFEDataAccessUtil.PLUGIN_NAME, new RequestConstraint("gfe"));
+        queryList.put(GFEDataAccessUtil.PARM_ID, getParmIdConstraint(selectedData));
         try {
-            String[] result = CatalogQuery.performQuery(GFEUtil.PARM_ID,
+            String[] result = CatalogQuery.performQuery(GFEDataAccessUtil.PARM_ID,
                     queryList);
             if (result != null && result.length > 0) {
                 ParmID sampleId = new ParmID(result[0]);
@@ -204,15 +207,15 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
     @Override
     protected void addProductParameters(IDataCatalogEntry catalogEntry,
             HashMap productParameters) {
-        productParameters.put(GFEUtil.PARM_ID,
+        productParameters.put(GFEDataAccessUtil.PARM_ID,
                 getParmIdConstraint(catalogEntry.getSelectedData()));
     }
 
     private String[] getParmIds() {
         HashMap queryList = new HashMap();
-        queryList.put(GFEUtil.PLUGIN_NAME, new RequestConstraint("gfe"));
+        queryList.put(GFEDataAccessUtil.PLUGIN_NAME, new RequestConstraint("gfe"));
         try {
-            return CatalogQuery.performQuery(GFEUtil.PARM_ID, queryList);
+            return CatalogQuery.performQuery(GFEDataAccessUtil.PARM_ID, queryList);
         } catch (VizException e) {
             throw new RuntimeException(e);
         }
@@ -248,7 +251,7 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
             DisplayType displayType) {
         if (catalogEntry instanceof GFECatalogEntry) {
             ParmID sampleId = ((GFECatalogEntry) catalogEntry).getSampleId();
-            ParamLevelMatchCriteria criteria = GFEUtil
+            ParamLevelMatchCriteria criteria = GFEGridResource
                     .getMatchCriteria(sampleId);
             StyleRule sr = null;
             try {
@@ -277,8 +280,8 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
             } else {
                 try {
                     return UnitFormat.getUCUMInstance().format(
-                            GFEUtil.getGridParmInfo(sampleId).getUnitObject());
-                } catch (VizException e) {
+                            GFEDataAccessUtil.getGridParmInfo(sampleId).getUnitObject());
+                } catch (Exception e) {
                     statusHandler.handle(Priority.PROBLEM,
                             "Unable to obtain a unit information for"
                                     + catalogEntry.getSelectedData()
@@ -297,9 +300,12 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
                 .getGfeLevel(selectedData.getPlanesKey());
         String modelName = VbGFEMapping.getGfeSource(selectedData
                 .getSourcesKey());
-        String parmId = String.format(GFEUtil.PARM_ID_FORMAT, parmName,
-                parmLevel, "%", "%", modelName, "%");
-        return new RequestConstraint(parmId, ConstraintType.LIKE);
+
+        Map parmIdComponents = new HashMap();
+        parmIdComponents.put(GFEDataAccessUtil.PARM_NAME, parmName);
+        parmIdComponents.put(GFEDataAccessUtil.PARM_LEVEL, parmLevel);
+        parmIdComponents.put(GFEDataAccessUtil.MODEL_NAME, modelName);
+        return GFEDataAccessUtil.createParmIdConstraint(parmIdComponents);
     }
 
     private static class GFECatalogEntry extends DataCatalogEntry {
diff --git a/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/rsc/GFEGridResource.java b/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/rsc/GFEGridResource.java
index 51cf7c4b98..4a7cd054be 100644
--- a/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/rsc/GFEGridResource.java
+++ b/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/rsc/GFEGridResource.java
@@ -19,12 +19,14 @@
  **/
 package com.raytheon.uf.viz.d2d.gfe.rsc;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 import org.geotools.coverage.grid.GridGeometry2D;
 
 import com.raytheon.uf.common.dataplugin.PluginDataObject;
+import com.raytheon.uf.common.dataplugin.gfe.dataaccess.GFEDataAccessUtil;
 import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord;
 import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
 import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
@@ -36,7 +38,8 @@ import com.raytheon.uf.viz.core.exception.VizException;
 import com.raytheon.uf.viz.core.rsc.DisplayType;
 import com.raytheon.uf.viz.core.rsc.LoadProperties;
 import com.raytheon.uf.viz.core.style.ParamLevelMatchCriteria;
-import com.raytheon.uf.viz.d2d.gfe.GFEUtil;
+import com.raytheon.uf.viz.core.style.level.Level;
+import com.raytheon.uf.viz.core.style.level.SingleLevel;
 import com.raytheon.viz.grid.rsc.general.AbstractGridResource;
 import com.raytheon.viz.grid.rsc.general.GeneralGridData;
 
@@ -90,15 +93,15 @@ public class GFEGridResource extends AbstractGridResource {
         }
         try {
             gfeRecord
-                    .setGridInfo(GFEUtil.getGridParmInfo(gfeRecord.getParmId()));
-        } catch (VizException e) {
+                    .setGridInfo(GFEDataAccessUtil.getGridParmInfo(gfeRecord.getParmId()));
+        } catch (Exception e) {
             throw new RuntimeException(e);
         }
     }
 
     @Override
     public ParamLevelMatchCriteria getMatchCriteria() {
-        return GFEUtil.getMatchCriteria(parmId);
+        return getMatchCriteria(parmId);
     }
 
     @Override
@@ -108,7 +111,12 @@ public class GFEGridResource extends AbstractGridResource {
             return null;
         }
         GFERecord gfeRecord = (GFERecord) pdos.get(0);
-        IGridSlice slice = GFEUtil.getSlice(gfeRecord);
+        IGridSlice slice = null;
+        try {
+            slice = GFEDataAccessUtil.getSlice(gfeRecord);
+        } catch (Exception e) {
+            throw new VizException(e);
+        }
         populateGridParmInfo(gfeRecord);
         GridGeometry2D gridGeometry = MapUtil.getGridGeometry(gfeRecord
                 .getGridInfo().getGridLoc());
@@ -160,4 +168,23 @@ public class GFEGridResource extends AbstractGridResource {
                 parmName, displayTypeString, unitLabel);
     }
 
+    public static ParamLevelMatchCriteria getMatchCriteria(ParmID parmId) {
+        ParamLevelMatchCriteria criteria = new ParamLevelMatchCriteria();
+        criteria.setParameterName(new ArrayList());
+        criteria.setLevels(new ArrayList());
+        criteria.setCreatingEntityNames(new ArrayList());
+        String parameter = "GFE:" + parmId.getParmName();
+        SingleLevel level = new SingleLevel(Level.LevelType.SURFACE);
+        String model = "GFE:" + parmId.getDbId().getModelName();
+        if (!criteria.getParameterNames().contains(parameter)) {
+            criteria.getParameterNames().add(parameter);
+        }
+        if (!criteria.getLevels().contains(level)) {
+            criteria.getLevels().add(level);
+        }
+        if (!criteria.getCreatingEntityNames().contains(model)) {
+            criteria.getCreatingEntityNames().add(model);
+        }
+        return criteria;
+    }
 }
diff --git a/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/xy/GfeTimeSeriesAdapter.java b/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/xy/GfeTimeSeriesAdapter.java
index 0ea4d17d0f..a459587ac8 100644
--- a/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/xy/GfeTimeSeriesAdapter.java
+++ b/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/xy/GfeTimeSeriesAdapter.java
@@ -12,6 +12,7 @@ import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
 
 import com.raytheon.uf.common.dataplugin.PluginDataObject;
+import com.raytheon.uf.common.dataplugin.gfe.dataaccess.GFEDataAccessUtil;
 import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord;
 import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
 import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
@@ -20,7 +21,6 @@ import com.raytheon.uf.common.geospatial.MapUtil;
 import com.raytheon.uf.viz.core.exception.VizException;
 import com.raytheon.uf.viz.core.style.level.Level;
 import com.raytheon.uf.viz.core.style.level.SingleLevel;
-import com.raytheon.uf.viz.d2d.gfe.GFEUtil;
 import com.raytheon.uf.viz.xy.timeseries.adapter.AbstractTimeSeriesAdapter;
 import com.raytheon.viz.core.graphing.xy.XYData;
 import com.raytheon.viz.core.graphing.xy.XYDataList;
@@ -50,7 +50,12 @@ public class GfeTimeSeriesAdapter extends AbstractTimeSeriesAdapter {
 
         DirectPosition2D point = null;
         for (GFERecord gfeRecord : recordsToLoad) {
-            IGridSlice slice = GFEUtil.getSlice(gfeRecord);
+            IGridSlice slice = null;
+            try {
+                slice = GFEDataAccessUtil.getSlice(gfeRecord);
+            } catch (Exception e) {
+                throw new VizException(e);
+            }
             if (slice != null) {
                 unit = slice.getGridInfo().getUnitObject();
                 if (point == null) {
diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/META-INF/MANIFEST.MF
index a794447395..b67e8aa896 100644
--- a/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/META-INF/MANIFEST.MF
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/META-INF/MANIFEST.MF
@@ -16,9 +16,13 @@ Require-Bundle: org.geotools,
  com.raytheon.uf.common.serialization,
  org.hibernate,
  com.raytheon.uf.common.auth;bundle-version="1.12.1174",
- com.raytheon.uf.common.cache
+ com.raytheon.uf.common.cache,
+ com.raytheon.uf.common.dataaccess;bundle-version="1.0.0",
+ com.raytheon.uf.common.dataquery;bundle-version="1.0.0",
+ com.raytheon.uf.common.datastorage;bundle-version="1.12.1174"
 Export-Package: com.raytheon.uf.common.dataplugin.gfe,
  com.raytheon.uf.common.dataplugin.gfe.config,
+ com.raytheon.uf.common.dataplugin.gfe.dataaccess,
  com.raytheon.uf.common.dataplugin.gfe.db.objects,
  com.raytheon.uf.common.dataplugin.gfe.db.type,
  com.raytheon.uf.common.dataplugin.gfe.discrete,
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
new file mode 100644
index 0000000000..42141fb382
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/res/spring/gfe-dataplugin-common.xml
@@ -0,0 +1,13 @@
+
+
+	
+	
+	
+		
+		
+		
+		
+	
+
\ No newline at end of file
diff --git a/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/GFEUtil.java b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/dataaccess/GFEDataAccessUtil.java
similarity index 50%
rename from cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/GFEUtil.java
rename to edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/dataaccess/GFEDataAccessUtil.java
index 2e59472878..03b07628da 100644
--- a/cave/com.raytheon.uf.viz.d2d.gfe/src/com/raytheon/uf/viz/d2d/gfe/GFEUtil.java
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/dataaccess/GFEDataAccessUtil.java
@@ -17,11 +17,11 @@
  * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
  * further licensing information.
  **/
-package com.raytheon.uf.viz.d2d.gfe;
+package com.raytheon.uf.common.dataplugin.gfe.dataaccess;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 
 import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord;
 import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo;
@@ -31,16 +31,13 @@ import com.raytheon.uf.common.dataplugin.gfe.request.GetGridParmInfoRequest;
 import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
 import com.raytheon.uf.common.dataplugin.gfe.server.request.GetGridRequest;
 import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
-import com.raytheon.uf.viz.core.VizApp;
-import com.raytheon.uf.viz.core.exception.VizException;
-import com.raytheon.uf.viz.core.requests.ThriftClient;
-import com.raytheon.uf.viz.core.style.ParamLevelMatchCriteria;
-import com.raytheon.uf.viz.core.style.level.Level;
-import com.raytheon.uf.viz.core.style.level.SingleLevel;
+import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
+import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
+import com.raytheon.uf.common.serialization.comm.RequestRouter;
 
 /**
  * 
- * TODO Add Description
+ * Some utility methods for querying and retrieving GFE data.
  * 
  * 
  * 
@@ -55,60 +52,110 @@ import com.raytheon.uf.viz.core.style.level.SingleLevel;
  * @author bsteffen
  * @version 1.0
  */
-public class GFEUtil {
+public class GFEDataAccessUtil {
 
-    public static final String PARM_ID_FORMAT = "%s_%s:%s_GRID_%s_%s_%s";
+    private static final String PARM_ID_FORMAT = "%s_%s:%s_GRID_%s_%s_%s";
 
     public static final String PARM_ID = "parmId";
 
     public static final String PLUGIN_NAME = "pluginName";
 
-    public static GridParmInfo getGridParmInfo(ParmID parmId)
-            throws VizException {
+    public static final String SITE_ID = "siteId";
+
+    public static final String DB_TYPE = "dbType";
+
+    public static final String MODEL_NAME = "modelName";
+
+    public static final String MODEL_TIME = "modelTime";
+
+    public static final String PARM_NAME = "parmName";
+
+    public static final String PARM_LEVEL = "parmLevel";
+
+    /**
+     * Retrieve the GridParmInfo for a ParmID
+     * 
+     * @param parmId
+     * @return
+     * @throws Exception
+     */
+    public static GridParmInfo getGridParmInfo(ParmID parmId) throws Exception {
         GetGridParmInfoRequest request = new GetGridParmInfoRequest();
         request.setParmIds(Arrays.asList(parmId));
         request.setSiteID(parmId.getDbId().getSiteId());
-        request.setWorkstationID(VizApp.getWsId());
         @SuppressWarnings("unchecked")
-        ServerResponse> response = (ServerResponse>) ThriftClient
-                .sendRequest(request);
+        ServerResponse> response = (ServerResponse>) RequestRouter
+                .route(request);
         return response.getPayload().get(0);
     }
 
-    public static ParamLevelMatchCriteria getMatchCriteria(ParmID parmId) {
-        ParamLevelMatchCriteria criteria = new ParamLevelMatchCriteria();
-        criteria.setParameterName(new ArrayList());
-        criteria.setLevels(new ArrayList());
-        criteria.setCreatingEntityNames(new ArrayList());
-        String parameter = "GFE:" + parmId.getParmName();
-        SingleLevel level = new SingleLevel(Level.LevelType.SURFACE);
-        String model = "GFE:" + parmId.getDbId().getModelName();
-        if (!criteria.getParameterNames().contains(parameter)) {
-            criteria.getParameterNames().add(parameter);
-        }
-        if (!criteria.getLevels().contains(level)) {
-            criteria.getLevels().add(level);
-        }
-        if (!criteria.getCreatingEntityNames().contains(model)) {
-            criteria.getCreatingEntityNames().add(model);
-        }
-        return criteria;
-    }
-
-    public static IGridSlice getSlice(GFERecord gfeRecord) throws VizException {
+    /**
+     * Send a GetGridDataRequest through the requestRouter to grab a single
+     * slice of grid data.
+     * 
+     * @param gfeRecord
+     * @return
+     * @throws Exception
+     */
+    public static IGridSlice getSlice(GFERecord gfeRecord) throws Exception {
         GetGridRequest gridRequest = new GetGridRequest();
         gridRequest.setParmId(gfeRecord.getParmId());
         gridRequest.setRecords(Arrays.asList(gfeRecord));
 
         GetGridDataRequest request = new GetGridDataRequest();
         request.setSiteID(gfeRecord.getDbId().getSiteId());
-        request.setWorkstationID(VizApp.getWsId());
         request.setRequests(Arrays.asList(gridRequest));
 
         @SuppressWarnings("unchecked")
-        ServerResponse> response = (ServerResponse>) ThriftClient
-                .sendRequest(request);
+        ServerResponse> response = (ServerResponse>) RequestRouter
+                .route(request);
         return response.getPayload().get(0);
     }
 
+    /**
+     * Take a map of value for various fields that make up the ParmId and
+     * convert it into a single like constraint for ParmId. ANd fields not in
+     * the map will accept any value.
+     * 
+     * @param components
+     * @return
+     */
+    public static RequestConstraint createParmIdConstraint(
+            Map components) {
+        String siteId = "%";
+        String modelName = "%";
+        String modelTime = "%";
+        String dbType = "%";
+        String parmName = "%";
+        String parmLevel = "%";
+
+        if (components.containsKey(SITE_ID)) {
+            siteId = components.get(SITE_ID);
+        }
+
+        if (components.containsKey(MODEL_NAME)) {
+            modelName = components.get(MODEL_NAME);
+        }
+
+        if (components.containsKey(MODEL_TIME)) {
+            modelTime = components.get(MODEL_TIME);
+        }
+
+        if (components.containsKey(DB_TYPE)) {
+            dbType = components.get(DB_TYPE);
+        }
+
+        if (components.containsKey(PARM_NAME)) {
+            parmName = components.get(PARM_NAME);
+        }
+
+        if (components.containsKey(PARM_LEVEL)) {
+            parmLevel = components.get(PARM_LEVEL);
+        }
+
+        String parmId = String.format(PARM_ID_FORMAT, parmName,
+                parmLevel, siteId, dbType, modelName, modelTime);
+        return new RequestConstraint(parmId, ConstraintType.LIKE);
+    }
+
 }
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
new file mode 100644
index 0000000000..9b83dcbb4b
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/src/com/raytheon/uf/common/dataplugin/gfe/dataaccess/GFEGridFactory.java
@@ -0,0 +1,220 @@
+/**
+ * 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.dataplugin.gfe.dataaccess;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.geotools.coverage.grid.GridGeometry2D;
+
+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.gfe.db.objects.GFERecord;
+import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
+import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo;
+import com.raytheon.uf.common.dataplugin.gfe.grid.Grid2DFloat;
+import com.raytheon.uf.common.dataplugin.gfe.slice.IGridSlice;
+import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice;
+import com.raytheon.uf.common.dataplugin.level.Level;
+import com.raytheon.uf.common.dataplugin.level.MasterLevel;
+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;
+
+/**
+ * A data factory for getting gfe data from the metadata database. There are
+ * currently not any required identifiers.
+ * 
+ * 
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 4, 2013            bsteffen     Initial creation
+ * 
+ * 
+ * + * @author bsteffen + * @version 1.0 + */ + +public class GFEGridFactory extends AbstractGridDataPluginFactory implements + IGridDataFactory { + + private static final String[] VALID_IDENTIFIERS = { GFEDataAccessUtil.MODEL_NAME, + GFEDataAccessUtil.MODEL_TIME, GFEDataAccessUtil.SITE_ID }; + + @Override + public String[] getValidIdentifiers() { + return VALID_IDENTIFIERS; + } + + @Override + protected IGridData constructGridDataResponse(IGridRequest request, + PluginDataObject pdo, GridGeometry2D gridGeometry, + IDataRecord dataRecord) { + GFERecord gfeRecord = asGFERecord(pdo); + + DefaultGridData defaultGridData = new DefaultGridData( + DataWrapperUtil.constructArrayWrapper(dataRecord, false), + gridGeometry); + defaultGridData.setDataTime(pdo.getDataTime()); + defaultGridData.setParameter(gfeRecord.getParmName()); + Level level = new Level(); + level.setMasterLevel(new MasterLevel(gfeRecord.getParmLevel())); + defaultGridData.setLevel(level); + defaultGridData.setUnit(gfeRecord.getGridInfo().getUnitObject()); + + Map attrs = new HashMap(); + attrs.put(GFEDataAccessUtil.MODEL_NAME, gfeRecord.getDbId() + .getModelName()); + attrs.put(GFEDataAccessUtil.MODEL_TIME, gfeRecord.getDbId() + .getModelTime()); + attrs.put(GFEDataAccessUtil.SITE_ID, gfeRecord.getDbId().getSiteId()); + + defaultGridData.setAttributes(attrs); + + return defaultGridData; + } + + @Override + protected Map buildConstraintsFromRequest( + IGridRequest request) { + HashMap constraints = new HashMap(); + + Map parmIdComponents = new HashMap(); + Map identifiers = request.getIdentifiers(); + if (identifiers != null) { + for (Entry entry : identifiers.entrySet()) { + parmIdComponents.put(entry.getKey(), entry.getValue() + .toString()); + } + } + + String[] parameters = request.getParameters(); + if (parameters != null) { + if (parameters.length == 1) { + parmIdComponents.put(GFEDataAccessUtil.PARM_NAME, parameters[0]); + } else if (parameters.length > 1) { + RequestConstraint paramNameConstraint = new RequestConstraint( + null, ConstraintType.IN); + paramNameConstraint.setConstraintValueList(parameters); + constraints.put(GFEDataAccessUtil.PARM_NAME, paramNameConstraint); + } + } + + Level[] levels = request.getLevels(); + if (levels != null) { + if (levels.length == 1) { + parmIdComponents.put(GFEDataAccessUtil.PARM_LEVEL, levels[0] + .getMasterLevel().getName()); + } else if (levels.length > 1) { + RequestConstraint paramLevelConstraint = new RequestConstraint( + null, ConstraintType.IN); + for (Level level : levels) { + paramLevelConstraint.addToConstraintValueList(level + .getMasterLevel().getName()); + } + constraints.put(GFEDataAccessUtil.PARM_LEVEL, paramLevelConstraint); + } + } + + constraints.put(GFEDataAccessUtil.PLUGIN_NAME, new RequestConstraint("gfe")); + constraints.put(GFEDataAccessUtil.PARM_ID, + GFEDataAccessUtil.createParmIdConstraint(parmIdComponents)); + return constraints; + } + + @Override + protected IDataRecord getDataRecord(PluginDataObject pdo, + Request storageRequest) { + GFERecord gfeRecord = asGFERecord(pdo); + + try { + IGridSlice slice = GFEDataAccessUtil + .getSlice(gfeRecord); + GridLocation loc = slice.getGridInfo().getGridLoc(); + gfeRecord.setGridInfo(slice.getGridInfo()); + Grid2DFloat data = null; + if(slice instanceof ScalarGridSlice){ + // This also grabs vector data. + data = ((ScalarGridSlice) slice).getScalarGrid(); + } else { + throw new DataRetrievalException("UNknown slice of type " + + slice.getClass().getSimpleName()); + } + return new FloatDataRecord("Data", gfeRecord.getDataURI(), data.getFloats(), 2, new long[] { + loc.getNx(), loc.getNy() }); + } catch (Exception e) { + throw new DataRetrievalException(e); + } + } + + @Override + protected GridGeometry2D getGridGeometry(PluginDataObject pdo) { + GFERecord gfeRecord = asGFERecord(pdo); + GridParmInfo info = gfeRecord.getGridInfo(); + if (info == null) { + try { + info = GFEDataAccessUtil.getGridParmInfo(gfeRecord.getParmId()); + } catch (Exception e) { + throw new DataRetrievalException(e); + } + gfeRecord.setGridInfo(info); + } + return MapUtil.getGridGeometry(info.getGridLoc()); + } + + @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; + } + + private GFERecord asGFERecord(Object obj) { + if (obj instanceof GFERecord == false) { + throw new DataRetrievalException(this.getClass().getSimpleName() + + " cannot handle " + obj.getClass().getSimpleName()); + } + + return (GFERecord) obj; + } + +}