diff --git a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java index ae54a36011..2e743b1a99 100644 --- a/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java +++ b/cave/com.raytheon.uf.viz.d2d.core/src/com/raytheon/uf/viz/d2d/core/time/D2DTimeMatcher.java @@ -42,6 +42,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.viz.core.AbstractTimeMatcher; +import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.VizConstants; import com.raytheon.uf.viz.core.comm.PerspectiveSpecificLoadProperties; @@ -192,8 +193,10 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { @Override public void redoTimeMatching(IDescriptor descriptor) throws VizException { synchronized (this) { - if (timeMatchBasis != null && ! validateTimeMatchBasis(descriptor.getResourceList())) - timeMatchBasis = null; + if (timeMatchBasis != null && timeMatchBasis.getDescriptor() == descriptor && + ! validateTimeMatchBasis(descriptor)) { + changeTimeMatchBasis(null); + } if (timeMatchBasis != null) { IDescriptor tmDescriptor = timeMatchBasis.getDescriptor(); if (tmDescriptor != null && tmDescriptor != descriptor) { @@ -993,6 +996,33 @@ public class D2DTimeMatcher extends AbstractTimeMatcher { configFactory.resetMultiload(); } + private boolean validateTimeMatchBasis(IDescriptor descriptor ) { + /* + * If a resource is shared by multiple panels (this can be the case with + * tools, at least), then it is necessary to search all of them as + * resource.descriptor() may not contain resource. TODO: Don't allow + * this condition to occur? + */ + IRenderableDisplay display = descriptor.getRenderableDisplay(); + IDisplayPaneContainer container = display != null ? + display.getContainer() : null; + if (container != null) { + for (IDisplayPane pane : container.getDisplayPanes()) { + IRenderableDisplay paneDisplay = pane.getRenderableDisplay(); + IDescriptor paneDescriptor = paneDisplay != null ? + paneDisplay.getDescriptor() : null; + if (paneDescriptor != null + && validateTimeMatchBasis(paneDescriptor + .getResourceList())) { + return true; + } + } + } else { + return validateTimeMatchBasis(descriptor.getResourceList()); + } + return false; + } + private boolean validateTimeMatchBasis(ResourceList list) { for (ResourcePair rp : list) { AbstractVizResource rsc = rp.getResource(); diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java index 62730bd507..7d9332ce12 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java @@ -715,7 +715,7 @@ public class FFMPMonitor extends ResourceMonitor { FFMPRecord record = siteDataMap.get(siteKey).getSourceData(sourceName) .getRecord(); - if ((record != null) && (record.getBasinData().getBasins().size() > 0)) { + if ((record != null) && (record.getBasinData().hasAnyBasins())) { SourceXML sourceXML = getSourceConfig().getSource(sourceName); diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataGenerator.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataGenerator.java index 81f53c0b40..5567528acd 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataGenerator.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPDataGenerator.java @@ -277,7 +277,7 @@ public class FFMPDataGenerator { statusHandler.handle(Priority.PROBLEM, - "Couldn't create table row", e); + "Couldn't create table row", e); } } } @@ -414,14 +414,14 @@ public class FFMPDataGenerator { try { if (rateRecord != null) { rateBasin = rateRecord.getBasinData(); - if (!rateBasin.getBasins().isEmpty()) { + if (rateBasin.hasAnyBasins()) { field = FIELDS.RATE; baseRec = rateRecord; } } if (qpeRecord != null) { qpeBasin = qpeRecord.getBasinData(); - if (!qpeBasin.getBasins().isEmpty()) { + if (qpeBasin.hasAnyBasins()) { field = FIELDS.QPE; if (baseRec == null) { diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResourceData.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResourceData.java index 7eebbba5b7..01ea33440b 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResourceData.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResourceData.java @@ -32,6 +32,7 @@ import javax.xml.bind.annotation.XmlType; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; import com.raytheon.uf.common.dataplugin.PluginDataObject; @@ -95,6 +96,12 @@ public class FFMPResourceData extends AbstractRequestableResourceData { /** Performance log entry prefix */ private static final String prefix = "FFMP ResourceData:"; + /** Number of hours back from the most recent time to load data for **/ + private static final int HOURS_BACK = 24; + + /** Number of hours a background data job should request data for **/ + private static final int LOAD_INCREMENT = 1; + /** Performance logger */ private final IPerformanceStatusHandler perfLog = PerformanceStatus .getHandler(prefix); @@ -227,14 +234,52 @@ public class FFMPResourceData extends AbstractRequestableResourceData { initialJob.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { - Date backgroundStartTime = new Date(mostRecentTime - .getTime() - (24 * TimeUtil.MILLIS_PER_HOUR)); - BackgroundLoadJob backgroundJob = new BackgroundLoadJob( - "Background FFMP Load", FFMPResourceData.this, - backgroundStartTime, timeBack, onlyAllHuc); - backgroundJob.setPreloadAvailableUris(true); - backgroundJob.schedule(); + // step back in time in increments and + // load the data in chunks all the way + // back to 24 hours + // before the current time + Date farthestBack = new Date(mostRecentTime.getTime() + - (HOURS_BACK * TimeUtil.MILLIS_PER_HOUR)); + int hourBack = (int) configTimeFrame; + Date loadedUpTo = new Date(timeBack.getTime()); + BackgroundLoadJob firstJob = null; + Job previousJob = null; + while (loadedUpTo.after(farthestBack)) { + Date startTime = new Date( + loadedUpTo.getTime() + - (LOAD_INCREMENT * TimeUtil.MILLIS_PER_HOUR)); + hourBack += LOAD_INCREMENT; + if (startTime.before(farthestBack)) { + startTime = farthestBack; + hourBack = HOURS_BACK; + } + String jobName = "FFMP loading to hr " + hourBack; + if (previousJob == null) { + firstJob = new BackgroundLoadJob(jobName, + FFMPResourceData.this, startTime, + loadedUpTo, onlyAllHuc); + firstJob.setPreloadAvailableUris(true); + previousJob = firstJob; + } else { + final BackgroundLoadJob nextJob = new BackgroundLoadJob( + jobName, FFMPResourceData.this, + startTime, loadedUpTo, onlyAllHuc); + nextJob.setPreloadAvailableUris(true); + previousJob + .addJobChangeListener(new JobChangeAdapter() { + @Override + public void done( + IJobChangeEvent event) { + nextJob.schedule(); + } + }); + previousJob = nextJob; + } + + loadedUpTo = startTime; + } + firstJob.schedule(); } }); initialJob.schedule(); diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java index c379b4e857..5ea9c066f0 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/db/dao/GFEDao.java @@ -1130,7 +1130,7 @@ public class GFEDao extends DefaultPluginDao { DatabaseQuery query = new DatabaseQuery(this.daoClass); query.addQueryParam("parmId.dbId.siteId", dbId.getSiteId(), QueryOperand.EQUALS); - query.addQueryParam("parmId.dbId.format", dbId.getFormat(), + query.addQueryParam("parmId.dbId.dbType", dbId.getDbType(), QueryOperand.EQUALS); query.addQueryParam("parmId.dbId.modelName", dbId.getModelName(), QueryOperand.EQUALS); diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasinData.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasinData.java index bc5f8caa07..cc32ea8dee 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasinData.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/FFMPBasinData.java @@ -214,11 +214,11 @@ public class FFMPBasinData implements ISerializableObject { * @return */ public float getAverageValue(ArrayList pfaf_ids, Date date) { - float tvalue = 0.0f; int i = 0; - for (Long pfaf : pfaf_ids) { - FFMPBasin basin = getBasins().get(pfaf); + Map localBasins = getBasins(); + for (long pfaf : pfaf_ids) { + FFMPBasin basin = localBasins.get(pfaf); if (basin != null) { tvalue += basin.getValue(date); i++; @@ -295,7 +295,6 @@ public class FFMPBasinData implements ISerializableObject { */ public float getAccumAverageValue(List pfaf_ids, Date beforeDate, Date afterDate, long expirationTime, boolean rate) { - float tvalue = 0.0f; int i = 0; Map localBasins = getBasins(); @@ -321,7 +320,6 @@ public class FFMPBasinData implements ISerializableObject { */ public float getMaxValue(ArrayList pfaf_ids, Date beforeDate, Date afterDate) { - float tvalue = 0.0f; Map localBasins = getBasins(); for (Long pfaf : pfaf_ids) { @@ -690,7 +688,6 @@ public class FFMPBasinData implements ISerializableObject { * @param times */ public void populate(List times) { - if (mapFactory == null) { mapFactory = new BasinMapFactory(Collections.reverseOrder(), getBasins().size());