From 8e7397ae8bd77f415c99c135af35e1f529e1d384 Mon Sep 17 00:00:00 2001 From: James Korman Date: Wed, 25 Jan 2012 16:38:43 -0600 Subject: [PATCH] Issue #13 - Modified/corrected handling of "ARCHIVE" time stamp Former-commit-id: 9eff1feaa07d210b7e35bb09b20cfc2f0ed37977 [formerly d845a111af9e771e60b379ea1987fb8089f4463a] [formerly 53b5faf65bf244de8b87794b7d6d363952db526d] [formerly 9eff1feaa07d210b7e35bb09b20cfc2f0ed37977 [formerly d845a111af9e771e60b379ea1987fb8089f4463a] [formerly 53b5faf65bf244de8b87794b7d6d363952db526d] [formerly 4095a560a39e56423ef664650061ea3c522ceb7d [formerly 53b5faf65bf244de8b87794b7d6d363952db526d [formerly a6e1864763ea7b16cd8199121cc45ec3dd1299d5]]]] Former-commit-id: 4095a560a39e56423ef664650061ea3c522ceb7d Former-commit-id: eb561063e3899bfe406166ef7982a60e64f469b8 [formerly bb29d1fdfccb73d51bf2f1fe941bf5a3bc31cbe7] [formerly 6666f4f6134c72eb3e4f1fed3d77af371e2ba0ca [formerly bf2e363042a0bf5b43d12027ff01368c93a5088d]] Former-commit-id: c908b7bc495fdbc4ec04d3d31621af07d56030e8 [formerly 9093243a8144f2cdd5bc511c3af106b28ab4f7b3] Former-commit-id: 19a1fe97c3ec6d86a7a50946a72a0f7fe41180a7 --- .../edex/plugin/obs/metar/MetarDecoder.java | 26 ++++++++++++------- .../edex/textdb/dbapi/impl/TextDB.java | 11 ++++++-- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java b/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java index 5d0a18cef7..c41996bdc8 100644 --- a/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java +++ b/edexOsgi/com.raytheon.edex.plugin.obs/src/com/raytheon/edex/plugin/obs/metar/MetarDecoder.java @@ -214,17 +214,14 @@ public class MetarDecoder extends AbstractDecoder { List retVal = new ArrayList(); -// 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((wmoHdr != null)&&(wmoHdr.isValid())) { - baseTime = TimeTools.findDataTime(wmoHdr.getYYGGgg(), headers); - } else { - baseTime = TimeTools.getSystemCalendar(); + if(TimeTools.allowArchive()) { + if((wmoHdr != null)&&(wmoHdr.isValid())) { + baseTime = TimeTools.findDataTime(wmoHdr.getYYGGgg(), headers); + } else { + 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() diff --git a/edexOsgi/com.raytheon.edex.textdb/src/com/raytheon/edex/textdb/dbapi/impl/TextDB.java b/edexOsgi/com.raytheon.edex.textdb/src/com/raytheon/edex/textdb/dbapi/impl/TextDB.java index 0fe437bb3a..a04115a4d3 100644 --- a/edexOsgi/com.raytheon.edex.textdb/src/com/raytheon/edex/textdb/dbapi/impl/TextDB.java +++ b/edexOsgi/com.raytheon.edex.textdb/src/com/raytheon/edex/textdb/dbapi/impl/TextDB.java @@ -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,8 +855,14 @@ 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()); textProduct.setWmoid(wmoid);