Issue #1954 Minor code cleanup throughout FFMP.

Former-commit-id: 64736c6447 [formerly 64736c6447 [formerly fca2bb60f97912f1748f2919df5fc638c1b635e1]]
Former-commit-id: 820b29235b
Former-commit-id: f85e5da204
This commit is contained in:
Ben Steffensmeier 2013-04-26 17:50:22 -05:00
parent cec8443e3f
commit ec9860cbaa
10 changed files with 681 additions and 1110 deletions

View file

@ -4,7 +4,6 @@ import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@ -29,7 +28,6 @@ import com.raytheon.uf.common.dataplugin.ffmp.FFMPAggregateRecord;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasin;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasinData;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPGuidanceBasin;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPGuidanceInterpolation;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord.FIELDS;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPTemplates;
@ -55,7 +53,6 @@ import com.raytheon.uf.common.monitor.xml.SourceXML;
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.common.time.DataTime;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.core.HDF5Util;
import com.raytheon.uf.viz.core.VizApp;
@ -101,6 +98,7 @@ import com.raytheon.uf.viz.monitor.listeners.IMonitorListener;
* Mar 6, 2013 1769 dhladky Changed threading to use count down latch.
* Apr 9, 2013 1890 dhladky Fixed the broken cache file load
* Apr 16, 2013 1912 bsteffen Initial bulk hdf5 access for ffmp
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
*
* </pre>
*
@ -111,21 +109,18 @@ import com.raytheon.uf.viz.monitor.listeners.IMonitorListener;
public class FFMPMonitor extends ResourceMonitor {
private static long SECONDS_PER_HOUR = 60 * 60;
/** boolean for initialization **/
public static boolean isInitialized = false;
/** Singleton instance of this class */
private static FFMPMonitor monitor = null;
/** Array of scan listeners **/
private ArrayList<IFFMPResourceListener> resourceListeners = new ArrayList<IFFMPResourceListener>();
private List<IFFMPResourceListener> resourceListeners = new ArrayList<IFFMPResourceListener>();
public FFMPSplash ffmpSplash;
private FFMPSplash ffmpSplash;
private String wfo = null;
/** Pattern for dates in radar */
public static ThreadLocal<SimpleDateFormat> datePattern = new ThreadLocal<SimpleDateFormat>() {
private static ThreadLocal<SimpleDateFormat> datePattern = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
@ -138,16 +133,11 @@ public class FFMPMonitor extends ResourceMonitor {
private FFMPSiteDataContainer siteDataMap = new FFMPSiteDataContainer();
// Interpolation Guidance Sources
public FFMPGuidanceInterpolation interpolation = null;
/** config manager **/
private FFMPSourceConfigurationManager fscm = null;
/** config manager **/
public FFMPSourceConfigurationManager fscm = null;
/** config manager **/
public FFMPConfig ffmpConfig = null;
public ArrayList<Date> dataTimes = null;
private FFMPConfig ffmpConfig = null;
private FFMPTimeWindow qpfWindow = null;
@ -246,7 +236,6 @@ public class FFMPMonitor extends ResourceMonitor {
public static synchronized FFMPMonitor getInstance() {
if (monitor == null) {
monitor = new FFMPMonitor();
isInitialized = true;
}
return monitor;
@ -274,7 +263,6 @@ public class FFMPMonitor extends ResourceMonitor {
public FFMPSourceConfigurationManager getSourceConfig() {
if (fscm == null) {
fscm = FFMPSourceConfigurationManager.getInstance();
fscm.readConfigXml();
}
return fscm;
@ -329,15 +317,8 @@ public class FFMPMonitor extends ResourceMonitor {
* @return
* @throws VizException
*/
public void populateFFMPRecord(ProductXML product, String siteKey,
String dataKey, String source, Date ptime, String phuc,
boolean retrieveNew) {
boolean isProductLoad = false;
if (product != null) {
isProductLoad = true;
}
public void populateFFMPRecord(String siteKey, String dataKey,
String source, Date ptime, String phuc, boolean retrieveNew) {
if (source != null) {
boolean dupOverride = false;
@ -357,7 +338,7 @@ public class FFMPMonitor extends ResourceMonitor {
|| !getLoadedUris(siteKey, source, phuc)
.contains(uri)) {
try {
populateFFMPRecord(isProductLoad, siteKey,
populateFFMPRecord(siteKey,
new FFMPRecord(uri), source, phuc);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
@ -381,12 +362,11 @@ public class FFMPMonitor extends ResourceMonitor {
* @return
* @throws VizException
*/
public FFMPRecord populateFFMPRecord(boolean isProductLoad, String uri,
String siteKey, String source, String phuc) throws Exception {
public FFMPRecord populateFFMPRecord(String uri, String siteKey,
String source, String phuc) throws Exception {
try {
populateFFMPRecord(isProductLoad, siteKey, new FFMPRecord(uri),
source, phuc);
populateFFMPRecord(siteKey, new FFMPRecord(uri), source, phuc);
} catch (VizException e) {
statusHandler.handle(Priority.INFO,
"FFMP Can't retrieve FFMP URI, " + uri, e);
@ -455,10 +435,10 @@ public class FFMPMonitor extends ResourceMonitor {
* @param phuc
* @throws Exception
*/
public void populateFFMPRecord(boolean isProductLoad, String siteKey,
public void populateFFMPRecord(String siteKey,
FFMPRecord ffmpRec, String source, String phuc) throws Exception {
FFMPLoadRecord flr = new FFMPLoadRecord(isProductLoad, siteKey,
FFMPLoadRecord flr = new FFMPLoadRecord(siteKey,
ffmpRec, source, phuc);
flr.run();
}
@ -481,8 +461,8 @@ public class FFMPMonitor extends ResourceMonitor {
if (!uris.contains(dataUri)) {
try {
SourceXML sourceXML = fscm.getSource(source);
FFMPRecord ffmpRec = populateFFMPRecord(true, dataUri,
siteKey, source, phuc);
FFMPRecord ffmpRec = populateFFMPRecord(dataUri, siteKey,
source, phuc);
File loc = HDF5Util.findHDF5Location(ffmpRec);
IDataStore dataStore = DataStoreFactory.getDataStore(loc);
@ -734,8 +714,6 @@ public class FFMPMonitor extends ResourceMonitor {
FFMPRecord record = siteDataMap.get(siteKey).getSourceData(sourceName)
.getRecord();
String guidSrc = FFMPConfig.getInstance().getFFMPConfigData()
.getGuidSrc();
if ((record != null)
&& (record.getBasinData(phuc).getBasins().size() > 0)) {
@ -754,7 +732,8 @@ public class FFMPMonitor extends ResourceMonitor {
ProductRunXML productRun = getRunConfig().getProduct(
siteKey);
String guidSrc = FFMPConfig.getInstance()
.getFFMPConfigData().getGuidSrc();
for (SourceXML source : productRun.getGuidanceSources(
product, guidSrc)) {
if (siteDataMap.get(siteKey)
@ -762,7 +741,7 @@ public class FFMPMonitor extends ResourceMonitor {
.hasLoadedAnyUris()) {
continue;
} else {
populateFFMPRecord(product, siteKey, dataKey,
populateFFMPRecord(siteKey, dataKey,
source.getSourceName(), ptime, phuc,
retrieveNew);
}
@ -771,8 +750,8 @@ public class FFMPMonitor extends ResourceMonitor {
// FFG is the primary if
if (!siteDataMap.get(siteKey).getSourceData(sourceName)
.hasLoadedAnyUris()) {
populateFFMPRecord(product, siteKey, dataKey,
sourceName, ptime, phuc, retrieveNew);
populateFFMPRecord(siteKey, dataKey, sourceName, ptime,
phuc, retrieveNew);
}
}
@ -780,8 +759,8 @@ public class FFMPMonitor extends ResourceMonitor {
.getRecord();
} else {
populateFFMPRecord(product, siteKey, dataKey, sourceName,
ptime, phuc, retrieveNew);
populateFFMPRecord(siteKey, dataKey, sourceName, ptime, phuc,
retrieveNew);
}
} else { // must populate for a different huc for all possible times
@ -801,20 +780,22 @@ public class FFMPMonitor extends ResourceMonitor {
.getSourceType()
.equals(FFMPSourceConfigurationManager.SOURCE_TYPE.GUIDANCE
.getSourceType())) {
String guidSrc = FFMPConfig.getInstance()
.getFFMPConfigData().getGuidSrc();
for (SourceXML ffgSource : productRun
.getGuidanceSources(product, guidSrc)) {
populateFFMPRecord(product, siteKey, dataKey,
populateFFMPRecord(siteKey, dataKey,
ffgSource.getSourceName(), ptime, phuc,
retrieveNew);
}
} else {
populateFFMPRecord(product, siteKey, dataKey,
populateFFMPRecord(siteKey, dataKey,
sourceName, ptime, phuc, retrieveNew);
}
}
} else {
populateFFMPRecord(product, siteKey, dataKey, sourceName,
populateFFMPRecord(siteKey, dataKey, sourceName,
ptime, phuc, retrieveNew);
}
} else {
@ -828,8 +809,8 @@ public class FFMPMonitor extends ResourceMonitor {
SOURCE_TYPE.GUIDANCE.getSourceType())) {
sourceName = sourcexml.getDisplayName();
} else {
populateFFMPRecord(product, siteKey, dataKey, sourceName,
ptime, phuc, retrieveNew);
populateFFMPRecord(siteKey, dataKey, sourceName, ptime,
phuc, retrieveNew);
}
}
@ -842,21 +823,6 @@ public class FFMPMonitor extends ResourceMonitor {
}
/**
* Sort by DataTime
*
* @author dhladky
*
*/
public class SortByDataTime implements Comparator<DataTime> {
@Override
public int compare(DataTime o1, DataTime o2) {
return o1.compareTo(o2);
}
}
/**
* gets the wfo
*
@ -883,21 +849,13 @@ public class FFMPMonitor extends ResourceMonitor {
*/
public FIELDS getField(String sourceName) {
String sfield = getSourceConfig().getSourceType(sourceName)
.getSourceType().toLowerCase();
FIELDS myField = null;
if (sfield.equals(FFMPRecord.FIELDS.QPE.getFieldName())) {
myField = FFMPRecord.FIELDS.QPE;
} else if (sfield.equals(FFMPRecord.FIELDS.RATE.getFieldName())) {
myField = FFMPRecord.FIELDS.RATE;
} else if (sfield.equals(FFMPRecord.FIELDS.QPF.getFieldName())) {
myField = FFMPRecord.FIELDS.QPF;
} else if (sfield.equals(FFMPRecord.FIELDS.GUIDANCE.getFieldName())) {
myField = FFMPRecord.FIELDS.GUIDANCE;
} else if (sfield.equals("gage")) {
myField = FFMPRecord.FIELDS.VIRTUAL;
String sourceType = getSourceConfig().getSource(sourceName)
.getSourceType();
if (sourceType.equalsIgnoreCase(SOURCE_TYPE.GAGE.name())) {
return FFMPRecord.FIELDS.VIRTUAL;
} else {
return FFMPRecord.FIELDS.valueOf(sourceType);
}
return myField;
}
/**
@ -933,10 +891,7 @@ public class FFMPMonitor extends ResourceMonitor {
}
public void launchSplash(String siteKey) {
final String fsiteKey = siteKey;
public void launchSplash(final String siteKey) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
@ -948,7 +903,7 @@ public class FFMPMonitor extends ResourceMonitor {
ffmpSplash.open();
// latch
int count = 0;
while (!getTemplates(fsiteKey).done) {
while (!getTemplates(siteKey).done) {
try {
count++;
@ -1110,7 +1065,7 @@ public class FFMPMonitor extends ResourceMonitor {
System.gc();
}
public ArrayList<IFFMPResourceListener> getResourceListenerList() {
public List<IFFMPResourceListener> getResourceListenerList() {
return resourceListeners;
}
@ -1327,13 +1282,13 @@ public class FFMPMonitor extends ResourceMonitor {
* @param retrieveNew
* @return
*/
public HashMap<String, FFMPRecord> getGuidanceRecords(ProductXML product,
public Map<String, FFMPRecord> getGuidanceRecords(ProductXML product,
String siteKey, Date date, String phuc, boolean retrieveNew) {
HashMap<String, FFMPRecord> guidRecs = new HashMap<String, FFMPRecord>();
Map<String, FFMPRecord> guidRecs = new HashMap<String, FFMPRecord>();
ProductRunXML productRun = FFMPRunConfigurationManager.getInstance()
.getProduct(siteKey);
ArrayList<String> guidTypes = productRun.getGuidanceTypes(product);
List<String> guidTypes = productRun.getGuidanceTypes(product);
for (String type : guidTypes) {
@ -1520,9 +1475,8 @@ public class FFMPMonitor extends ResourceMonitor {
* @param sourceName
* @return
*/
public long getSourceTimeWindow(String sourceName, String siteKey) {
return getSourceConfig().getSource(sourceName).getExpirationMinutes(
siteKey) * 60 * 1000;
private long getSourceTimeWindow(SourceXML source, String siteKey) {
return source.getExpirationMinutes(siteKey) * 60 * 1000;
}
/**
@ -1531,10 +1485,10 @@ public class FFMPMonitor extends ResourceMonitor {
* @param sourceName
* @return
*/
public FFMPTimeWindow getTimeWindow(String sourceName, Date date,
public FFMPTimeWindow getTimeWindow(SourceXML source, Date date,
String siteKey) {
FFMPTimeWindow window = new FFMPTimeWindow();
long lwindow = getSourceTimeWindow(sourceName, siteKey);
long lwindow = getSourceTimeWindow(source, siteKey);
window.setAfterTime(new Date(date.getTime() - lwindow));
window.setBeforeTime(new Date(date.getTime() + lwindow));
@ -1730,11 +1684,11 @@ public class FFMPMonitor extends ResourceMonitor {
* @param barrierTime
* @param phuc
*/
public void processUri(boolean isProductLoad, String uri, String siteKey,
public void processUri(String uri, String siteKey,
String sourceName, Date barrierTime, String phuc) {
if (uri != null) {
try {
FFMPRecord record = populateFFMPRecord(isProductLoad, uri,
FFMPRecord record = populateFFMPRecord(uri,
siteKey, sourceName, phuc);
if (record != null) {
record.getBasinData(phuc).loadNow();
@ -1759,10 +1713,8 @@ public class FFMPMonitor extends ResourceMonitor {
* @param sourceName
*/
public void processUris(NavigableMap<Date, List<String>> uriMap,
boolean isProductLoad, String siteKey, String sourceName,
Date barrierTime, String phuc) {
FFMPProcessUris processor = new FFMPProcessUris(uriMap, isProductLoad,
String siteKey, String sourceName, Date barrierTime, String phuc) {
FFMPProcessUris processor = new FFMPProcessUris(uriMap,
siteKey, sourceName, barrierTime, phuc);
processor.run();
}
@ -2226,8 +2178,8 @@ public class FFMPMonitor extends ResourceMonitor {
final String fsiteKey;
public FFMPLoadRecord(boolean isProductLoad, String siteKey,
FFMPRecord ffmpRec, String source, String huc) throws Exception {
public FFMPLoadRecord(String siteKey, FFMPRecord ffmpRec,
String source, String huc) throws Exception {
this.fffmpRec = ffmpRec;
this.fsource = source;
this.fsiteKey = siteKey;
@ -2318,7 +2270,6 @@ public class FFMPMonitor extends ResourceMonitor {
final NavigableMap<Date, List<String>> furiMap;
final boolean fisProductLoad;
final String fsiteKey;
@ -2329,13 +2280,10 @@ public class FFMPMonitor extends ResourceMonitor {
final String fhuc;
public FFMPProcessUris(NavigableMap<Date, List<String>> uriMap,
boolean isProductLoad, String siteKey, String sourceName,
Date barrierTime, String phuc) {
String siteKey, String sourceName, Date barrierTime, String phuc) {
this.furiMap = uriMap;
this.fsiteKey = siteKey;
this.fbarrierTime = barrierTime;
this.fisProductLoad = isProductLoad;
this.fsourceName = sourceName;
this.fhuc = phuc;
@ -2363,8 +2311,8 @@ public class FFMPMonitor extends ResourceMonitor {
.after(fbarrierTime)
|| isGuidance) {
try {
record = populateFFMPRecord(fisProductLoad,
uri, fsiteKey, fsourceName, fhuc);
record = populateFFMPRecord(uri, fsiteKey,
fsourceName, fhuc);
if (record != null) {
populatedRecords.add(record);
if (source != null) {

View file

@ -21,7 +21,10 @@ package com.raytheon.uf.viz.monitor.ffmp.ui.dialogs;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXB;
@ -57,6 +60,7 @@ import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPTableColumnXML;
* getting ColorCell and ReverseFilter
* Apr 12, 2013 1902 mpduff Speed up cell coloring.
* Apr 15. 2013 1890 dhladky Added Mikes fix for singleton.
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
*
* </pre>
*
@ -111,14 +115,16 @@ public class FFMPConfig {
private final Color vgbColor = new Color(Display.getDefault(), 196, 137,
250);
private final String defaultConfigXml = "DefaultFFMPconfig_basin.xml";
private static final String DEFAULT_CONFIG_XML = "ffmp"
+ IPathManager.SEPARATOR + "guiConfig" + IPathManager.SEPARATOR
+ "DefaultFFMPconfig_basin.xml";
/**
* Used for looking up data - NOT for editing.
*/
private HashMap<ThreshColNames, ThresholdManager> threshMgrMap;
private Map<ThreshColNames, ThresholdManager> threshMgrMap;
private HashMap<String, ThreshColNames> thresholdLookup;
private Map<String, ThreshColNames> thresholdLookup;
private AttributesDlgData attrData = null;
@ -133,7 +139,8 @@ public class FFMPConfig {
}
private void init() {
threshMgrMap = new HashMap<ThreshColNames, ThresholdManager>();
threshMgrMap = new EnumMap<ThreshColNames, ThresholdManager>(
ThreshColNames.class);
thresholdLookup = new HashMap<String, ThreshColNames>();
@ -141,7 +148,7 @@ public class FFMPConfig {
thresholdLookup.put(threshColName.name(), threshColName);
}
readDefaultFFMPConfigBasin(defaultConfigXml);
readDefaultFFMPConfigBasin();
}
public boolean isThreshold(String colName) {
@ -182,7 +189,7 @@ public class FFMPConfig {
}
public void loadDefaultConfig() {
readDefaultFFMPConfigBasin(defaultConfigXml);
readDefaultFFMPConfigBasin();
}
private void readNewFFMPConfigBasin(LocalizationFile xmlFileName) {
@ -198,19 +205,14 @@ public class FFMPConfig {
}
}
private void readDefaultFFMPConfigBasin(String xmlFileName) {
private void readDefaultFFMPConfigBasin() {
ffmpCfgBasin = null;
String fs = String.valueOf(File.separatorChar);
try {
IPathManager pm = PathManagerFactory.getPathManager();
String path = null;
File file = pm.getStaticFile("ffmp" + fs + "guiConfig" + fs
+ xmlFileName);
if (file != null) {
path = file.getAbsolutePath();
} else {
File file = pm.getStaticFile(DEFAULT_CONFIG_XML);
if (file == null) {
// Should never get here since there is a baseline version of
// the file.
statusHandler.handle(Priority.ERROR,
@ -218,9 +220,9 @@ public class FFMPConfig {
return;
}
System.out.println("Path Config FFMP: " + path);
System.out.println("Path Config FFMP: " + file.getAbsolutePath());
ffmpCfgBasin = JAXB.unmarshal(new File(path),
ffmpCfgBasin = JAXB.unmarshal(file,
FFMPConfigBasinXML.class);
createThresholdManager();
@ -333,15 +335,15 @@ public class FFMPConfig {
private void createThresholdManager() {
threshMgrMap.clear();
ArrayList<FFMPTableColumnXML> tableColData = ffmpCfgBasin
List<FFMPTableColumnXML> tableColData = ffmpCfgBasin
.getTableColumnData();
for (ThreshColNames threshName : ThreshColNames.values()) {
for (FFMPTableColumnXML tcXML : tableColData) {
if (threshName.name().compareTo(tcXML.getColumnName()) == 0) {
ThresholdManager threshMgr = new ThresholdManager(tcXML);
threshMgrMap.put(threshName, threshMgr);
}
for (FFMPTableColumnXML tcXML : tableColData) {
ThreshColNames colNames = thresholdLookup
.get(tcXML.getColumnName());
if (colNames != null) {
ThresholdManager threshMgr = new ThresholdManager(tcXML);
threshMgrMap.put(colNames, threshMgr);
}
}
}

View file

@ -20,6 +20,7 @@
package com.raytheon.uf.viz.monitor.ffmp.ui.rsc;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;
import org.eclipse.swt.graphics.RGB;
@ -50,6 +51,8 @@ import com.raytheon.viz.core.style.image.ImagePreferences;
* ------------ ---------- ----------- --------------------------
* 08/29/09 2152 D. Hladky Initial release
* 05/21/12 DR 14833 G. Zhang Error handling for invalid cmap
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
*
* </pre>
*
* @author dhladky
@ -155,18 +158,15 @@ public class FFMPColorUtils {
* @return
*/
private static RGB convert(Color color) {
int blue;
int green;
int red;
RGB returnColor = null;
if (color != null) {
blue = new Float(color.getBlue() * 255.0).intValue();
green = new Float(color.getGreen() * 255.0).intValue();
red = new Float(color.getRed() * 255.0).intValue();
returnColor = new RGB(red, green, blue);
int blue = (int) (color.getBlue() * 255.0f);
int green = (int) (color.getGreen() * 255.0f);
int red = (int) (color.getRed() * 255.0f);
return new RGB(red, green, blue);
}
return returnColor;
return null;
}
/**
@ -186,37 +186,31 @@ public class FFMPColorUtils {
return rgb;
}
double val2 = (Math.round(valueArg * 100.0)) / 100.0;
Double value = val2;
double value = (Math.round(valueArg * 100.0)) / 100.0;
if (value < 0.005 && field != FIELDS.DIFF) {
ret = 0;
} else if (field == FIELDS.DIFF) {
Color color = colormapparams.getColorByValue(value.floatValue());
if (field == FIELDS.DIFF) {
Color color = colormapparams.getColorByValue((float) value);
rgb = convert(color);
return rgb;
} else {
if (value < 0.0) {
ret = 0;
} else {
Color color = colormapparams
.getColorByValue(value.floatValue());
} else if (value >= 0.005) {
Color color = colormapparams.getColorByValue((float) value);
rgb = convert(color);
return rgb;
}
}
if (ret >= getColorMap().getColors().size()) {
ret = getColorMap().getColors().size() - 1;
List<Color> colors = getColorMap().getColors();
if (ret >= colors.size()) {
ret = colors.size() - 1;
}
if (ret < 0) {
ret = 0;
}
rgb = convert(getColorMap().getColors().get(ret));
rgb = convert(colors.get(ret));
return rgb;
}

View file

@ -20,9 +20,11 @@
package com.raytheon.uf.viz.monitor.ffmp.ui.rsc;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasin;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasinData;
@ -37,7 +39,6 @@ import com.raytheon.uf.common.dataplugin.ffmp.FFMPVirtualGageBasin;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPVirtualGageBasinMetaData;
import com.raytheon.uf.common.monitor.config.FFFGDataMgr;
import com.raytheon.uf.common.monitor.config.FFMPRunConfigurationManager;
import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager;
import com.raytheon.uf.common.monitor.xml.DomainXML;
import com.raytheon.uf.common.monitor.xml.ProductRunXML;
import com.raytheon.uf.common.monitor.xml.ProductXML;
@ -73,6 +74,8 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.dialogs.FfmpTableConfigData;
* Feb 28, 2013 1729 dhladky General enhancements for speed.
* Apr 12, 2013 1902 mpduff Code Cleanup.
* Apr 15, 2013 1890 dhladky Added another constant fix
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
*
* </pre>
*
* @author dhladky
@ -85,83 +88,57 @@ public class FFMPDataGenerator {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(FFMPDataGenerator.class);
private final String ALL = FFMPRecord.ALL;
private static final String ALL = FFMPRecord.ALL;
private final String NA = "NA";
private static final String NA = "NA";
private final String siteKey;
private final String dataKey;
private final ProductXML product;
private final Date paintRefTime;
private final Date tableTime;
private final Object centeredAggregationKey;
private final String huc;
private final List<DomainXML> domains;
private final double sliderTime;
private boolean isWorstCase = false;
FFMPConfig ffmpCfg = FFMPConfig.getInstance();
private FFMPTemplates ft = null;
FFMPTemplates ft = null;
private FFMPResource resource = null;
FFMPResource resource = null;
private FFMPMonitor monitor = null;
FFMPMonitor monitor = null;
private FFMPBasinData qpeBasin = null;
FFMPBasinData qpeBasin = null;
private FFMPBasinData qpfBasin = null;
FFMPBasinData qpfBasin = null;
private FFMPBasinData rateBasin = null;
FFMPBasinData rateBasin = null;
private Map<String, FFMPBasinData> guidBasins = null;
HashMap<String, FFMPBasinData> guidBasins = null;
private FFMPBasinData virtualBasin = null;
FFMPBasinData virtualBasin = null;
private Map<String, FFMPRecord> guidRecords = null;
FFMPRecord rateRecord = null;
private FFMPRecord baseRec = null;
FFMPRecord qpeRecord = null;
private boolean isRate = false;
FFMPRecord qpfRecord = null;
HashMap<String, FFMPRecord> guidRecords = null;
FFMPRecord virtualRecord = null;
FFMPRecord baseRec = null;
SourceXML primarySource = null;
FFFGDataMgr dman = null;
boolean isRate = false;
long expirationTime = 0l;
private long expirationTime = 0l;
private String[] cwaArr = null;
private HashMap<String, FFFGForceUtil> forceUtils = null;
private Map<String, FFFGForceUtil> forceUtils = null;
private FfmpTableConfigData ffmpTableCfgData = null;
public FFMPDataGenerator(FFMPMonitor monitor, FFMPResource resource) {
siteKey = resource.getSiteKey();
dataKey = resource.getDataKey();
product = resource.getProduct();
paintRefTime = resource.getPaintTime().getRefTime();
tableTime = resource.getTableTime();
centeredAggregationKey = resource.centeredAggregationKey;
huc = resource.getHuc();
domains = resource.getDomains();
sliderTime = resource.getTime();
isWorstCase = resource.isWorstCase();
@ -169,10 +146,11 @@ public class FFMPDataGenerator {
this.resource = resource;
this.monitor = monitor;
this.ft = monitor.getTemplates(siteKey);
this.primarySource = resource.getResourceData().getPrimarySourceXML();
SourceXML primarySource = resource.getResourceData()
.getPrimarySourceXML();
this.isRate = primarySource.isRate();
this.expirationTime = primarySource.getExpirationMinutes(resource
.getSiteKey()) * TimeUtil.MILLIS_PER_MINUTE;
this.expirationTime = primarySource.getExpirationMinutes(siteKey)
* TimeUtil.MILLIS_PER_MINUTE;
ffmpTableCfgData = tableConfig.getTableConfigData(siteKey);
}
@ -187,93 +165,53 @@ public class FFMPDataGenerator {
try {
FIELDS field = getBaseField();
if (field != null) {
if (baseRec != null) {
FFMPBasinData fbd = null;
if (centeredAggregationKey != null) {
fbd = baseRec.getBasinData(ALL);
} else {
fbd = baseRec.getBasinData(huc);
}
if (field == null || baseRec == null) {
return tData;
}
FFMPBasinData fbd = null;
if (centeredAggregationKey != null) {
fbd = baseRec.getBasinData(ALL);
} else {
fbd = baseRec.getBasinData(huc);
}
if (!fbd.getBasins().isEmpty()) {
if ((centeredAggregationKey == null) || huc.equals(ALL)) {
// System.out.println(fbd.getBasins().keySet().size()
// + " rows in the table");
for (Long key : fbd.getBasins().keySet()) {
if (huc.equals(ALL)) {
for (DomainXML domain : domains) {
List<DomainXML> domains = resource.getDomains();
if (!fbd.getBasins().isEmpty()) {
if ((centeredAggregationKey == null) || huc.equals(ALL)) {
// System.out.println(fbd.getBasins().keySet().size()
// + " rows in the table");
for (Long key : fbd.getBasins().keySet()) {
if (huc.equals(ALL)) {
FFMPBasinMetaData fmdb = ft.getBasin(siteKey, key);
if (fmdb == null) {
continue;
}
FFMPBasinMetaData fmdb = ft.getBasin(
siteKey, key);
String cwa = domain.getCwa();
for (DomainXML domain : domains) {
String cwa = domain.getCwa();
if (fmdb == null) {
continue;
}
if ((cwa.equals(fmdb.getCwa()))
|| (domain.isPrimary() && fmdb
.isPrimaryCwa())) {
try {
setFFMPRow(fbd.get(key), tData,
false, cwa);
} catch (Exception e) {
statusHandler.handle(
Priority.PROBLEM,
if ((cwa.equals(fmdb.getCwa()))
|| (domain.isPrimary() && fmdb
.isPrimaryCwa())) {
try {
setFFMPRow(fbd.get(key), tData, false,
cwa);
} catch (Exception e) {
statusHandler
.handle(Priority.PROBLEM,
"Couldn't create table row"
+ e);
}
if (virtualBasin != null) {
for (Long id : ft
.getVirtualGageBasinLookupIds(
siteKey,
key,
huc,
resource.basinTableDlg
.getRowName())) {
try {
setFFMPRow(
virtualBasin
.get(id),
tData, true,
domain.getCwa());
} catch (Exception e) {
statusHandler
.handle(Priority.PROBLEM,
"Couldn't create table row"
+ e);
}
}
}
}
}
} else {
/*
* make sure at least one basin in the agg
* is in the CWA
*/
List<Long> pfafs = ft.getAggregatePfafs(
key, siteKey, huc);
boolean isVGB = false;
if (ft.checkVGBsInAggregate(key, siteKey,
huc)) {
isVGB = true;
}
if (!pfafs.isEmpty()) {
FFMPBasinMetaData fmdb = ft
.getBasinInDomains(siteKey,
domains, pfafs);
if (fmdb != null) {
if (virtualBasin != null) {
for (Long id : ft
.getVirtualGageBasinLookupIds(
siteKey, key, huc,
resource.basinTableDlg
.getRowName())) {
try {
setFFMPRow(fbd.get(key), tData,
isVGB, null);
setFFMPRow(
virtualBasin.get(id),
tData, true, cwa);
} catch (Exception e) {
statusHandler.handle(
Priority.PROBLEM,
@ -284,77 +222,99 @@ public class FFMPDataGenerator {
}
}
}
}
// show pfafs in aggregation
else {
for (Long key : resource
.getCenteredAggregatePfafs()) {
FFMPBasinMetaData fmdb = ft.getBasin(siteKey,
key);
} else {
/*
* make sure at least one basin in the agg is in the
* CWA
*/
List<Long> pfafs = ft.getAggregatePfafs(key,
siteKey, huc);
boolean isVGB = false;
if (ft.checkVGBsInAggregate(key, siteKey, huc)) {
isVGB = true;
}
if (!pfafs.isEmpty()) {
FFMPBasinMetaData fmdb = ft.getBasinInDomains(
siteKey, domains, pfafs);
if (fmdb != null) {
for (DomainXML domain : domains) {
try {
setFFMPRow(fbd.get(key), tData, isVGB,
null);
} catch (Exception e) {
statusHandler
.handle(Priority.PROBLEM,
"Couldn't create table row"
+ e);
}
}
}
}
}
}
// show pfafs in aggregation
else {
for (Long key : resource.getCenteredAggregatePfafs()) {
if ((domain.getCwa().equals(fmdb
.getCwa()))
|| (domain.isPrimary() && fmdb
.isPrimaryCwa())) {
FFMPBasinMetaData fmdb = ft.getBasin(siteKey, key);
setFFMPRow(fbd.get(key), tData,
false, null);
if (fmdb != null) {
for (DomainXML domain : domains) {
if (virtualBasin != null) {
for (Long id : ft
.getVirtualGageBasinLookupIds(
siteKey,
key,
huc,
resource.basinTableDlg
.getRowName())) {
try {
setFFMPRow(
virtualBasin
.get(id),
tData, true,
null);
} catch (Exception e) {
statusHandler
.handle(Priority.PROBLEM,
"Couldn't create table row"
+ e);
}
}
if ((domain.getCwa().equals(fmdb.getCwa()))
|| (domain.isPrimary() && fmdb
.isPrimaryCwa())) {
setFFMPRow(fbd.get(key), tData, false, null);
if (virtualBasin != null) {
for (Long id : ft
.getVirtualGageBasinLookupIds(
siteKey, key, huc,
resource.basinTableDlg
.getRowName())) {
try {
setFFMPRow(
virtualBasin.get(id),
tData, true, null);
} catch (Exception e) {
statusHandler.handle(
Priority.PROBLEM,
"Couldn't create table row"
+ e);
}
}
}
}
}
}
tData.sortData();
}
}
tData.sortData();
}
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Failed to load FFMP table data!", e);
}
return tData;
}
private void setFFMPRow(FFMPBasin cBasin, FFMPTableData tData,
boolean isVGB, String domain) {
try {
String pfafToTest = null;
if (cBasin instanceof FFMPVirtualGageBasin) {
if (tData.containsPfaf(((FFMPVirtualGageBasin) cBasin).getLid()
.toString())) {
return;
}
pfafToTest = ((FFMPVirtualGageBasin) cBasin).getLid();
} else {
if (tData.containsPfaf(cBasin.getPfaf().toString())) {
return;
}
pfafToTest = cBasin.getPfaf().toString();
}
if (tData.containsPfaf(pfafToTest)) {
return;
}
} catch (Exception e) {
return;
@ -377,31 +337,28 @@ public class FFMPDataGenerator {
}
if (cBasin instanceof FFMPVirtualGageBasin) {
rowField = FIELDS.VIRTUAL;
String lid = ((FFMPVirtualGageBasin) cBasin).getLid();
FFMPVirtualGageBasin vgBasin = (FFMPVirtualGageBasin) cBasin;
String lid = vgBasin.getLid();
if (lid != null) {
StringBuilder sb = new StringBuilder(lid);
// in this special case it is actually the LID
trd.setPfaf(((FFMPVirtualGageBasin) cBasin).getLid());
trd.setPfaf(lid);
FFMPVirtualGageBasinMetaData fvgmbd = ft
.getVirtualGageBasinMetaData(siteKey,
((FFMPVirtualGageBasin) cBasin).getLid());
.getVirtualGageBasinMetaData(siteKey, lid);
FFMPBasinMetaData metabasin = ft.getBasin(siteKey,
fvgmbd.getParentPfaf());
Long parentBasinPfaf = fvgmbd.getParentPfaf();
if (fvgmbd != null) {
mouseOverText = metabasin.getBasinId() + "\n" + lid + "-"
+ fvgmbd.getName();
mouseOverText = metabasin.getBasinId() + "\n"
+ fvgmbd.getLid() + "-" + fvgmbd.getName();
if (!huc.equals(ALL)) {
sb.append("-").append(fvgmbd.getName());
}
if (!huc.equals(ALL)) {
sb.append("-").append(fvgmbd.getName());
}
trd.setTableCellData(0,
@ -412,29 +369,29 @@ public class FFMPDataGenerator {
|| (centeredAggregationKey != null)) {
if (!cBasin.getValues().isEmpty()) {
rate = ((FFMPVirtualGageBasin) cBasin)
.getValue(paintRefTime);
}
trd.setTableCellData(1, new FFMPTableCellData(FIELDS.RATE,
rate));
if (!cBasin.getValues().isEmpty()) {
rate = vgBasin.getValue(paintRefTime);
if (sliderTime > 0.00) {
qpe = cBasin.getAccumValue(monitor.getQpeWindow()
.getAfterTime(), monitor.getQpeWindow()
.getBeforeTime(), expirationTime, isRate);
FFMPTimeWindow window = monitor.getQpeWindow();
qpe = cBasin.getAccumValue(window.getAfterTime(),
window.getBeforeTime(), expirationTime,
isRate);
} else {
qpe = 0.0f;
}
}
trd.setTableCellData(1, new FFMPTableCellData(FIELDS.RATE,
rate));
trd.setTableCellData(2, new FFMPTableCellData(FIELDS.QPE,
qpe));
if ((qpfBasin != null)
&& (qpfBasin.get(parentBasinPfaf) != null)) {
qpf = qpfBasin.get(parentBasinPfaf).getAverageValue(
monitor.getQpfWindow().getAfterTime(),
monitor.getQpfWindow().getBeforeTime());
if (qpfBasin != null) {
FFMPBasin basin = qpfBasin.get(parentBasinPfaf);
if (basin != null) {
FFMPTimeWindow window = monitor.getQpfWindow();
qpf = basin.getAverageValue(window.getAfterTime(),
window.getBeforeTime());
}
}
trd.setTableCellData(3, new FFMPTableCellData(FIELDS.QPF,
qpf));
@ -442,108 +399,23 @@ public class FFMPDataGenerator {
// run over each guidance type
int i = 0;
for (String guidType : guidBasins.keySet()) {
List<Long> pfafList = new ArrayList<Long>();
List<Long> forcedPfafs = new ArrayList<Long>();
guidance = Float.NaN;
boolean forced = false;
Float diffValue = Float.NaN;
Float ratioValue = Float.NaN;
FFFGForceUtil forceUtil = forceUtils.get(guidType);
forceUtil.setSliderTime(sliderTime);
FFMPBasinData guidBasin = guidBasins.get(guidType);
if ((guidBasin != null)
&& ((FFMPGuidanceBasin) guidBasin
.get(parentBasinPfaf) != null)) {
FFMPGuidanceBasin ffmpGuidBasin = ((FFMPGuidanceBasin) guidBasin
.get(parentBasinPfaf));
// If aggregate, get basins within the aggregate
if (cBasin.getAggregated()) {
if (domain == null) {
pfafList = ft.getAggregatePfafs(
cBasin.getPfaf(), siteKey, huc);
} else if (!domain.equals(NA)) {
if (!huc.equals(ALL)) {
pfafList = ft
.getAggregatePfafsByDomain(
parentBasinPfaf,
siteKey, domain, huc);
}
} else {
pfafList = ft.getAggregatePfafsByDomain(
parentBasinPfaf, siteKey, domain,
huc);
pfafList.add(ft.getAggregatedPfaf(
cBasin.getPfaf(), siteKey, huc));
}
}
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
if (fdm.isForcingConfigured()) {
FFMPBasin parentBasin = baseRec.getBasinData(
ALL).get(parentBasinPfaf);
forceUtil.calculateForcings(domain, ft,
parentBasin);
forcedPfafs = forceUtil.getForcedPfafList();
forced = forceUtil.isForced();
}
if ((!forcedPfafs.isEmpty()) && forced) {
// Recalculate the guidance using the forced
// value(s)
guidance = guidRecords
.get(guidType)
.getBasinData(ALL)
.getAverageGuidanceValue(
pfafList,
resource.getGuidanceInterpolators()
.get(guidType),
guidance,
forcedPfafs,
resource.getGuidSourceExpiration(guidType));
} else if (!forcedPfafs.isEmpty()) {
guidance = guidRecords
.get(guidType)
.getBasinData(ALL)
.getAverageGuidanceValue(
pfafList,
resource.getGuidanceInterpolators()
.get(guidType),
Float.NaN,
forcedPfafs,
resource.getGuidSourceExpiration(guidType));
forced = true;
} else if (!pfafList.isEmpty()) {
guidance = guidRecords
.get(guidType)
.getBasinData(ALL)
.getAverageGuidanceValue(
pfafList,
resource.getGuidanceInterpolators()
.get(guidType),
Float.NaN,
forcedPfafs,
resource.getGuidSourceExpiration(guidType));
} else {
guidance = resource.getGuidanceValue(
ffmpGuidBasin, paintRefTime, guidType);
if (guidance < 0.0f) {
guidance = Float.NaN;
}
}
trd.setTableCellData(i + 4, new FFMPTableCellData(
FIELDS.GUIDANCE, guidance, forced));
FFMPTableCellData guidCellData = getGuidanceCellData(
cBasin, domain, guidType, parentBasinPfaf);
if (guidCellData == null) {
guidCellData = new FFMPTableCellData(
FIELDS.GUIDANCE, Float.NaN);
} else {
trd.setTableCellData(i + 4, new FFMPTableCellData(
FIELDS.GUIDANCE, Float.NaN));
guidance = guidCellData.getValueAsFloat();
}
trd.setTableCellData(i + 4, guidCellData);
float ratioValue = Float.NaN;
float diffValue = Float.NaN;
// If guidance is NaN then it cannot be > 0
if (!qpe.isNaN() && (guidance > 0.0f)) {
ratioValue = FFMPUtils.getRatioValue(qpe, guidance);
@ -567,162 +439,72 @@ public class FFMPDataGenerator {
displayName = getDisplayName(cBasin);
if (displayName != null) {
String cbasinPfaf = cBasin.getPfaf().toString();
StringBuilder sb = new StringBuilder(cbasinPfaf);
long cBasinPfaf = cBasin.getPfaf();
String cBasinPfafStr = Long.toString(cBasinPfaf);
StringBuilder sb = new StringBuilder(cBasinPfafStr);
sb.append("\n").append(displayName);
trd.setPfaf(cbasinPfaf);
trd.setPfaf(cBasinPfafStr);
trd.setTableCellData(0, new FFMPTableCellData(rowField,
displayName, sb.toString()));
if (!isWorstCase || huc.equals(ALL)
|| (centeredAggregationKey != null)) {
if ((rateBasin != null)
&& (rateBasin.get(cBasin.getPfaf()) != null)) {
rate = rateBasin.get(cBasin.getPfaf()).getValue(
paintRefTime);
if (rateBasin != null) {
FFMPBasin basin = rateBasin.get(cBasinPfaf);
if (basin != null) {
rate = basin.getValue(paintRefTime);
}
}
trd.setTableCellData(1, new FFMPTableCellData(FIELDS.RATE,
rate));
if ((qpeBasin != null)
&& (qpeBasin.get(cBasin.getPfaf()) != null)) {
qpe = qpeBasin.get(cBasin.getPfaf()).getAccumValue(
monitor.getQpeWindow().getAfterTime(),
monitor.getQpeWindow().getBeforeTime(),
expirationTime, isRate);
if (qpeBasin != null) {
FFMPBasin basin = qpeBasin.get(cBasinPfaf);
if (basin != null) {
FFMPTimeWindow window = monitor.getQpeWindow();
qpe = basin.getAccumValue(window.getAfterTime(),
window.getBeforeTime(), expirationTime,
isRate);
}
}
trd.setTableCellData(2, new FFMPTableCellData(FIELDS.QPE,
qpe));
if ((qpfBasin != null)
&& (qpfBasin.get(cBasin.getPfaf()) != null)) {
if (qpfBasin != null) {
FFMPBasin basin = qpfBasin.get(cBasinPfaf);
if (basin != null) {
FFMPTimeWindow window = monitor.getQpfWindow();
qpf = basin.getAverageValue(window.getAfterTime(),
window.getBeforeTime());
}
qpf = qpfBasin.get(cBasin.getPfaf()).getAverageValue(
monitor.getQpfWindow().getAfterTime(),
monitor.getQpfWindow().getBeforeTime());
// qpf = getQPFValue(false, cBasin.getPfaf(),
// new ArrayList<Long>());/* DR13839 */
}
trd.setTableCellData(3, new FFMPTableCellData(FIELDS.QPF,
qpf));
// run over each guidance type
int i = 0;
Float ratioValue;
Float diffValue;
for (String guidType : guidBasins.keySet()) {
List<Long> pfafList = new ArrayList<Long>();
List<Long> forcedPfafs = new ArrayList<Long>();
guidance = Float.NaN;
boolean forced = false;
ratioValue = Float.NaN;
diffValue = Float.NaN;
FFFGForceUtil forceUtil = forceUtils.get(guidType);
forceUtil.setSliderTime(sliderTime);
FFMPBasinData guidBasin = guidBasins.get(guidType);
if ((guidBasin != null)
&& ((FFMPGuidanceBasin) guidBasin.get(cBasin
.getPfaf()) != null)) {
FFMPGuidanceBasin ffmpGuidBasin = ((FFMPGuidanceBasin) guidBasin
.get(cBasin.getPfaf()));
// If aggregate, get basins within the aggregate
if (cBasin.getAggregated()) {
if (domain == null) {
pfafList = ft.getAggregatePfafs(
cBasin.getPfaf(), siteKey, huc);
} else if (!domain.equals(NA)) {
if (!huc.equals(ALL)) {
pfafList = ft
.getAggregatePfafsByDomain(
cBasin.getPfaf(),
siteKey, domain, huc);
}
} else {
pfafList = ft.getAggregatePfafsByDomain(
cBasin.getPfaf(), siteKey, domain,
huc);
pfafList.add(ft.getAggregatedPfaf(
cBasin.getPfaf(), siteKey, huc));
}
}
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
if (fdm.isForcingConfigured()) {
forceUtil.calculateForcings(domain, ft, cBasin);
forcedPfafs = forceUtil.getForcedPfafList();
forced = forceUtil.isForced();
}
if ((!forcedPfafs.isEmpty()) && forced) {
// Recalculate the guidance using the forced
// value(s)
guidance = guidRecords
.get(guidType)
.getBasinData(ALL)
.getAverageGuidanceValue(
pfafList,
resource.getGuidanceInterpolators()
.get(guidType),
guidance,
forcedPfafs,
resource.getGuidSourceExpiration(guidType));
} else if (!forcedPfafs.isEmpty()) {
guidance = guidRecords
.get(guidType)
.getBasinData(ALL)
.getAverageGuidanceValue(
pfafList,
resource.getGuidanceInterpolators()
.get(guidType),
Float.NaN,
forcedPfafs,
resource.getGuidSourceExpiration(guidType));
forced = true;
} else if (!pfafList.isEmpty()) {
guidance = guidRecords
.get(guidType)
.getBasinData(ALL)
.getAverageGuidanceValue(
pfafList,
resource.getGuidanceInterpolators()
.get(guidType),
Float.NaN,
forcedPfafs,
resource.getGuidSourceExpiration(guidType));
if (!forcedPfafs.isEmpty()) {
forced = true;
}
} else {
guidance = resource.getGuidanceValue(
ffmpGuidBasin, monitor.getQpeWindow()
.getBeforeTime(), guidType);
if (guidance < 0.0f) {
guidance = Float.NaN;
}
}
trd.setTableCellData(i + 4, new FFMPTableCellData(
FIELDS.GUIDANCE, guidance, forced));
} else {
FFMPTableCellData guidCellData = getGuidanceCellData(
cBasin, domain, guidType, cBasinPfaf);
if (guidCellData == null) {
// check for forcing even if no data are available
guidance = getForcedAvg(forceUtil, domain, cBasin,
guidType);
if (!guidance.isNaN()) {
forced = true;
} else {
forced = false;
}
trd.setTableCellData(i + 4, new FFMPTableCellData(
FIELDS.GUIDANCE, guidance, forced));
boolean forced = !guidance.isNaN();
guidCellData = new FFMPTableCellData(
FIELDS.GUIDANCE, guidance, forced);
} else {
guidance = guidCellData.getValueAsFloat();
}
trd.setTableCellData(i + 4, guidCellData);
float ratioValue = Float.NaN;
float diffValue = Float.NaN;
// If guidance is NaN then it cannot be > 0
if (!qpe.isNaN() && (guidance > 0.0f)) {
ratioValue = FFMPUtils.getRatioValue(qpe, guidance);
@ -744,6 +526,71 @@ public class FFMPDataGenerator {
}
}
private FFMPTableCellData getGuidanceCellData(FFMPBasin cBasin,
String domain, String guidType, Long parentBasinPfaf) {
long cBasinPfaf = cBasin.getPfaf();
FFMPBasinData guidBasin = guidBasins.get(guidType);
FFMPGuidanceBasin ffmpGuidBasin = null;
if (guidBasin != null) {
ffmpGuidBasin = (FFMPGuidanceBasin) guidBasin.get(cBasinPfaf);
}
if (ffmpGuidBasin == null) {
return null;
}
List<Long> pfafList = Collections.emptyList();
List<Long> forcedPfafs = Collections.emptyList();
boolean forced = false;
Float guidance = Float.NaN;
FFFGForceUtil forceUtil = forceUtils.get(guidType);
// If aggregate, get basins within the aggregate
if (cBasin.getAggregated()) {
if (domain == null) {
pfafList = ft.getAggregatePfafs(cBasinPfaf, siteKey, huc);
} else if (!domain.equals(NA)) {
if (!huc.equals(ALL)) {
pfafList = ft.getAggregatePfafsByDomain(parentBasinPfaf,
siteKey, domain, huc);
}
} else {
pfafList = ft.getAggregatePfafsByDomain(parentBasinPfaf,
siteKey, domain, huc);
pfafList.add(ft.getAggregatedPfaf(cBasinPfaf, siteKey, huc));
}
}
if (FFFGDataMgr.getInstance().isForcingConfigured()) {
FFMPBasin parentBasin = cBasin;
if (cBasinPfaf != parentBasinPfaf.longValue()) {
parentBasin = baseRec.getBasinData(ALL).get(parentBasinPfaf);
}
forceUtil.calculateForcings(domain, ft, parentBasin);
forcedPfafs = forceUtil.getForcedPfafList();
forced = forceUtil.isForced();
}
if (!forcedPfafs.isEmpty() || !pfafList.isEmpty() && centeredAggregationKey == null) {
FFMPBasinData basinData = guidRecords.get(guidType).getBasinData(
ALL);
guidance = basinData.getAverageGuidanceValue(pfafList, resource
.getGuidanceInterpolators().get(guidType), guidance,
forcedPfafs, resource.getGuidSourceExpiration(guidType));
forced = !forcedPfafs.isEmpty();
} else {
guidance = resource.getGuidanceValue(ffmpGuidBasin, paintRefTime,
guidType);
if (guidance < 0.0f) {
guidance = Float.NaN;
}
}
return new FFMPTableCellData(FIELDS.GUIDANCE, guidance, forced);
}
private float getForcedAvg(FFFGForceUtil forceUtil, String domain,
FFMPBasin cBasin, String guidType) {
FFFGDataMgr fdm = FFFGDataMgr.getInstance();
@ -1127,17 +974,19 @@ public class FFMPDataGenerator {
*/
private FIELDS getBaseField() {
String dataKey = resource.getDataKey();
ProductXML product = resource.getProduct();
Date tableTime = resource.getTableTime();
FIELDS field = null;
String localHuc = null;
dman = FFFGDataMgr.getInstance();
FfmpTableConfigData ffmpTableCfgData = FfmpTableConfig.getInstance()
.getTableConfigData(siteKey);
String qpfType = ffmpTableCfgData.getQpfType();
ProductRunXML productRun = FFMPRunConfigurationManager.getInstance()
.getProduct(siteKey);
String qpfSource = productRun.getQpfSources(product, qpfType).get(0)
.getSourceName();
SourceXML qpfSource = productRun.getQpfSources(product, qpfType).get(0);
FFMPConfig config = FFMPConfig.getInstance();
String includedCWAs = config.getFFMPConfigData().getIncludedCWAs();
@ -1148,41 +997,33 @@ public class FFMPDataGenerator {
if (resource.isSplit()) {
// hack off the QPF duration for the table values of QPE (Split
// Window)
double duration = FFMPSourceConfigurationManager.getInstance()
.getSource(qpfSource).getDurationHour();
double duration = qpfSource.getDurationHour();
qpeTime = new Date(
(long) (qpeTime.getTime() - (duration * TimeUtil.MILLIS_PER_HOUR)));
}
monitor.setQpeWindow(new FFMPTimeWindow(tableTime, qpeTime));
if (isWorstCase || (centeredAggregationKey != null)) {
// make sure that "ALL" is loaded
localHuc = ALL;
rateRecord = monitor.getRateRecord(product, siteKey, dataKey,
product.getRate(), paintRefTime, localHuc, true);
qpeRecord = monitor.getQPERecord(product, siteKey, dataKey,
product.getQpe(), tableTime, localHuc, true);
qpfRecord = monitor.getQPFRecord(product, siteKey, dataKey, null,
paintRefTime, localHuc, true);
guidRecords = monitor.getGuidanceRecords(product, siteKey,
tableTime, localHuc, true);
} else {
localHuc = huc;
}
FFMPRecord rateRecord = monitor.getRateRecord(product, siteKey,
dataKey, product.getRate(), paintRefTime, localHuc, true);
FFMPRecord qpeRecord = monitor.getQPERecord(product, siteKey, dataKey,
product.getQpe(), tableTime, localHuc, true);
FFMPRecord qpfRecord = monitor.getQPFRecord(product, siteKey, dataKey,
null, paintRefTime, localHuc, true);
guidRecords = monitor.getGuidanceRecords(product, siteKey, tableTime,
localHuc, true);
FFMPRecord virtualRecord = null;
if (localHuc.equals(ALL)) {
virtualRecord = monitor.getVirtualRecord(product, siteKey, dataKey,
product.getVirtual(), tableTime, localHuc, true);
} else {
rateRecord = monitor.getRateRecord(product, siteKey, dataKey,
product.getRate(), paintRefTime, huc, true);
qpeRecord = monitor.getQPERecord(product, siteKey, dataKey,
product.getQpe(), tableTime, huc, true);
qpfRecord = monitor.getQPFRecord(product, siteKey, dataKey, null,
paintRefTime, huc, true);
guidRecords = monitor.getGuidanceRecords(product, siteKey,
tableTime, huc, true);
if (huc.equals(ALL)) {
virtualRecord = monitor.getVirtualRecord(product, siteKey,
dataKey, product.getVirtual(), tableTime, huc, true);
}
localHuc = huc;
}
try {

View file

@ -71,6 +71,7 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.listeners.FFMPLoaderEvent;
* Mar 6, 2013 1769 dhladky Changed threading to use count down latch.
* Apr 9, 2013 1890 dhladky removed loading of phantom Virtual template and cache file processing.
* Apr 18, 2013 1912 bsteffen Increase bulk requests to pypies.
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
*
* </pre>
*
@ -96,7 +97,7 @@ public class FFMPDataLoader extends Thread {
private String dataKey = null;
private ArrayList<String> hucsToLoad = null;
private List<String> hucsToLoad = null;
private String wfo = null;
@ -109,8 +110,7 @@ public class FFMPDataLoader extends Thread {
private CountDownLatch latch;
public FFMPDataLoader(FFMPResourceData resourceData, Date timeBack,
Date mostRecentTime, LOADER_TYPE loadType,
ArrayList<String> hucsToLoad) {
Date mostRecentTime, LOADER_TYPE loadType, List<String> hucsToLoad) {
this.product = resourceData.getProduct();
this.siteKey = resourceData.siteKey;
@ -172,9 +172,8 @@ public class FFMPDataLoader extends Thread {
.getSourceConfig();
ProductRunXML productRun = runner.getProduct(siteKey);
ArrayList<SourceXML> qpfSources = new ArrayList<SourceXML>();
List<SourceXML> qpfSources = new ArrayList<SourceXML>();
String layer = config.getFFMPConfigData().getLayer();
boolean isProductLoad = true;
String rateURI = null;
if (loadType != LOADER_TYPE.GENERAL) {
@ -278,8 +277,8 @@ public class FFMPDataLoader extends Thread {
fireLoaderEvent(loadType, "Processing " + product.getRate(),
isDone());
for (String phuc : hucsToLoad) {
monitor.processUri(isProductLoad, rateURI, siteKey,
product.getRate(), timeBack, phuc);
monitor.processUri(rateURI, siteKey, product.getRate(),
timeBack, phuc);
}
fireLoaderEvent(loadType, product.getRate(), isDone());
}
@ -305,8 +304,8 @@ public class FFMPDataLoader extends Thread {
if (!qpeURIs.isEmpty()) {
for (String phuc : hucsToLoad) {
if (phuc.equals(layer) || phuc.equals(FFMPRecord.ALL)) {
monitor.processUris(qpeURIs, isProductLoad, siteKey,
product.getQpe(), timeBack, phuc);
monitor.processUris(qpeURIs, siteKey, product.getQpe(),
timeBack, phuc);
}
}
}
@ -338,8 +337,8 @@ public class FFMPDataLoader extends Thread {
if (!qpfURIs.isEmpty()) {
for (String phuc : hucsToLoad) {
if (phuc.equals(layer) || phuc.equals(FFMPRecord.ALL)) { // old
monitor.processUris(qpfURIs, isProductLoad,
siteKey, product.getQpf(i), timeBack, phuc);
monitor.processUris(qpfURIs, siteKey,
product.getQpf(i), timeBack, phuc);
}
}
}
@ -353,8 +352,8 @@ public class FFMPDataLoader extends Thread {
isDone());
// process virtual all for all only, never uses cache files
if (!virtualURIs.isEmpty()) {
monitor.processUris(virtualURIs, isProductLoad, siteKey,
product.getVirtual(), timeBack, FFMPRecord.ALL);
monitor.processUris(virtualURIs, siteKey, product.getVirtual(),
timeBack, FFMPRecord.ALL);
}
fireLoaderEvent(loadType, product.getVirtual(), isDone());
@ -373,7 +372,7 @@ public class FFMPDataLoader extends Thread {
"Processing " + guidSource.getSourceName(),
isDone());
monitor.processUris(iguidURIs, isProductLoad, siteKey,
monitor.processUris(iguidURIs, siteKey,
guidSource.getSourceName(), timeBack,
FFMPRecord.ALL);

View file

@ -41,6 +41,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@ -82,6 +83,7 @@ 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.viz.core.DrawableLine;
import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.IGraphicsTarget;
@ -164,6 +166,7 @@ import com.vividsolutions.jts.geom.Point;
* time matcher.
* Apr 25, 2013 1954 bsteffen Skip extent checking for FFMP shape
* generation.
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
*
* </pre>
*
@ -348,9 +351,6 @@ public class FFMPResource extends
// complete reset
public boolean isQuery = true;
/** the last extent **/
private PixelExtent lastExtent;
/**
* FFMP basin table dialog.
*/
@ -458,14 +458,15 @@ public class FFMPResource extends
} else {
previousMostRecentTime = tok.get(0);
}
updateTimeOrderedkeys(ffmpRec.getDataTime().getRefTime());
Date refTime = ffmpRec.getDataTime().getRefTime();
updateTimeOrderedkeys(refTime);
if (getResourceData().tableLoad) {
setTableTime();
}
setRecord(ffmpRec);
resourceData.populateRecord(ffmpRec);
statusHandler.handle(Priority.INFO, "Updating : Previous: "
+ previousMostRecentTime + " New: "
@ -474,8 +475,7 @@ public class FFMPResource extends
if (getResourceData().tableLoad) {
if (loader == null) {
startLoader(previousMostRecentTime, ffmpRec
.getDataTime().getRefTime(),
startLoader(previousMostRecentTime, refTime,
LOADER_TYPE.GENERAL);
} else {
try {
@ -485,8 +485,7 @@ public class FFMPResource extends
e.getLocalizedMessage(), e);
}
startLoader(previousMostRecentTime, ffmpRec
.getDataTime().getRefTime(),
startLoader(previousMostRecentTime, refTime,
LOADER_TYPE.GENERAL);
try {
loader.waitFor();
@ -496,7 +495,7 @@ public class FFMPResource extends
}
}
purge(ffmpRec.getDataTime().getRefTime());
purge(refTime);
}
resetRecords();
@ -1062,16 +1061,6 @@ public class FFMPResource extends
return null;
}
/**
* Set the Record straight.
*
* @throws VizException
*
*/
protected void setRecord(FFMPRecord ffmpRecord) throws VizException {
getResourceData().populateRecord(getProduct(), ffmpRecord, getHuc());
}
@Override
protected void disposeInternal() {
IDisplayPaneContainer container = getResourceContainer();
@ -1152,7 +1141,7 @@ public class FFMPResource extends
}
// DR 14522: use Display.getDefault().asyncExec() for GUI thread.
org.eclipse.swt.widgets.Display.getDefault().asyncExec(new Runnable() {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
@ -1208,237 +1197,208 @@ public class FFMPResource extends
@Override
protected void paintInternal(IGraphicsTarget aTarget,
PaintProperties paintProps) throws VizException {
if (getTimeOrderedKeys() == null || getTimeOrderedKeys().isEmpty()
|| getDomains() == null) {
return;
}
// clear the screen
aTarget.clearClippingPlane();
if ((getTimeOrderedKeys() != null) && (getTimeOrderedKeys().size() > 0)
&& (getDomains() != null)) {
paintTime = paintProps.getDataTime();
paintProps.setAlpha(getCapability(ImagingCapability.class).getAlpha());
paintTime = paintProps.getDataTime();
paintProps.setAlpha(getCapability(ImagingCapability.class)
.getAlpha());
FFMPDrawable drawable = null;
boolean isShaded = true;
FFMPDrawable drawable = null;
if (paintTime != null) {
if (loader != null && !loader.isDone()
&& loader.loadType == LOADER_TYPE.GENERAL) {
return;
}
if (!drawables.containsKey(paintTime)) {
if (paintTime != null) {
if (loader != null && !loader.isDone()
&& loader.loadType == LOADER_TYPE.GENERAL) {
return;
}
if (!drawables.containsKey(paintTime)) {
drawable = new FFMPDrawable(getDomains());
drawables.put(paintTime, drawable);
} else {
// we found it!
drawable = drawables.get(paintTime);
// System.out.println("Found the drawable");
drawable = new FFMPDrawable(getDomains());
drawables.put(paintTime, drawable);
} else {
// we found it!
drawable = drawables.get(paintTime);
// System.out.println("Found the drawable");
if (!paintTime.equals(drawable.getTime())) {
drawable.setDirty(true);
}
// auto refresh state
if (isQuery) {
drawable.setDirty(true);
}
if (!paintTime.equals(drawable.getTime())) {
drawable.setDirty(true);
}
if (getResourceData().tableLoad
&& !paintTime.getRefTime().equals(getMostRecentTime())) {
setMostRecentTime(paintTime.getRefTime());
setTableTime();
// if (isLinkToFrame && loader != null && loader.loadType !=
// LOADER_TYPE.GENERAL) {
if (isLinkToFrame) {
updateDialog();
// auto refresh state
if (isQuery) {
drawable.setDirty(true);
}
}
if (getResourceData().tableLoad
&& !paintTime.getRefTime().equals(getMostRecentTime())) {
setMostRecentTime(paintTime.getRefTime());
setTableTime();
// if (isLinkToFrame && loader != null && loader.loadType !=
// LOADER_TYPE.GENERAL) {
if (isLinkToFrame) {
updateDialog();
}
}
} else {
getResourceData().getMonitor().forceKillFFMPSplash();
}
if ((drawable != null) && drawable.isDirty()) {
// only need to do the query if extent changed, pfafs may be
// fine
if (!isFirst || queryJob.getState() == Job.NONE) {
queryJob.request(aTarget, drawable, paintTime);
}
}
if (drawable != null && isFfmpDataToggle()) {
IColormapShadedShapeExtension ext = aTarget
.getExtension(IColormapShadedShapeExtension.class);
ImagingCapability imageCap = getCapability(ImagingCapability.class);
float brightness = imageCap.getBrightness();
float alpha = imageCap.getAlpha();
for (DomainXML domain : getDomains()) {
String cwa = domain.getCwa();
IColormapShadedShape shape = shadedShapes.getDrawableShape(cwa,
drawable.getShadedHuc());
Map<Object, RGB> colorMap = drawable.getColorMap(cwa);
if (shape != null && colorMap != null) {
ext.drawColormapShadedShape(shape, colorMap, alpha,
brightness);
}
}
}
boolean isAllHuc = getHuc().equals(FFMPRecord.ALL);
if (getResourceData().tableLoad) {
int mapWidth = getDescriptor().getMapWidth() / 1000;
double zoom = getDescriptor().getRenderableDisplay().getZoom();
// determine whether or not to draw the small guys
if ((mapWidth * zoom) > 250.0) {
if (isSmallBasins) {
isSmallBasins = false;
refresh();
}
} else if ((mapWidth * zoom) < 250.0) {
if (!isSmallBasins) {
isSmallBasins = true;
if (smallBasinOverlayShape == null) {
drawable.setDirty(true);
} else {
refresh();
}
}
}
if (isSmallBasins && this.isBasinToggle()) {
OutlineCapability lineCap = getCapability(OutlineCapability.class);
if ((smallBasinOverlayShape != null)
&& smallBasinOverlayShape.isDrawable()) {
if (basinBoundaryColor == null) {
basinBoundaryColor = getCapability(
ColorableCapability.class).getColor();
}
aTarget.drawWireframeShape(smallBasinOverlayShape,
basinBoundaryColor, lineCap.getOutlineWidth(),
lineCap.getLineStyle());
} else if ((smallBasinOverlayShape == null)
&& lineCap.isOutlineOn()) {
issueRefresh();
}
}
// the product string
if (isFfmpDataToggle() && fieldDescString != null) {
paintProductString(aTarget, paintProps);
}
}
// re-centered ?
if (centeredAggregationKey != null) {
vgbDrawables.clear();
// create pixelCoverages for the VGB's
if (isAllHuc) {
for (DomainXML domain : getDomains()) {
for (Long pfaf : monitor.getTemplates(getSiteKey())
.getMap(getSiteKey(), domain.getCwa(), getHuc())
.keySet()) {
List<FFMPVirtualGageBasinMetaData> fvgmdList = monitor
.getTemplates(getSiteKey())
.getVirtualGageBasinMetaData(getSiteKey(),
domain.getCwa(), pfaf);
if (fvgmdList != null) {
for (FFMPVirtualGageBasinMetaData fvgmd : fvgmdList) {
vgbDrawables.put(
fvgmd.getLid(),
getPixelCoverage(fvgmd.getCoordinate(),
paintProps));
}
}
}
}
} else {
if (getResourceData().getMonitor().ffmpSplash != null) {
getResourceData().getMonitor().ffmpSplash.close();
getResourceData().getMonitor().ffmpSplash = null;
}
}
if ((drawable != null) && drawable.isDirty()) {
// only need to do the query if extent changed, pfafs may be
// fine
if (!isFirst || queryJob.getState() == Job.NONE) {
queryJob.request(aTarget, isShaded, drawable, paintTime);
}
}
boolean isAllHuc = getHuc().equals(FFMPRecord.ALL);
for (DomainXML domain : getDomains()) {
String cwa = domain.getCwa();
if (isShaded) {
if (drawable != null) {
IColormapShadedShape shape = shadedShapes
.getDrawableShape(cwa, drawable.getShadedHuc());
Map<Object, RGB> colorMap = drawable.getColorMap(cwa);
if (this.isFfmpDataToggle() && (shape != null)
&& (colorMap != null)) {
aTarget.getExtension(
IColormapShadedShapeExtension.class)
.drawColormapShadedShape(
shape,
colorMap,
paintProps.getAlpha(),
getCapability(
ImagingCapability.class)
.getBrightness());
}
}
}
if (getResourceData().tableLoad) {
int mapWidth = getDescriptor().getMapWidth() / 1000;
double zoom = getDescriptor().getRenderableDisplay()
.getZoom();
// determine whether or not to draw the small guys
if ((mapWidth * zoom) > 250.0) {
if (isSmallBasins) {
isSmallBasins = false;
refresh();
}
} else if ((mapWidth * zoom) < 250.0) {
if (!isSmallBasins) {
isSmallBasins = true;
if (smallBasinOverlayShape == null) {
drawable.setDirty(true);
} else {
refresh();
}
}
}
if ((lowestCenter == ZOOM.AGGREGATE)
|| (lowestCenter == ZOOM.BASIN) || isAllHuc
|| this.isBasinToggle() || isSmallBasins) {
if (isSmallBasins && this.isBasinToggle()) {
if ((smallBasinOverlayShape != null)
&& smallBasinOverlayShape.isDrawable()) {
if (basinBoundaryColor == null) {
basinBoundaryColor = getCapability(
ColorableCapability.class)
.getColor();
}
aTarget.drawWireframeShape(
smallBasinOverlayShape,
basinBoundaryColor,
getCapability(OutlineCapability.class)
.getOutlineWidth(),
getCapability(OutlineCapability.class)
.getLineStyle());
} else if ((smallBasinOverlayShape == null)
&& getCapability(OutlineCapability.class)
.isOutlineOn()) {
aTarget.setNeedsRefresh(true);
}
}
}
// the product string
if (isFfmpDataToggle() && fieldDescString != null) {
paintProductString(aTarget, paintProps);
}
}
}
// re-centered ?
if (centeredAggregationKey != null) {
vgbDrawables.clear();
// create pixelCoverages for the VGB's
if (isAllHuc) {
for (DomainXML domain : getDomains()) {
for (Long pfaf : monitor
if (lowestCenter == FFMPRecord.ZOOM.AGGREGATE) {
for (Long pfaf : monitor.getTemplates(getSiteKey())
.getAllAggregatePfafs(centeredAggregationKey,
getHuc())) {
List<FFMPVirtualGageBasinMetaData> fvgmdList = monitor
.getTemplates(getSiteKey())
.getMap(getSiteKey(), domain.getCwa(), getHuc())
.keySet()) {
ArrayList<FFMPVirtualGageBasinMetaData> fvgmdList = monitor
.getTemplates(getSiteKey())
.getVirtualGageBasinMetaData(getSiteKey(),
domain.getCwa(), pfaf);
if (fvgmdList != null) {
for (FFMPVirtualGageBasinMetaData fvgmd : fvgmdList) {
vgbDrawables.put(
fvgmd.getLid(),
getPixelCoverage(
fvgmd.getCoordinate(),
paintProps));
}
.getVirtualGageBasinMetaData(getSiteKey(),
null, pfaf);
if (fvgmdList != null) {
for (FFMPVirtualGageBasinMetaData fvgmd : fvgmdList) {
vgbDrawables.put(
fvgmd.getLid(),
getPixelCoverage(fvgmd.getCoordinate(),
paintProps));
}
}
}
} else {
if (lowestCenter == FFMPRecord.ZOOM.AGGREGATE) {
for (Long pfaf : monitor.getTemplates(getSiteKey())
.getAllAggregatePfafs(centeredAggregationKey,
getHuc())) {
ArrayList<FFMPVirtualGageBasinMetaData> fvgmdList = monitor
.getTemplates(getSiteKey())
.getVirtualGageBasinMetaData(getSiteKey(),
null, pfaf);
if (fvgmdList != null) {
for (FFMPVirtualGageBasinMetaData fvgmd : fvgmdList) {
vgbDrawables.put(
fvgmd.getLid(),
getPixelCoverage(
fvgmd.getCoordinate(),
paintProps));
}
}
}
} else {
for (DomainXML domain : getDomains()) {
for (Entry<String, FFMPVirtualGageBasinMetaData> entry : monitor
.getTemplates(getSiteKey())
.getVirtualGageBasins(getSiteKey(),
domain.getCwa()).entrySet()) {
if (entry.getValue() != null) {
vgbDrawables.put(
entry.getKey(),
getPixelCoverage(entry.getValue()
.getCoordinate(),
paintProps));
}
for (DomainXML domain : getDomains()) {
for (Entry<String, FFMPVirtualGageBasinMetaData> entry : monitor
.getTemplates(getSiteKey())
.getVirtualGageBasins(getSiteKey(),
domain.getCwa()).entrySet()) {
if (entry.getValue() != null) {
vgbDrawables.put(
entry.getKey(),
getPixelCoverage(entry.getValue()
.getCoordinate(), paintProps));
}
}
}
}
paintCenter(aTarget, paintProps);
paintVGBs(aTarget, paintProps);
}
// draw or clear the colorMap
if (!isFfmpDataToggle()) { // clear if ffmpDataToggle is false
getCapability(ColorMapCapability.class).setColorMapParameters(
null);
} else if (getColorUtil().getColorMapParameters() != null) {
// restore if null
getCapability(ColorMapCapability.class).setColorMapParameters(
getColorUtil().getColorMapParameters());
}
// draw stream trace?
if (isShowStream() && isStreamFollow()) {
paintUpAndDownStream(aTarget, paintProps, isShaded);
}
// always reset
isQuery = false;
paintCenter(aTarget, paintProps);
paintVGBs(aTarget, paintProps);
}
// draw or clear the colorMap
if (!isFfmpDataToggle()) { // clear if ffmpDataToggle is false
getCapability(ColorMapCapability.class).setColorMapParameters(null);
} else if (getColorUtil().getColorMapParameters() != null) {
// restore if null
getCapability(ColorMapCapability.class).setColorMapParameters(
getColorUtil().getColorMapParameters());
}
// draw stream trace?
if (isShowStream() && isStreamFollow()) {
paintUpAndDownStream(aTarget, paintProps);
}
// always reset
isQuery = false;
}
/**
@ -1487,7 +1447,7 @@ public class FFMPResource extends
* @throws VizException
*/
private void paintUpAndDownStream(IGraphicsTarget target,
PaintProperties paintProps, boolean isShaded) throws VizException {
PaintProperties paintProps) throws VizException {
if (basinTraceColor == null) {
basinTraceColor = getCapability(ColorableCapability.class)
@ -1495,7 +1455,7 @@ public class FFMPResource extends
}
if (isShowStream() && (streamShadedShape != null)
&& streamShadedShape.isDrawable() && isShaded) {
&& streamShadedShape.isDrawable()) {
target.drawShadedShape(streamShadedShape, paintProps.getAlpha());
}
if (isShowStream() && (streamOutlineShape != null)
@ -1824,10 +1784,8 @@ public class FFMPResource extends
if (stream.equals(FFMPRecord.CLICK_TYPE.TREND)) {
monitor.basinTrend(newPfaf);
}
// only re-draw the screen for UP/DOWN
if (!stream.equals(FFMPRecord.CLICK_TYPE.TREND)) {
} else {
// only re-draw the screen for UP/DOWN
nextStreamPfaf = newPfaf;
dirty();
}
@ -2101,29 +2059,16 @@ public class FFMPResource extends
*/
private void drawSquare(PixelCoverage pc, IGraphicsTarget target)
throws VizException {
// target.drawLine(lines)
target.drawLine(pc.getLl().x, pc.getLl().y, 0.0, pc.getUl().x, pc
.getUl().y, 0.0, getCapability(ColorableCapability.class)
.getColor(), getCapability(OutlineCapability.class)
.getOutlineWidth(), getCapability(OutlineCapability.class)
.getLineStyle());
target.drawLine(pc.getUl().x, pc.getUl().y, 0.0, pc.getUr().x, pc
.getUr().y, 0.0, getCapability(ColorableCapability.class)
.getColor(), getCapability(OutlineCapability.class)
.getOutlineWidth(), getCapability(OutlineCapability.class)
.getLineStyle());
target.drawLine(pc.getUr().x, pc.getUr().y, 0.0, pc.getLr().x, pc
.getLr().y, 0.0, getCapability(ColorableCapability.class)
.getColor(), getCapability(OutlineCapability.class)
.getOutlineWidth(), getCapability(OutlineCapability.class)
.getLineStyle());
target.drawLine(pc.getLr().x, pc.getLr().y, 0.0, pc.getLl().x, pc
.getLl().y, 0.0, getCapability(ColorableCapability.class)
.getColor(), getCapability(OutlineCapability.class)
.getOutlineWidth(), getCapability(OutlineCapability.class)
.getLineStyle());
DrawableLine line = new DrawableLine();
line.lineStyle = getCapability(OutlineCapability.class).getLineStyle();
line.width = getCapability(OutlineCapability.class).getOutlineWidth();
line.basics.color = getCapability(ColorableCapability.class).getColor();
line.addPoint(pc.getLl().x, pc.getLl().y);
line.addPoint(pc.getUl().x, pc.getUl().y);
line.addPoint(pc.getUr().x, pc.getUr().y);
line.addPoint(pc.getLr().x, pc.getLr().y);
line.addPoint(pc.getLl().x, pc.getLl().y);
target.drawLine(line);
}
/**
@ -2188,23 +2133,6 @@ public class FFMPResource extends
}
}
/**
* See if you are in the coverage of this feature
*
* @param c
* @return
*/
private boolean contains(PixelCoverage pc, Coordinate c) {
boolean inside = false;
double[] center = descriptor.worldToPixel(new double[] { c.x, c.y });
if ((center[0] > pc.getMinX()) && (center[0] < pc.getMaxX())
&& (center[1] > pc.getMinY()) && (center[1] < pc.getMaxY())) {
inside = true;
}
return inside;
}
/**
* Set the center
*
@ -2353,56 +2281,6 @@ public class FFMPResource extends
}
}
/**
* Gets the VGB value when querried
*
* @param pfaf
* @return
*/
private float getVGBValue(Long pfaf, Date recentTime) {
float value = 0.0f;
if (getField() == FIELDS.RATE) {
value = getVirtualRecord().getBasinsMap().get(FFMPRecord.ALL)
.get(pfaf).getValue(recentTime);
} else if (getField() == FIELDS.QPE) {
value = getVirtualRecord()
.getBasinsMap()
.get(FFMPRecord.ALL)
.get(pfaf)
.getAccumValue(getTableTime(), getMostRecentTime(),
getQpeSourceExpiration(), isRate());
} else if (getField() == FIELDS.RATIO) {
float qpe = getVirtualRecord()
.getBasinsMap()
.get(FFMPRecord.ALL)
.get(pfaf)
.getAccumValue(getTableTime(), getMostRecentTime(),
getQpeSourceExpiration(), isRate());
float guidance = getGuidanceValue(
((FFMPGuidanceBasin) getGuidanceRecord().getBasinsMap()
.get(FFMPRecord.ALL).get(pfaf)), recentTime,
getFFGName());
value = FFMPUtils.getRatioValue(qpe, guidance);
} else if (getField() == FIELDS.DIFF) {
float qpe = getVirtualRecord()
.getBasinsMap()
.get(FFMPRecord.ALL)
.get(pfaf)
.getAccumValue(getTableTime(), getMostRecentTime(),
getQpeSourceExpiration(), isRate());
float guidance = getGuidanceValue(
((FFMPGuidanceBasin) getGuidanceRecord().getBasinsMap()
.get(FFMPRecord.ALL).get(pfaf)), recentTime,
getFFGName());
value = FFMPUtils.getDiffValue(qpe, guidance);
} else if (getField() == FIELDS.GUIDANCE) {
value = getGuidanceValue(((FFMPGuidanceBasin) getGuidanceRecord()
.getBasinsMap().get(FFMPRecord.ALL).get(pfaf)), recentTime,
getFFGName());
}
return value;
}
private class FFMPDataRetrievalJob extends Job {
private static final int QUEUE_LIMIT = 1;
@ -2420,29 +2298,25 @@ public class FFMPResource extends
IGraphicsTarget target;
boolean shaded;
FFMPDrawable drawable;
DataTime time;
Request(IGraphicsTarget target, boolean shaded,
FFMPDrawable drawable, DataTime time) {
Request(IGraphicsTarget target, FFMPDrawable drawable, DataTime time) {
this.target = target;
this.shaded = shaded;
this.drawable = drawable;
this.time = time;
}
}
public void request(IGraphicsTarget target, boolean shaded,
FFMPDrawable drawable, DataTime time) {
public void request(IGraphicsTarget target, FFMPDrawable drawable,
DataTime time) {
if (drawable != null) {
if (requestQueue.size() == QUEUE_LIMIT) {
requestQueue.poll();
}
Request req = new Request(target, shaded, drawable,
Request req = new Request(target, drawable,
time);
requestQueue.add(req);
this.schedule();
@ -2867,10 +2741,8 @@ public class FFMPResource extends
// create the frames/shaded shapes here
localWireframeShape = req.target.createWireframeShape(false,
descriptor, 0.0f);
if (req.shaded) {
localShadedShape = req.target.createShadedShape(false,
descriptor.getGridGeometry(), true);
}
localShadedShape = req.target.createShadedShape(false,
descriptor.getGridGeometry(), true);
JTSCompiler jtsCompiler2 = new JTSCompiler(localShadedShape,
localWireframeShape, descriptor, PointStyle.CROSS);
@ -2916,7 +2788,7 @@ public class FFMPResource extends
}
}
if (req.shaded && (localShadedShape != null)) {
if (localShadedShape != null) {
localShadedShape.compile();
localShadedShape.setFillPattern(FFMPUtils.STREAM_FILL);
if (streamShadedShape != null) {
@ -3633,7 +3505,7 @@ public class FFMPResource extends
*
* @return list of Domains
*/
public ArrayList<DomainXML> getDomains() {
public List<DomainXML> getDomains() {
return getResourceData().getDomains();
}
@ -3718,11 +3590,7 @@ public class FFMPResource extends
SortedSet<Date> keys = monitor.getAvailableUris(getSiteKey(),
getDataKey(), getPrimarySource(), oldestTime).keySet();
for (Date date : keys) {
timeOrderedKeys.add(date);
}
timeOrderedKeys.addAll(keys);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"No available times for the FFMPResource");
@ -4180,7 +4048,7 @@ public class FFMPResource extends
*/
public FFMPDrawable getDrawable(DataTime time) {
FFMPDrawable drawable = null;
if (drawables != null) {
if (drawables != null && time != null) {
drawable = drawables.get(time);
}
return drawable;

View file

@ -20,7 +20,6 @@
package com.raytheon.uf.viz.monitor.ffmp.ui.rsc;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.NavigableMap;
@ -35,11 +34,7 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord.FIELDS;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPTemplates;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.monitor.config.FFMPRunConfigurationManager;
import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager.SOURCE_TYPE;
import com.raytheon.uf.common.monitor.xml.DomainXML;
@ -54,6 +49,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.core.rsc.AbstractNameGenerator;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
@ -78,6 +74,7 @@ import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPConfigBasinXML;
* Feb 10, 2013 1584 mpduff Add performance logging.
* Feb 28, 2013 1729 dhladky Got rid of thread sleeps
* Mar 6, 2013 1769 dhladky Changed threading to use count down latch.
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
*
* </pre>
*
@ -134,7 +131,7 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
protected FFMPMonitor monitor = null;
/** County Warning Area (Domain) for which to display **/
protected ArrayList<DomainXML> domains = null;
protected List<DomainXML> domains = null;
/** Product Displayed **/
private ProductXML product = null;
@ -177,10 +174,7 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
protected AbstractVizResource<?, ?> constructResource(
LoadProperties loadProperties, PluginDataObject[] objects)
throws VizException {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
this.wfo = context.getContextName();
this.wfo = LocalizationManager.getContextName(LocalizationLevel.SITE);
FFMPMonitor monitor = getMonitor();
monitor.setWfo(wfo);
this.field = monitor.getField(sourceName);
@ -192,8 +186,8 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
DataTime[] availableTimes = this.getAvailableTimes();
// no data available;
if (availableTimes.length != 0) {
if (getMonitor().getProductXML(sourceName) != null) {
setProduct(getMonitor().getProductXML(sourceName));
product = monitor.getProductXML(sourceName);
if (product != null) {
monitor.launchSplash(siteKey);
FFMPTemplates templates = monitor.getTemplates(siteKey);
@ -227,11 +221,12 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
FFMPConfig ffmpConfig = monitor.getConfig();
FFMPConfigBasinXML cfgBasinXML = ffmpConfig.getFFMPConfigData();
String[] sdomains = cfgBasinXML.getIncludedCWAs().split(",");
ArrayList<DomainXML> defaults = new ArrayList<DomainXML>();
List<DomainXML> defaults = new ArrayList<DomainXML>(
sdomains.length);
for (String domain : sdomains) {
if (domain.length() == 0) {
if (domain.isEmpty()) {
defaults.add(monitor.getRunConfig().getDomain(wfo));
break;
}
@ -247,26 +242,18 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
this.domains = defaults;
DataTime mostRecentTime = availableTimes[availableTimes.length - 1];
Date mostRecentTime = availableTimes[availableTimes.length - 1]
.getRefTime();
this.timeBack = new Date(
(long) (mostRecentTime.getRefTime().getTime() - (cfgBasinXML
(long) (mostRecentTime.getTime() - (cfgBasinXML
.getTimeFrame() * TimeUtil.MILLIS_PER_HOUR)));
ArrayList<String> hucsToLoad = monitor.getTemplates(siteKey)
List<String> hucsToLoad = monitor.getTemplates(siteKey)
.getTemplateMgr().getHucLevels();
// goes back X hours and pre populates the Data Hashes
FFMPDataLoader loader = new FFMPDataLoader(this, timeBack,
mostRecentTime.getRefTime(), LOADER_TYPE.INITIAL,
mostRecentTime, LOADER_TYPE.INITIAL,
hucsToLoad);
loader.start();
// make the table load wait for finish of initial data load
try {
loader.waitFor();
} catch (InterruptedException e) {
statusHandler.handle(Priority.INFO,
"Data Loader thread interrupted, dying!", e);
}
loader.run();
} else {
/*
* This appears completely un-orthodox for anything in D2D. But
@ -305,7 +292,7 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
NavigableMap<Date, List<String>> sourceURIs = getMonitor()
.getAvailableUris(siteKey, dataKey, sourceName,
standAloneTime);
getMonitor().processUris(sourceURIs, false, siteKey,
monitor.processUris(sourceURIs, siteKey,
sourceName, standAloneTime, FFMPRecord.ALL);
}
}
@ -405,50 +392,14 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
*
* @param record
*/
public void populateRecord(ProductXML product, FFMPRecord precord,
String phuc) throws VizException {
public void populateRecord(FFMPRecord precord)
throws VizException {
try {
boolean isProductLoad = false;
if (product != null) {
isProductLoad = true;
}
getMonitor().populateFFMPRecord(isProductLoad, siteKey, precord,
precord.getSourceName(), phuc);
getMonitor().populateFFMPRecord(siteKey, precord,
precord.getSourceName(), huc);
} catch (Exception e) {
throw new VizException("Failed to populate ffmp record "
+ precord.getDataURI() + " for huc " + phuc);
}
}
/**
* Sort by Date
*
* @author dhladky
*
*/
public class SortByDate implements Comparator<FFMPRecord> {
@Override
public int compare(FFMPRecord o1, FFMPRecord o2) {
return o1.getDataTime().getRefTime()
.compareTo(o2.getDataTime().getRefTime());
}
}
/**
* Sort by DataTime
*
* @author dhladky
*
*/
public class SortByDataTime implements Comparator<DataTime> {
@Override
public int compare(DataTime o1, DataTime o2) {
return o1.compareTo(o2);
+ precord.getDataURI() + " for huc " + huc);
}
}
@ -488,7 +439,7 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
this.domains = domains;
}
public ArrayList<DomainXML> getDomains() {
public List<DomainXML> getDomains() {
return domains;
}
@ -548,7 +499,7 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
* @param pfield
* @return
*/
public ArrayList<String> getSourceName(FIELDS pfield) {
public List<String> getSourceName(FIELDS pfield) {
ArrayList<String> sourceNames = null;
ProductXML product = getProduct();
ProductRunXML productRun = FFMPRunConfigurationManager.getInstance()

View file

@ -46,6 +46,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Apr 22, 2013 1912 bsteffen optimized the creation of NavigableMaps
* from aggregate records and delayed
* TreeMap creation to the tertiary loader.
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
*
* </pre>
*
@ -174,19 +175,12 @@ public class FFMPBasin implements ISerializableObject, Cloneable {
synchronized (values) {
ArrayList<Date> keys = new ArrayList<Date>();
for (Date date : values.keySet()) {
if (date.before(beforeDate) && date.after(afterDate)) {
keys.add(date);
}
}
float factor = 0.0f;
for (Date key : keys) {
Date tdate = key;
float val = values.get(key);
for (Entry<Date, Float> entry : values.subMap(beforeDate,
false, afterDate, false).entrySet()) {
Date tdate = entry.getKey();
float val = entry.getValue();
if (!rate) {
@ -214,7 +208,7 @@ public class FFMPBasin implements ISerializableObject, Cloneable {
}
dvalue += val;
prevDate = key;
prevDate = tdate;
}
}
}

View file

@ -52,6 +52,7 @@ import com.raytheon.uf.common.serialization.SerializationUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 2012-09-04 DR 14404 gzhang Fixing ConcurrentModificationException
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
*
* </pre>
*
@ -60,7 +61,8 @@ import com.raytheon.uf.common.serialization.SerializationUtil;
public class FFMPRunConfigurationManager implements ILocalizationFileObserver {
/** Path to FFMP Source config. */
private static final String CONFIG_FILE_NAME = "ffmp" + File.separatorChar
private static final String CONFIG_FILE_NAME = "ffmp"
+ IPathManager.SEPARATOR
+ "FFMPRunConfig.xml";
/**
@ -211,24 +213,14 @@ public class FFMPRunConfigurationManager implements ILocalizationFileObserver {
}
public DomainXML getDomain(String domainname) {
DomainXML domain = null;
for (FFMPRunXML runner : getFFMPRunners()) {
if (runner.getPrimaryDomain().getCwa().equals(domainname)) {
domain = runner.getPrimaryDomain();
break;
} else {
if (runner.getBackupDomains() != null) {
for (DomainXML backup : runner.getBackupDomains()) {
if (backup.getCwa().equals(domainname)) {
domain = backup;
break;
}
}
for (DomainXML domain : runner.getDomains()) {
if (domain.getCwa().equals(domainname)) {
return domain;
}
}
}
return domain;
return null;
}
public FFMPRunXML getRunner(String domainName) {
@ -259,9 +251,11 @@ public class FFMPRunConfigurationManager implements ILocalizationFileObserver {
}
public ProductRunXML getProduct(String productKey) {
for (ProductRunXML product : getProducts()) {
if (product.getProductKey().equals(productKey)) {
return product;
for (FFMPRunXML runner : getFFMPRunners()) {
for (ProductRunXML product : runner.getProducts()) {
if (product.getProductKey().equals(productKey)) {
return product;
}
}
}

View file

@ -21,6 +21,8 @@ package com.raytheon.uf.common.monitor.config;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import com.raytheon.uf.common.localization.FileUpdatedMessage;
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
@ -47,6 +49,7 @@ import com.raytheon.uf.common.serialization.SerializationUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 2012-09-04 DR 14404 gzhang Fixing ConcurrentModificationException
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
*
* </pre>
*
@ -56,8 +59,8 @@ public class FFMPSourceConfigurationManager implements
ILocalizationFileObserver {
/** Path to FFMP Source config. */
private static final String CONFIG_FILE_NAME = "ffmp" + File.separatorChar
+ "FFMPSourceConfig.xml";
private static final String CONFIG_FILE_NAME = "ffmp"
+ IPathManager.SEPARATOR + "FFMPSourceConfig.xml";
/**
* FFMP Source Configuration XML object.
@ -67,20 +70,19 @@ public class FFMPSourceConfigurationManager implements
/** Singleton instance of this class */
private static FFMPSourceConfigurationManager instance = new FFMPSourceConfigurationManager();
private ArrayList<String> virtuals = null;
private List<String> virtuals = null;
private ArrayList<String> rates = null;
private List<String> rates = null;
private ArrayList<String> guidances = null;
private ArrayList<String> forecasts = null;
private ArrayList<String> accumulators = null;
private List<String> accumulators = null;
private LocalizationFile lf = null;
private java.util.concurrent.CopyOnWriteArrayList<MonitorConfigListener> listeners = new java.util.concurrent.CopyOnWriteArrayList<MonitorConfigListener>();// DR 14404
//private ArrayList<MonitorConfigListener> listeners = new ArrayList<MonitorConfigListener>();// DR 14404
private List<MonitorConfigListener> listeners = new CopyOnWriteArrayList<MonitorConfigListener>();
/* Private Constructor */
private FFMPSourceConfigurationManager() {
@ -109,18 +111,17 @@ public class FFMPSourceConfigurationManager implements
* Read the XML configuration data for the current XML file name.
*/
public synchronized void readConfigXml() {
IPathManager pm = PathManagerFactory.getPathManager();
try {
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext lc = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
lf = pm.getLocalizationFile(lc, CONFIG_FILE_NAME);
lf.addFileUpdatedObserver(this);
File file = lf.getFile();
// System.out.println("Reading -- " + file.getAbsolutePath());
FFMPSourceConfigXML configXmltmp = (FFMPSourceConfigXML) SerializationUtil
.jaxbUnmarshalFromXmlFile(file.getAbsolutePath());
FFMPSourceConfigXML configXmltmp = SerializationUtil
.jaxbUnmarshalFromXmlFile(FFMPSourceConfigXML.class, file);
configXml = configXmltmp;
@ -128,18 +129,17 @@ public class FFMPSourceConfigurationManager implements
System.err.println("No SITE FFMP Source configuration file found");
// fall back to BASE
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext lc = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE);
lf = pm.getLocalizationFile(lc, CONFIG_FILE_NAME);
lf.addFileUpdatedObserver(this);
File file = lf.getFile();
// System.out.println("Reading -- " + file.getAbsolutePath());
FFMPSourceConfigXML configXmltmp = null;
try {
configXmltmp = (FFMPSourceConfigXML) SerializationUtil
.jaxbUnmarshalFromXmlFile(file.getAbsolutePath());
.jaxbUnmarshalFromXmlFile(FFMPSourceConfigXML.class,
file);
} catch (SerializationException e1) {
e1.printStackTrace();
}
@ -160,23 +160,18 @@ public class FFMPSourceConfigurationManager implements
LocalizationLevel.SITE);
LocalizationFile newXmlFile = pm.getLocalizationFile(lc,
CONFIG_FILE_NAME);
if (newXmlFile.getFile().getParentFile().exists() == false) {
// System.out.println("Creating new directory");
if (newXmlFile.getFile().getParentFile().mkdirs() == false) {
// System.out.println("Could not create new directory...");
}
File file = newXmlFile.getFile();
if (file.getParentFile().exists() == false) {
file.getParentFile().mkdirs();
}
try {
// System.out.println("Saving -- "
// + newXmlFile.getFile().getAbsolutePath());
SerializationUtil.jaxbMarshalToXmlFile(configXml, newXmlFile
.getFile().getAbsolutePath());
SerializationUtil.jaxbMarshalToXmlFile(configXml,
file.getAbsolutePath());
newXmlFile.save();
lf = newXmlFile;
lf.addFileUpdatedObserver(this);
} catch (Exception e) {
e.printStackTrace();
}
@ -218,7 +213,7 @@ public class FFMPSourceConfigurationManager implements
* @param name
* @return
*/
public ArrayList<String> getVirtuals() {
public List<String> getVirtuals() {
if (virtuals == null) {
virtuals = new ArrayList<String>();
}
@ -273,7 +268,7 @@ public class FFMPSourceConfigurationManager implements
*
* @return
*/
public ArrayList<String> getQPESources() {
public List<String> getQPESources() {
if (accumulators == null) {
accumulators = new ArrayList<String>();
}
@ -290,7 +285,7 @@ public class FFMPSourceConfigurationManager implements
*
* @return
*/
public ArrayList<String> getRates() {
public List<String> getRates() {
if (rates == null) {
rates = new ArrayList<String>();
}
@ -431,26 +426,11 @@ public class FFMPSourceConfigurationManager implements
}
public SOURCE_TYPE getSourceType(String sourceName) {
SOURCE_TYPE source = null;
if (getSource(sourceName) != null) {
if (getSource(sourceName).getSourceType().equals(
SOURCE_TYPE.RATE.getSourceType())) {
source = SOURCE_TYPE.RATE;
} else if (getSource(sourceName).getSourceType().equals(
SOURCE_TYPE.QPE.getSourceType())) {
source = SOURCE_TYPE.QPE;
} else if (getSource(sourceName).getSourceType().equals(
SOURCE_TYPE.QPF.getSourceType())) {
source = SOURCE_TYPE.QPF;
} else if (getSource(sourceName).getSourceType().equals(
SOURCE_TYPE.GUIDANCE.getSourceType())) {
source = SOURCE_TYPE.GUIDANCE;
} else if (getSource(sourceName).getSourceType().equals(
SOURCE_TYPE.GAGE.getSourceType())) {
source = SOURCE_TYPE.GAGE;
}
SourceXML sourceXml = getSource(sourceName);
if (sourceXml != null) {
return SOURCE_TYPE.valueOf(sourceXml.getSourceType());
}
return source;
return null;
}
/**