Omaha #3170 add data times to ffmp geometries being returned, also aggregate data as it is more useful that way

Former-commit-id: 1454e1272c [formerly 90b0619656] [formerly 118d811eee] [formerly 1454e1272c [formerly 90b0619656] [formerly 118d811eee] [formerly 980d7bf5ad [formerly 118d811eee [formerly dd691896f03ba16d683a284a26b8ef923e364834]]]]
Former-commit-id: 980d7bf5ad
Former-commit-id: fe8590a5ad [formerly 23d1a555a7] [formerly 07db45d8c2f90726ce2ca244d474b22e41d26939 [formerly bce9e0595c]]
Former-commit-id: 731b6187aa3cf4c1ec5f86cd015cfafb90225a50 [formerly a1ea03c29b]
Former-commit-id: 667ce84a62
This commit is contained in:
Matt Nash 2014-09-03 14:11:15 -05:00
parent f3e79fbd6f
commit e0b5070083

View file

@ -20,6 +20,7 @@
package com.raytheon.uf.common.dataplugin.ffmp.dataaccess; package com.raytheon.uf.common.dataplugin.ffmp.dataaccess;
import java.util.ArrayList; import java.util.ArrayList;
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 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.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.TimeRange; import com.raytheon.uf.common.time.TimeRange;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
@ -121,22 +123,26 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
List<Map<String, Object>> results = dbQueryResponse.getResults(); List<Map<String, Object>> results = dbQueryResponse.getResults();
Map<Long, DefaultGeometryData> cache = new HashMap<Long, DefaultGeometryData>(); Map<Long, DefaultGeometryData> cache = new HashMap<Long, DefaultGeometryData>();
FFMPRecord record = null; FFMPRecord record = null;
TimeRange range = new TimeRange(); Date start = new Date(Long.MAX_VALUE);
Date end = new Date(0);
for (Map<String, Object> map : results) { for (Map<String, Object> map : results) {
for (Map.Entry<String, Object> es : map.entrySet()) { for (Map.Entry<String, Object> es : map.entrySet()) {
FFMPRecord rec = (FFMPRecord) es.getValue(); 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) { if (record == null) {
record = rec; record = rec;
} }
// building a time range of the earliest FFMP time (based on // building a time range of the earliest FFMP time (based on
// each record) to the latest FFMP time (based on each record) // each record) to the latest FFMP time (based on each record)
if (range.getStart().after(rec.getDataTime().getRefTime())) { if (start.after(rec.getDataTime().getRefTime())) {
range.setStart(rec.getDataTime().getRefTime()); start = rec.getDataTime().getRefTime();
} }
if (range.getEnd().before(rec.getDataTime().getRefTime())) { if (end.before(rec.getDataTime().getRefTime())) {
range.setEnd(rec.getDataTime().getRefTime()); end = rec.getDataTime().getRefTime();
} }
try { try {
@ -147,11 +153,11 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
+ rec.toString(), e); + rec.toString(), e);
} }
// loop over each pfaf id in the current record (rec) we are /*
// iterating. * loop over each pfaf id in the current record (rec) we are
// Add that basin data to the record that we are keeping around * iterating. Add that basin data to the record that we are
// (record) * keeping around (record) to use to get the accumulated value.
// to use to get the accumulated value. */
for (Long pfaf : rec.getBasinData().getPfafIds()) { for (Long pfaf : rec.getBasinData().getPfafIds()) {
// setValue is a misnomer here, it is actually an add // setValue is a misnomer here, it is actually an add
record.getBasinData() 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 * now that we have all the basin data in a single record (record), we
// value in the case of a non-guidance basin * can use the methods on the FFMPRecord class to get the accumulated
* value in the case of a non-guidance basin
*/
try { try {
cache = makeGeometryData(record, request, cache, range); cache = makeGeometryData(record, request, cache, start, end);
} catch (Exception e) { } catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Unable to create the geoemtry data from the records.", e); "Unable to create the geoemtry data from the records.", e);
@ -226,7 +234,7 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
*/ */
private Map<Long, DefaultGeometryData> makeGeometryData(FFMPRecord rec, private Map<Long, DefaultGeometryData> makeGeometryData(FFMPRecord rec,
IDataRequest request, Map<Long, DefaultGeometryData> cache, IDataRequest request, Map<Long, DefaultGeometryData> cache,
TimeRange range) throws Exception { Date start, Date end) throws Exception {
String huc = (String) request.getIdentifiers().get(HUC); String huc = (String) request.getIdentifiers().get(HUC);
String dataKey = (String) request.getIdentifiers().get(DATA_KEY); String dataKey = (String) request.getIdentifiers().get(DATA_KEY);
String siteKey = (String) request.getIdentifiers().get(SITE_KEY); String siteKey = (String) request.getIdentifiers().get(SITE_KEY);
@ -275,6 +283,8 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
data.setAttributes(attrs); data.setAttributes(attrs);
data.setLocationName(String.valueOf(pfaf)); data.setLocationName(String.valueOf(pfaf));
data.setGeometry(geomMap.get(pfaf)); data.setGeometry(geomMap.get(pfaf));
data.setDataTime(new DataTime(start.getTime(),
new TimeRange(start, end)));
cache.put(pfaf, data); cache.put(pfaf, data);
} }
@ -294,8 +304,7 @@ public class FFMPGeometryFactory extends AbstractDataPluginFactory {
value = ((FFMPGuidanceBasin) basin).getValue( value = ((FFMPGuidanceBasin) basin).getValue(
rec.getSourceName(), 1000); rec.getSourceName(), 1000);
} else { } else {
value = basin.getAccumValue(range.getStart(), value = basin.getAccumValue(start, end,
range.getEnd(),
sourceXml.getExpirationMinutes(rec.getSiteKey()), sourceXml.getExpirationMinutes(rec.getSiteKey()),
false); false);
// value = basin.getValue(rec.getDataTime().getRefTime()); // value = basin.getValue(rec.getDataTime().getRefTime());