Issue #1949 Update GFE data access in Product Browser, Volume Browser, and Data Access Framework.
Former-commit-id:c1e14e69f7
[formerly926af755fe
[formerly 5539e83d56681d680ec92378b4dd408da2f94ae6]] Former-commit-id:926af755fe
Former-commit-id:09bbd5f2c9
This commit is contained in:
parent
5683873c24
commit
70a705e9c6
5 changed files with 156 additions and 305 deletions
|
@ -20,23 +20,16 @@
|
|||
package com.raytheon.uf.viz.d2d.gfe.browser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
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.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.rsc.GFEGridResourceData;
|
||||
import com.raytheon.uf.viz.productbrowser.AbstractRequestableProductBrowserDataDefinition;
|
||||
import com.raytheon.uf.viz.productbrowser.ProductBrowserLabel;
|
||||
import com.raytheon.uf.viz.productbrowser.ProductBrowserPreference;
|
||||
import com.raytheon.viz.grid.rsc.GridLoadProperties;
|
||||
|
||||
/**
|
||||
|
@ -50,8 +43,9 @@ import com.raytheon.viz.grid.rsc.GridLoadProperties;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 9, 2011 bsteffen Initial creation
|
||||
* May 02, 2013 1949 bsteffen Switch Product Browser from uengine to
|
||||
* DbQueryRequest.
|
||||
* May 02, 2013 1949 bsteffen Update GFE data access in Product
|
||||
* Browser, Volume Browser, and Data Access
|
||||
* Framework.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -92,119 +86,4 @@ public class GFEDataDefinition extends
|
|||
return type;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.productbrowser.
|
||||
* AbstractRequestableProductBrowserDataDefinition
|
||||
* #buildProductList(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public List<String> buildProductList(List<String> historyList) {
|
||||
String[] parameters = queryData(GFEDataAccessUtil.PARM_ID,
|
||||
getProductParameters(new String[0], null));
|
||||
List<String> result = new ArrayList<String>();
|
||||
for (String orderString : order) {
|
||||
List<ProductBrowserLabel> labels = formatData(orderString,
|
||||
parameters);
|
||||
for (ProductBrowserLabel label : labels) {
|
||||
if (!result.contains(label.getName())) {
|
||||
result.add(label.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String populateInitial() {
|
||||
if (!isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
String[] parameters = queryData(GFEDataAccessUtil.PARM_ID,
|
||||
getProductParameters(new String[0], null));
|
||||
|
||||
if (parameters != null) {
|
||||
if (parameters.length > 0) {
|
||||
return displayName;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] queryData(String param,
|
||||
Map<String, RequestConstraint> queryList) {
|
||||
return super.queryData(GFEDataAccessUtil.PARM_ID, queryList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductBrowserLabel> formatData(String param,
|
||||
String[] parameters) {
|
||||
Set<ProductBrowserLabel> labels = new HashSet<ProductBrowserLabel>();
|
||||
for (String value : parameters) {
|
||||
String label = value;
|
||||
try {
|
||||
ParmID parmId = new ParmID(value);
|
||||
if (param.equals(GFEDataAccessUtil.SITE_ID)) {
|
||||
label = parmId.getDbId().getSiteId();
|
||||
} else if (param.equals(GFEDataAccessUtil.MODEL_NAME)) {
|
||||
label = parmId.getDbId().getModelName();
|
||||
} else if (param.equals(GFEDataAccessUtil.MODEL_TIME)) {
|
||||
label = parmId.getDbId().getModelTime();
|
||||
} else if (param.equals(GFEDataAccessUtil.DB_TYPE)) {
|
||||
label = parmId.getDbId().getDbType();
|
||||
} else if (param.equals(GFEDataAccessUtil.PARM_NAME)) {
|
||||
label = parmId.getParmName();
|
||||
} else if (param.equals(GFEDataAccessUtil.PARM_LEVEL)) {
|
||||
label = parmId.getParmLevel();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
labels.add(new ProductBrowserLabel(label, label));
|
||||
}
|
||||
ArrayList<ProductBrowserLabel> finalLabels = new ArrayList<ProductBrowserLabel>(
|
||||
labels);
|
||||
Collections.sort(finalLabels);
|
||||
return finalLabels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, RequestConstraint> getProductParameters(
|
||||
String[] selection, String[] order) {
|
||||
if (order == null) {
|
||||
order = this.order;
|
||||
}
|
||||
|
||||
Map<String, String> parmIdComponents = new HashMap<String, String>();
|
||||
if (selection.length > 1) {
|
||||
String[] usedSelection = realignSelection(selection);
|
||||
for (int i = 0; i < usedSelection.length; i++) {
|
||||
parmIdComponents.put(order[i], usedSelection[i]);
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, RequestConstraint> queryList = new HashMap<String, RequestConstraint>();
|
||||
queryList.put(PLUGIN_NAME, new RequestConstraint(productName));
|
||||
|
||||
queryList.put(GFEDataAccessUtil.PARM_ID,
|
||||
GFEDataAccessUtil.createParmIdConstraint(parmIdComponents));
|
||||
return queryList;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.productbrowser.xml.IProductBrowserPreferences#
|
||||
* configurePreferences()
|
||||
*/
|
||||
@Override
|
||||
public List<ProductBrowserPreference> configurePreferences() {
|
||||
return super.configurePreferences();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,14 +28,18 @@ 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.GFERecord;
|
||||
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.catalog.CatalogQuery;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
|
||||
import com.raytheon.uf.viz.core.rsc.DisplayType;
|
||||
|
@ -66,6 +70,9 @@ import com.raytheon.viz.volumebrowser.vbui.VBMenuBarItemsMgr.ViewMenu;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 9, 2011 bsteffen Initial creation
|
||||
* May 02, 2013 1949 bsteffen Update GFE data access in Product
|
||||
* Browser, Volume Browser, and Data Access
|
||||
* Framework.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -80,7 +87,7 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
|
|||
public IDataCatalogEntry getCatalogEntry(SelectedData selectedData) {
|
||||
HashMap<String, RequestConstraint> queryList = new HashMap<String, RequestConstraint>();
|
||||
queryList.put(GFEDataAccessUtil.PLUGIN_NAME, new RequestConstraint("gfe"));
|
||||
queryList.put(GFEDataAccessUtil.PARM_ID, getParmIdConstraint(selectedData));
|
||||
queryList.putAll(getParmIdConstraint(selectedData));
|
||||
try {
|
||||
String[] result = CatalogQuery.performQuery(GFEDataAccessUtil.PARM_ID,
|
||||
queryList);
|
||||
|
@ -103,7 +110,7 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
|
|||
|
||||
List<String> gfeSources = null;
|
||||
if (selectedSources != null && selectedSources.length != 0) {
|
||||
gfeSources = new ArrayList<String>();
|
||||
gfeSources = new ArrayList<String>(selectedSources.length);
|
||||
for (String selectedSource : selectedSources) {
|
||||
String gfeSource = VbGFEMapping.getGfeSource(selectedSource);
|
||||
if (gfeSource != null) {
|
||||
|
@ -117,7 +124,7 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
|
|||
|
||||
List<String> gfeFields = null;
|
||||
if (selectedFields != null && selectedFields.length != 0) {
|
||||
gfeFields = new ArrayList<String>();
|
||||
gfeFields = new ArrayList<String>(selectedFields.length);
|
||||
for (String selectedField : selectedFields) {
|
||||
String gfeParam = VbGFEMapping.getGfeParam(selectedField);
|
||||
if (gfeParam != null) {
|
||||
|
@ -131,7 +138,7 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
|
|||
|
||||
List<String> gfePlanes = null;
|
||||
if (selectedPlanes != null && selectedPlanes.length != 0) {
|
||||
gfePlanes = new ArrayList<String>();
|
||||
gfePlanes = new ArrayList<String>(selectedPlanes.length);
|
||||
for (String selectedPlane : selectedPlanes) {
|
||||
String gfePlane = VbGFEMapping.getGfeLevel(selectedPlane);
|
||||
if (gfePlane != null) {
|
||||
|
@ -143,40 +150,56 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
|
|||
}
|
||||
}
|
||||
|
||||
for (String parmIdStr : getParmIds()) {
|
||||
ParmID parmId = new ParmID(parmIdStr);
|
||||
DbQueryRequest dbRequest = new DbQueryRequest();
|
||||
dbRequest.setEntityClass(GFERecord.class);
|
||||
dbRequest.addRequestField(GFEDataAccessUtil.MODEL_NAME);
|
||||
dbRequest.addRequestField(GFEDataAccessUtil.PARM_NAME);
|
||||
dbRequest.addRequestField(GFEDataAccessUtil.PARM_LEVEL);
|
||||
DbQueryResponse dbResponse = null;
|
||||
try {
|
||||
dbResponse = (DbQueryResponse) ThriftClient.sendRequest(dbRequest);
|
||||
} catch (VizException e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Unable to load availability for GFE in the Volume Browser",
|
||||
e);
|
||||
return;
|
||||
}
|
||||
|
||||
for (Map<String, Object> row : dbResponse.getResults()) {
|
||||
String modelName = row.get(GFEDataAccessUtil.MODEL_NAME).toString();
|
||||
String parmName = row.get(GFEDataAccessUtil.PARM_NAME).toString();
|
||||
String parmLevel = row.get(GFEDataAccessUtil.PARM_LEVEL).toString();
|
||||
boolean source = true;
|
||||
boolean field = true;
|
||||
boolean plane = true;
|
||||
|
||||
if (gfeSources != null
|
||||
&& !gfeSources.contains(parmId.getDbId().getModelName())) {
|
||||
if (gfeSources != null && !gfeSources.contains(modelName)) {
|
||||
field = false;
|
||||
plane = false;
|
||||
}
|
||||
if (gfeFields != null && !gfeFields.contains(parmId.getParmName())) {
|
||||
if (gfeFields != null && !gfeFields.contains(parmName)) {
|
||||
source = false;
|
||||
plane = false;
|
||||
}
|
||||
if (gfePlanes != null && !gfePlanes.contains(parmId.getParmLevel())) {
|
||||
if (gfePlanes != null && !gfePlanes.contains(parmLevel)) {
|
||||
source = false;
|
||||
field = false;
|
||||
}
|
||||
if (source) {
|
||||
String vbSource = VbGFEMapping.getVbSource(parmId.getDbId()
|
||||
.getModelName());
|
||||
String vbSource = VbGFEMapping.getVbSource(modelName);
|
||||
if (vbSource != null) {
|
||||
request.addAvailableSource(vbSource);
|
||||
}
|
||||
}
|
||||
if (field) {
|
||||
String vbParam = VbGFEMapping.getVbParam(parmId.getParmName());
|
||||
String vbParam = VbGFEMapping.getVbParam(parmName);
|
||||
if (vbParam != null) {
|
||||
request.addAvailableField(vbParam);
|
||||
}
|
||||
}
|
||||
if (plane) {
|
||||
String vbLevel = VbGFEMapping.getVbLevel(parmId.getParmLevel());
|
||||
String vbLevel = VbGFEMapping.getVbLevel(parmLevel);
|
||||
if (vbLevel != null) {
|
||||
request.addAvailablePlane(vbLevel);
|
||||
}
|
||||
|
@ -188,13 +211,24 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
|
|||
@Override
|
||||
public List<String> getSupportedSources() {
|
||||
List<String> results = new ArrayList<String>();
|
||||
for (String parmIdStr : getParmIds()) {
|
||||
ParmID parmId = new ParmID(parmIdStr);
|
||||
String vbSource = VbGFEMapping.getVbSource(parmId.getDbId()
|
||||
.getModelName());
|
||||
if (vbSource != null) {
|
||||
results.add(vbSource);
|
||||
|
||||
DbQueryRequest dbRequest = new DbQueryRequest();
|
||||
dbRequest.setEntityClass(GFERecord.class);
|
||||
dbRequest.setDistinct(true);
|
||||
dbRequest.addRequestField(GFEDataAccessUtil.MODEL_NAME);
|
||||
try {
|
||||
DbQueryResponse dbResponse = (DbQueryResponse) ThriftClient
|
||||
.sendRequest(dbRequest);
|
||||
for (String modelName : dbResponse.getFieldObjects(
|
||||
GFEDataAccessUtil.MODEL_NAME, String.class)) {
|
||||
String vbSource = VbGFEMapping.getVbSource(modelName);
|
||||
if (vbSource != null) {
|
||||
results.add(vbSource);
|
||||
}
|
||||
}
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to load any GFE sources in the Volume Browser", e);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
@ -207,18 +241,8 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
|
|||
@Override
|
||||
protected void addProductParameters(IDataCatalogEntry catalogEntry,
|
||||
HashMap<String, RequestConstraint> productParameters) {
|
||||
productParameters.put(GFEDataAccessUtil.PARM_ID,
|
||||
getParmIdConstraint(catalogEntry.getSelectedData()));
|
||||
}
|
||||
|
||||
private String[] getParmIds() {
|
||||
HashMap<String, RequestConstraint> queryList = new HashMap<String, RequestConstraint>();
|
||||
queryList.put(GFEDataAccessUtil.PLUGIN_NAME, new RequestConstraint("gfe"));
|
||||
try {
|
||||
return CatalogQuery.performQuery(GFEDataAccessUtil.PARM_ID, queryList);
|
||||
} catch (VizException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
productParameters.putAll(getParmIdConstraint(catalogEntry
|
||||
.getSelectedData()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -249,63 +273,61 @@ public class GFEVbDataCatalog extends AbstractDataCatalog {
|
|||
@Override
|
||||
protected String getDisplayUnit(IDataCatalogEntry catalogEntry,
|
||||
DisplayType displayType) {
|
||||
if (catalogEntry instanceof GFECatalogEntry) {
|
||||
ParmID sampleId = ((GFECatalogEntry) catalogEntry).getSampleId();
|
||||
ParamLevelMatchCriteria criteria = GFEGridResource
|
||||
.getMatchCriteria(sampleId);
|
||||
StyleRule sr = null;
|
||||
try {
|
||||
ParmID sampleId = ((GFECatalogEntry) catalogEntry).getSampleId();
|
||||
ParamLevelMatchCriteria criteria = GFEGridResource
|
||||
.getMatchCriteria(sampleId);
|
||||
StyleRule sr = null;
|
||||
try {
|
||||
|
||||
StyleManager.StyleType styleType = StyleManager.StyleType.CONTOUR;
|
||||
StyleManager.StyleType styleType = StyleManager.StyleType.CONTOUR;
|
||||
|
||||
if (displayType.equals(DisplayType.IMAGE)) {
|
||||
styleType = StyleManager.StyleType.IMAGERY;
|
||||
}
|
||||
|
||||
if (displayType.equals(DisplayType.BARB)) {
|
||||
styleType = StyleManager.StyleType.ARROW;
|
||||
}
|
||||
|
||||
sr = StyleManager.getInstance().getStyleRule(styleType,
|
||||
criteria);
|
||||
} catch (VizStyleException e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Unable to obtain a style rule for"
|
||||
+ catalogEntry.getSelectedData()
|
||||
.getUniqueKey(), e);
|
||||
if (displayType.equals(DisplayType.IMAGE)) {
|
||||
styleType = StyleManager.StyleType.IMAGERY;
|
||||
}
|
||||
if (sr != null) {
|
||||
return sr.getPreferences().getDisplayUnitLabel();
|
||||
} else {
|
||||
try {
|
||||
return UnitFormat.getUCUMInstance().format(
|
||||
GFEDataAccessUtil.getGridParmInfo(sampleId).getUnitObject());
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to obtain a unit information for"
|
||||
|
||||
if (displayType.equals(DisplayType.BARB)) {
|
||||
styleType = StyleManager.StyleType.ARROW;
|
||||
}
|
||||
|
||||
sr = StyleManager.getInstance().getStyleRule(styleType,
|
||||
criteria);
|
||||
} catch (VizStyleException e) {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Unable to obtain a style rule for"
|
||||
+ catalogEntry.getSelectedData()
|
||||
.getUniqueKey(), e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sr != null) {
|
||||
return sr.getPreferences().getDisplayUnitLabel();
|
||||
} else {
|
||||
return super.getDisplayUnit(catalogEntry, displayType);
|
||||
try {
|
||||
return UnitFormat.getUCUMInstance().format(
|
||||
GFEDataAccessUtil.getGridParmInfo(sampleId).getUnitObject());
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to obtain a unit information for"
|
||||
+ catalogEntry.getSelectedData()
|
||||
.getUniqueKey(), e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private RequestConstraint getParmIdConstraint(SelectedData selectedData) {
|
||||
private Map<String, RequestConstraint> getParmIdConstraint(SelectedData selectedData) {
|
||||
String parmName = VbGFEMapping.getGfeParam(selectedData.getFieldsKey());
|
||||
String parmLevel = VbGFEMapping
|
||||
.getGfeLevel(selectedData.getPlanesKey());
|
||||
String modelName = VbGFEMapping.getGfeSource(selectedData
|
||||
.getSourcesKey());
|
||||
|
||||
Map<String, String> parmIdComponents = new HashMap<String, String>();
|
||||
parmIdComponents.put(GFEDataAccessUtil.PARM_NAME, parmName);
|
||||
parmIdComponents.put(GFEDataAccessUtil.PARM_LEVEL, parmLevel);
|
||||
parmIdComponents.put(GFEDataAccessUtil.MODEL_NAME, modelName);
|
||||
return GFEDataAccessUtil.createParmIdConstraint(parmIdComponents);
|
||||
Map<String, RequestConstraint> result = new HashMap<String, RequestConstraint>();
|
||||
result.put(GFEDataAccessUtil.PARM_NAME, new RequestConstraint(parmName));
|
||||
result.put(GFEDataAccessUtil.PARM_LEVEL, new RequestConstraint(
|
||||
parmLevel));
|
||||
result.put(GFEDataAccessUtil.MODEL_NAME, new RequestConstraint(
|
||||
modelName));
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class GFECatalogEntry extends DataCatalogEntry {
|
||||
|
|
|
@ -79,6 +79,8 @@ import com.raytheon.uf.viz.productbrowser.xml.ProductBrowserBookmarksXML;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 3, 2010 mnash Initial creation
|
||||
* May 02, 2013 1949 bsteffen Switch Product Browser from uengine to
|
||||
* DbQueryRequest.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -141,7 +143,7 @@ public class ProductBrowserView extends ViewPart {
|
|||
// createBookmarkTreeContextMenu();
|
||||
createProductTree(fullComp);
|
||||
createProductBrowserContextMenu();
|
||||
createSearchBar(fullComp);
|
||||
// createSearchBar(fullComp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,6 @@ package com.raytheon.uf.common.dataplugin.gfe.dataaccess;
|
|||
|
||||
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,8 +30,6 @@ 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.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
|
||||
import com.raytheon.uf.common.serialization.comm.RequestRouter;
|
||||
|
||||
/**
|
||||
|
@ -46,6 +43,9 @@ import com.raytheon.uf.common.serialization.comm.RequestRouter;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 9, 2011 bsteffen Initial creation
|
||||
* May 02, 2013 1949 bsteffen Update GFE data access in Product
|
||||
* Browser, Volume Browser, and Data Access
|
||||
* Framework.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -54,25 +54,21 @@ import com.raytheon.uf.common.serialization.comm.RequestRouter;
|
|||
*/
|
||||
public class GFEDataAccessUtil {
|
||||
|
||||
private static final String PARM_ID_FORMAT = "%s_%s:%s_GRID_%s_%s_%s";
|
||||
public static final String PLUGIN_NAME = "pluginName";
|
||||
|
||||
public static final String PARM_ID = "parmId";
|
||||
|
||||
public static final String DB_ID = "dbId";
|
||||
public static final String DB_ID = PARM_ID + ".dbId";
|
||||
|
||||
public static final String PLUGIN_NAME = "pluginName";
|
||||
public static final String SITE_ID = DB_ID + ".siteId";
|
||||
|
||||
public static final String SITE_ID = "siteId";
|
||||
public static final String MODEL_NAME = DB_ID + ".modelName";
|
||||
|
||||
public static final String DB_TYPE = "dbType";
|
||||
public static final String MODEL_TIME = DB_ID + ".modelTime";
|
||||
|
||||
public static final String MODEL_NAME = "modelName";
|
||||
public static final String PARM_NAME = PARM_ID + ".parmName";
|
||||
|
||||
public static final String MODEL_TIME = "modelTime";
|
||||
|
||||
public static final String PARM_NAME = "parmName";
|
||||
|
||||
public static final String PARM_LEVEL = "parmLevel";
|
||||
public static final String PARM_LEVEL = PARM_ID + ".parmLevel";
|
||||
|
||||
/**
|
||||
* Retrieve the GridParmInfo for a ParmID
|
||||
|
@ -114,50 +110,4 @@ public class GFEDataAccessUtil {
|
|||
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<String, String> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,12 +19,9 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.dataplugin.gfe.dataaccess;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
|
@ -36,7 +33,6 @@ 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.DatabaseID;
|
||||
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;
|
||||
|
@ -66,6 +62,9 @@ import com.raytheon.uf.common.geospatial.MapUtil;
|
|||
* Feb 4, 2013 bsteffen Initial creation
|
||||
* Feb 14, 2013 1614 bsteffen Refactor data access framework to use
|
||||
* single request.
|
||||
* May 02, 2013 1949 bsteffen Update GFE data access in Product
|
||||
* Browser, Volume Browser, and Data Access
|
||||
* Framework.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -76,8 +75,16 @@ import com.raytheon.uf.common.geospatial.MapUtil;
|
|||
public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
||||
IDataFactory {
|
||||
|
||||
private static final String[] VALID_IDENTIFIERS = { GFEDataAccessUtil.MODEL_NAME,
|
||||
GFEDataAccessUtil.MODEL_TIME, GFEDataAccessUtil.SITE_ID };
|
||||
public static final String MODEL_TIME = "modelTime";
|
||||
|
||||
private static final String MODEL_NAME = "modelName";
|
||||
|
||||
private static final String SITE_ID = "siteId";
|
||||
|
||||
// The more full version from GFEDataAccessUtil is prefered but the smaller
|
||||
// keys are needed for backwards compatibility.
|
||||
private static final String[] VALID_IDENTIFIERS = { MODEL_NAME, MODEL_TIME,
|
||||
SITE_ID };
|
||||
|
||||
@Override
|
||||
public String[] getValidIdentifiers() {
|
||||
|
@ -102,11 +109,11 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
|||
defaultGridData.setLocationName(gfeRecord.getDbId().getSiteId());
|
||||
|
||||
Map<String, Object> attrs = new HashMap<String, Object>();
|
||||
attrs.put(GFEDataAccessUtil.MODEL_NAME, gfeRecord.getDbId()
|
||||
attrs.put(MODEL_NAME, gfeRecord.getDbId()
|
||||
.getModelName());
|
||||
attrs.put(GFEDataAccessUtil.MODEL_TIME, gfeRecord.getDbId()
|
||||
attrs.put(MODEL_TIME, gfeRecord.getDbId()
|
||||
.getModelTime());
|
||||
attrs.put(GFEDataAccessUtil.SITE_ID, gfeRecord.getDbId().getSiteId());
|
||||
attrs.put(SITE_ID, gfeRecord.getDbId().getSiteId());
|
||||
|
||||
defaultGridData.setAttributes(attrs);
|
||||
|
||||
|
@ -118,19 +125,31 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
|||
IDataRequest request) {
|
||||
HashMap<String, RequestConstraint> constraints = new HashMap<String, RequestConstraint>();
|
||||
|
||||
Map<String, String> parmIdComponents = new HashMap<String, String>();
|
||||
Map<String, Object> identifiers = request.getIdentifiers();
|
||||
if (identifiers != null) {
|
||||
for (Entry<String, Object> entry : identifiers.entrySet()) {
|
||||
parmIdComponents.put(entry.getKey(), entry.getValue()
|
||||
.toString());
|
||||
if (entry.getKey().equals(MODEL_NAME)) {
|
||||
constraints.put(GFEDataAccessUtil.MODEL_NAME,
|
||||
new RequestConstraint(entry
|
||||
.getValue().toString()));
|
||||
} else if (entry.getKey().equals(SITE_ID)) {
|
||||
constraints.put(GFEDataAccessUtil.SITE_ID,
|
||||
new RequestConstraint(entry.getValue().toString()));
|
||||
} else if (entry.getKey().equals(MODEL_TIME)) {
|
||||
constraints.put(GFEDataAccessUtil.MODEL_TIME,
|
||||
new RequestConstraint(entry.getValue().toString()));
|
||||
} else {
|
||||
constraints.put(entry.getKey(), new RequestConstraint(entry
|
||||
.getValue().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String[] parameters = request.getParameters();
|
||||
if (parameters != null) {
|
||||
if (parameters.length == 1) {
|
||||
parmIdComponents.put(GFEDataAccessUtil.PARM_NAME, parameters[0]);
|
||||
constraints.put(GFEDataAccessUtil.PARM_NAME,
|
||||
new RequestConstraint(parameters[0]));
|
||||
} else if (parameters.length > 1) {
|
||||
RequestConstraint paramNameConstraint = new RequestConstraint(
|
||||
null, ConstraintType.IN);
|
||||
|
@ -142,8 +161,9 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
|||
Level[] levels = request.getLevels();
|
||||
if (levels != null) {
|
||||
if (levels.length == 1) {
|
||||
parmIdComponents.put(GFEDataAccessUtil.PARM_LEVEL, levels[0]
|
||||
.getMasterLevel().getName());
|
||||
constraints.put(GFEDataAccessUtil.PARM_LEVEL,
|
||||
new RequestConstraint(levels[0].getMasterLevel()
|
||||
.getName()));
|
||||
} else if (levels.length > 1) {
|
||||
RequestConstraint paramLevelConstraint = new RequestConstraint(
|
||||
null, ConstraintType.IN);
|
||||
|
@ -158,34 +178,16 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
|||
String[] locationNames = request.getLocationNames();
|
||||
if (locationNames != null) {
|
||||
if (locationNames.length == 1) {
|
||||
parmIdComponents.put(GFEDataAccessUtil.SITE_ID,
|
||||
locationNames[0]);
|
||||
constraints.put(GFEDataAccessUtil.SITE_ID,
|
||||
new RequestConstraint(locationNames[0]));
|
||||
} else if (locationNames.length > 1) {
|
||||
RequestConstraint dbIdConstraint = new RequestConstraint(null,
|
||||
RequestConstraint siteConstraint = new RequestConstraint(null,
|
||||
ConstraintType.IN);
|
||||
HashSet<String> locationNamesSet = new HashSet<String>(
|
||||
Arrays.asList(locationNames));
|
||||
DbQueryRequest dbRequest = new DbQueryRequest();
|
||||
dbRequest.addRequestField(GFEDataAccessUtil.DB_ID);
|
||||
dbRequest.setDistinct(true);
|
||||
DbQueryResponse dbResonse = executeDbQueryRequest(dbRequest,
|
||||
request.toString());
|
||||
for (Map<String, Object> resultMap : dbResonse.getResults()) {
|
||||
DatabaseID dbId = (DatabaseID) resultMap
|
||||
.get(GFEDataAccessUtil.DB_ID);
|
||||
if (locationNamesSet.contains(dbId.getSiteId())) {
|
||||
dbIdConstraint
|
||||
.addToConstraintValueList(dbId.toString());
|
||||
}
|
||||
}
|
||||
constraints.put(GFEDataAccessUtil.DB_ID, dbIdConstraint);
|
||||
|
||||
siteConstraint.setConstraintValueList(locationNames);
|
||||
constraints.put(GFEDataAccessUtil.SITE_ID, siteConstraint);
|
||||
}
|
||||
}
|
||||
|
||||
constraints.put(GFEDataAccessUtil.PARM_ID,
|
||||
GFEDataAccessUtil.createParmIdConstraint(parmIdComponents));
|
||||
|
||||
return constraints;
|
||||
}
|
||||
|
||||
|
@ -231,17 +233,13 @@ public class GFEGridFactory extends AbstractGridDataPluginFactory implements
|
|||
@Override
|
||||
public String[] getAvailableLocationNames(IDataRequest request) {
|
||||
DbQueryRequest dbRequest = buildDbQueryRequest(request);
|
||||
dbRequest.addRequestField(GFEDataAccessUtil.DB_ID);
|
||||
dbRequest.addRequestField(GFEDataAccessUtil.SITE_ID);
|
||||
dbRequest.setDistinct(true);
|
||||
DbQueryResponse dbResonse = executeDbQueryRequest(dbRequest,
|
||||
request.toString());
|
||||
Set<String> locationNames = new HashSet<String>();
|
||||
for (Map<String, Object> resultMap : dbResonse.getResults()) {
|
||||
DatabaseID dbId = (DatabaseID) resultMap
|
||||
.get(GFEDataAccessUtil.DB_ID);
|
||||
locationNames.add(dbId.getSiteId());
|
||||
}
|
||||
return locationNames.toArray(new String[0]);
|
||||
|
||||
return dbResonse.getFieldObjects(GFEDataAccessUtil.SITE_ID,
|
||||
String.class);
|
||||
}
|
||||
|
||||
private GFERecord asGFERecord(Object obj) {
|
||||
|
|
Loading…
Add table
Reference in a new issue