Omaha #4121 - Fix bug in caching uncovered when hperadarresult table data were corrected.
Change-Id: I88611082397933676c13c58f65fb29a5745ac263 Former-commit-id:105a862d2e
[formerly8119fe20a0
[formerly705d5b4f2b
] [formerly105a862d2e
[formerly f4d4701fd39202f0610e6c4621f106557648050d]]] Former-commit-id:8119fe20a0
[formerly705d5b4f2b
] Former-commit-id:8119fe20a0
Former-commit-id:b6379af6fb
This commit is contained in:
parent
4b526a8813
commit
610bca03e1
3 changed files with 273 additions and 29 deletions
|
@ -22,8 +22,11 @@ package com.raytheon.uf.viz.hpe.rsc;
|
|||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
@ -32,6 +35,7 @@ import org.eclipse.core.runtime.jobs.Job;
|
|||
import org.eclipse.swt.graphics.RGB;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.plugin.hpe.data.HpeLabelKey;
|
||||
import com.raytheon.uf.common.plugin.hpe.request.HpeLabelDataRequest;
|
||||
import com.raytheon.uf.common.plugin.hpe.request.HpeLabelDataResponse;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
|
@ -66,6 +70,7 @@ import com.raytheon.viz.grid.rsc.general.D2DGridResource;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* May 5, 2014 3026 mpduff Initial creation
|
||||
* Dec 16, 2014 3026 mpduff Change location of text
|
||||
* Feb 13, 2015 4121 mpduff Change label caching.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -80,8 +85,8 @@ public class HpeLabelResource extends
|
|||
private final IUFStatusHandler logger = UFStatus
|
||||
.getHandler(HpeLabelResource.class);
|
||||
|
||||
private final Map<Date, String> hpeTextCache = Collections
|
||||
.synchronizedMap(new HashMap<Date, String>());
|
||||
private final Map<HpeLabelKey, String> hpeTextCache = Collections
|
||||
.synchronizedMap(new HashMap<HpeLabelKey, String>());
|
||||
|
||||
private DrawableString drawableString = null;
|
||||
|
||||
|
@ -98,7 +103,16 @@ public class HpeLabelResource extends
|
|||
public void resourceChanged(ChangeType type, Object object) {
|
||||
if (type == ChangeType.DATA_REMOVE) {
|
||||
if (object instanceof DataTime) {
|
||||
hpeTextCache.remove(((DataTime) object).getRefTime());
|
||||
Set<Entry<HpeLabelKey, String>> entrySet = hpeTextCache
|
||||
.entrySet();
|
||||
Iterator<Entry<HpeLabelKey, String>> iter = entrySet.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Entry<HpeLabelKey, String> entry = iter.next();
|
||||
HpeLabelKey key = entry.getKey();
|
||||
if (key.getDate().equals(((DataTime) object).getRefTime())) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +177,8 @@ public class HpeLabelResource extends
|
|||
}
|
||||
|
||||
private String getText(Date date, String productId) {
|
||||
String text = hpeTextCache.get(date);
|
||||
HpeLabelKey key = new HpeLabelKey(productId, date);
|
||||
String text = hpeTextCache.get(key);
|
||||
if (text == null) {
|
||||
dataJob.scheduleRetrieval(date, productId);
|
||||
}
|
||||
|
@ -214,7 +229,8 @@ public class HpeLabelResource extends
|
|||
.sendRequest(req);
|
||||
Map<Date, String> data = response.getData();
|
||||
for (Date d : data.keySet()) {
|
||||
hpeTextCache.put(d, data.get(d));
|
||||
HpeLabelKey key = new HpeLabelKey(productId, d);
|
||||
hpeTextCache.put(key, data.get(d));
|
||||
}
|
||||
} catch (VizException e) {
|
||||
statusHandler.error(e.getLocalizedMessage(), e);
|
||||
|
|
|
@ -81,6 +81,7 @@ import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager;
|
|||
import com.raytheon.uf.common.monitor.xml.DomainXML;
|
||||
import com.raytheon.uf.common.monitor.xml.ProductXML;
|
||||
import com.raytheon.uf.common.monitor.xml.SourceXML;
|
||||
import com.raytheon.uf.common.plugin.hpe.data.HpeLabelKey;
|
||||
import com.raytheon.uf.common.plugin.hpe.request.HpeLabelDataRequest;
|
||||
import com.raytheon.uf.common.plugin.hpe.request.HpeLabelDataResponse;
|
||||
import com.raytheon.uf.common.status.IPerformanceStatusHandler;
|
||||
|
@ -91,7 +92,6 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.common.time.util.ITimer;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.StringUtil;
|
||||
import com.raytheon.uf.viz.core.DrawableLine;
|
||||
import com.raytheon.uf.viz.core.DrawableString;
|
||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||
|
@ -198,7 +198,8 @@ import com.vividsolutions.jts.geom.Point;
|
|||
* assignments.
|
||||
* Sep 23, 2014 3009 njensen Overrode recycleInternal()
|
||||
* Nov 10, 2014 3026 dhladky HPE BIAS displays.
|
||||
* Dec 16, 2014 3026 mpduff Change location of text
|
||||
* Dec 16, 2014 3026 mpduff Change location of text.
|
||||
* Feb 13, 2015 4121 mpduff Change label caching.
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
|
@ -268,6 +269,9 @@ public class FFMPResource extends
|
|||
/** HPE Constant */
|
||||
private static final String HPE = "HPE";
|
||||
|
||||
/** BiasHPE Constant */
|
||||
private static final String BHPE = "BHPE";
|
||||
|
||||
/** the stream cross hatched area **/
|
||||
private IWireframeShape streamOutlineShape = null;
|
||||
|
||||
|
@ -424,6 +428,8 @@ public class FFMPResource extends
|
|||
|
||||
private DrawableString basinLocatorString = null;
|
||||
|
||||
private DrawableString hpeLabelString = null;
|
||||
|
||||
private RGB basinTraceColor = null;
|
||||
|
||||
private RGB basinBoundaryColor = null;
|
||||
|
@ -440,8 +446,12 @@ public class FFMPResource extends
|
|||
private boolean restoreTable = false;
|
||||
|
||||
/** HPE bias source legend cache */
|
||||
private final Map<Date, String> hpeLegendMap = Collections
|
||||
.synchronizedMap(new HashMap<Date, String>());
|
||||
private final Map<HpeLabelKey, String> hpeLegendMap = Collections
|
||||
.synchronizedMap(new HashMap<HpeLabelKey, String>());
|
||||
|
||||
/** Lookup of Date to product ids displaying for that date */
|
||||
private final Map<Date, List<String>> hpeCacheLookup = Collections
|
||||
.synchronizedMap(new HashMap<Date, List<String>>());
|
||||
|
||||
/** Flag denoting data as HPE */
|
||||
private boolean isHpe;
|
||||
|
@ -538,11 +548,30 @@ public class FFMPResource extends
|
|||
PluginDataObject[] pdos = (PluginDataObject[]) object;
|
||||
for (PluginDataObject pdo : pdos) {
|
||||
FFMPRecord ffmpRec = (FFMPRecord) pdo;
|
||||
hpeLegendMap.remove(ffmpRec.getDataTime().getRefTime());
|
||||
Date date = ffmpRec.getDataTime().getRefTime();
|
||||
removeHpeLabels(date);
|
||||
}
|
||||
} else if (object instanceof DataTime) {
|
||||
DataTime dt = (DataTime) object;
|
||||
hpeLegendMap.remove(dt.getRefTime());
|
||||
removeHpeLabels(dt.getRefTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the labels in the cache for the given time and product.
|
||||
*
|
||||
* @param date
|
||||
* The time to remove
|
||||
* @param productId
|
||||
* The product to remove
|
||||
*/
|
||||
private void removeHpeLabels(Date date) {
|
||||
List<String> products = hpeCacheLookup.remove(date);
|
||||
if (products != null) {
|
||||
for (String product : products) {
|
||||
HpeLabelKey key = new HpeLabelKey(product, date);
|
||||
hpeLegendMap.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1253,12 +1282,19 @@ public class FFMPResource extends
|
|||
basinLocatorString.horizontalAlignment = HorizontalAlignment.CENTER;
|
||||
basinLocatorString.verticallAlignment = VerticalAlignment.MIDDLE;
|
||||
basinLocatorString.addTextStyle(TextStyle.BLANKED);
|
||||
|
||||
hpeLabelString = new DrawableString("", getCapability(
|
||||
ColorableCapability.class).getColor());
|
||||
hpeLabelString.font = font;
|
||||
hpeLabelString.horizontalAlignment = HorizontalAlignment.CENTER;
|
||||
hpeLabelString.verticallAlignment = VerticalAlignment.TOP;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// Set flag for HPE data
|
||||
isHpe = resourceData.siteKey.equalsIgnoreCase(HPE)
|
||||
|| resourceData.siteKey.equalsIgnoreCase("BHPE");
|
||||
isHpe = resourceData.dataKey.equalsIgnoreCase(HPE)
|
||||
|| resourceData.dataKey.equalsIgnoreCase(BHPE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1479,6 +1515,24 @@ public class FFMPResource extends
|
|||
paintUpAndDownStream(aTarget, paintProps);
|
||||
}
|
||||
|
||||
// draw hpe strings if HPE
|
||||
if (isHpe) {
|
||||
// Paint the HPE bias source text if HPE
|
||||
String text = getHpeText(paintTime.getRefTime());
|
||||
|
||||
if (text != null && text.trim().length() > 0) {
|
||||
double[] pixel = paintProps.getView().getDisplayCoords(
|
||||
new double[] { 110, 120 }, aTarget);
|
||||
hpeLabelString
|
||||
.setText(text,
|
||||
getCapability(ColorableCapability.class)
|
||||
.getColor());
|
||||
hpeLabelString.setCoordinates(pixel[0], pixel[1]);
|
||||
aTarget.drawStrings(hpeLabelString);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// always reset
|
||||
isQuery = false;
|
||||
} finally {
|
||||
|
@ -1503,15 +1557,6 @@ public class FFMPResource extends
|
|||
.append(FFMPRecord.getFieldLongDescription(getField()));
|
||||
}
|
||||
|
||||
// Paint the HPE bias source text if HPE
|
||||
if (isHpe && qpeRecord != null) {
|
||||
String text = getText(paintTime.getRefTime());
|
||||
if (text != null) {
|
||||
sb.append(StringUtil.NEWLINE);
|
||||
sb.append(text);
|
||||
}
|
||||
}
|
||||
|
||||
fieldDescString.setText(sb.toString(),
|
||||
getCapability(ColorableCapability.class).getColor());
|
||||
fieldDescString.setCoordinates(pixel[0], pixel[1]);
|
||||
|
@ -4178,14 +4223,44 @@ public class FFMPResource extends
|
|||
* @param date
|
||||
* @return
|
||||
*/
|
||||
private String getText(Date date) {
|
||||
String text = hpeLegendMap.get(date);
|
||||
private String getHpeText(Date date) {
|
||||
List<String> products = hpeCacheLookup.get(date);
|
||||
if (products == null) {
|
||||
products = new ArrayList<String>(0);
|
||||
}
|
||||
HpeLabelKey key = new HpeLabelKey();
|
||||
key.setDate(date);
|
||||
for (String product : products) {
|
||||
key.setProductName(product);
|
||||
}
|
||||
String text = hpeLegendMap.get(key);
|
||||
if (text == null) {
|
||||
FFMPRecord hpeQpeRecord = getQpeRecord();
|
||||
String wfo = null;
|
||||
String siteKey = null;
|
||||
String dataKey = null;
|
||||
String sourceName = null;
|
||||
|
||||
if (qpeRecord != null) {
|
||||
wfo = qpeRecord.getWfo();
|
||||
siteKey = qpeRecord.getSiteKey();
|
||||
dataKey = qpeRecord.getDataKey();
|
||||
sourceName = qpeRecord.getSourceName();
|
||||
} else if (qpfRecord != null) {
|
||||
wfo = qpfRecord.getWfo();
|
||||
siteKey = qpfRecord.getSiteKey();
|
||||
dataKey = qpfRecord.getDataKey();
|
||||
sourceName = qpfRecord.getSourceName();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
String productId = monitor.getProductID(paintTime.getRefTime(),
|
||||
hpeQpeRecord.getWfo(), hpeQpeRecord.getSiteKey(),
|
||||
hpeQpeRecord.getDataKey(), hpeQpeRecord.getSourceName());
|
||||
wfo, siteKey, dataKey, sourceName);
|
||||
dataJob.scheduleRetrieval(date, productId);
|
||||
statusHandler.info("Loading product " + productId);
|
||||
}
|
||||
|
||||
if (text == null) {
|
||||
text = "";
|
||||
}
|
||||
|
||||
return text;
|
||||
|
@ -4237,7 +4312,12 @@ public class FFMPResource extends
|
|||
.sendRequest(req);
|
||||
Map<Date, String> data = response.getData();
|
||||
for (Date d : data.keySet()) {
|
||||
hpeLegendMap.put(d, data.get(d));
|
||||
HpeLabelKey key = new HpeLabelKey(productId, d);
|
||||
hpeLegendMap.put(key, data.get(d));
|
||||
if (!hpeCacheLookup.containsKey(d)) {
|
||||
hpeCacheLookup.put(d, new ArrayList<String>());
|
||||
}
|
||||
hpeCacheLookup.get(d).add(productId);
|
||||
}
|
||||
} catch (VizException e) {
|
||||
statusHandler.error(e.getLocalizedMessage(), e);
|
||||
|
|
|
@ -0,0 +1,148 @@
|
|||
/**
|
||||
* 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.plugin.hpe.data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* An object to act as the HPE/BiasHPE text key
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 11, 2015 4121 mpduff Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
* @version 1.0
|
||||
*/
|
||||
public class HpeLabelKey {
|
||||
/** Product Name */
|
||||
private String productName;
|
||||
|
||||
/** Product date/time */
|
||||
private Date date;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public HpeLabelKey() {
|
||||
|
||||
}
|
||||
|
||||
public HpeLabelKey(String productName, Date date) {
|
||||
this.productName = productName;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the productName
|
||||
*/
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param productName
|
||||
* the productName to set
|
||||
*/
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the date
|
||||
*/
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date
|
||||
* the date to set
|
||||
*/
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((date == null) ? 0 : date.hashCode());
|
||||
result = prime * result
|
||||
+ ((productName == null) ? 0 : productName.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
HpeLabelKey other = (HpeLabelKey) obj;
|
||||
if (date == null) {
|
||||
if (other.date != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!date.equals(other.date)) {
|
||||
return false;
|
||||
}
|
||||
if (productName == null) {
|
||||
if (other.productName != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!productName.equals(other.productName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "HpeLabelKey [productName=" + productName + ", date=" + date
|
||||
+ "]";
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue