From bce9e0595c47bee79082ebf0c3f73bc93d89b85a Mon Sep 17 00:00:00 2001 From: Matt Nash Date: Wed, 3 Sep 2014 14:11:15 -0500 Subject: [PATCH] Omaha #3170 add data times to ffmp geometries being returned, also aggregate data as it is more useful that way Former-commit-id: 118d811eee44c43f780b57587e9910cbfdb412fe [formerly dd691896f03ba16d683a284a26b8ef923e364834] Former-commit-id: 980d7bf5ad78815059728c7d52202999b8aa7aff --- .../ffmp/dataaccess/FFMPGeometryFactory.java | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/dataaccess/FFMPGeometryFactory.java b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/dataaccess/FFMPGeometryFactory.java index 6b250e369f..725ff5ae7d 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/dataaccess/FFMPGeometryFactory.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.ffmp/src/com/raytheon/uf/common/dataplugin/ffmp/dataaccess/FFMPGeometryFactory.java @@ -20,6 +20,7 @@ package com.raytheon.uf.common.dataplugin.ffmp.dataaccess; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -52,6 +53,7 @@ import com.raytheon.uf.common.monitor.xml.SourceXML; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.TimeRange; import com.vividsolutions.jts.geom.Geometry; @@ -121,22 +123,26 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory { List> results = dbQueryResponse.getResults(); Map cache = new HashMap(); FFMPRecord record = null; - TimeRange range = new TimeRange(); + Date start = new Date(Long.MAX_VALUE); + Date end = new Date(0); + for (Map map : results) { for (Map.Entry es : map.entrySet()) { FFMPRecord rec = (FFMPRecord) es.getValue(); - // Adding all of the basin data to a single record so that we - // can get the accumulated values from that record + /* + * Adding all of the basin data to a single record so that we + * can get the accumulated values from that record + */ if (record == null) { record = rec; } // building a time range of the earliest FFMP time (based on // each record) to the latest FFMP time (based on each record) - if (range.getStart().after(rec.getDataTime().getRefTime())) { - range.setStart(rec.getDataTime().getRefTime()); + if (start.after(rec.getDataTime().getRefTime())) { + start = rec.getDataTime().getRefTime(); } - if (range.getEnd().before(rec.getDataTime().getRefTime())) { - range.setEnd(rec.getDataTime().getRefTime()); + if (end.before(rec.getDataTime().getRefTime())) { + end = rec.getDataTime().getRefTime(); } try { @@ -147,11 +153,11 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory { + rec.toString(), e); } - // loop over each pfaf id in the current record (rec) we are - // iterating. - // Add that basin data to the record that we are keeping around - // (record) - // to use to get the accumulated value. + /* + * loop over each pfaf id in the current record (rec) we are + * iterating. Add that basin data to the record that we are + * keeping around (record) to use to get the accumulated value. + */ for (Long pfaf : rec.getBasinData().getPfafIds()) { // setValue is a misnomer here, it is actually an add record.getBasinData() @@ -162,11 +168,13 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory { } } - // now that we have all the basin data in a single record (record), we - // can use the methods on the FFMPRecord class to get the accumulated - // value in the case of a non-guidance basin + /* + * now that we have all the basin data in a single record (record), we + * can use the methods on the FFMPRecord class to get the accumulated + * value in the case of a non-guidance basin + */ try { - cache = makeGeometryData(record, request, cache, range); + cache = makeGeometryData(record, request, cache, start, end); } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, "Unable to create the geoemtry data from the records.", e); @@ -226,7 +234,7 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory { */ private Map makeGeometryData(FFMPRecord rec, IDataRequest request, Map cache, - TimeRange range) throws Exception { + Date start, Date end) throws Exception { String huc = (String) request.getIdentifiers().get(HUC); String dataKey = (String) request.getIdentifiers().get(DATA_KEY); String siteKey = (String) request.getIdentifiers().get(SITE_KEY); @@ -275,6 +283,8 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory { data.setAttributes(attrs); data.setLocationName(String.valueOf(pfaf)); data.setGeometry(geomMap.get(pfaf)); + data.setDataTime(new DataTime(start.getTime(), + new TimeRange(start, end))); cache.put(pfaf, data); } @@ -294,8 +304,7 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory { value = ((FFMPGuidanceBasin) basin).getValue( rec.getSourceName(), 1000); } else { - value = basin.getAccumValue(range.getStart(), - range.getEnd(), + value = basin.getAccumValue(start, end, sourceXml.getExpirationMinutes(rec.getSiteKey()), false); // value = basin.getValue(rec.getDataTime().getRefTime());