Merge changes I92d52e19,Ia6e18647 into 9-Wes2Bridge

* changes:
  Issue #13 Corrected valid month check - from code review Change-Id: I92d52e191749313b846871c5d8cd7c2fdc3c73c3
  Issue #13 - Modified/corrected handling of "ARCHIVE" time stamp


Former-commit-id: 9cc539f8a4 [formerly bc6f1a41c0dee1c2030d1a2c90d337ddef20b36e]
Former-commit-id: db74c784d6
This commit is contained in:
Lee Venable 2012-02-08 09:06:55 -06:00 committed by Gerrit Code Review
commit 74cd5a6f0b
3 changed files with 28 additions and 14 deletions

View file

@ -214,17 +214,14 @@ public class MetarDecoder extends AbstractDecoder {
List<PluginDataObject> retVal = new ArrayList<PluginDataObject>();
// String fileName = null;
// if (headers != null) {
// fileName = (String) headers
// .get(DecoderTools.INGEST_FILE_NAME);
// }
Calendar baseTime;
Calendar baseTime = TimeTools.getSystemCalendar();
WMOHeader wmoHdr = sep.getWMOHeader();
if(TimeTools.allowArchive()) {
if((wmoHdr != null)&&(wmoHdr.isValid())) {
baseTime = TimeTools.findDataTime(wmoHdr.getYYGGgg(), headers);
} else {
baseTime = TimeTools.getSystemCalendar();
logger.error("ARCHIVE MODE-No WMO Header found in file" + headers.get(WMOHeader.INGEST_FILE_NAME));
}
}
while (sep.hasNext()) {
@ -326,6 +323,15 @@ public class MetarDecoder extends AbstractDecoder {
Calendar obsTime = record.getTimeObs();
if (obsTime != null) {
Calendar currTime = TimeTools.copy(baseTime);
// Do this only for archive mode!!! Otherwise valid data will not pass if the WMO header
// date/time is much less than the obstime. For instance
// WMO Header time = dd1200
// Observed time = dd1235
// To solve this will require greater precision in the file timestamp.
if(TimeTools.allowArchive()) {
currTime.add(Calendar.HOUR, 1);
}
currTime.add(Calendar.MINUTE, METAR_FUTURE_LIMIT);
long diff = currTime.getTimeInMillis()

View file

@ -50,6 +50,7 @@ import com.raytheon.uf.common.message.Header;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.site.SiteMap;
import com.raytheon.uf.edex.core.props.PropertiesFactory;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
@ -854,7 +855,13 @@ public class TextDB {
}
product.append(reportData);
long writeTime = System.currentTimeMillis();
Long writeTime = new Long(System.currentTimeMillis());
if(TimeTools.allowArchive()) {
Calendar c = header.getHeaderDate();
writeTime = new Long(c.getTimeInMillis());
}
StdTextProduct textProduct = (operationalMode ? new OperationalStdTextProduct()
: new PracticeStdTextProduct());

View file

@ -128,7 +128,8 @@ public class TimeTools {
/**
* Get a calendar that expresses the current system time based from specified
* date information if the
* date information only if the archive flag is set. Otherwise the current
* system time is returned.
* @param year Year to set.
* @param month
* @param day
@ -503,7 +504,7 @@ public class TimeTools {
* @return Is the month valid?
*/
public static final boolean isValidMonth(int month) {
return ((month > -1)&&(month <= 12));
return ((month > 0)&&(month <= 12));
}
/**