Issue #3669 Ensure best res does not parse alert messages.

Former-commit-id: c573db2918 [formerly e93157375f90c6cc2038db9a78346592e4d46b0e]
Former-commit-id: 95b096192b
This commit is contained in:
Ben Steffensmeier 2014-09-26 10:48:24 -05:00
parent ef4b05effe
commit 3c55b8166c
9 changed files with 83 additions and 95 deletions

View file

@ -26,8 +26,7 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
/**
* To allow spatial information in various plugins based on what is in the
* bundle
* @deprecated do not extend this class, only exists for XML compatibility.
*
* <pre>
*
@ -36,6 +35,7 @@ import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
* ------------- -------- ----------- --------------------------
* Mar 2, 2010 mnash Initial creation
* Oct 23, 2013 2491 bsteffen Remove ISerializableObject
* Sep 26, 2014 3669 bsteffen Deprecate
*
*
* </pre>
@ -43,9 +43,11 @@ import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
* @author mnash
* @version 1.0
*/
@Deprecated
@XmlAccessorType(XmlAccessType.NONE)
public abstract class AbstractSpatialEnabler {
public void enable(PluginDataObject d, AbstractRequestableResourceData arrd) {
/* Nothing calls this method */
}
}

View file

@ -36,10 +36,12 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.RecordFactory;
import com.raytheon.uf.viz.core.alerts.AlertMessage;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.exception.NoDataAvailableException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
@ -52,9 +54,10 @@ import com.raytheon.uf.viz.core.rsc.ResourceList;
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 5, 2010 mnash Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jan 05, 2010 mnash Initial creation
* Sep 26, 2014 3669 bsteffen Fix updates so that no alert parser is used.
*
* </pre>
*
@ -73,6 +76,8 @@ public class BestResResourceData extends AbstractRequestableResourceData
@XmlAttribute
private String productIdentifierKey;
/** @deprecated only exists for xml compatibility. */
@Deprecated
@XmlElement
private AbstractSpatialEnabler enabler = null;
@ -132,6 +137,67 @@ public class BestResResourceData extends AbstractRequestableResourceData
}
}
private AbstractResourceData getRscToUpdate(Map<String, Object> recordMap) {
AbstractVizResource<?, ?> rscToUse = null;
for (AbstractVizResource<?, ?> rsc : rscs) {
if (rsc != null) {
AbstractRequestableResourceData arrd = (AbstractRequestableResourceData) rsc
.getResourceData();
String rscValue = arrd.getMetadataMap()
.get(productIdentifierKey).getConstraintValue();
String updateValue = recordMap.get(productIdentifierKey)
.toString();
if (rscValue != null && rscValue.equals(updateValue)) {
rscToUse = rsc;
break;
}
}
}
// no resource found for update
if (rscToUse == null) {
return null;
}
DataTime updateTime = (DataTime) recordMap
.get(PluginDataObject.DATATIME_ID);
AbstractVizResource<?, ?> curRes = bestResTimes.get(updateTime);
// we already have this time?
if (rscToUse == curRes) {
return null;
}
// new time, rscToUse is best res
if (curRes == null) {
bestResTimes.put(updateTime, rscToUse);
return rscToUse.getResourceData();
} else {
// Check to see if rscToUse is higher res than curRes
int curIdx = rscs.indexOf(curRes);
int rscToUseIdx = rscs.indexOf(rscToUse);
if (curIdx == -1 /* shouldn't happen */
|| rscToUseIdx < curIdx) {
// rscToUse is higher res than curRes
curRes.remove(updateTime);
bestResTimes.put(updateTime, rscToUse);
return rscToUse.getResourceData();
}
}
return null;
}
@Override
protected void update(AlertMessage... messages) {
for (AlertMessage message : messages) {
AbstractResourceData rscData = getRscToUpdate(message.decodedAlert);
if (rscData != null) {
rscData.update(new AlertMessage[] { message });
}
}
}
/*
* (non-Javadoc)
*
@ -151,57 +217,9 @@ public class BestResResourceData extends AbstractRequestableResourceData
} catch (VizException e) {
e.printStackTrace();
}
AbstractVizResource<?, ?> rscToUse = null;
for (AbstractVizResource<?, ?> rsc : rscs) {
if (rsc != null) {
AbstractRequestableResourceData arrd = (AbstractRequestableResourceData) rsc
.getResourceData();
String rscValue = arrd.getMetadataMap()
.get(productIdentifierKey).getConstraintValue();
String updateValue = recordMap
.get(productIdentifierKey).toString();
if (rscValue != null && rscValue.equals(updateValue)) {
rscToUse = rsc;
break;
}
}
}
// no resource found for update
if (rscToUse == null) {
continue;
}
// We know the resource it is for
if (enabler != null) {
enabler.enable(updatePDO[i], this);
}
DataTime updateTime = updatePDO[i].getDataTime();
AbstractVizResource<?, ?> curRes = bestResTimes.get(updateTime);
// we already have this time?
if (rscToUse == curRes) {
continue;
}
// new time, rscToUse is best res
if (curRes == null) {
rscToUse.getResourceData().update(
new PluginDataObject[] { updatePDO[i] });
bestResTimes.put(updateTime, rscToUse);
} else {
// Check to see if rscToUse is higher res than curRes
int curIdx = rscs.indexOf(curRes);
int rscToUseIdx = rscs.indexOf(rscToUse);
if (curIdx == -1 /* shouldn't happen */
|| rscToUseIdx < curIdx) {
// rscToUse is higher res than curRes
curRes.remove(updateTime);
rscToUse.getResourceData().update(
new PluginDataObject[] { updatePDO[i] });
bestResTimes.put(updateTime, rscToUse);
}
AbstractResourceData rscData = getRscToUpdate(recordMap);
if (rscData != null) {
rscData.update(new PluginDataObject[] { updatePDO[i] });
}
}
}
@ -235,6 +253,7 @@ public class BestResResourceData extends AbstractRequestableResourceData
protected AbstractVizResource<?, ?> constructResource(
LoadProperties loadProperties, PluginDataObject[] objects)
throws VizException {
this.enabler = null;
this.retrieveData = true;
return new BestResResource(this, loadProperties);
}

View file

@ -60,7 +60,6 @@
</properties>
<resourceData xsi:type="bestResResourceData"
productIdentifierKey="productCode" retrieveData="false">
<enabler xsi:type="radarSpatialEnabler" />
<metadataMap>
<mapping key="productCode">
<constraint constraintValue="37,35" constraintType="IN" />
@ -130,7 +129,6 @@
<properties isSystemResource="false" isBlinking="false" isMapLayer="false" isHoverOn="false" isVisible="true">
</properties>
<resourceData xsi:type="bestResResourceData" productIdentifierKey="productCode" retrieveData="false">
<enabler xsi:type="radarSpatialEnabler" />
<metadataMap>
<mapping key="productCode">
<constraint constraintValue="38,36" constraintType="IN" />
@ -211,7 +209,6 @@
</properties>
<resourceData xsi:type="bestResResourceData"
productIdentifierKey="productCode" retrieveData="false">
<enabler xsi:type="radarSpatialEnabler" />
<metadataMap>
<mapping key="productCode">
<constraint constraintValue="153,94,19,20"

View file

@ -70,7 +70,6 @@
</properties>
<resourceData xsi:type="bestResResourceData"
productIdentifierKey="productCode" retrieveData="false">
<enabler xsi:type="radarSpatialEnabler" />
<metadataMap>
<mapping key="productCode">
<constraint constraintValue="37,35" constraintType="IN" />
@ -159,7 +158,6 @@
</properties>
<resourceData xsi:type="bestResResourceData"
productIdentifierKey="productCode" retrieveData="false">
<enabler xsi:type="radarSpatialEnabler" />
<metadataMap>
<mapping key="productCode">
<constraint constraintValue="38,36" constraintType="IN" />

View file

@ -59,7 +59,6 @@
<properties isSystemResource="false" isBlinking="false" isMapLayer="false" isHoverOn="false" isVisible="true">
</properties>
<resourceData xsi:type="bestResResourceData" productIdentifierKey="productCode" retrieveData="false">
<enabler xsi:type="radarSpatialEnabler" />
<metadataMap>
<mapping key="productCode">
<constraint constraintValue="37,36,57" constraintType="IN" />

View file

@ -104,7 +104,6 @@
<properties isSystemResource="false" isBlinking="false" isMapLayer="false" isHoverOn="false" isVisible="true">
</properties>
<resourceData xsi:type="bestResResourceData" productIdentifierKey="productCode" retrieveData="false">
<enabler xsi:type="radarSpatialEnabler" />
<metadataMap>
<mapping key="productCode">
<constraint constraintValue="153,94,19,20" constraintType="IN" />

View file

@ -97,7 +97,6 @@
</properties>
<resourceData xsi:type="bestResResourceData"
productIdentifierKey="productCode" retrieveData="false">
<enabler xsi:type="radarSpatialEnabler" />
<metadataMap>
<mapping key="productCode">
<constraint constraintValue="37,35" constraintType="IN" />
@ -167,7 +166,6 @@
<properties isSystemResource="false" isBlinking="false" isMapLayer="false" isHoverOn="false" isVisible="true">
</properties>
<resourceData xsi:type="bestResResourceData" productIdentifierKey="productCode" retrieveData="false">
<enabler xsi:type="radarSpatialEnabler" />
<metadataMap>
<mapping key="productCode">
<constraint constraintValue="38,36" constraintType="IN" />

View file

@ -62,7 +62,6 @@
</properties>
<resourceData xsi:type="bestResResourceData"
productIdentifierKey="productCode" retrieveData="false">
<enabler xsi:type="radarSpatialEnabler" />
<metadataMap>
<mapping key="productCode">
<constraint constraintValue="37,35" constraintType="IN" />
@ -132,7 +131,6 @@
<properties isSystemResource="false" isBlinking="false" isMapLayer="false" isHoverOn="false" isVisible="true">
</properties>
<resourceData xsi:type="bestResResourceData" productIdentifierKey="productCode" retrieveData="false">
<enabler xsi:type="radarSpatialEnabler" />
<metadataMap>
<mapping key="productCode">
<constraint constraintValue="38,36,57" constraintType="IN" />

View file

@ -22,50 +22,28 @@ package com.raytheon.viz.radar;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.viz.core.rsc.AbstractSpatialEnabler;
import com.raytheon.viz.radar.rsc.RadarResourceData;
/**
* TODO Add Description
* @deprecated do not use this class, it only exists for XML compatibility.
*
* <pre>
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 2, 2010 mnash Initial creation
* Sep 26, 2014 3669 bsteffen Deprecate
*
* </pre>
*
* @author mnash
* @version 1.0
*/
@Deprecated
@XmlAccessorType(XmlAccessType.NONE)
public class RadarSpatialEnabler extends AbstractSpatialEnabler {
public final class RadarSpatialEnabler extends AbstractSpatialEnabler {
private final String elevAngle = "primaryElevationAngle";
/* Empty due to deprecation */
public RadarSpatialEnabler() {
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.rsc.AbstractSpatialEnabler#enable(com.raytheon.
* uf.common.dataplugin.PluginDataObject,
* com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData)
*/
@Override
public void enable(PluginDataObject d, AbstractRequestableResourceData arrd) {
if (arrd instanceof RadarResourceData && d instanceof RadarRecord) {
RadarRecord rr = (RadarRecord) d;
RadarResourceData rrd = (RadarResourceData) arrd;
rr.setAddSpatial(!rrd.isLatest());
}
}
}