Merge "Issue #1954 Minor code cleanup throughout FFMP." into omaha_13.4.1

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

View file

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

View file

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

View file

@ -20,9 +20,11 @@
package com.raytheon.uf.viz.monitor.ffmp.ui.rsc; package com.raytheon.uf.viz.monitor.ffmp.ui.rsc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasin; import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasin;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPBasinData; 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.dataplugin.ffmp.FFMPVirtualGageBasinMetaData;
import com.raytheon.uf.common.monitor.config.FFFGDataMgr; import com.raytheon.uf.common.monitor.config.FFFGDataMgr;
import com.raytheon.uf.common.monitor.config.FFMPRunConfigurationManager; 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.DomainXML;
import com.raytheon.uf.common.monitor.xml.ProductRunXML; import com.raytheon.uf.common.monitor.xml.ProductRunXML;
import com.raytheon.uf.common.monitor.xml.ProductXML; 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. * Feb 28, 2013 1729 dhladky General enhancements for speed.
* Apr 12, 2013 1902 mpduff Code Cleanup. * Apr 12, 2013 1902 mpduff Code Cleanup.
* Apr 15, 2013 1890 dhladky Added another constant fix * Apr 15, 2013 1890 dhladky Added another constant fix
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
*
* </pre> * </pre>
* *
* @author dhladky * @author dhladky
@ -85,83 +88,57 @@ public class FFMPDataGenerator {
private static final IUFStatusHandler statusHandler = UFStatus private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(FFMPDataGenerator.class); .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 siteKey;
private final String dataKey;
private final ProductXML product;
private final Date paintRefTime; private final Date paintRefTime;
private final Date tableTime;
private final Object centeredAggregationKey; private final Object centeredAggregationKey;
private final String huc; private final String huc;
private final List<DomainXML> domains;
private final double sliderTime; private final double sliderTime;
private boolean isWorstCase = false; 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; private long expirationTime = 0l;
HashMap<String, FFMPRecord> guidRecords = null;
FFMPRecord virtualRecord = null;
FFMPRecord baseRec = null;
SourceXML primarySource = null;
FFFGDataMgr dman = null;
boolean isRate = false;
long expirationTime = 0l;
private String[] cwaArr = null; private String[] cwaArr = null;
private HashMap<String, FFFGForceUtil> forceUtils = null; private Map<String, FFFGForceUtil> forceUtils = null;
private FfmpTableConfigData ffmpTableCfgData = null; private FfmpTableConfigData ffmpTableCfgData = null;
public FFMPDataGenerator(FFMPMonitor monitor, FFMPResource resource) { public FFMPDataGenerator(FFMPMonitor monitor, FFMPResource resource) {
siteKey = resource.getSiteKey(); siteKey = resource.getSiteKey();
dataKey = resource.getDataKey();
product = resource.getProduct();
paintRefTime = resource.getPaintTime().getRefTime(); paintRefTime = resource.getPaintTime().getRefTime();
tableTime = resource.getTableTime();
centeredAggregationKey = resource.centeredAggregationKey; centeredAggregationKey = resource.centeredAggregationKey;
huc = resource.getHuc(); huc = resource.getHuc();
domains = resource.getDomains();
sliderTime = resource.getTime(); sliderTime = resource.getTime();
isWorstCase = resource.isWorstCase(); isWorstCase = resource.isWorstCase();
@ -169,10 +146,11 @@ public class FFMPDataGenerator {
this.resource = resource; this.resource = resource;
this.monitor = monitor; this.monitor = monitor;
this.ft = monitor.getTemplates(siteKey); this.ft = monitor.getTemplates(siteKey);
this.primarySource = resource.getResourceData().getPrimarySourceXML(); SourceXML primarySource = resource.getResourceData()
.getPrimarySourceXML();
this.isRate = primarySource.isRate(); this.isRate = primarySource.isRate();
this.expirationTime = primarySource.getExpirationMinutes(resource this.expirationTime = primarySource.getExpirationMinutes(siteKey)
.getSiteKey()) * TimeUtil.MILLIS_PER_MINUTE; * TimeUtil.MILLIS_PER_MINUTE;
ffmpTableCfgData = tableConfig.getTableConfigData(siteKey); ffmpTableCfgData = tableConfig.getTableConfigData(siteKey);
} }
@ -187,93 +165,53 @@ public class FFMPDataGenerator {
try { try {
FIELDS field = getBaseField(); FIELDS field = getBaseField();
if (field != null) { if (field == null || baseRec == null) {
if (baseRec != null) { return tData;
FFMPBasinData fbd = null; }
if (centeredAggregationKey != null) { FFMPBasinData fbd = null;
fbd = baseRec.getBasinData(ALL); if (centeredAggregationKey != null) {
} else { fbd = baseRec.getBasinData(ALL);
fbd = baseRec.getBasinData(huc); } else {
} fbd = baseRec.getBasinData(huc);
}
if (!fbd.getBasins().isEmpty()) { List<DomainXML> domains = resource.getDomains();
if ((centeredAggregationKey == null) || huc.equals(ALL)) { if (!fbd.getBasins().isEmpty()) {
// System.out.println(fbd.getBasins().keySet().size() if ((centeredAggregationKey == null) || huc.equals(ALL)) {
// + " rows in the table"); // System.out.println(fbd.getBasins().keySet().size()
for (Long key : fbd.getBasins().keySet()) { // + " rows in the table");
if (huc.equals(ALL)) { for (Long key : fbd.getBasins().keySet()) {
for (DomainXML domain : domains) { if (huc.equals(ALL)) {
FFMPBasinMetaData fmdb = ft.getBasin(siteKey, key);
if (fmdb == null) {
continue;
}
FFMPBasinMetaData fmdb = ft.getBasin( for (DomainXML domain : domains) {
siteKey, key); String cwa = domain.getCwa();
String cwa = domain.getCwa();
if (fmdb == null) { if ((cwa.equals(fmdb.getCwa()))
continue; || (domain.isPrimary() && fmdb
} .isPrimaryCwa())) {
try {
if ((cwa.equals(fmdb.getCwa())) setFFMPRow(fbd.get(key), tData, false,
|| (domain.isPrimary() && fmdb cwa);
.isPrimaryCwa())) { } catch (Exception e) {
try { statusHandler
setFFMPRow(fbd.get(key), tData, .handle(Priority.PROBLEM,
false, cwa);
} catch (Exception e) {
statusHandler.handle(
Priority.PROBLEM,
"Couldn't create table row" "Couldn't create table row"
+ e); + 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);
}
}
}
}
} }
if (virtualBasin != null) {
} else { for (Long id : ft
/* .getVirtualGageBasinLookupIds(
* make sure at least one basin in the agg siteKey, key, huc,
* is in the CWA resource.basinTableDlg
*/ .getRowName())) {
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) {
try { try {
setFFMPRow(fbd.get(key), tData, setFFMPRow(
isVGB, null); virtualBasin.get(id),
tData, true, cwa);
} catch (Exception e) { } catch (Exception e) {
statusHandler.handle( statusHandler.handle(
Priority.PROBLEM, Priority.PROBLEM,
@ -284,77 +222,99 @@ public class FFMPDataGenerator {
} }
} }
} }
}
// show pfafs in aggregation
else {
for (Long key : resource
.getCenteredAggregatePfafs()) {
FFMPBasinMetaData fmdb = ft.getBasin(siteKey, } else {
key); /*
* 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 (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 FFMPBasinMetaData fmdb = ft.getBasin(siteKey, key);
.getCwa()))
|| (domain.isPrimary() && fmdb
.isPrimaryCwa())) {
setFFMPRow(fbd.get(key), tData, if (fmdb != null) {
false, null); for (DomainXML domain : domains) {
if (virtualBasin != null) { if ((domain.getCwa().equals(fmdb.getCwa()))
for (Long id : ft || (domain.isPrimary() && fmdb
.getVirtualGageBasinLookupIds( .isPrimaryCwa())) {
siteKey,
key, setFFMPRow(fbd.get(key), tData, false, null);
huc,
resource.basinTableDlg if (virtualBasin != null) {
.getRowName())) { for (Long id : ft
try { .getVirtualGageBasinLookupIds(
setFFMPRow( siteKey, key, huc,
virtualBasin resource.basinTableDlg
.get(id), .getRowName())) {
tData, true, try {
null); setFFMPRow(
} catch (Exception e) { virtualBasin.get(id),
statusHandler tData, true, null);
.handle(Priority.PROBLEM, } catch (Exception e) {
"Couldn't create table row" statusHandler.handle(
+ e); Priority.PROBLEM,
} "Couldn't create table row"
} + e);
} }
} }
} }
} }
} }
} }
tData.sortData();
} }
} }
tData.sortData();
} }
} catch (Exception e) { } catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Failed to load FFMP table data!", e); "Failed to load FFMP table data!", e);
} }
return tData; return tData;
} }
private void setFFMPRow(FFMPBasin cBasin, FFMPTableData tData, private void setFFMPRow(FFMPBasin cBasin, FFMPTableData tData,
boolean isVGB, String domain) { boolean isVGB, String domain) {
try { try {
String pfafToTest = null;
if (cBasin instanceof FFMPVirtualGageBasin) { if (cBasin instanceof FFMPVirtualGageBasin) {
if (tData.containsPfaf(((FFMPVirtualGageBasin) cBasin).getLid() pfafToTest = ((FFMPVirtualGageBasin) cBasin).getLid();
.toString())) {
return;
}
} else { } else {
if (tData.containsPfaf(cBasin.getPfaf().toString())) { pfafToTest = cBasin.getPfaf().toString();
return; }
} if (tData.containsPfaf(pfafToTest)) {
return;
} }
} catch (Exception e) { } catch (Exception e) {
return; return;
@ -377,31 +337,28 @@ public class FFMPDataGenerator {
} }
if (cBasin instanceof FFMPVirtualGageBasin) { if (cBasin instanceof FFMPVirtualGageBasin) {
rowField = FIELDS.VIRTUAL; rowField = FIELDS.VIRTUAL;
String lid = ((FFMPVirtualGageBasin) cBasin).getLid(); FFMPVirtualGageBasin vgBasin = (FFMPVirtualGageBasin) cBasin;
String lid = vgBasin.getLid();
if (lid != null) { if (lid != null) {
StringBuilder sb = new StringBuilder(lid); StringBuilder sb = new StringBuilder(lid);
// in this special case it is actually the LID // in this special case it is actually the LID
trd.setPfaf(((FFMPVirtualGageBasin) cBasin).getLid()); trd.setPfaf(lid);
FFMPVirtualGageBasinMetaData fvgmbd = ft FFMPVirtualGageBasinMetaData fvgmbd = ft
.getVirtualGageBasinMetaData(siteKey, .getVirtualGageBasinMetaData(siteKey, lid);
((FFMPVirtualGageBasin) cBasin).getLid());
FFMPBasinMetaData metabasin = ft.getBasin(siteKey, FFMPBasinMetaData metabasin = ft.getBasin(siteKey,
fvgmbd.getParentPfaf()); fvgmbd.getParentPfaf());
Long parentBasinPfaf = fvgmbd.getParentPfaf(); Long parentBasinPfaf = fvgmbd.getParentPfaf();
if (fvgmbd != null) { mouseOverText = metabasin.getBasinId() + "\n" + lid + "-"
+ fvgmbd.getName();
mouseOverText = metabasin.getBasinId() + "\n" if (!huc.equals(ALL)) {
+ fvgmbd.getLid() + "-" + fvgmbd.getName(); sb.append("-").append(fvgmbd.getName());
if (!huc.equals(ALL)) {
sb.append("-").append(fvgmbd.getName());
}
} }
trd.setTableCellData(0, trd.setTableCellData(0,
@ -412,29 +369,29 @@ public class FFMPDataGenerator {
|| (centeredAggregationKey != null)) { || (centeredAggregationKey != null)) {
if (!cBasin.getValues().isEmpty()) { if (!cBasin.getValues().isEmpty()) {
rate = ((FFMPVirtualGageBasin) cBasin) rate = vgBasin.getValue(paintRefTime);
.getValue(paintRefTime);
}
trd.setTableCellData(1, new FFMPTableCellData(FIELDS.RATE,
rate));
if (!cBasin.getValues().isEmpty()) {
if (sliderTime > 0.00) { if (sliderTime > 0.00) {
qpe = cBasin.getAccumValue(monitor.getQpeWindow() FFMPTimeWindow window = monitor.getQpeWindow();
.getAfterTime(), monitor.getQpeWindow() qpe = cBasin.getAccumValue(window.getAfterTime(),
.getBeforeTime(), expirationTime, isRate); window.getBeforeTime(), expirationTime,
isRate);
} else { } else {
qpe = 0.0f; qpe = 0.0f;
} }
} }
trd.setTableCellData(1, new FFMPTableCellData(FIELDS.RATE,
rate));
trd.setTableCellData(2, new FFMPTableCellData(FIELDS.QPE, trd.setTableCellData(2, new FFMPTableCellData(FIELDS.QPE,
qpe)); qpe));
if ((qpfBasin != null) if (qpfBasin != null) {
&& (qpfBasin.get(parentBasinPfaf) != null)) { FFMPBasin basin = qpfBasin.get(parentBasinPfaf);
qpf = qpfBasin.get(parentBasinPfaf).getAverageValue( if (basin != null) {
monitor.getQpfWindow().getAfterTime(), FFMPTimeWindow window = monitor.getQpfWindow();
monitor.getQpfWindow().getBeforeTime()); qpf = basin.getAverageValue(window.getAfterTime(),
window.getBeforeTime());
}
} }
trd.setTableCellData(3, new FFMPTableCellData(FIELDS.QPF, trd.setTableCellData(3, new FFMPTableCellData(FIELDS.QPF,
qpf)); qpf));
@ -442,108 +399,23 @@ public class FFMPDataGenerator {
// run over each guidance type // run over each guidance type
int i = 0; int i = 0;
for (String guidType : guidBasins.keySet()) { for (String guidType : guidBasins.keySet()) {
List<Long> pfafList = new ArrayList<Long>();
List<Long> forcedPfafs = new ArrayList<Long>();
guidance = Float.NaN; guidance = Float.NaN;
boolean forced = false;
Float diffValue = Float.NaN;
Float ratioValue = Float.NaN;
FFFGForceUtil forceUtil = forceUtils.get(guidType); FFFGForceUtil forceUtil = forceUtils.get(guidType);
forceUtil.setSliderTime(sliderTime); forceUtil.setSliderTime(sliderTime);
FFMPBasinData guidBasin = guidBasins.get(guidType); FFMPTableCellData guidCellData = getGuidanceCellData(
cBasin, domain, guidType, parentBasinPfaf);
if ((guidBasin != null) if (guidCellData == null) {
&& ((FFMPGuidanceBasin) guidBasin guidCellData = new FFMPTableCellData(
.get(parentBasinPfaf) != null)) { FIELDS.GUIDANCE, Float.NaN);
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));
} else { } else {
trd.setTableCellData(i + 4, new FFMPTableCellData( guidance = guidCellData.getValueAsFloat();
FIELDS.GUIDANCE, Float.NaN));
} }
trd.setTableCellData(i + 4, guidCellData);
float ratioValue = Float.NaN;
float diffValue = Float.NaN;
// If guidance is NaN then it cannot be > 0 // If guidance is NaN then it cannot be > 0
if (!qpe.isNaN() && (guidance > 0.0f)) { if (!qpe.isNaN() && (guidance > 0.0f)) {
ratioValue = FFMPUtils.getRatioValue(qpe, guidance); ratioValue = FFMPUtils.getRatioValue(qpe, guidance);
@ -567,162 +439,72 @@ public class FFMPDataGenerator {
displayName = getDisplayName(cBasin); displayName = getDisplayName(cBasin);
if (displayName != null) { if (displayName != null) {
String cbasinPfaf = cBasin.getPfaf().toString(); long cBasinPfaf = cBasin.getPfaf();
StringBuilder sb = new StringBuilder(cbasinPfaf); String cBasinPfafStr = Long.toString(cBasinPfaf);
StringBuilder sb = new StringBuilder(cBasinPfafStr);
sb.append("\n").append(displayName); sb.append("\n").append(displayName);
trd.setPfaf(cbasinPfaf); trd.setPfaf(cBasinPfafStr);
trd.setTableCellData(0, new FFMPTableCellData(rowField, trd.setTableCellData(0, new FFMPTableCellData(rowField,
displayName, sb.toString())); displayName, sb.toString()));
if (!isWorstCase || huc.equals(ALL) if (!isWorstCase || huc.equals(ALL)
|| (centeredAggregationKey != null)) { || (centeredAggregationKey != null)) {
if ((rateBasin != null) if (rateBasin != null) {
&& (rateBasin.get(cBasin.getPfaf()) != null)) { FFMPBasin basin = rateBasin.get(cBasinPfaf);
rate = rateBasin.get(cBasin.getPfaf()).getValue( if (basin != null) {
paintRefTime); rate = basin.getValue(paintRefTime);
}
} }
trd.setTableCellData(1, new FFMPTableCellData(FIELDS.RATE, trd.setTableCellData(1, new FFMPTableCellData(FIELDS.RATE,
rate)); rate));
if ((qpeBasin != null) if (qpeBasin != null) {
&& (qpeBasin.get(cBasin.getPfaf()) != null)) { FFMPBasin basin = qpeBasin.get(cBasinPfaf);
qpe = qpeBasin.get(cBasin.getPfaf()).getAccumValue( if (basin != null) {
monitor.getQpeWindow().getAfterTime(), FFMPTimeWindow window = monitor.getQpeWindow();
monitor.getQpeWindow().getBeforeTime(), qpe = basin.getAccumValue(window.getAfterTime(),
expirationTime, isRate); window.getBeforeTime(), expirationTime,
isRate);
}
} }
trd.setTableCellData(2, new FFMPTableCellData(FIELDS.QPE, trd.setTableCellData(2, new FFMPTableCellData(FIELDS.QPE,
qpe)); qpe));
if ((qpfBasin != null) if (qpfBasin != null) {
&& (qpfBasin.get(cBasin.getPfaf()) != 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, trd.setTableCellData(3, new FFMPTableCellData(FIELDS.QPF,
qpf)); qpf));
// run over each guidance type // run over each guidance type
int i = 0; int i = 0;
Float ratioValue;
Float diffValue;
for (String guidType : guidBasins.keySet()) { for (String guidType : guidBasins.keySet()) {
List<Long> pfafList = new ArrayList<Long>();
List<Long> forcedPfafs = new ArrayList<Long>();
guidance = Float.NaN; guidance = Float.NaN;
boolean forced = false;
ratioValue = Float.NaN;
diffValue = Float.NaN;
FFFGForceUtil forceUtil = forceUtils.get(guidType); FFFGForceUtil forceUtil = forceUtils.get(guidType);
forceUtil.setSliderTime(sliderTime); forceUtil.setSliderTime(sliderTime);
FFMPTableCellData guidCellData = getGuidanceCellData(
FFMPBasinData guidBasin = guidBasins.get(guidType); cBasin, domain, guidType, cBasinPfaf);
if (guidCellData == null) {
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 {
// check for forcing even if no data are available // check for forcing even if no data are available
guidance = getForcedAvg(forceUtil, domain, cBasin, guidance = getForcedAvg(forceUtil, domain, cBasin,
guidType); guidType);
if (!guidance.isNaN()) { boolean forced = !guidance.isNaN();
forced = true; guidCellData = new FFMPTableCellData(
} else { FIELDS.GUIDANCE, guidance, forced);
forced = false; } else {
} guidance = guidCellData.getValueAsFloat();
trd.setTableCellData(i + 4, new FFMPTableCellData(
FIELDS.GUIDANCE, guidance, forced));
} }
trd.setTableCellData(i + 4, guidCellData);
float ratioValue = Float.NaN;
float diffValue = Float.NaN;
// If guidance is NaN then it cannot be > 0 // If guidance is NaN then it cannot be > 0
if (!qpe.isNaN() && (guidance > 0.0f)) { if (!qpe.isNaN() && (guidance > 0.0f)) {
ratioValue = FFMPUtils.getRatioValue(qpe, guidance); 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, private float getForcedAvg(FFFGForceUtil forceUtil, String domain,
FFMPBasin cBasin, String guidType) { FFMPBasin cBasin, String guidType) {
FFFGDataMgr fdm = FFFGDataMgr.getInstance(); FFFGDataMgr fdm = FFFGDataMgr.getInstance();
@ -1127,17 +974,19 @@ public class FFMPDataGenerator {
*/ */
private FIELDS getBaseField() { private FIELDS getBaseField() {
String dataKey = resource.getDataKey();
ProductXML product = resource.getProduct();
Date tableTime = resource.getTableTime();
FIELDS field = null; FIELDS field = null;
String localHuc = null; String localHuc = null;
dman = FFFGDataMgr.getInstance();
FfmpTableConfigData ffmpTableCfgData = FfmpTableConfig.getInstance() FfmpTableConfigData ffmpTableCfgData = FfmpTableConfig.getInstance()
.getTableConfigData(siteKey); .getTableConfigData(siteKey);
String qpfType = ffmpTableCfgData.getQpfType(); String qpfType = ffmpTableCfgData.getQpfType();
ProductRunXML productRun = FFMPRunConfigurationManager.getInstance() ProductRunXML productRun = FFMPRunConfigurationManager.getInstance()
.getProduct(siteKey); .getProduct(siteKey);
String qpfSource = productRun.getQpfSources(product, qpfType).get(0) SourceXML qpfSource = productRun.getQpfSources(product, qpfType).get(0);
.getSourceName();
FFMPConfig config = FFMPConfig.getInstance(); FFMPConfig config = FFMPConfig.getInstance();
String includedCWAs = config.getFFMPConfigData().getIncludedCWAs(); String includedCWAs = config.getFFMPConfigData().getIncludedCWAs();
@ -1148,41 +997,33 @@ public class FFMPDataGenerator {
if (resource.isSplit()) { if (resource.isSplit()) {
// hack off the QPF duration for the table values of QPE (Split // hack off the QPF duration for the table values of QPE (Split
// Window) // Window)
double duration = FFMPSourceConfigurationManager.getInstance() double duration = qpfSource.getDurationHour();
.getSource(qpfSource).getDurationHour();
qpeTime = new Date( qpeTime = new Date(
(long) (qpeTime.getTime() - (duration * TimeUtil.MILLIS_PER_HOUR))); (long) (qpeTime.getTime() - (duration * TimeUtil.MILLIS_PER_HOUR)));
} }
monitor.setQpeWindow(new FFMPTimeWindow(tableTime, qpeTime)); monitor.setQpeWindow(new FFMPTimeWindow(tableTime, qpeTime));
if (isWorstCase || (centeredAggregationKey != null)) { if (isWorstCase || (centeredAggregationKey != null)) {
// make sure that "ALL" is loaded // make sure that "ALL" is loaded
localHuc = ALL; localHuc = ALL;
rateRecord = monitor.getRateRecord(product, siteKey, dataKey, } else {
product.getRate(), paintRefTime, localHuc, true); localHuc = huc;
qpeRecord = monitor.getQPERecord(product, siteKey, dataKey, }
product.getQpe(), tableTime, localHuc, true);
qpfRecord = monitor.getQPFRecord(product, siteKey, dataKey, null, FFMPRecord rateRecord = monitor.getRateRecord(product, siteKey,
paintRefTime, localHuc, true); dataKey, product.getRate(), paintRefTime, localHuc, true);
guidRecords = monitor.getGuidanceRecords(product, siteKey, FFMPRecord qpeRecord = monitor.getQPERecord(product, siteKey, dataKey,
tableTime, localHuc, true); 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, virtualRecord = monitor.getVirtualRecord(product, siteKey, dataKey,
product.getVirtual(), tableTime, localHuc, true); 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 { 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. * 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 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 18, 2013 1912 bsteffen Increase bulk requests to pypies.
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
* *
* </pre> * </pre>
* *
@ -96,7 +97,7 @@ public class FFMPDataLoader extends Thread {
private String dataKey = null; private String dataKey = null;
private ArrayList<String> hucsToLoad = null; private List<String> hucsToLoad = null;
private String wfo = null; private String wfo = null;
@ -109,8 +110,7 @@ public class FFMPDataLoader extends Thread {
private CountDownLatch latch; private CountDownLatch latch;
public FFMPDataLoader(FFMPResourceData resourceData, Date timeBack, public FFMPDataLoader(FFMPResourceData resourceData, Date timeBack,
Date mostRecentTime, LOADER_TYPE loadType, Date mostRecentTime, LOADER_TYPE loadType, List<String> hucsToLoad) {
ArrayList<String> hucsToLoad) {
this.product = resourceData.getProduct(); this.product = resourceData.getProduct();
this.siteKey = resourceData.siteKey; this.siteKey = resourceData.siteKey;
@ -172,9 +172,8 @@ public class FFMPDataLoader extends Thread {
.getSourceConfig(); .getSourceConfig();
ProductRunXML productRun = runner.getProduct(siteKey); ProductRunXML productRun = runner.getProduct(siteKey);
ArrayList<SourceXML> qpfSources = new ArrayList<SourceXML>(); List<SourceXML> qpfSources = new ArrayList<SourceXML>();
String layer = config.getFFMPConfigData().getLayer(); String layer = config.getFFMPConfigData().getLayer();
boolean isProductLoad = true;
String rateURI = null; String rateURI = null;
if (loadType != LOADER_TYPE.GENERAL) { if (loadType != LOADER_TYPE.GENERAL) {
@ -278,8 +277,8 @@ public class FFMPDataLoader extends Thread {
fireLoaderEvent(loadType, "Processing " + product.getRate(), fireLoaderEvent(loadType, "Processing " + product.getRate(),
isDone()); isDone());
for (String phuc : hucsToLoad) { for (String phuc : hucsToLoad) {
monitor.processUri(isProductLoad, rateURI, siteKey, monitor.processUri(rateURI, siteKey, product.getRate(),
product.getRate(), timeBack, phuc); timeBack, phuc);
} }
fireLoaderEvent(loadType, product.getRate(), isDone()); fireLoaderEvent(loadType, product.getRate(), isDone());
} }
@ -305,8 +304,8 @@ public class FFMPDataLoader extends Thread {
if (!qpeURIs.isEmpty()) { if (!qpeURIs.isEmpty()) {
for (String phuc : hucsToLoad) { for (String phuc : hucsToLoad) {
if (phuc.equals(layer) || phuc.equals(FFMPRecord.ALL)) { if (phuc.equals(layer) || phuc.equals(FFMPRecord.ALL)) {
monitor.processUris(qpeURIs, isProductLoad, siteKey, monitor.processUris(qpeURIs, siteKey, product.getQpe(),
product.getQpe(), timeBack, phuc); timeBack, phuc);
} }
} }
} }
@ -338,8 +337,8 @@ public class FFMPDataLoader extends Thread {
if (!qpfURIs.isEmpty()) { if (!qpfURIs.isEmpty()) {
for (String phuc : hucsToLoad) { for (String phuc : hucsToLoad) {
if (phuc.equals(layer) || phuc.equals(FFMPRecord.ALL)) { // old if (phuc.equals(layer) || phuc.equals(FFMPRecord.ALL)) { // old
monitor.processUris(qpfURIs, isProductLoad, monitor.processUris(qpfURIs, siteKey,
siteKey, product.getQpf(i), timeBack, phuc); product.getQpf(i), timeBack, phuc);
} }
} }
} }
@ -353,8 +352,8 @@ public class FFMPDataLoader extends Thread {
isDone()); isDone());
// process virtual all for all only, never uses cache files // process virtual all for all only, never uses cache files
if (!virtualURIs.isEmpty()) { if (!virtualURIs.isEmpty()) {
monitor.processUris(virtualURIs, isProductLoad, siteKey, monitor.processUris(virtualURIs, siteKey, product.getVirtual(),
product.getVirtual(), timeBack, FFMPRecord.ALL); timeBack, FFMPRecord.ALL);
} }
fireLoaderEvent(loadType, product.getVirtual(), isDone()); fireLoaderEvent(loadType, product.getVirtual(), isDone());
@ -373,7 +372,7 @@ public class FFMPDataLoader extends Thread {
"Processing " + guidSource.getSourceName(), "Processing " + guidSource.getSourceName(),
isDone()); isDone());
monitor.processUris(iguidURIs, isProductLoad, siteKey, monitor.processUris(iguidURIs, siteKey,
guidSource.getSourceName(), timeBack, guidSource.getSourceName(), timeBack,
FFMPRecord.ALL); FFMPRecord.ALL);

View file

@ -41,6 +41,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI; 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.DataTime;
import com.raytheon.uf.common.time.util.ITimer; import com.raytheon.uf.common.time.util.ITimer;
import com.raytheon.uf.common.time.util.TimeUtil; 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.DrawableString;
import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
@ -164,6 +166,7 @@ import com.vividsolutions.jts.geom.Point;
* time matcher. * time matcher.
* Apr 25, 2013 1954 bsteffen Skip extent checking for FFMP shape * Apr 25, 2013 1954 bsteffen Skip extent checking for FFMP shape
* generation. * generation.
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
* *
* </pre> * </pre>
* *
@ -348,9 +351,6 @@ public class FFMPResource extends
// complete reset // complete reset
public boolean isQuery = true; public boolean isQuery = true;
/** the last extent **/
private PixelExtent lastExtent;
/** /**
* FFMP basin table dialog. * FFMP basin table dialog.
*/ */
@ -458,14 +458,15 @@ public class FFMPResource extends
} else { } else {
previousMostRecentTime = tok.get(0); previousMostRecentTime = tok.get(0);
} }
Date refTime = ffmpRec.getDataTime().getRefTime();
updateTimeOrderedkeys(ffmpRec.getDataTime().getRefTime()); updateTimeOrderedkeys(refTime);
if (getResourceData().tableLoad) { if (getResourceData().tableLoad) {
setTableTime(); setTableTime();
} }
setRecord(ffmpRec); resourceData.populateRecord(ffmpRec);
statusHandler.handle(Priority.INFO, "Updating : Previous: " statusHandler.handle(Priority.INFO, "Updating : Previous: "
+ previousMostRecentTime + " New: " + previousMostRecentTime + " New: "
@ -474,8 +475,7 @@ public class FFMPResource extends
if (getResourceData().tableLoad) { if (getResourceData().tableLoad) {
if (loader == null) { if (loader == null) {
startLoader(previousMostRecentTime, ffmpRec startLoader(previousMostRecentTime, refTime,
.getDataTime().getRefTime(),
LOADER_TYPE.GENERAL); LOADER_TYPE.GENERAL);
} else { } else {
try { try {
@ -485,8 +485,7 @@ public class FFMPResource extends
e.getLocalizedMessage(), e); e.getLocalizedMessage(), e);
} }
startLoader(previousMostRecentTime, ffmpRec startLoader(previousMostRecentTime, refTime,
.getDataTime().getRefTime(),
LOADER_TYPE.GENERAL); LOADER_TYPE.GENERAL);
try { try {
loader.waitFor(); loader.waitFor();
@ -496,7 +495,7 @@ public class FFMPResource extends
} }
} }
purge(ffmpRec.getDataTime().getRefTime()); purge(refTime);
} }
resetRecords(); resetRecords();
@ -1062,16 +1061,6 @@ public class FFMPResource extends
return null; return null;
} }
/**
* Set the Record straight.
*
* @throws VizException
*
*/
protected void setRecord(FFMPRecord ffmpRecord) throws VizException {
getResourceData().populateRecord(getProduct(), ffmpRecord, getHuc());
}
@Override @Override
protected void disposeInternal() { protected void disposeInternal() {
IDisplayPaneContainer container = getResourceContainer(); IDisplayPaneContainer container = getResourceContainer();
@ -1152,7 +1141,7 @@ public class FFMPResource extends
} }
// DR 14522: use Display.getDefault().asyncExec() for GUI thread. // DR 14522: use Display.getDefault().asyncExec() for GUI thread.
org.eclipse.swt.widgets.Display.getDefault().asyncExec(new Runnable() { Display.getDefault().asyncExec(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -1208,237 +1197,208 @@ public class FFMPResource extends
@Override @Override
protected void paintInternal(IGraphicsTarget aTarget, protected void paintInternal(IGraphicsTarget aTarget,
PaintProperties paintProps) throws VizException { PaintProperties paintProps) throws VizException {
if (getTimeOrderedKeys() == null || getTimeOrderedKeys().isEmpty()
|| getDomains() == null) {
return;
}
// clear the screen
aTarget.clearClippingPlane(); aTarget.clearClippingPlane();
if ((getTimeOrderedKeys() != null) && (getTimeOrderedKeys().size() > 0) paintTime = paintProps.getDataTime();
&& (getDomains() != null)) { paintProps.setAlpha(getCapability(ImagingCapability.class).getAlpha());
paintTime = paintProps.getDataTime(); FFMPDrawable drawable = null;
paintProps.setAlpha(getCapability(ImagingCapability.class)
.getAlpha());
boolean isShaded = true; if (paintTime != null) {
FFMPDrawable drawable = null; if (loader != null && !loader.isDone()
&& loader.loadType == LOADER_TYPE.GENERAL) {
return;
}
if (!drawables.containsKey(paintTime)) {
if (paintTime != null) { drawable = new FFMPDrawable(getDomains());
if (loader != null && !loader.isDone() drawables.put(paintTime, drawable);
&& loader.loadType == LOADER_TYPE.GENERAL) { } else {
return; // we found it!
} drawable = drawables.get(paintTime);
if (!drawables.containsKey(paintTime)) { // System.out.println("Found the drawable");
drawable = new FFMPDrawable(getDomains()); if (!paintTime.equals(drawable.getTime())) {
drawables.put(paintTime, drawable); drawable.setDirty(true);
} 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 (getResourceData().tableLoad // auto refresh state
&& !paintTime.getRefTime().equals(getMostRecentTime())) { if (isQuery) {
setMostRecentTime(paintTime.getRefTime()); drawable.setDirty(true);
setTableTime(); }
// if (isLinkToFrame && loader != null && loader.loadType != }
// LOADER_TYPE.GENERAL) {
if (isLinkToFrame) { if (getResourceData().tableLoad
updateDialog(); && !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 { } else {
if (getResourceData().getMonitor().ffmpSplash != null) { if (lowestCenter == FFMPRecord.ZOOM.AGGREGATE) {
getResourceData().getMonitor().ffmpSplash.close(); for (Long pfaf : monitor.getTemplates(getSiteKey())
getResourceData().getMonitor().ffmpSplash = null; .getAllAggregatePfafs(centeredAggregationKey,
} getHuc())) {
} List<FFMPVirtualGageBasinMetaData> fvgmdList = monitor
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
.getTemplates(getSiteKey()) .getTemplates(getSiteKey())
.getMap(getSiteKey(), domain.getCwa(), getHuc()) .getVirtualGageBasinMetaData(getSiteKey(),
.keySet()) { null, pfaf);
ArrayList<FFMPVirtualGageBasinMetaData> fvgmdList = monitor if (fvgmdList != null) {
.getTemplates(getSiteKey()) for (FFMPVirtualGageBasinMetaData fvgmd : fvgmdList) {
.getVirtualGageBasinMetaData(getSiteKey(), vgbDrawables.put(
domain.getCwa(), pfaf); fvgmd.getLid(),
if (fvgmdList != null) { getPixelCoverage(fvgmd.getCoordinate(),
for (FFMPVirtualGageBasinMetaData fvgmd : fvgmdList) { paintProps));
vgbDrawables.put(
fvgmd.getLid(),
getPixelCoverage(
fvgmd.getCoordinate(),
paintProps));
}
} }
} }
} }
} else { } else {
if (lowestCenter == FFMPRecord.ZOOM.AGGREGATE) { for (DomainXML domain : getDomains()) {
for (Long pfaf : monitor.getTemplates(getSiteKey()) for (Entry<String, FFMPVirtualGageBasinMetaData> entry : monitor
.getAllAggregatePfafs(centeredAggregationKey, .getTemplates(getSiteKey())
getHuc())) { .getVirtualGageBasins(getSiteKey(),
ArrayList<FFMPVirtualGageBasinMetaData> fvgmdList = monitor domain.getCwa()).entrySet()) {
.getTemplates(getSiteKey()) if (entry.getValue() != null) {
.getVirtualGageBasinMetaData(getSiteKey(), vgbDrawables.put(
null, pfaf); entry.getKey(),
if (fvgmdList != null) { getPixelCoverage(entry.getValue()
for (FFMPVirtualGageBasinMetaData fvgmd : fvgmdList) { .getCoordinate(), paintProps));
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));
}
} }
} }
} }
} }
paintCenter(aTarget, paintProps);
paintVGBs(aTarget, paintProps);
} }
// draw or clear the colorMap paintCenter(aTarget, paintProps);
if (!isFfmpDataToggle()) { // clear if ffmpDataToggle is false paintVGBs(aTarget, paintProps);
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;
} }
// 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 * @throws VizException
*/ */
private void paintUpAndDownStream(IGraphicsTarget target, private void paintUpAndDownStream(IGraphicsTarget target,
PaintProperties paintProps, boolean isShaded) throws VizException { PaintProperties paintProps) throws VizException {
if (basinTraceColor == null) { if (basinTraceColor == null) {
basinTraceColor = getCapability(ColorableCapability.class) basinTraceColor = getCapability(ColorableCapability.class)
@ -1495,7 +1455,7 @@ public class FFMPResource extends
} }
if (isShowStream() && (streamShadedShape != null) if (isShowStream() && (streamShadedShape != null)
&& streamShadedShape.isDrawable() && isShaded) { && streamShadedShape.isDrawable()) {
target.drawShadedShape(streamShadedShape, paintProps.getAlpha()); target.drawShadedShape(streamShadedShape, paintProps.getAlpha());
} }
if (isShowStream() && (streamOutlineShape != null) if (isShowStream() && (streamOutlineShape != null)
@ -1824,10 +1784,8 @@ public class FFMPResource extends
if (stream.equals(FFMPRecord.CLICK_TYPE.TREND)) { if (stream.equals(FFMPRecord.CLICK_TYPE.TREND)) {
monitor.basinTrend(newPfaf); monitor.basinTrend(newPfaf);
} } else {
// only re-draw the screen for UP/DOWN
// only re-draw the screen for UP/DOWN
if (!stream.equals(FFMPRecord.CLICK_TYPE.TREND)) {
nextStreamPfaf = newPfaf; nextStreamPfaf = newPfaf;
dirty(); dirty();
} }
@ -2101,29 +2059,16 @@ public class FFMPResource extends
*/ */
private void drawSquare(PixelCoverage pc, IGraphicsTarget target) private void drawSquare(PixelCoverage pc, IGraphicsTarget target)
throws VizException { throws VizException {
DrawableLine line = new DrawableLine();
// target.drawLine(lines) line.lineStyle = getCapability(OutlineCapability.class).getLineStyle();
target.drawLine(pc.getLl().x, pc.getLl().y, 0.0, pc.getUl().x, pc line.width = getCapability(OutlineCapability.class).getOutlineWidth();
.getUl().y, 0.0, getCapability(ColorableCapability.class) line.basics.color = getCapability(ColorableCapability.class).getColor();
.getColor(), getCapability(OutlineCapability.class) line.addPoint(pc.getLl().x, pc.getLl().y);
.getOutlineWidth(), getCapability(OutlineCapability.class) line.addPoint(pc.getUl().x, pc.getUl().y);
.getLineStyle()); line.addPoint(pc.getUr().x, pc.getUr().y);
target.drawLine(pc.getUl().x, pc.getUl().y, 0.0, pc.getUr().x, pc line.addPoint(pc.getLr().x, pc.getLr().y);
.getUr().y, 0.0, getCapability(ColorableCapability.class) line.addPoint(pc.getLl().x, pc.getLl().y);
.getColor(), getCapability(OutlineCapability.class) target.drawLine(line);
.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());
} }
/** /**
@ -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 * 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 class FFMPDataRetrievalJob extends Job {
private static final int QUEUE_LIMIT = 1; private static final int QUEUE_LIMIT = 1;
@ -2420,29 +2298,25 @@ public class FFMPResource extends
IGraphicsTarget target; IGraphicsTarget target;
boolean shaded;
FFMPDrawable drawable; FFMPDrawable drawable;
DataTime time; DataTime time;
Request(IGraphicsTarget target, boolean shaded, Request(IGraphicsTarget target, FFMPDrawable drawable, DataTime time) {
FFMPDrawable drawable, DataTime time) {
this.target = target; this.target = target;
this.shaded = shaded;
this.drawable = drawable; this.drawable = drawable;
this.time = time; this.time = time;
} }
} }
public void request(IGraphicsTarget target, boolean shaded, public void request(IGraphicsTarget target, FFMPDrawable drawable,
FFMPDrawable drawable, DataTime time) { DataTime time) {
if (drawable != null) { if (drawable != null) {
if (requestQueue.size() == QUEUE_LIMIT) { if (requestQueue.size() == QUEUE_LIMIT) {
requestQueue.poll(); requestQueue.poll();
} }
Request req = new Request(target, shaded, drawable, Request req = new Request(target, drawable,
time); time);
requestQueue.add(req); requestQueue.add(req);
this.schedule(); this.schedule();
@ -2867,10 +2741,8 @@ public class FFMPResource extends
// create the frames/shaded shapes here // create the frames/shaded shapes here
localWireframeShape = req.target.createWireframeShape(false, localWireframeShape = req.target.createWireframeShape(false,
descriptor, 0.0f); descriptor, 0.0f);
if (req.shaded) { localShadedShape = req.target.createShadedShape(false,
localShadedShape = req.target.createShadedShape(false, descriptor.getGridGeometry(), true);
descriptor.getGridGeometry(), true);
}
JTSCompiler jtsCompiler2 = new JTSCompiler(localShadedShape, JTSCompiler jtsCompiler2 = new JTSCompiler(localShadedShape,
localWireframeShape, descriptor, PointStyle.CROSS); localWireframeShape, descriptor, PointStyle.CROSS);
@ -2916,7 +2788,7 @@ public class FFMPResource extends
} }
} }
if (req.shaded && (localShadedShape != null)) { if (localShadedShape != null) {
localShadedShape.compile(); localShadedShape.compile();
localShadedShape.setFillPattern(FFMPUtils.STREAM_FILL); localShadedShape.setFillPattern(FFMPUtils.STREAM_FILL);
if (streamShadedShape != null) { if (streamShadedShape != null) {
@ -3633,7 +3505,7 @@ public class FFMPResource extends
* *
* @return list of Domains * @return list of Domains
*/ */
public ArrayList<DomainXML> getDomains() { public List<DomainXML> getDomains() {
return getResourceData().getDomains(); return getResourceData().getDomains();
} }
@ -3718,11 +3590,7 @@ public class FFMPResource extends
SortedSet<Date> keys = monitor.getAvailableUris(getSiteKey(), SortedSet<Date> keys = monitor.getAvailableUris(getSiteKey(),
getDataKey(), getPrimarySource(), oldestTime).keySet(); getDataKey(), getPrimarySource(), oldestTime).keySet();
timeOrderedKeys.addAll(keys);
for (Date date : keys) {
timeOrderedKeys.add(date);
}
} catch (VizException e) { } catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"No available times for the FFMPResource"); "No available times for the FFMPResource");
@ -4180,7 +4048,7 @@ public class FFMPResource extends
*/ */
public FFMPDrawable getDrawable(DataTime time) { public FFMPDrawable getDrawable(DataTime time) {
FFMPDrawable drawable = null; FFMPDrawable drawable = null;
if (drawables != null) { if (drawables != null && time != null) {
drawable = drawables.get(time); drawable = drawables.get(time);
} }
return drawable; return drawable;

View file

@ -20,7 +20,6 @@
package com.raytheon.uf.viz.monitor.ffmp.ui.rsc; package com.raytheon.uf.viz.monitor.ffmp.ui.rsc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.NavigableMap; 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;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord.FIELDS; import com.raytheon.uf.common.dataplugin.ffmp.FFMPRecord.FIELDS;
import com.raytheon.uf.common.dataplugin.ffmp.FFMPTemplates; 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.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.FFMPRunConfigurationManager;
import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager.SOURCE_TYPE; import com.raytheon.uf.common.monitor.config.FFMPSourceConfigurationManager.SOURCE_TYPE;
import com.raytheon.uf.common.monitor.xml.DomainXML; 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.DataTime;
import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.core.exception.VizException; 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.AbstractNameGenerator;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource; 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 10, 2013 1584 mpduff Add performance logging.
* Feb 28, 2013 1729 dhladky Got rid of thread sleeps * Feb 28, 2013 1729 dhladky Got rid of thread sleeps
* Mar 6, 2013 1769 dhladky Changed threading to use count down latch. * Mar 6, 2013 1769 dhladky Changed threading to use count down latch.
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
* *
* </pre> * </pre>
* *
@ -134,7 +131,7 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
protected FFMPMonitor monitor = null; protected FFMPMonitor monitor = null;
/** County Warning Area (Domain) for which to display **/ /** County Warning Area (Domain) for which to display **/
protected ArrayList<DomainXML> domains = null; protected List<DomainXML> domains = null;
/** Product Displayed **/ /** Product Displayed **/
private ProductXML product = null; private ProductXML product = null;
@ -177,10 +174,7 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
protected AbstractVizResource<?, ?> constructResource( protected AbstractVizResource<?, ?> constructResource(
LoadProperties loadProperties, PluginDataObject[] objects) LoadProperties loadProperties, PluginDataObject[] objects)
throws VizException { throws VizException {
IPathManager pm = PathManagerFactory.getPathManager(); this.wfo = LocalizationManager.getContextName(LocalizationLevel.SITE);
LocalizationContext context = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
this.wfo = context.getContextName();
FFMPMonitor monitor = getMonitor(); FFMPMonitor monitor = getMonitor();
monitor.setWfo(wfo); monitor.setWfo(wfo);
this.field = monitor.getField(sourceName); this.field = monitor.getField(sourceName);
@ -192,8 +186,8 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
DataTime[] availableTimes = this.getAvailableTimes(); DataTime[] availableTimes = this.getAvailableTimes();
// no data available; // no data available;
if (availableTimes.length != 0) { if (availableTimes.length != 0) {
if (getMonitor().getProductXML(sourceName) != null) { product = monitor.getProductXML(sourceName);
setProduct(getMonitor().getProductXML(sourceName)); if (product != null) {
monitor.launchSplash(siteKey); monitor.launchSplash(siteKey);
FFMPTemplates templates = monitor.getTemplates(siteKey); FFMPTemplates templates = monitor.getTemplates(siteKey);
@ -227,11 +221,12 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
FFMPConfig ffmpConfig = monitor.getConfig(); FFMPConfig ffmpConfig = monitor.getConfig();
FFMPConfigBasinXML cfgBasinXML = ffmpConfig.getFFMPConfigData(); FFMPConfigBasinXML cfgBasinXML = ffmpConfig.getFFMPConfigData();
String[] sdomains = cfgBasinXML.getIncludedCWAs().split(","); String[] sdomains = cfgBasinXML.getIncludedCWAs().split(",");
ArrayList<DomainXML> defaults = new ArrayList<DomainXML>(); List<DomainXML> defaults = new ArrayList<DomainXML>(
sdomains.length);
for (String domain : sdomains) { for (String domain : sdomains) {
if (domain.length() == 0) { if (domain.isEmpty()) {
defaults.add(monitor.getRunConfig().getDomain(wfo)); defaults.add(monitor.getRunConfig().getDomain(wfo));
break; break;
} }
@ -247,26 +242,18 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
this.domains = defaults; this.domains = defaults;
DataTime mostRecentTime = availableTimes[availableTimes.length - 1]; Date mostRecentTime = availableTimes[availableTimes.length - 1]
.getRefTime();
this.timeBack = new Date( this.timeBack = new Date(
(long) (mostRecentTime.getRefTime().getTime() - (cfgBasinXML (long) (mostRecentTime.getTime() - (cfgBasinXML
.getTimeFrame() * TimeUtil.MILLIS_PER_HOUR))); .getTimeFrame() * TimeUtil.MILLIS_PER_HOUR)));
ArrayList<String> hucsToLoad = monitor.getTemplates(siteKey) List<String> hucsToLoad = monitor.getTemplates(siteKey)
.getTemplateMgr().getHucLevels(); .getTemplateMgr().getHucLevels();
// goes back X hours and pre populates the Data Hashes // goes back X hours and pre populates the Data Hashes
FFMPDataLoader loader = new FFMPDataLoader(this, timeBack, FFMPDataLoader loader = new FFMPDataLoader(this, timeBack,
mostRecentTime.getRefTime(), LOADER_TYPE.INITIAL, mostRecentTime, LOADER_TYPE.INITIAL,
hucsToLoad); hucsToLoad);
loader.start(); loader.run();
// 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);
}
} else { } else {
/* /*
* This appears completely un-orthodox for anything in D2D. But * 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() NavigableMap<Date, List<String>> sourceURIs = getMonitor()
.getAvailableUris(siteKey, dataKey, sourceName, .getAvailableUris(siteKey, dataKey, sourceName,
standAloneTime); standAloneTime);
getMonitor().processUris(sourceURIs, false, siteKey, monitor.processUris(sourceURIs, siteKey,
sourceName, standAloneTime, FFMPRecord.ALL); sourceName, standAloneTime, FFMPRecord.ALL);
} }
} }
@ -405,50 +392,14 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
* *
* @param record * @param record
*/ */
public void populateRecord(ProductXML product, FFMPRecord precord, public void populateRecord(FFMPRecord precord)
String phuc) throws VizException { throws VizException {
try { try {
boolean isProductLoad = false; getMonitor().populateFFMPRecord(siteKey, precord,
if (product != null) { precord.getSourceName(), huc);
isProductLoad = true;
}
getMonitor().populateFFMPRecord(isProductLoad, siteKey, precord,
precord.getSourceName(), phuc);
} catch (Exception e) { } catch (Exception e) {
throw new VizException("Failed to populate ffmp record " throw new VizException("Failed to populate ffmp record "
+ precord.getDataURI() + " for huc " + phuc); + precord.getDataURI() + " for huc " + huc);
}
}
/**
* 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);
} }
} }
@ -488,7 +439,7 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
this.domains = domains; this.domains = domains;
} }
public ArrayList<DomainXML> getDomains() { public List<DomainXML> getDomains() {
return domains; return domains;
} }
@ -548,7 +499,7 @@ public class FFMPResourceData extends AbstractRequestableResourceData {
* @param pfield * @param pfield
* @return * @return
*/ */
public ArrayList<String> getSourceName(FIELDS pfield) { public List<String> getSourceName(FIELDS pfield) {
ArrayList<String> sourceNames = null; ArrayList<String> sourceNames = null;
ProductXML product = getProduct(); ProductXML product = getProduct();
ProductRunXML productRun = FFMPRunConfigurationManager.getInstance() 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 * Apr 22, 2013 1912 bsteffen optimized the creation of NavigableMaps
* from aggregate records and delayed * from aggregate records and delayed
* TreeMap creation to the tertiary loader. * TreeMap creation to the tertiary loader.
* Apr 26, 2013 1954 bsteffen Minor code cleanup throughout FFMP.
* *
* </pre> * </pre>
* *
@ -174,19 +175,12 @@ public class FFMPBasin implements ISerializableObject, Cloneable {
synchronized (values) { 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; float factor = 0.0f;
for (Date key : keys) { for (Entry<Date, Float> entry : values.subMap(beforeDate,
Date tdate = key; false, afterDate, false).entrySet()) {
float val = values.get(key); Date tdate = entry.getKey();
float val = entry.getValue();
if (!rate) { if (!rate) {
@ -214,7 +208,7 @@ public class FFMPBasin implements ISerializableObject, Cloneable {
} }
dvalue += val; dvalue += val;
prevDate = key; prevDate = tdate;
} }
} }
} }

View file

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