Issue #1273 product browser re-orders for all applicable data types

Change-Id: I8612578d239119e9df22724ebb0bc100cf7826af

Former-commit-id: 3ec3104feb [formerly 5fa5302739] [formerly 3f2c497286] [formerly 3ec3104feb [formerly 5fa5302739] [formerly 3f2c497286] [formerly 73a0b0da75 [formerly 3f2c497286 [formerly c4e2ff5e1b4f22b1bf712f26dea71ab8d15a75f1]]]]
Former-commit-id: 73a0b0da75
Former-commit-id: d2fe46ce1a [formerly 7687db01f4] [formerly 009331e4c9c0ec761422e6c0b20ed4b8c91a5a2d [formerly 1b2d3d642d]]
Former-commit-id: be148945847e4ab601d6ac04786d8d6f0c3ac2f8 [formerly 2c4164decc]
Former-commit-id: d72df0dc66
This commit is contained in:
Matt Nash 2012-11-29 09:54:50 -06:00
parent aa311c56f2
commit 1c50091222
15 changed files with 106 additions and 66 deletions

View file

@ -75,8 +75,7 @@ public class GFEDataDefinition extends
public GFEDataDefinition() { public GFEDataDefinition() {
productName = "gfe"; productName = "gfe";
displayName = "GFE"; displayName = "GFE";
order = new String[] { GFEUtil.PLUGIN_NAME, SITE_ID, MODEL_NAME, order = new String[] { SITE_ID, MODEL_NAME, PARM_NAME, PARM_LEVEL };
PARM_NAME, PARM_LEVEL };
order = getOrder(); order = getOrder();
loadProperties = new GridLoadProperties(); loadProperties = new GridLoadProperties();
loadProperties.setResourceType(getResourceType()); loadProperties.setResourceType(getResourceType());
@ -116,9 +115,6 @@ public class GFEDataDefinition extends
getProductParameters(new String[0], null)); getProductParameters(new String[0], null));
List<String> result = new ArrayList<String>(); List<String> result = new ArrayList<String>();
for (String orderString : order) { for (String orderString : order) {
if (orderString == order[0]) {
continue;
}
List<ProductBrowserLabel> labels = formatData(orderString, List<ProductBrowserLabel> labels = formatData(orderString,
parameters); parameters);
for (ProductBrowserLabel label : labels) { for (ProductBrowserLabel label : labels) {
@ -202,20 +198,23 @@ public class GFEDataDefinition extends
String parmLevel = "%"; String parmLevel = "%";
HashMap<String, RequestConstraint> queryList = new HashMap<String, RequestConstraint>(); HashMap<String, RequestConstraint> queryList = new HashMap<String, RequestConstraint>();
queryList.put(order[0], new RequestConstraint(productName)); queryList.put(PLUGIN_NAME, new RequestConstraint(productName));
for (int i = 1; i < selection.length; i++) { if (selection.length > 1) {
if (order[i].equals(SITE_ID)) { String[] usedSelection = realignSelection(selection);
siteId = selection[i]; for (int i = 0; i < usedSelection.length; i++) {
} else if (order[i].equals(MODEL_NAME)) { if (order[i].equals(SITE_ID)) {
modelName = selection[i]; siteId = usedSelection[i];
} else if (order[i].equals(MODEL_TIME)) { } else if (order[i].equals(MODEL_NAME)) {
modelTime = selection[i]; modelName = usedSelection[i];
} else if (order[i].equals(DB_TYPE)) { } else if (order[i].equals(MODEL_TIME)) {
dbType = selection[i]; modelTime = usedSelection[i];
} else if (order[i].equals(PARM_NAME)) { } else if (order[i].equals(DB_TYPE)) {
parmName = selection[i]; dbType = usedSelection[i];
} else if (order[i].equals(PARM_LEVEL)) { } else if (order[i].equals(PARM_NAME)) {
parmLevel = selection[i]; parmName = usedSelection[i];
} else if (order[i - 1].equals(PARM_LEVEL)) {
parmLevel = usedSelection[i];
}
} }
} }
String parmId = String.format(GFEUtil.PARM_ID_FORMAT, parmName, String parmId = String.format(GFEUtil.PARM_ID_FORMAT, parmName,

View file

@ -13,7 +13,7 @@
<page <page
class="com.raytheon.uf.viz.productbrowser.DataTypePreferencePage" class="com.raytheon.uf.viz.productbrowser.DataTypePreferencePage"
id="com.raytheon.uf.viz.productbrowser.productbrowserdatapreferencepage" id="com.raytheon.uf.viz.productbrowser.productbrowserdatapreferencepage"
name="CRiMSS" name="CrIMSS"
category="com.raytheon.uf.viz.productbrowser.productbrowserpreferencespage"/> category="com.raytheon.uf.viz.productbrowser.productbrowserpreferencespage"/>
</extension> </extension>

View file

@ -83,7 +83,7 @@ public class CrimssDataDefinition
public CrimssDataDefinition() { public CrimssDataDefinition() {
productName = "crimss"; productName = "crimss";
displayName = "CrIMSS"; displayName = "CrIMSS";
order = new String[] { "pluginName", POINT }; order = new String[] { POINT };
order = getOrder(); order = getOrder();
loadProperties = new LoadProperties(); loadProperties = new LoadProperties();
loadProperties.setResourceType(getResourceType()); loadProperties.setResourceType(getResourceType());

View file

@ -35,4 +35,12 @@
name="com.raytheon.uf.viz.npp.viirs.viirsProductBrowserDefinition"> name="com.raytheon.uf.viz.npp.viirs.viirsProductBrowserDefinition">
</dataDefinition> </dataDefinition>
</extension> </extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
class="com.raytheon.uf.viz.productbrowser.DataTypePreferencePage"
id="com.raytheon.uf.viz.productbrowser.productbrowserdatapreferencepage"
name="VIIRS"
category="com.raytheon.uf.viz.productbrowser.productbrowserpreferencespage"/>
</extension>
</plugin> </plugin>

View file

@ -46,8 +46,7 @@ public class VIIRSProductBrowserDefinition extends
public VIIRSProductBrowserDefinition() { public VIIRSProductBrowserDefinition() {
productName = "viirs"; productName = "viirs";
displayName = "VIIRS"; displayName = "VIIRS";
order = new String[] { "pluginName", "region", "channelType", order = new String[] { "region", "channelType", "wavelength" };
"wavelength" };
order = getOrder(); order = getOrder();
loadProperties = new LoadProperties(); loadProperties = new LoadProperties();
} }

View file

@ -51,7 +51,7 @@ public class PrecipRateDataDefinition extends
public PrecipRateDataDefinition() { public PrecipRateDataDefinition() {
productName = "preciprate"; productName = "preciprate";
displayName = "Precipitation Rate"; displayName = "Precipitation Rate";
order = new String[] { "pluginName", "icao" }; order = new String[] { "icao" };
order = getOrder(); order = getOrder();
loadProperties = new LoadProperties(); loadProperties = new LoadProperties();
loadProperties.setResourceType(getResourceType()); loadProperties.setResourceType(getResourceType());

View file

@ -79,6 +79,9 @@ public abstract class AbstractRequestableProductBrowserDataDefinition<T extends
private static final transient IUFStatusHandler statusHandler = UFStatus private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(AbstractRequestableProductBrowserDataDefinition.class); .getHandler(AbstractRequestableProductBrowserDataDefinition.class);
// for requestable products, pluginName must be part of the request
public String PLUGIN_NAME = "pluginName";
// name of the product for the request constraints // name of the product for the request constraints
public String productName; public String productName;
@ -100,7 +103,7 @@ public abstract class AbstractRequestableProductBrowserDataDefinition<T extends
return null; return null;
} }
List<Object[]> parameters = null; List<Object[]> parameters = null;
if (order.length > 1) { if (order.length >= 1) {
try { try {
DbQuery query = new DbQuery(productName); DbQuery query = new DbQuery(productName);
query.setMaxResults(1); query.setMaxResults(1);
@ -135,10 +138,10 @@ public abstract class AbstractRequestableProductBrowserDataDefinition<T extends
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
List<ProductBrowserLabel> parameters = null; List<ProductBrowserLabel> parameters = null;
boolean product = false; boolean product = false;
String param = order[selection.length]; String param = order[selection.length - 1];
HashMap<String, RequestConstraint> queryList = getProductParameters( HashMap<String, RequestConstraint> queryList = getProductParameters(
selection, order); selection, order);
product = (selection.length + 1) == order.length; product = selection.length == order.length;
String[] temp = queryData(param, queryList); String[] temp = queryData(param, queryList);
if (temp != null) { if (temp != null) {
@ -154,6 +157,7 @@ public abstract class AbstractRequestableProductBrowserDataDefinition<T extends
parameters.get(i).setProduct(product); parameters.get(i).setProduct(product);
} }
} }
System.out.println("Time to query for " System.out.println("Time to query for "
+ selection[selection.length - 1] + ": " + selection[selection.length - 1] + ": "
+ (System.currentTimeMillis() - time) + "ms"); + (System.currentTimeMillis() - time) + "ms");
@ -227,8 +231,8 @@ public abstract class AbstractRequestableProductBrowserDataDefinition<T extends
historyList.add(displayName); historyList.add(displayName);
Map<String, RequestConstraint> queryList = new HashMap<String, RequestConstraint>(); Map<String, RequestConstraint> queryList = new HashMap<String, RequestConstraint>();
RequestConstraint contstraint = new RequestConstraint(productName); RequestConstraint contstraint = new RequestConstraint(productName);
queryList.put(order[0], contstraint); queryList.put(PLUGIN_NAME, contstraint);
for (int i = 1; i < order.length; i++) { for (int i = 0; i < order.length; i++) {
try { try {
String[] items = CatalogQuery.performQuery(order[i], queryList); String[] items = CatalogQuery.performQuery(order[i], queryList);
List<ProductBrowserLabel> labels = formatData(order[i], items); List<ProductBrowserLabel> labels = formatData(order[i], items);
@ -254,13 +258,29 @@ public abstract class AbstractRequestableProductBrowserDataDefinition<T extends
public HashMap<String, RequestConstraint> getProductParameters( public HashMap<String, RequestConstraint> getProductParameters(
String[] selection, String[] order) { String[] selection, String[] order) {
HashMap<String, RequestConstraint> queryList = new HashMap<String, RequestConstraint>(); HashMap<String, RequestConstraint> queryList = new HashMap<String, RequestConstraint>();
queryList.put(order[0], new RequestConstraint(productName)); queryList.put(PLUGIN_NAME, new RequestConstraint(productName));
for (int i = 1; i < selection.length; i++) {
queryList.put(order[i], new RequestConstraint(selection[i])); String[] usedSelection = realignSelection(selection);
for (int i = 0; i < usedSelection.length; i++) {
queryList.put(order[i], new RequestConstraint(usedSelection[i]));
} }
return queryList; return queryList;
} }
/**
* Reorder the selection so that it lines up with the order
*
* @param selection
* @return
*/
protected final String[] realignSelection(String[] selection) {
String[] usedSelection = new String[selection.length - 1];
for (int i = 1; i < selection.length; i++) {
usedSelection[i - 1] = selection[i];
}
return usedSelection;
}
public ResourceType getResourceType() { public ResourceType getResourceType() {
return ResourceType.PLAN_VIEW; return ResourceType.PLAN_VIEW;
} }

View file

@ -574,7 +574,7 @@ public class ProductBrowserView extends ViewPart {
ti.setData(((AbstractRequestableProductBrowserDataDefinition<?>) prod).productName); ti.setData(((AbstractRequestableProductBrowserDataDefinition<?>) prod).productName);
ti.setData( ti.setData(
"product", "product",
((AbstractRequestableProductBrowserDataDefinition<?>) prod).order.length == 1 ? true ((AbstractRequestableProductBrowserDataDefinition<?>) prod).order.length == 0 ? true
: false); : false);
} else { } else {
ti.setData(prod.displayName); ti.setData(prod.displayName);

View file

@ -56,7 +56,7 @@ public class QPFProductBrowserDataDefinition extends
public QPFProductBrowserDataDefinition() { public QPFProductBrowserDataDefinition() {
productName = "qpf"; productName = "qpf";
displayName = "QPF"; displayName = "QPF";
order = new String[] { "pluginName", "icao", "fieldName" }; order = new String[] { "icao", "fieldName" };
order = getOrder(); order = getOrder();
loadProperties = new LoadProperties(); loadProperties = new LoadProperties();
loadProperties.setResourceType(getResourceType()); loadProperties.setResourceType(getResourceType());
@ -76,7 +76,8 @@ public class QPFProductBrowserDataDefinition extends
if ("fieldName".equals(param)) { if ("fieldName".equals(param)) {
for (int i = 0; i < parameters.length; i++) { for (int i = 0; i < parameters.length; i++) {
labels.add(new ProductBrowserLabel(DATA_TYPE.valueOf( labels.add(new ProductBrowserLabel(DATA_TYPE.valueOf(
parameters[i]).getFieldName(), parameters[i])); parameters[i]).getFieldName()
+ " (" + parameters[i] + ")", parameters[i]));
} }
Collections.sort(labels); Collections.sort(labels);
} else { } else {
@ -95,7 +96,6 @@ public class QPFProductBrowserDataDefinition extends
*/ */
@Override @Override
public Map<ResourceType, List<DisplayType>> getDisplayTypes() { public Map<ResourceType, List<DisplayType>> getDisplayTypes() {
// TODO Auto-generated method stub
Map<ResourceType, List<DisplayType>> type = new HashMap<ResourceType, List<DisplayType>>(); Map<ResourceType, List<DisplayType>> type = new HashMap<ResourceType, List<DisplayType>>();
List<DisplayType> types = new ArrayList<DisplayType>(); List<DisplayType> types = new ArrayList<DisplayType>();
types.add(DisplayType.CONTOUR); types.add(DisplayType.CONTOUR);

View file

@ -109,8 +109,8 @@ public class GridProductBrowserDataDefinition extends
public GridProductBrowserDataDefinition() { public GridProductBrowserDataDefinition() {
productName = GridInventory.PLUGIN_NAME; productName = GridInventory.PLUGIN_NAME;
displayName = "Grid"; displayName = "Grid";
order = new String[] { GridInventory.PLUGIN_NAME_QUERY, order = new String[] { GridInventory.MODEL_NAME_QUERY,
GridInventory.MODEL_NAME_QUERY, GridInventory.PARAMETER_QUERY, GridInventory.PARAMETER_QUERY,
GridInventory.MASTER_LEVEL_QUERY, GridInventory.LEVEL_ID_QUERY }; GridInventory.MASTER_LEVEL_QUERY, GridInventory.LEVEL_ID_QUERY };
order = getOrder(); order = getOrder();
loadProperties = new LoadProperties(); loadProperties = new LoadProperties();

View file

@ -63,7 +63,7 @@ public class LightningProductBrowserDataDefinition extends
public LightningProductBrowserDataDefinition() { public LightningProductBrowserDataDefinition() {
productName = "binlightning"; productName = "binlightning";
displayName = "Lightning"; displayName = "Lightning";
order = new String[] { "pluginName", "startTime", "type" }; order = new String[] { "startTime", "type" };
order = getOrder(); order = getOrder();
loadProperties = new LoadProperties(); loadProperties = new LoadProperties();
loadProperties.setResourceType(getResourceType()); loadProperties.setResourceType(getResourceType());
@ -78,17 +78,26 @@ public class LightningProductBrowserDataDefinition extends
*/ */
@Override @Override
public List<ProductBrowserLabel> populateData(String[] selection) { public List<ProductBrowserLabel> populateData(String[] selection) {
if (selection.length == 1) { List<ProductBrowserLabel> labels = null;
if (order[selection.length - 1].equals("startTime")) {
String[] strings = new String[offsets.length]; String[] strings = new String[offsets.length];
for (int i = 0; i < offsets.length; i++) { for (int i = 0; i < offsets.length; i++) {
strings[i] = String.valueOf(offsets[i]); strings[i] = String.valueOf(offsets[i]);
} }
return formatData("pluginName", strings);
} else if (selection.length == 2) { labels = formatData("startTime", strings);
return formatData("startTime", types); } else if (order[selection.length - 1].equals("type")) {
} else { labels = formatData("type", types);
return formatData("type", types);
} }
for (ProductBrowserLabel label : labels) {
if (selection.length == order.length) {
label.setProduct(true);
} else {
label.setProduct(false);
}
}
return labels;
} }
/* /*
@ -101,24 +110,21 @@ public class LightningProductBrowserDataDefinition extends
@Override @Override
public List<ProductBrowserLabel> formatData(String param, public List<ProductBrowserLabel> formatData(String param,
String[] parameters) { String[] parameters) {
if ("pluginName".equals(param)) { if ("startTime".equals(param)) {
List<ProductBrowserLabel> labels = new ArrayList<ProductBrowserLabel>(); List<ProductBrowserLabel> labels = new ArrayList<ProductBrowserLabel>();
for (int i = 0; i < offsets.length; i++) { for (int i = 0; i < offsets.length; i++) {
labels.add(new ProductBrowserLabel((offsets[i] / 60) + " min", labels.add(new ProductBrowserLabel((offsets[i] / 60) + " min",
"" + offsets[i])); "" + offsets[i]));
labels.get(i).setProduct(false);
} }
return labels; return labels;
} else if ("startTime".equals(param)) { } else if ("type".equals(param)) {
List<ProductBrowserLabel> labels = new ArrayList<ProductBrowserLabel>(); List<ProductBrowserLabel> labels = new ArrayList<ProductBrowserLabel>();
for (int i = 0; i < types.length; i++) { for (int i = 0; i < types.length; i++) {
labels.add(new ProductBrowserLabel(types[i], types[i])); labels.add(new ProductBrowserLabel(types[i], types[i]));
labels.get(i).setProduct(true);
} }
return labels; return labels;
} else {
return null;
} }
return null;
} }
/* /*
@ -153,8 +159,17 @@ public class LightningProductBrowserDataDefinition extends
@Override @Override
public void constructResource(String[] selection, ResourceType type) { public void constructResource(String[] selection, ResourceType type) {
String[] sel = new String[] { selection[0] }; String[] sel = new String[] { selection[0] };
negativeOffset = Integer.parseInt(selection[1]); int timeOffset = 0;
lightningType = selection[selection.length - 1]; int posNegOffset = 0;
for (int i = 0; i < order.length; i++) {
if ("startTime".equals(order[i])) {
timeOffset = i;
} else if ("type".equals(order[i])) {
posNegOffset = i;
}
}
negativeOffset = Integer.parseInt(selection[timeOffset + 1]);
lightningType = selection[posNegOffset + 1];
super.constructResource(sel, type); super.constructResource(sel, type);
} }

View file

@ -54,7 +54,7 @@ public class PlotModelDataDefinition extends
public PlotModelDataDefinition() { public PlotModelDataDefinition() {
productName = "plotModels"; productName = "plotModels";
displayName = "Plot Models"; displayName = "Plot Models";
order = new String[] { "pluginName", "type", "svg", "level" }; order = new String[] { "type", "svg", "level" };
loadProperties = new LoadProperties(); loadProperties = new LoadProperties();
} }
@ -89,7 +89,7 @@ public class PlotModelDataDefinition extends
public HashMap<String, RequestConstraint> getProductParameters( public HashMap<String, RequestConstraint> getProductParameters(
String[] selection, String[] order) { String[] selection, String[] order) {
HashMap<String, RequestConstraint> queryList = new HashMap<String, RequestConstraint>(); HashMap<String, RequestConstraint> queryList = new HashMap<String, RequestConstraint>();
queryList.put(order[0], new RequestConstraint(selection[1])); queryList.put(PLUGIN_NAME, new RequestConstraint(selection[1]));
PointDataInventory inv = getInventory(); PointDataInventory inv = getInventory();
if (!inv.getTypeKey(selection[1]) if (!inv.getTypeKey(selection[1])
.equals(PointDataInventory.PLUGIN_NAME)) { .equals(PointDataInventory.PLUGIN_NAME)) {
@ -129,7 +129,7 @@ public class PlotModelDataDefinition extends
String param = null; String param = null;
if (selection.length == 1) { if (selection.length == 1) {
results = inv.getPlugins().toArray(new String[0]); results = inv.getPlugins().toArray(new String[0]);
param = order[0]; param = PLUGIN_NAME;
return formatData(param, results); return formatData(param, results);
} }
String source = selection[1]; String source = selection[1];
@ -151,13 +151,13 @@ public class PlotModelDataDefinition extends
} }
if ((hasType && selection.length == 3) || selection.length == 2) { if ((hasType && selection.length == 3) || selection.length == 2) {
results = getModels(source); results = getModels(source);
param = order[2]; param = order[1];
return formatData(param, results); return formatData(param, results);
} }
if ((hasType && selection.length == 4) || selection.length == 3) { if ((hasType && selection.length == 4) || selection.length == 3) {
results = getLevels(source, selection[selection.length - 1]); results = getLevels(source, selection[selection.length - 1]);
param = order[3]; param = order[2];
return formatData(param, results); return formatData(param, results);
} }
return null; return null;
@ -169,13 +169,13 @@ public class PlotModelDataDefinition extends
Arrays.sort(parameters); Arrays.sort(parameters);
List<ProductBrowserLabel> labels = new ArrayList<ProductBrowserLabel>(); List<ProductBrowserLabel> labels = new ArrayList<ProductBrowserLabel>();
for (int i = 0; i < parameters.length; i++) { for (int i = 0; i < parameters.length; i++) {
if (param == order[2]) { if (param == order[1]) {
labels.add(new ProductBrowserLabel(parameters[i].replace( labels.add(new ProductBrowserLabel(parameters[i].replace(
".svg", ""), parameters[i])); ".svg", ""), parameters[i]));
} else { } else {
labels.add(new ProductBrowserLabel(parameters[i], parameters[i])); labels.add(new ProductBrowserLabel(parameters[i], parameters[i]));
} }
labels.get(i).setProduct(param == order[3]); labels.get(i).setProduct(param == order[2]);
} }
return labels; return labels;
} }

View file

@ -86,8 +86,7 @@ public class RadarProductBrowserDataDefinition extends
} }
productName = "radar"; productName = "radar";
displayName = "Radar"; displayName = "Radar";
order = new String[] { "pluginName", "icao", "productCode", order = new String[] { "icao", "productCode", "primaryElevationAngle" };
"primaryElevationAngle" };
order = getOrder(); order = getOrder();
loadProperties = new LoadProperties(); loadProperties = new LoadProperties();
loadProperties.getCapabilities().addCapability(ImagingCapability.class); loadProperties.getCapabilities().addCapability(ImagingCapability.class);
@ -131,7 +130,8 @@ public class RadarProductBrowserDataDefinition extends
.getResolution() / 1000) + " km "; .getResolution() / 1000) + " km ";
} }
labels.add(new ProductBrowserLabel(infoDict.getInfo(tmp) labels.add(new ProductBrowserLabel(infoDict.getInfo(tmp)
.getName() + "::" + parm, parameters[i])); .getName() + " (" + tmp + ")" + "::" + parm,
parameters[i]));
} }
Collections.sort(labels); Collections.sort(labels);
for (int i = 0; i < parameters.length; i++) { for (int i = 0; i < parameters.length; i++) {

View file

@ -65,7 +65,7 @@ public class RedbookProductBrowserDataDefinition extends
public RedbookProductBrowserDataDefinition() { public RedbookProductBrowserDataDefinition() {
productName = "redbook"; productName = "redbook";
displayName = "Redbook"; displayName = "Redbook";
order = new String[] { "pluginName", "wmoTTAAii" }; order = new String[] { "wmoTTAAii" };
order = getOrder(); order = getOrder();
try { try {
mapping = null; mapping = null;

View file

@ -48,8 +48,7 @@ public class SatelliteProductBrowserDataDefinition extends
public SatelliteProductBrowserDataDefinition() { public SatelliteProductBrowserDataDefinition() {
productName = "satellite"; productName = "satellite";
displayName = "Satellite"; displayName = "Satellite";
order = new String[] { "pluginName", "creatingEntity", "sectorID", order = new String[] { "creatingEntity", "sectorID", "physicalElement" };
"physicalElement" };
order = getOrder(); order = getOrder();
loadProperties = new LoadProperties(); loadProperties = new LoadProperties();
loadProperties.setResourceType(getResourceType()); loadProperties.setResourceType(getResourceType());