Omaha #2536 moved WMO Header into new common plugin

moved WMO time parsing code from TimeTools to WMOTimeParser


Former-commit-id: 55103a72f5 [formerly 95a233a3a0] [formerly 437d9bb781] [formerly 0f10b8f99b59bb2bc67338696d81e902bcfc4dc0 [formerly 437d9bb781 [formerly 2b1c7eaa37]]] [formerly 6bd43f79ff [formerly 437d9bb781 [formerly 2b1c7eaa37] [formerly 6bd43f79ff [formerly c2e57be98850284cb01ba921b9dddcadbe66b311]]]]
Former-commit-id: 6bd43f79ff
Former-commit-id: 0a6c63157fff72ed05c2605dc73a9bdfe3035ad0 [formerly b75f809dcbc407fb62db7fd2cd75e86e51c75269] [formerly abd29bf492 [formerly ee9757ea39]]
Former-commit-id: abd29bf492
Former-commit-id: f291884a77
This commit is contained in:
Brian Clements 2014-05-13 09:41:29 -05:00
parent 164386478e
commit a1d481654d
222 changed files with 1384 additions and 1195 deletions

View file

@ -112,4 +112,11 @@
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.common.wmo"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>

View file

@ -43,4 +43,5 @@ Import-Package: com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.warning.util,
com.raytheon.uf.common.dissemination,
com.raytheon.uf.common.message,
com.raytheon.uf.common.wmo,
com.raytheon.uf.viz.ui.menus

View file

@ -23,8 +23,8 @@ import com.raytheon.uf.common.dataplugin.text.db.OperationalStdTextProduct;
import com.raytheon.uf.common.dataplugin.text.db.PracticeStdTextProduct;
import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct;
import com.raytheon.uf.common.dataplugin.text.db.StdTextProductId;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.AFOSProductId;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.viz.core.mode.CAVEMode;
/**

View file

@ -28,8 +28,8 @@ import java.util.regex.Pattern;
import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct;
import com.raytheon.uf.common.site.SiteMap;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.AFOSProductId;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.viz.core.mode.CAVEMode;
import com.raytheon.viz.texteditor.msgs.IAviationObserver;

View file

@ -52,7 +52,7 @@ import com.raytheon.uf.common.dataplugin.text.request.RemoteRetrievalRequest;
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.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.texteditor.command.CommandFactory;

View file

@ -120,9 +120,9 @@ import com.raytheon.uf.common.dataplugin.text.db.StdTextProductId;
import com.raytheon.uf.common.dataplugin.text.request.RemoteRetrievalRequest;
import com.raytheon.uf.common.dataplugin.text.request.StdTextProductServerRequest;
import com.raytheon.uf.common.dataplugin.text.request.TextProductInfoCreateRequest;
import com.raytheon.uf.common.dissemination.OUPTestRequest;
import com.raytheon.uf.common.dissemination.OUPRequest;
import com.raytheon.uf.common.dissemination.OUPResponse;
import com.raytheon.uf.common.dissemination.OUPTestRequest;
import com.raytheon.uf.common.dissemination.OfficialUserProduct;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
@ -137,9 +137,8 @@ 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.util.TimeUtil;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.services.textdbsrv.IQueryTransport;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.exception.VizException;
@ -336,6 +335,7 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox;
* 10Dec2013 2601 mpduff Fix NullPointerException.
* 28Jan2014 DR14595 mgamazaychikov Added template loading and editing functionality.
* 14Mar2014 DR 17175 D. Friedman Get correct time zone for MND header time sync.
* 13May2014 2536 bclement moved WMO Header to common, switched from TimeTools to TimeUtil
* </pre>
*
* @author lvenable
@ -506,8 +506,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
private static final SimpleDateFormat AUTOSAVE_DATE_FORMAT = new SimpleDateFormat(
"yyMMdd_HHmm");
static {
AUTOSAVE_DATE_FORMAT.setTimeZone(TimeZone
.getTimeZone(TimeTools.ZULU_TIMEZONE));
AUTOSAVE_DATE_FORMAT.setTimeZone(TimeUtil.GMT_TIME_ZONE);
}
/*
@ -3935,7 +3934,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
rightPart = "";
}
String newString = leftPart + rightPart;
int width = newString.length();
int neededPadSpaces = editableTextWidth - newString.length();
String newPaddedString = String.format("%1$-"
+ (neededPadSpaces+1) + "s", newString);
@ -7287,7 +7285,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
+ "_"
+ filenameIdentifier
+ "_"
+ AUTOSAVE_DATE_FORMAT.format(TimeTools.getSystemCalendar()
+ AUTOSAVE_DATE_FORMAT.format(TimeUtil.newGmtCalendar()
.getTime()) + ".txt";
BufferedOutputStream bufStream = null;

View file

@ -31,7 +31,7 @@ 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.SimulatedTime;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.texteditor.msgs.IRadarObserver;

View file

@ -9,6 +9,7 @@ Export-Package: com.raytheon.edex.plugin.binlightning.dao
Import-Package: com.raytheon.edex.esb,
com.raytheon.edex.exception,
com.raytheon.edex.plugin,
com.raytheon.uf.common.wmo,
org.apache.commons.logging
Require-Bundle: com.raytheon.uf.common.dataplugin.binlightning;bundle-version="1.12.1174",
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",

View file

@ -39,9 +39,10 @@ import com.raytheon.uf.common.dataplugin.binlightning.impl.LightningStrikePoint;
import com.raytheon.uf.common.dataplugin.binlightning.impl.LtgStrikeType;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.common.wmo.WMOTimeParser;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* AWIPS decoder adapter strategy for binary lightning data.<br/>
@ -82,6 +83,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Jan 24, 2014 DR 16774 Wufeng Zhou Modified for updated Bin-lightning data spec,
* and to used WMO header to distinguish bit-shifted
* GLD360 and NLDN data.
* May 14, 2014 2536 bclement moved WMO Header to common
*
* </pre>
*
@ -134,9 +136,10 @@ public class BinLightningDecoder extends AbstractDecoder {
WMOHeader wmoHdr = new WMOHeader(data);
if (wmoHdr.isValid()) {
Calendar baseTime = TimeTools.findDataTime(wmoHdr.getYYGGgg(),
headers);
String fileName = (String) headers
.get(WMOHeader.INGEST_FILE_NAME);
Calendar baseTime = WMOTimeParser.findDataTime(
wmoHdr.getYYGGgg(), fileName);
// Because binary nature of the encrypted data, the string created with its byte[] array may not have the same length of the byte[] array length
// So when DecoderTools.stripWMOHeader() assumes byte[] length == String length in its logic, it is observed that it may return a shorter byte[] than

View file

@ -25,30 +25,31 @@ import java.util.Iterator;
import java.util.List;
import com.raytheon.uf.common.dataplugin.binlightning.impl.LightningStrikePoint;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.decodertools.core.BasePoint;
import com.raytheon.uf.edex.decodertools.core.IBinDataSource;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
/**
* Provide the base class for the binary lightning decoders. This class abstracts
* data and methods common to the current lightning decoder types.
* Provide the base class for the binary lightning decoders. This class
* abstracts data and methods common to the current lightning decoder types.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20070810 379 jkorman Initial Coding from prototype.
* 20070912 379 jkorman Code review cleanup.
* May 14, 2014 2536 bclement removed TimeTools
* </pre>
*
*
* @author jkorman
* @version 1.0
*/
abstract class BaseLightningDecoder implements IBinLightningDecoder
{
private final Calendar BASE_TIME = TimeTools.getBaseCalendar(1980,2,29);
private final Calendar BASE_TIME = TimeUtil.newGmtCalendar(1980, 2, 29);
private static final int DAYS_MASK = 0xFFFE;
@ -98,10 +99,10 @@ abstract class BaseLightningDecoder implements IBinLightningDecoder
int b2 = msgData.getU8();
int word1 = msgData.getU16();
//********* Don't reorder these reads!!!
Calendar obsTime = TimeTools.copy(BASE_TIME);
Calendar obsTime = (Calendar) BASE_TIME.clone();
// number of days since BASE_TIME
int days = ((word1 & DAYS_MASK) >> DAYS_SHFT);
TimeTools.rollByDays(obsTime,days);
obsTime.add(Calendar.DAY_OF_MONTH, days);
point.setYear(obsTime.get(Calendar.YEAR));
//Increment month, Calendar returns 0..11

View file

@ -24,9 +24,9 @@ import com.raytheon.edex.plugin.binlightning.impl.LightningDataSource;
import com.raytheon.uf.common.dataplugin.binlightning.impl.LightningStrikePoint;
import com.raytheon.uf.common.dataplugin.binlightning.impl.LtgMsgType;
import com.raytheon.uf.common.dataplugin.binlightning.impl.LtgStrikeType;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.core.BasePoint;
import com.raytheon.uf.edex.decodertools.core.IBinDataSource;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* BinLigntningDecoderUtil

View file

@ -22,4 +22,5 @@ Require-Bundle: com.raytheon.uf.common.dataplugin.bufrua;bundle-version="1.12.11
com.raytheon.uf.edex.ndm;bundle-version="1.0.0"
Import-Package: com.raytheon.edex.esb,
com.raytheon.edex.plugin,
com.raytheon.uf.common.wmo,
org.apache.commons.logging

View file

@ -41,13 +41,13 @@ import com.raytheon.uf.common.status.IPerformanceStatusHandler;
import com.raytheon.uf.common.status.PerformanceStatus;
import com.raytheon.uf.common.time.util.ITimer;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.bufrtools.AbstractBUFRDecoder;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.descriptors.DefaultDescriptorDelegate;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Decoder strategy for BUFR upper air observation data. Most common usage is as

View file

@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.plugin.AbstractRecordSeparator;
import com.raytheon.edex.plugin.bufrua.decoder.UARawinDescriptorDelegate;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRFile;
@ -38,7 +39,6 @@ import com.raytheon.uf.edex.decodertools.bufr.descriptors.IDescriptorFactorySele
import com.raytheon.uf.edex.decodertools.bufr.packets.BUFRSublistPacket;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* The BufrUASeparator takes a potential weather message and attempts to
@ -57,6 +57,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 20071127 382 jkorman Initial Coding.
* 20080107 382 jkorman Fixed NullPointerEx in hasNext.
* 20080214 862 jkorman Refactored data separation into BUFRFile.
* May 14, 2014 2536 bclement moved WMO Header to common
*
* </pre>
*
@ -124,8 +125,9 @@ public class BufrUASeparator extends AbstractRecordSeparator implements
reports = new ArrayList<BUFROffsets>();
try {
if (rawMessage != null) {
wmoHeader = new WMOHeader(rawMessage, headers);
String fileName = (String) headers
.get(WMOHeader.INGEST_FILE_NAME);
wmoHeader = new WMOHeader(rawMessage, fileName);
if ((wmoHeader != null) && (wmoHeader.isValid())) {

View file

@ -32,13 +32,13 @@ import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.pointdata.PointDataView;
import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.bufrtools.BUFRPointDataAdapter;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* This class contains several utility methods that construct a ProfilerObs
@ -54,6 +54,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Jul 19, 2013 1992 bsteffen Remove redundant time columns from
* bufrua.
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools
*
* </pre>
*
@ -62,9 +63,6 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
*/
public abstract class AbstractBUFRUAAdapter extends BUFRPointDataAdapter<UAObs> {
// Allowable future time in milliseconds (2 hours).
private static final long ALLOWABLE_TIME = 2 * 3600 * 1000;
private static final int[] HOUR_MAP = {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
0, -1, -2, -3, 2, 1, 0, -1, -2, -3, 2, 1, 0, -1, -2, -3, 2, 1, 0,
@ -130,7 +128,7 @@ public abstract class AbstractBUFRUAAdapter extends BUFRPointDataAdapter<UAObs>
return null;
}
obsData.setDataTime(new DataTime(TimeTools.copy(validTime)));
obsData.setDataTime(new DataTime(validTime.getTime()));
// We have times now, so ok to get container.
PointDataContainer container = getContainer(obsData);
@ -157,8 +155,8 @@ public abstract class AbstractBUFRUAAdapter extends BUFRPointDataAdapter<UAObs>
/**
* Empty implementation of this method.
*
* @see com.raytheon.uf.edex.bufrtools.BUFRPointDataAdapter#createDataList(java.util.Iterator,
* com.raytheon.uf.edex.wmo.message.WMOHeader)
* @see com.raytheon.uf.edex.bufrtools.BUFRPointDataAdapter#createDataList(Iterator,
* WMOHeader)
*/
@Override
public List<UAObs> createDataList(Iterator<BUFRDataDocument> iterator,
@ -245,7 +243,7 @@ public abstract class AbstractBUFRUAAdapter extends BUFRPointDataAdapter<UAObs>
year += 1900;
}
}
baseTime = TimeTools.getBaseCalendar(year, month, day);
baseTime = TimeUtil.newGmtCalendar(year, month, day);
baseTime.set(Calendar.HOUR_OF_DAY, hour);
baseTime.set(Calendar.MINUTE, minute);
baseTime.set(Calendar.SECOND, 0);

View file

@ -24,8 +24,8 @@ import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.dataplugin.bufrua.UAObs;
import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* TODO Add Description

View file

@ -25,10 +25,10 @@ import java.util.List;
import com.raytheon.uf.common.dataplugin.bufrua.UAObs;
import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.pointdata.PointDataView;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* TODO Add Description

View file

@ -19,5 +19,6 @@ Import-Package: com.raytheon.uf.common.dataplugin.goessounding,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.pointdata.spatial,
com.raytheon.uf.common.status,
com.raytheon.uf.common.wmo,
com.raytheon.uf.edex.pointdata,
org.apache.commons.logging

View file

@ -39,6 +39,7 @@ import com.raytheon.uf.common.dataplugin.goessounding.GOESSounding;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.pointdata.PointDataView;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRFile;
@ -47,7 +48,6 @@ import com.raytheon.uf.edex.decodertools.bufr.descriptors.IDescriptorFactoryDele
import com.raytheon.uf.edex.decodertools.bufr.descriptors.IDescriptorFactorySelector;
import com.raytheon.uf.edex.decodertools.bufr.packets.BUFRSublistPacket;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Perform decode on BUFR GOES satellite sounding data. Currently this decoder

View file

@ -22,16 +22,13 @@ package com.raytheon.edex.plugin.goessounding;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.plugin.AbstractRecordSeparator;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFROffsets;
import com.raytheon.uf.edex.decodertools.bufr.BUFRSection0;
import com.raytheon.uf.edex.decodertools.bufr.BUFRSection5;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* The GOESSounding a potential weather message and attempts to determine the
@ -46,6 +43,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20080414 1077 jkorman Initial implementation.
* May 14, 2014 2536 bclement moved WMO Header to common, removed unused logger
*
* </pre>
*
@ -54,8 +52,6 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
*/
public class GOESSoundingSeparator extends AbstractRecordSeparator {
private Log logger = LogFactory.getLog(getClass());
private WMOHeader wmoHeader;
private byte[] rawBUFR;
@ -124,8 +120,9 @@ public class GOESSoundingSeparator extends AbstractRecordSeparator {
if (rawMessage != null) {
rawBUFR = rawMessage;
reportData = new ArrayList<BUFROffsets>();
wmoHeader = new WMOHeader(rawMessage, headers);
String fileName = (String) headers
.get(WMOHeader.INGEST_FILE_NAME);
wmoHeader = new WMOHeader(rawMessage, fileName);
int start = findStart(0, rawMessage);
while (start >= 0) {

View file

@ -19,10 +19,11 @@
**/
package com.raytheon.edex.plugin.goessounding;
import com.raytheon.uf.edex.decodertools.core.IDecoderInput;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import java.util.Properties;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.core.IDecoderInput;
/**
* TODO Add Description
*

View file

@ -26,9 +26,9 @@ import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.goessounding.GOESSounding;
import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Provide data access services against the SoundingSite data object.

View file

@ -43,12 +43,12 @@ import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.pointdata.PointDataView;
import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.packets.BUFRSublistPacket;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* This class contains several utility methods that construct a GOESSounding
@ -61,6 +61,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Apr 14, 2008 1077 jkorman Initial implementation.
* May 09, 2013 1869 bsteffen Modified D2D time series of point data to
* work without dataURI.
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
*
* </pre>
*
@ -213,14 +214,14 @@ public class GOESSoundingDataAdapter {
// seconds = (dp.getValue() != null) ? ((Double) dp.getValue())
// .intValue() : null;
Calendar baseTime = TimeTools.getBaseCalendar(year, 1, 1);
Calendar baseTime = TimeUtil.newGmtCalendar(year, 1, 1);
baseTime.set(Calendar.DAY_OF_YEAR, day);
baseTime.set(Calendar.HOUR_OF_DAY, hour);
baseTime.set(Calendar.MINUTE, minute);
baseTime.set(Calendar.SECOND, seconds);
baseTime.set(Calendar.MILLISECOND, 0);
obsData.setTimeObs(TimeTools.copy(baseTime));
DataTime dt = new DataTime(TimeTools.copy(baseTime));
obsData.setTimeObs((Calendar) baseTime.clone());
DataTime dt = new DataTime((Calendar) baseTime.clone());
obsData.setDataTime(dt);
}
}

View file

@ -24,4 +24,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.raytheon.uf.common.dataplugin.obs.metar,
com.raytheon.uf.common.dataplugin.obs.metar.util,
com.raytheon.uf.common.status,
com.raytheon.uf.common.wmo,
org.apache.commons.logging

View file

@ -32,7 +32,7 @@ import com.raytheon.uf.common.status.IPerformanceStatusHandler;
import com.raytheon.uf.common.status.PerformanceStatus;
import com.raytheon.uf.common.time.util.ITimer;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
* Decoder implementation for observation data types. This class provides a
@ -55,6 +55,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* status to decode.
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Oct 23, 2013 2361 njensen Removed dead mesowest code
* May 14, 2014 2536 bclement moved WMO Header to common
* </pre>
*
* @author bphillip
@ -122,12 +123,11 @@ public class ObsDecoder extends AbstractDecoder {
*/
private MetarDecoder getDecoderStrategy(byte[] messageData, Headers headers)
throws DecoderException {
String message = new String(messageData).trim();
// We can never be sure when this method is called so make sure
// to null out the decoder strategy.
MetarDecoder decoder = null;
WMOHeader header = new WMOHeader(messageData, headers);
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
WMOHeader header = new WMOHeader(messageData, fileName);
if (header.isValid()) {
if ('S' == header.getT1()) {
switch (header.getT2()) {

View file

@ -37,11 +37,13 @@ import com.raytheon.uf.common.dataplugin.obs.metar.util.WeatherCondition;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.common.wmo.WMOTimeParser;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
@ -79,6 +81,7 @@ import com.vividsolutions.jts.geom.impl.CoordinateArraySequence;
* Nov 11, 2008 1684 chammack Camel refactor.
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Sep 17, 2013 2378 njensen Improve 3/6 hr precip decoding
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
* </pre>
*
* @author bphillip
@ -216,11 +219,14 @@ public class MetarDecoder extends AbstractDecoder {
List<PluginDataObject> retVal = new ArrayList<PluginDataObject>();
Calendar baseTime = TimeTools.getSystemCalendar();
Calendar baseTime = TimeUtil.newGmtCalendar();
WMOHeader wmoHdr = sep.getWMOHeader();
if (TimeTools.allowArchive()) {
if (WMOTimeParser.allowArchive()) {
if ((wmoHdr != null) && (wmoHdr.isValid())) {
baseTime = TimeTools.findDataTime(wmoHdr.getYYGGgg(), headers);
String fileName = (String) headers
.get(WMOHeader.INGEST_FILE_NAME);
baseTime = WMOTimeParser.findDataTime(wmoHdr.getYYGGgg(),
fileName);
} else {
logger.error("ARCHIVE MODE-No WMO Header found in file"
+ headers.get(WMOHeader.INGEST_FILE_NAME));
@ -299,7 +305,7 @@ public class MetarDecoder extends AbstractDecoder {
Integer hr = DecoderTools.getInt(timeGroup, 2, 4);
Integer mi = DecoderTools.getInt(timeGroup, 4, 6);
if ((da != null) && (hr != null) && (mi != null)) {
obsTime = TimeTools.copy(baseTime);
obsTime = (Calendar) baseTime.clone();
obsTime.set(Calendar.DAY_OF_MONTH, da);
obsTime.set(Calendar.HOUR_OF_DAY, hr);
obsTime.set(Calendar.MINUTE, mi);
@ -326,7 +332,7 @@ public class MetarDecoder extends AbstractDecoder {
// into the future
Calendar obsTime = record.getTimeObs();
if (obsTime != null) {
Calendar currTime = TimeTools.copy(baseTime);
Calendar currTime = (Calendar) baseTime.clone();
// Do this only for archive mode!!! Otherwise valid data
// will not pass if the WMO header
@ -335,7 +341,7 @@ public class MetarDecoder extends AbstractDecoder {
// Observed time = dd1235
// To solve this will require greater precision in the file
// timestamp.
if (TimeTools.allowArchive()) {
if (WMOTimeParser.allowArchive()) {
currTime.add(Calendar.HOUR, 1);
}
currTime.add(Calendar.MINUTE, METAR_FUTURE_LIMIT);
@ -712,7 +718,7 @@ public class MetarDecoder extends AbstractDecoder {
hh = pkHHmm / 100;
}
Calendar obsT = record.getTimeObs();
Calendar pkTim = TimeTools.copy(obsT);
Calendar pkTim = (Calendar) obsT.clone();
int obsMin = obsT.get(Calendar.MINUTE);
int obsHr = obsT.get(Calendar.HOUR_OF_DAY);
@ -923,8 +929,6 @@ public class MetarDecoder extends AbstractDecoder {
record.setSunshine(value);
}
record.constructDataURI();
record.setWmoHeader(sep.getWMOHeader().getWmoHeader());
retVal.add(record);
@ -1055,7 +1059,7 @@ public class MetarDecoder extends AbstractDecoder {
}
String indent = " ";
ArrayList<String> parts = new ArrayList<String>();
int rmkPos = sb.indexOf("RMK");
// int rmkPos = sb.indexOf("RMK");
parts.add(sb.toString());
// if(rmkPos > 0) {

View file

@ -41,8 +41,8 @@ import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.pointdata.PointDataView;
import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
/**
* Provides a transform from MetarRecords to PointDataContainer and vice versa.
@ -61,6 +61,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* work without dataURI.
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Dec 16, 2013 DR 16920 D. Friemdan Fix type of tempFromTenths access.
* May 14, 2014 2536 bclement removed TimeTools usage
*
* </pre>
*
@ -480,7 +481,7 @@ public class MetarPointDataTransform {
mr.setPkWndSpd(pdv.getNumber(PK_WND_SPD).intValue());
long t = pdv.getNumber(PK_WND_TIME).longValue();
if (t >= 0) {
mr.setPkWndTime(TimeTools.newCalendar(t));
mr.setPkWndTime(TimeUtil.newGmtCalendar(new Date(t)));
}
return mr;

View file

@ -39,7 +39,7 @@ import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.exception.DecoderException;
import com.raytheon.edex.plugin.AbstractRecordSeparator;
import com.raytheon.uf.common.util.StringUtil;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
*
@ -57,6 +57,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 14Nov2006 71 Rockwood Implemented filter for NIL observations
* 20080418 1093 jkorman Added filter for Alaskan &quot;Airways&quot;
* observations.
* May 14, 2014 2536 bclement moved WMO Header to common, removed unused HEADERREGEX
* </pre>
*
* @author bphillip
@ -79,9 +80,6 @@ public class MetarSeparator extends AbstractRecordSeparator {
/** Regex used for determining metar type */
private static final String METARTYPE = "METAR|SPECI";
/** Regex used for extracting the header */
private static final String HEADERREGEX = "[A-Z]{4}[0-9]{1,2} [A-Z]{4} [0-9]{6}";
private static final String AIRWAYS = "[A-Z][A-Z,0-9]{3} (SP|SA) \\d{4} AWOS";
/** Regex used to search for NIL messages */

View file

@ -19,5 +19,6 @@ Import-Package: com.raytheon.uf.common.dataplugin.poessounding,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.pointdata.spatial,
com.raytheon.uf.common.status,
com.raytheon.uf.common.wmo,
com.raytheon.uf.edex.pointdata,
org.apache.commons.logging

View file

@ -38,6 +38,7 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.poessounding.POESSounding;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.database.plugin.PluginFactory;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDocument;
@ -47,7 +48,6 @@ import com.raytheon.uf.edex.decodertools.bufr.descriptors.IDescriptorFactoryDele
import com.raytheon.uf.edex.decodertools.bufr.descriptors.IDescriptorFactorySelector;
import com.raytheon.uf.edex.decodertools.bufr.packets.BUFRSublistPacket;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Perform decode on BUFR model sounding data. Currently this decoder does not
@ -65,6 +65,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Jul 17, 2013 2112 bsteffen Split poes data so it gets stored in
* correct file.
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* May 14, 2014 2536 bclement moved WMO Header to common
*
* </pre>
*
@ -127,8 +128,8 @@ public class POESSoundingDecoder extends AbstractDecoder implements
PluginDataObject[] decodedData = null;
if ((data != null) && (data.length > 0)) {
WMOHeader wmoHeader = new WMOHeader(data, headers);
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
WMOHeader wmoHeader = new WMOHeader(data, fileName);
if ((wmoHeader != null) && (wmoHeader.isValid())) {
try {

View file

@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.plugin.AbstractRecordSeparator;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRFile;
@ -34,7 +35,6 @@ import com.raytheon.uf.edex.decodertools.bufr.descriptors.DefaultDescriptorDeleg
import com.raytheon.uf.edex.decodertools.bufr.descriptors.IDescriptorFactorySelector;
import com.raytheon.uf.edex.decodertools.bufr.packets.BUFRSublistPacket;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* The ProfilerSeparator takes a potential weather message and attempts to
@ -49,6 +49,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20080303 1026 jkorman Initial implementation.
* May 14, 2014 2536 bclement moved WMO Header to common
*
* </pre>
*
@ -111,8 +112,9 @@ public class POESSoundingSeparator extends AbstractRecordSeparator implements
currentReport = -1;
try {
if (rawMessage != null) {
wmoHeader = new WMOHeader(rawMessage, headers);
String fileName = (String) headers
.get(WMOHeader.INGEST_FILE_NAME);
wmoHeader = new WMOHeader(rawMessage, fileName);
if ((wmoHeader != null) && (wmoHeader.isValid())) {

View file

@ -26,9 +26,9 @@ import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.poessounding.POESSounding;
import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Provide data access services against the SoundingSite data object.

View file

@ -42,11 +42,11 @@ import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.pointdata.PointDataView;
import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* This class contains several utility methods that construct a ProfilerObs
@ -59,6 +59,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Mar 17, 2008 1026 jkorman Initial implementation.
* Jul 17, 2013 2112 bsteffen Split poes data so it gets stored in
* correct file.
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
*
* </pre>
*
@ -206,13 +207,14 @@ public class POESSoundingDataAdapter {
// date-time and datatime info.
if ((year > 0) && (month > 0) && (day > 0)
&& (hour >= 0)) {
Calendar baseTime = TimeTools.getBaseCalendar(year,
Calendar baseTime = TimeUtil.newGmtCalendar(year,
month, day);
baseTime.set(Calendar.HOUR_OF_DAY, hour);
baseTime.set(Calendar.MINUTE, minute);
baseTime.set(Calendar.SECOND, seconds);
DataTime dt = new DataTime(TimeTools.copy(baseTime));
DataTime dt = new DataTime(
(Calendar) baseTime.clone());
obsData.setDataTime(dt);
}
@ -297,25 +299,6 @@ public class POESSoundingDataAdapter {
return retValue;
}
/**
*
* @param packet
* @param defaultValue
* @return
*/
private static Integer getInt(IBUFRDataPacket packet, Integer defaultValue) {
Integer retValue = defaultValue;
if(packet != null) {
Object o = packet.getValue();
if(o instanceof Double) {
retValue = ((Double) o).intValue();
} else if(o instanceof Long) {
retValue = ((Long) o).intValue();
}
}
return retValue;
}
/**
*
* @return

View file

@ -18,4 +18,5 @@ Require-Bundle: com.raytheon.uf.common.dataplugin.profiler,
com.raytheon.uf.edex.pointdata,
com.raytheon.uf.edex.decodertools
Import-Package: com.raytheon.edex.esb,
com.raytheon.edex.plugin
com.raytheon.edex.plugin,
com.raytheon.uf.common.wmo

View file

@ -32,6 +32,7 @@ import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRFile;
@ -40,7 +41,6 @@ import com.raytheon.uf.edex.decodertools.bufr.descriptors.IDescriptorFactoryDele
import com.raytheon.uf.edex.decodertools.bufr.descriptors.IDescriptorFactorySelector;
import com.raytheon.uf.edex.decodertools.bufr.packets.BUFRSublistPacket;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Perform decode on BUFR Profiler data. Currently this decoder does not check
@ -56,6 +56,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Apr 08, 2008 1039 jkorman Added traceId for tracing data.
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Dec 03, 2013 2537 bsteffen Switch logger to ufstatus.
* May 14, 2014 2536 bclement moved WMO Header to common
*
* </pre>
*
@ -130,8 +131,8 @@ public class ProfilerDecoder extends AbstractDecoder implements
PluginDataObject[] decodedData = null;
if ((data != null) && (data.length > 0)) {
WMOHeader wmoHeader = new WMOHeader(data, headers);
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
WMOHeader wmoHeader = new WMOHeader(data, fileName);
if ((wmoHeader != null) && (wmoHeader.isValid())) {
try {

View file

@ -26,6 +26,7 @@ import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.plugin.AbstractRecordSeparator;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRFile;
@ -33,7 +34,6 @@ import com.raytheon.uf.edex.decodertools.bufr.descriptors.DefaultDescriptorDeleg
import com.raytheon.uf.edex.decodertools.bufr.descriptors.IDescriptorFactorySelector;
import com.raytheon.uf.edex.decodertools.bufr.packets.BUFRSublistPacket;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* The ProfilerSeparator takes a potential weather message and attempts to
@ -49,6 +49,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* ------------- -------- ----------- --------------------------
* Mar 03, 2008 969 jkorman Initial implementation.
* Dec 03, 2013 2537 bsteffen Switch logger to ufstatus.
* May 14, 2014 2536 bclement moved WMO Header to common
*
* </pre>
*
@ -112,8 +113,9 @@ public class ProfilerSeparator extends AbstractRecordSeparator implements
currentReport = -1;
try {
if (rawMessage != null) {
wmoHeader = new WMOHeader(rawMessage, headers);
String fileName = (String) headers
.get(WMOHeader.INGEST_FILE_NAME);
wmoHeader = new WMOHeader(rawMessage, fileName);
if ((wmoHeader != null) && (wmoHeader.isValid())) {

View file

@ -41,12 +41,12 @@ import com.raytheon.uf.common.pointdata.spatial.SurfaceObsLocation;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.packets.BUFRSublistPacket;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* This class contains several utility methods that construct a ProfilerObs
@ -60,6 +60,8 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* May 09, 2013 1869 bsteffen Modified D2D time series of point data to
* work without dataURI.
* Dec 03, 2013 2537 bsteffen Switch logger to ufstatus.
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
* added breaks/default to switch
*
* </pre>
*
@ -224,8 +226,8 @@ public class ProfilerDataAdapter {
obsData.setLocation(location);
Calendar baseTime = getTimeInfo(dataList);
if (baseTime != null) {
obsData.setTimeObs(TimeTools.copy(baseTime));
DataTime dt = new DataTime(TimeTools.copy(baseTime));
obsData.setTimeObs((Calendar) baseTime.clone());
DataTime dt = new DataTime((Calendar) baseTime.clone());
obsData.setDataTime(dt);
} else {
logger.error(traceId
@ -323,7 +325,7 @@ public class ProfilerDataAdapter {
// Ensure that we have all of the time info and create the
// date-time and datatime info.
if ((year > 0) && (month > 0) && (day > 0) && (hour >= 0)) {
baseTime = TimeTools.getBaseCalendar(year, month, day);
baseTime = TimeUtil.newGmtCalendar(year, month, day);
baseTime.set(Calendar.HOUR_OF_DAY, hour);
baseTime.set(Calendar.MINUTE, minute);
}
@ -409,33 +411,35 @@ public class ProfilerDataAdapter {
Object o = packet.getValue();
if (o != null) {
switch (t) {
case STRING: {
case STRING:
if (o instanceof String) {
view.setString(parmName, (String) o, index);
}
}
case INT: {
break;
case INT:
if (o instanceof Double) {
view.setInt(parmName, ((Double) o).intValue(), index);
} else if (o instanceof Long) {
view.setInt(parmName, ((Long) o).intValue(), index);
}
}
case LONG: {
break;
case LONG:
if (o instanceof Double) {
view.setLong(parmName, ((Double) o).longValue(), index);
} else if (o instanceof Long) {
view.setLong(parmName, (Long) o, index);
}
}
case FLOAT: {
break;
case FLOAT:
if (o instanceof Double) {
view.setFloat(parmName, ((Double) o).floatValue(),
index);
} else if (o instanceof Long) {
view.setFloat(parmName, ((Long) o).floatValue(), index);
}
}
break;
default:
logger.warn("Unsupported point data view type: " + t);
}
}
}

View file

@ -23,6 +23,7 @@ Export-Package: com.raytheon.edex.plugin.radar,
com.raytheon.edex.uengine.tasks.radar
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.raytheon.uf.common.comm,
com.raytheon.uf.common.inventory.tree,
com.raytheon.uf.common.dataplugin.text.db,
com.raytheon.uf.common.inventory.tree,
com.raytheon.uf.common.wmo,
org.apache.commons.logging

View file

@ -73,12 +73,12 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.util.ITimer;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.AFOSProductId;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.common.wmo.WMOTimeParser;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils;
import com.raytheon.uf.edex.database.cluster.ClusterTask;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Decoder implementation for radar plugin
@ -98,6 +98,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Oct 09, 2013 2457 bsteffen Improve error message for missing icao.
* Jan 21, 2014 2627 njensen Removed decode()'s try/catch, camel route will do try/catch
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
*
* </pre>
*
@ -199,15 +200,17 @@ public class RadarDecoder extends AbstractDecoder {
// handle an interesting special case
String wmoHeader = headers.get("header").toString();
if (wmoHeader.contains("SDUS4")) {
String fileName = (String) headers
.get(WMOHeader.INGEST_FILE_NAME);
WMOHeader header = new WMOHeader(wmoHeader.getBytes(),
headers);
fileName);
String dataString = new String(messageData, 0,
messageData.length).substring(1,
messageData.length - 1);
String siteId = dataString.substring(0, 3);
AFOSProductId afos = new AFOSProductId("WSR", "ROB", siteId);
// store the product ROB that is barely do-able
Calendar cal = (TimeTools.allowArchive() ? header
Calendar cal = (WMOTimeParser.allowArchive() ? header
.getHeaderDate() : Calendar.getInstance());
RadarEdexTextProductUtil.storeTextProduct(afos, header,
dataString, true, cal);
@ -250,7 +253,7 @@ public class RadarDecoder extends AbstractDecoder {
// -- some product specific decode functionality --
// the general status message product
if (l3Radar.getMessageCode() == l3Radar.GSM_MESSAGE) {
if (l3Radar.getMessageCode() == Level3BaseRadar.GSM_MESSAGE) {
record.setGsmMessage(l3Radar.getGsmBlock().getMessage());
record.setPrimaryElevationAngle(0.0);
record.setTrueElevationAngle(0.0f);
@ -516,7 +519,8 @@ public class RadarDecoder extends AbstractDecoder {
private void decodeFreeTextMessage(byte[] messageData, Headers headers) {
String temp = new String(messageData);
temp = temp.substring(0, temp.length() - 4);
WMOHeader header = new WMOHeader(messageData, headers);
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
WMOHeader header = new WMOHeader(messageData, fileName);
temp = temp.replace(header.toString(), "");
String[] splits = temp.split(" ");
@ -525,7 +529,7 @@ public class RadarDecoder extends AbstractDecoder {
splits[1].substring(1)));
// store the product to the text database
Calendar cal = (TimeTools.allowArchive() ? header.getHeaderDate()
Calendar cal = (WMOTimeParser.allowArchive() ? header.getHeaderDate()
: Calendar.getInstance());
RadarEdexTextProductUtil
.storeTextProduct(afos, header, temp, true, cal);
@ -538,8 +542,7 @@ public class RadarDecoder extends AbstractDecoder {
private void finalizeRecord(RadarRecord record) throws PluginException {
record.setTraceId(traceId);
record.constructDataURI();
record.setInsertTime(TimeTools.getSystemCalendar());
record.setInsertTime(TimeUtil.newGmtCalendar());
// for GSM, we want all the messages as they have the possibility of
// being different
if (record.getProductCode() == Level3BaseRadar.GSM_MESSAGE) {

View file

@ -56,10 +56,10 @@ 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.wmo.AFOSProductId;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.common.wmo.WMOTimeParser;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* BaseRadar is a class that will allow the user to do the following:
@ -99,6 +99,8 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* ------------- -------- ----------- --------------------------
* --/--/2006 brockwoo Initial creation
* Jan 21, 2014 2627 njensen Changed offset errors to MalformedDataException
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
* added storeTextProduct()
*
* </pre>
*
@ -795,20 +797,7 @@ public class Level3BaseRadar {
}
if (RadarTextProductUtil.radarTable.keySet().contains(
theProductCode)) {
byte[] wmoid = wmoHeader.getBytes();
WMOHeader header = new WMOHeader(wmoid, headers);
AFOSProductId afos = new AFOSProductId(afosId);
if (afos.isFilled()) {
try {
Calendar cal = (TimeTools.allowArchive() ? theMsgTimestamp
: Calendar.getInstance());
RadarEdexTextProductUtil.storeTextProduct(afos, header,
tabularBlock.getString(), true, cal);
} catch (Exception e) {
theHandler.handle(Priority.ERROR,
"Could not store text product", e);
}
}
storeTextProduct(headers);
}
}
}
@ -872,19 +861,32 @@ public class Level3BaseRadar {
lookupAfosId();
if (RadarTextProductUtil.radarTable.keySet().contains(theMessageCode)) {
byte[] wmoid = wmoHeader.getBytes();
WMOHeader header = new WMOHeader(wmoid, headers);
AFOSProductId afos = new AFOSProductId(afosId);
if (afos.isFilled()) {
try {
Calendar cal = (TimeTools.allowArchive() ? theMsgTimestamp
: Calendar.getInstance());
RadarEdexTextProductUtil.storeTextProduct(afos, header,
tabularBlock.getString(), true, cal);
} catch (Exception e) {
theHandler.handle(Priority.ERROR,
"Could not store text product", e);
}
storeTextProduct(headers);
}
}
/**
* Stores text from tabular block if AFOS product id is filled.
*
* @see RadarEdexTextProductUtil#storeTextProduct(AFOSProductId, WMOHeader,
* String, boolean, Calendar)
* @see AFOSProductId#isFilled()
* @param headers
*/
private void storeTextProduct(Headers headers) {
byte[] wmoid = wmoHeader.getBytes();
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
WMOHeader header = new WMOHeader(wmoid, fileName);
AFOSProductId afos = new AFOSProductId(afosId);
if (afos.isFilled()) {
try {
Calendar cal = (WMOTimeParser.allowArchive() ? theMsgTimestamp
: Calendar.getInstance());
RadarEdexTextProductUtil.storeTextProduct(afos, header,
tabularBlock.getString(), true, cal);
} catch (Exception e) {
theHandler.handle(Priority.ERROR,
"Could not store text product", e);
}
}
}

View file

@ -28,9 +28,9 @@ import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct;
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.wmo.AFOSProductId;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* TODO Add Description

View file

@ -15,4 +15,5 @@ Require-Bundle: com.raytheon.edex.common,
javax.persistence,
com.raytheon.uf.edex.decodertools;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.apache.commons.logging
Import-Package: com.raytheon.uf.common.wmo,
org.apache.commons.logging

View file

@ -27,13 +27,12 @@ import com.raytheon.edex.plugin.AbstractDecoder;
import com.raytheon.edex.plugin.recco.common.RECCORecord;
import com.raytheon.edex.plugin.recco.decoder.ReccoParser;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.pointdata.spatial.AircraftObsLocation;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
import com.raytheon.uf.edex.decodertools.core.IDecoderInput;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Decoder strategy for text aircraft RECCO observation data. Most common usage
@ -57,14 +56,13 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Jan 03, 2008 384 jkorman Initial Coding.
* Nov 25, 2008 1684 chammack Camel Refactor
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* May 14, 2014 2536 bclement moved WMO Header to common, removed PLUGIN_NAME
* </pre>
*
* @author jkorman
* @version 1.0
*/
public class RECCODecoder extends AbstractDecoder {
// Name of the plugin controlling this decoder.
private final String PLUGIN_NAME;
private boolean removeNILs = true;
@ -73,8 +71,8 @@ public class RECCODecoder extends AbstractDecoder {
* Name that identifies this decoder.
* @throws DecoderException
*/
@Deprecated
public RECCODecoder(String pluginName) {
PLUGIN_NAME = pluginName;
}
/**
@ -116,11 +114,6 @@ public class RECCODecoder extends AbstractDecoder {
input.getWmoHeader());
if (report != null) {
report.setTraceId(traceId);
try {
report.constructDataURI();
} catch (PluginException e) {
throw new DecoderException("Unable to construct dataURI", e);
}
reports = new PluginDataObject[] { report };
}

View file

@ -31,10 +31,10 @@ import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.plugin.AbstractRecordSeparator;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.core.DecoderInput;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.decodertools.core.IDecoderInput;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* The SfcObsSeparator takes a potential weather message and attempts to
@ -55,6 +55,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* ------------ ---------- ----------- --------------------------
* 20080103 384 jkorman Initial Coding.
* 11/25/08 #1684 chammack Camel Refactor
* May 14, 2014 2536 bclement moved WMO Header to common
* </pre>
*
* @author jkorman
@ -119,7 +120,8 @@ public class RECCOSeparator extends AbstractRecordSeparator {
reports = new ArrayList<String>();
rawMessage = DecoderTools.cleanData(rawMessage);
if (rawMessage != null) {
wmoHeader = new WMOHeader(rawMessage, headers);
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
wmoHeader = new WMOHeader(rawMessage, fileName);
if (wmoHeader.isValid()) {
messageData = DecoderTools.stripWMOHeader(rawMessage,
WMO_HEADER);

View file

@ -26,10 +26,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.raytheon.edex.esb.Headers;
import com.raytheon.uf.common.wmo.WMOTimeParser;
import com.raytheon.uf.edex.decodertools.aircraft.AircraftFlightLevel;
import com.raytheon.uf.edex.decodertools.core.BasePoint;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
/**
* This class parses Pirep reports. Some of the parsing is ported from the NCEP
@ -41,6 +41,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20080103 384 jkorman Initial Coding.
* May 14, 2014 2536 bclement removed TimeTools usage
* </pre>
*
* @author dweeks
@ -433,7 +434,7 @@ public class ReccoParser {
private void createObsTime(Headers headers) {
observationTime = TimeTools.getSystemCalendar((String) headers
observationTime = WMOTimeParser.getSystemCalendar((String) headers
.get(DecoderTools.INGEST_FILE_NAME));
int dow = observationTime.get(Calendar.DAY_OF_WEEK);

View file

@ -20,4 +20,5 @@ Import-Package: com.raytheon.uf.common.dataplugin.sfcobs,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.pointdata.spatial,
com.raytheon.uf.common.status,
com.raytheon.uf.common.wmo,
org.apache.commons.logging

View file

@ -33,15 +33,14 @@ import com.raytheon.edex.plugin.AbstractDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.ISfcObsDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.SfcObsDecoderFactory;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
import com.raytheon.uf.common.status.IPerformanceStatusHandler;
import com.raytheon.uf.common.status.PerformanceStatus;
import com.raytheon.uf.common.time.util.ITimer;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.common.wmo.WMOTimeParser;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Decoder strategy for text surface observation data. Most common usage is as
@ -73,6 +72,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Mar 19, 2013 1785 bgonzale Added performance status handler and
* added status to decode.
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
* </pre>
*
* @author jkorman
@ -170,11 +170,6 @@ public class SfcObsDecoder extends AbstractDecoder {
}
if (report != null) {
report.setTraceId(traceId);
try {
report.constructDataURI();
} catch (PluginException e) {
throw new DecoderException("Error Constructing dataURI", e);
}
if (!obsMap.containsKey(report.getDataURI())) {
retVal.add(report);
obsMap.put(report.getDataURI(), Boolean.TRUE);
@ -207,10 +202,10 @@ public class SfcObsDecoder extends AbstractDecoder {
boolean isValid = false;
if (report != null) {
Calendar curr = TimeTools.getSystemCalendar((String) headers
Calendar curr = WMOTimeParser.getSystemCalendar((String) headers
.get(DecoderTools.INGEST_FILE_NAME));
Calendar rHour = TimeTools.copy(report.getRefHour());
Calendar rHour = (Calendar) report.getRefHour().clone();
rHour.add(Calendar.MINUTE, -15);
long delta = curr.getTimeInMillis() - rHour.getTimeInMillis();

View file

@ -36,8 +36,8 @@ import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.plugin.AbstractRecordSeparator;
import com.raytheon.edex.plugin.sfcobs.common.SfcObsPart;
import com.raytheon.edex.plugin.sfcobs.common.SfcObsSubMessage;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* The SfcObsSeparator takes a potential weather message and attempts to
@ -57,6 +57,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20070925 391 jkorman Initial Coding.
* May 14, 2014 2536 bclement moved WMO Header to common
* </pre>
*
* @author jkorman
@ -135,7 +136,8 @@ public class SfcObsSeparator extends AbstractRecordSeparator {
reports = null;
rawMessage = DecoderTools.cleanData(rawMessage);
if (rawMessage != null) {
wmoHeader = new WMOHeader(rawMessage, headers);
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
wmoHeader = new WMOHeader(rawMessage, fileName);
if (wmoHeader.isValid()) {
messageData = DecoderTools.stripWMOHeader(rawMessage,
WMO_HEADER);

View file

@ -23,9 +23,9 @@ import java.util.Calendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.core.DefaultParserStrategy;
import com.raytheon.uf.edex.decodertools.core.ReportParser;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* AbstractSfcObsDecoder is the base class for all surface observation decoders.

View file

@ -23,8 +23,8 @@ import java.util.Calendar;
import com.raytheon.edex.exception.DecoderException;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Declare the methods common to the surface observation class data. In the

View file

@ -34,7 +34,7 @@ import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.LandSynopticDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.MAROBSynopticDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.MobileSynopticDecoder;
import com.raytheon.edex.plugin.sfcobs.decoder.synoptic.SHIPSynopticDecoder;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
* This factory examines the incoming observation data to determine the proper

View file

@ -29,6 +29,7 @@ import com.raytheon.edex.plugin.sfcobs.decoder.AbstractSfcObsDecoder;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.decodertools.time.ITimeService;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
@ -45,6 +46,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20070928 391 jkorman Initial Coding.
* May 14, 2014 2536 bclement removed TimeTools usage
* </pre>
*
* @author jkorman
@ -392,7 +394,7 @@ public abstract class AbstractSynopticDecoder extends AbstractSfcObsDecoder {
ObsCommon report = null;
Calendar oTime = calculateObsDateTime(
TimeTools.getSystemCalendar(obsYear, obsMonth, obsDay), obsDay,
TimeUtil.newGmtCalendar(obsYear, obsMonth, obsDay), obsDay,
obsHour, obsYear, obsMonth);
if (oTime != null) {
report = new ObsCommon();
@ -460,7 +462,7 @@ public abstract class AbstractSynopticDecoder extends AbstractSfcObsDecoder {
Integer obsDay, Integer obsHour, Integer obsYear, Integer obsMonth) {
Calendar obsTime = null;
Calendar tTime = TimeTools.copyToNearestHour(currentClock);
TimeTools.rollByDays(tTime, 1);
tTime.add(Calendar.DAY_OF_MONTH, 1);
if ((obsDay != null) && (obsHour != null)) {
if (obsDay == currentClock.get(Calendar.DAY_OF_MONTH)) {
@ -475,7 +477,7 @@ public abstract class AbstractSynopticDecoder extends AbstractSfcObsDecoder {
int i = 0;
while (i++ < 25) {
// Go back a day
TimeTools.rollByDays(tTime, -1);
tTime.add(Calendar.DAY_OF_MONTH, -1);
if (obsDay == tTime.get(Calendar.DAY_OF_MONTH)) {
// Day values are equal, so this is it.
obsTime = TimeTools.copyToNearestHour(tTime);
@ -553,7 +555,8 @@ public abstract class AbstractSynopticDecoder extends AbstractSfcObsDecoder {
Integer obsDay = 31;
Integer obsHour = 21;
Calendar currentClock = TimeTools.getSystemCalendar(obsYear, obsMonth, obsDay);
Calendar currentClock = TimeUtil.newGmtCalendar(obsYear, obsMonth,
obsDay);
System.out.println(TMFMT.format(currentClock.getTime()));
Calendar c = calculateObsDateTime(currentClock,obsDay,obsHour,obsYear,obsMonth);

View file

@ -29,5 +29,6 @@ Import-Package: com.raytheon.edex.plugin.obs,
com.raytheon.uf.common.dataplugin.sfcobs,
com.raytheon.uf.common.dataplugin.text.request,
com.raytheon.uf.common.ohd,
com.raytheon.uf.common.wmo,
org.apache.commons.logging

View file

@ -48,7 +48,7 @@ import com.raytheon.uf.common.dataplugin.shef.util.SHEFErrorCodes;
import com.raytheon.uf.common.dataplugin.shef.util.SHEFTimezone;
import com.raytheon.uf.common.dataplugin.shef.util.ShefConstants;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
* The SHEFParser provides the text parsing for SHEF data. This class was

View file

@ -41,9 +41,9 @@ import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.plugin.AbstractRecordSeparator;
import com.raytheon.edex.plugin.shef.util.SHEFErrors;
import com.raytheon.uf.common.dataplugin.shef.util.SHEFErrorCodes;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
*
@ -59,6 +59,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 11/29/2012 lbousaidi fixed the decoding issue when the shef starts
* with :
* 6/27/2013 16225 wkwock Fixed trail with slash and space issue.
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
*
* </pre>
*
@ -150,7 +151,8 @@ public class ShefSeparator extends AbstractRecordSeparator {
currentRecord = -1;
/* Extracts the header */
wmoHeader = new WMOHeader(data, headers);
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
wmoHeader = new WMOHeader(data, fileName);
if (wmoHeader.isValid()) {
if (traceId == null) {
traceId = wmoHeader.getWmoHeader();
@ -165,7 +167,7 @@ public class ShefSeparator extends AbstractRecordSeparator {
} else {
// No WMO header found or bad one, so process as best
// as we can.
Calendar c = TimeTools.getSystemCalendar();
Calendar c = TimeUtil.newGmtCalendar();
if (c != null) {
productTime = c.getTime();
}

View file

@ -78,6 +78,7 @@ import com.raytheon.uf.common.dataplugin.shef.util.ShefConstants;
import com.raytheon.uf.common.dataplugin.shef.util.ShefConstants.IngestSwitch;
import com.raytheon.uf.common.dataplugin.shef.util.ShefQC;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
@ -110,7 +111,8 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* 10/28/2013 16711 lbousaidi if the id is not in location table,but defined in geoarea table
* data can be posted to appropriate pe-based tables only if the data
* type is not READING like in A1 code.
* 02/18/2014 16572 l. Bousaidi only apply adjust factor to non missing values.
* 02/18/2014 16572 l. Bousaidi only apply adjust factor to non missing values.
* May 14, 2014 2536 bclement removed TimeTools usage
*
* </pre>
*
@ -3328,16 +3330,16 @@ public class PostShef {
public static final void main(String[] args) {
Calendar postDate = TimeTools.getBaseCalendar(2011, 1, 12);
Calendar postDate = TimeUtil.newGmtCalendar(2011, 1, 12);
postDate.set(Calendar.HOUR_OF_DAY, 17);
postDate.set(Calendar.MINUTE, 25);
Calendar obsTimef = TimeTools.getBaseCalendar(2011, 1, 12);
Calendar obsTimef = TimeUtil.newGmtCalendar(2011, 1, 12);
obsTimef.set(Calendar.HOUR_OF_DAY, 17);
obsTimef.set(Calendar.MINUTE, 25);
obsTimef.add(Calendar.DAY_OF_MONTH, -30);
Calendar obsTimeb = TimeTools.getBaseCalendar(2011, 1, 12);
Calendar obsTimeb = TimeUtil.newGmtCalendar(2011, 1, 12);
obsTimeb.set(Calendar.HOUR_OF_DAY, 17);
obsTimeb.set(Calendar.MINUTE, 25);
obsTimeb.add(Calendar.MINUTE, 10);

View file

@ -36,9 +36,9 @@ import com.raytheon.uf.common.dataplugin.shef.tables.TextproductId;
import com.raytheon.uf.common.dataplugin.shef.util.SHEFTimezone;
import com.raytheon.uf.common.dataplugin.shef.util.ShefConstants;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Handles storing of Shef Products and updating the purge text product.
@ -51,6 +51,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* ------------ ---------- ----------- --------------------------
* Mar 8, 2010 jkorman Initial creation
* Dec 03, 2013 2051 rjpeter Fixed storeTextProduct issue.
* May 14, 2014 2536 bclement moved WMO Header to common, removed unused int
* </pre>
*
* @author jkorman
@ -324,7 +325,7 @@ public class PurgeText {
String poDate = dFmt.format(toDate(t[numToKeep - 1]));
query = String.format(purQuery, productId, poDate);
int n = dao.executeSQLUpdate(query);
dao.executeSQLUpdate(query);
}
}
}

View file

@ -26,13 +26,10 @@ import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.plugin.shef.data.ShefRecord;
import com.raytheon.uf.common.dataplugin.shef.util.SHEFErrorCodes;
import com.raytheon.uf.common.dataplugin.shef.util.ShefConstants;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
* SHEF Utility class
@ -46,12 +43,12 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 03/19/08 387 M. Duff Initial creation.
* 12/12/08 1786 J. Sanchez Handled date parsing exceptions.
* 01/12/08 1846 J. Sanchez Update parseCreationDate to use default year.
*
* May 14, 2014 2536 bclement moved WMO Header to common, removed unused log
*
* </pre>
*/
public final class ShefUtil {
private final static Log log = LogFactory.getLog(ShefUtil.class);
/**
* Parses the date/data string and sets the time using the record date and
* time zone as a base time value.

View file

@ -37,8 +37,9 @@ import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.transform.shef.obs.ObsToSHEFOptions;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.common.wmo.WMOTimeParser;
/**
* Base class for observation data to SHEF conversions.
@ -50,7 +51,8 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Oct 30, 2008 1659 jkorman Initial creation
* ======================================
* AWIPS2 DR Work
* 20120918 1185 jkorman Added save to archive capability.
* 20120918 1185 jkorman Added save to archive capability.
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
* </pre>
*
* @author jkorman
@ -248,9 +250,10 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
Calendar c = null;
if((hdr != null)&&(headers != null)) {
c = TimeTools.findDataTime(hdr.getYYGGgg(), headers);
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
c = WMOTimeParser.findDataTime(hdr.getYYGGgg(), fileName);
} else {
c = TimeTools.getSystemCalendar();
c = TimeUtil.newGmtCalendar();
}
buffer.append(String.format(WMO_HEADER_FMT, stationId, c));

View file

@ -35,9 +35,10 @@ import com.raytheon.edex.transform.shef.obs.SHEF_Metar_Codes;
import com.raytheon.edex.transform.shef.obs.SHEF_Obs_Codes;
import com.raytheon.edex.transform.shef.obs.Utilities;
import com.raytheon.uf.common.dataplugin.obs.metar.MetarRecord;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.common.wmo.WMOTimeParser;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Transforms a decoded METAR observation into a series of SHEF encoded data
@ -53,6 +54,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 20120918 1185 jkorman Added save to archive capability.
* Jan 30, 2010 15779 lbousaidi added 4 letter to station id for ACR
* Aug 08, 2013 16408 wkwock Use different metar.cfg file and options
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
* </pre>
*
* @author jkorman
@ -125,9 +127,9 @@ public class MetarToShefTransformer extends
// Transformed METAR PluginDataObject to SHEF
byte[] result = null;
Calendar nowCalendar = TimeTools.getSystemCalendar();
Calendar nowCalendar = TimeUtil.newGmtCalendar();
Calendar metarTime = TimeTools.getSystemCalendar((String) headers
Calendar metarTime = WMOTimeParser.getSystemCalendar((String) headers
.get(DecoderTools.INGEST_FILE_NAME));
logger.debug("report object type = " + report.getClass().getName());
@ -225,7 +227,7 @@ public class MetarToShefTransformer extends
try {
MetarRecord report = wxReport;
Calendar c = TimeTools.getSystemCalendar((String) headers
Calendar c = WMOTimeParser.getSystemCalendar((String) headers
.get(DecoderTools.INGEST_FILE_NAME));
StringBuilder lineHdr = new StringBuilder();

View file

@ -27,10 +27,10 @@ import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.transform.shef.obs.SHEF_Obs_Codes;
import com.raytheon.edex.transform.shef.obs.SHEF_SM_Codes;
import com.raytheon.uf.common.dataplugin.sfcobs.ObsCommon;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.common.wmo.WMOTimeParser;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Transforms a decoded synoptic observation into a series of SHEF encoded data
@ -45,6 +45,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* ======================================
* AWIPS2 DR Work
* 20120918 1185 jkorman Added save to archive capability.
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
* </pre>
*
* @author jkorman
@ -130,7 +131,7 @@ public class SMToShefTransformer extends AbstractShefTransformer<ObsCommon> {
int place = 0;
try {
Calendar c = TimeTools.getSystemCalendar((String) headers
Calendar c = WMOTimeParser.getSystemCalendar((String) headers
.get(DecoderTools.INGEST_FILE_NAME));
StringBuilder lineHdr = new StringBuilder();

View file

@ -14,4 +14,5 @@ Require-Bundle: com.raytheon.edex.common,
org.apache.commons.lang,
javax.persistence
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.apache.commons.logging
Import-Package: com.raytheon.uf.common.wmo,
org.apache.commons.logging

View file

@ -26,7 +26,7 @@ import com.raytheon.edex.plugin.taf.common.TafRecord;
import com.raytheon.edex.plugin.taf.decoder.TAFParser;
import com.raytheon.edex.plugin.taf.decoder.TAFParts;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
*
@ -42,6 +42,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Jun 21, 2007 180 bphillip Updated to use new plugin pattern
* Apr 25, 2008 1001 jkorman Extracted decoder code into TAFParser.
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* May 14, 2014 2536 bclement moved WMO Header to common, removed constrcutDataURI() call
* </pre>
*
* @author bphillip
@ -88,7 +89,6 @@ public class TafDecoder extends AbstractDecoder {
record = parser.getDecodedRecord();
if (record != null) {
record.setTraceId(traceId);
record.constructDataURI();
} else {
TAFParts parts = input.tafParts;
if (parts.getTafHeader() != null) {

View file

@ -28,8 +28,8 @@ import javax.persistence.Embeddable;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
*
@ -47,6 +47,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 23Mar2005 1055 D. Weeks Modified for use to decode TAFs for JET
* 30Aug2006 B. Phillippe Modified for use to decode TAFs for AWIPS
* Nov 01, 2013 2361 njensen Remove XML annotations
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
*
* </pre>
*
@ -114,9 +115,10 @@ public class TafPeriod implements Serializable {
*/
public static TafPeriod copy(TafPeriod period) {
TafPeriod periodCopy = new TafPeriod();
periodCopy.startDate = TimeTools.copy(period.startDate);
periodCopy.transitionEndDate = TimeTools.copy(period.transitionEndDate);
periodCopy.endDate = TimeTools.copy(period.endDate);
periodCopy.startDate = (Calendar) period.startDate.clone();
periodCopy.transitionEndDate = (Calendar) period.transitionEndDate
.clone();
periodCopy.endDate = (Calendar) period.endDate.clone();
return periodCopy;
}
@ -144,7 +146,7 @@ public class TafPeriod implements Serializable {
int hour2 = Integer.parseInt(aValidPeriod.substring(4, 6).trim());
// Get the current time : In GMT!
Calendar startTime = TimeTools.getSystemCalendar(header.getYear(),
Calendar startTime = TimeUtil.newGmtCalendar(header.getYear(),
header.getMonth(), header.getDay());
return TafPeriod.determineValidPeriod(startTime, day, hour1, hour2);
@ -163,7 +165,7 @@ public class TafPeriod implements Serializable {
public static TafPeriod determineValidPeriod(Calendar baseTime, int day,
int hour1, int hour2) {
Calendar sTime = TimeTools.copy(baseTime);
Calendar sTime = (Calendar) baseTime.clone();
// get start time day
int startTimeDay = sTime.get(Calendar.DAY_OF_MONTH);
@ -190,7 +192,7 @@ public class TafPeriod implements Serializable {
sTime.set(Calendar.SECOND, 0);
// Set the ending time for the period
Calendar eTime = TimeTools.copy(sTime);
Calendar eTime = (Calendar) sTime.clone();
// Add a day to ending time if the hour is less than or equal
// to the the start hour
@ -224,7 +226,7 @@ public class TafPeriod implements Serializable {
public static TafPeriod determineValidPeriod(Calendar baseTime, int day1,
int hour1, int day2, int hour2) {
Calendar sTime = TimeTools.copy(baseTime);
Calendar sTime = (Calendar) baseTime.clone();
// get start time day
int startTimeDay = sTime.get(Calendar.DAY_OF_MONTH);
@ -251,7 +253,7 @@ public class TafPeriod implements Serializable {
sTime.set(Calendar.SECOND, 0);
// Set the ending time for the period
Calendar eTime = TimeTools.copy(sTime);
Calendar eTime = (Calendar) sTime.clone();
// Add a day to ending time if the hour is less than or equal
// to the the start hour
@ -289,7 +291,7 @@ public class TafPeriod implements Serializable {
Calendar tafStartTime = aTAFValidPeriod.getStartDate();
Calendar sDate = TimeTools.copy(tafStartTime);
Calendar sDate = (Calendar) tafStartTime.clone();
if (hour1 < tafStartTime.get(Calendar.HOUR_OF_DAY)) {
sDate.add(Calendar.DAY_OF_MONTH, 1);
}
@ -298,7 +300,7 @@ public class TafPeriod implements Serializable {
sDate.set(Calendar.SECOND, 0);
sDate.set(Calendar.MILLISECOND, 0);
Calendar eDate = TimeTools.copy(tafStartTime);
Calendar eDate = (Calendar) tafStartTime.clone();
if (hour2 <= tafStartTime.get(Calendar.HOUR_OF_DAY)) {
eDate.add(Calendar.DAY_OF_MONTH, 1);
}
@ -373,7 +375,7 @@ public class TafPeriod implements Serializable {
public static TafPeriod determineChangeGroupPeriodSSss(int hour, int min,
TafPeriod aTAFValidPeriod) {
Calendar startDate = TimeTools.copy(aTAFValidPeriod.getStartDate());
Calendar startDate = (Calendar) aTAFValidPeriod.getStartDate().clone();
if (hour <= startDate.get(Calendar.HOUR_OF_DAY)) {
startDate.add(Calendar.DAY_OF_MONTH, 1);
}
@ -495,7 +497,7 @@ public class TafPeriod implements Serializable {
int min) {
Calendar cal = null;
Calendar target = TimeTools.copy(base);
Calendar target = (Calendar) base.clone();
target.set(Calendar.SECOND, 0);
target.set(Calendar.MILLISECOND, 0);
@ -504,7 +506,7 @@ public class TafPeriod implements Serializable {
for (int i = 0; i < 4; i++) {
int sDay = target.get(Calendar.DAY_OF_MONTH);
if (sDay == day) {
cal = TimeTools.copy(target);
cal = (Calendar) target.clone();
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, min);
break;
@ -518,7 +520,7 @@ public class TafPeriod implements Serializable {
public static final void main(String [] args) {
Calendar cA = TimeTools.getBaseCalendar(2012, 4, 1);
Calendar cA = TimeUtil.newGmtCalendar(2012, 4, 1);
Calendar cB = setDayHourMin(cA, 31, 23, 0);

View file

@ -41,8 +41,7 @@ import com.raytheon.edex.plugin.taf.common.TafRecord;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
*
@ -54,6 +53,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Oct 20, 2008 1515 jkorman Initial implementation to
* add 30 Hour tafs.
* Nov 12, 2013 2546 bclement added check for legacy valid time
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
* </pre>
*
* @author jkorman
@ -423,7 +423,7 @@ public class TAFChangeGroupFactory {
int iHour = cvtInt(issueTm.substring(2, 4));
int iMin = cvtInt(issueTm.substring(4, 6));
issueTime = TimeTools.getSystemCalendar(wmoHeader.getYear(),
issueTime = TimeUtil.newGmtCalendar(wmoHeader.getYear(),
wmoHeader.getMonth(), wmoHeader.getDay());
int sDay = issueTime.get(Calendar.DAY_OF_MONTH);
if (sDay == iDay) {
@ -583,11 +583,12 @@ public class TAFChangeGroupFactory {
period1 = group1.getTafChangePeriod();
period2 = group2.getTafChangePeriod();
period1.setEndDate(TimeTools.copy(period2.getStartDate()));
period1.setEndDate((Calendar) period2.getStartDate()
.clone());
}
// The last group gets the TAF end datetime.
period2.setEndDate(TimeTools.copy(validPeriod.getEndDate()));
period2.setEndDate((Calendar) validPeriod.getEndDate().clone());
}
record.setIssue_time(issueTime.getTime());

View file

@ -51,10 +51,10 @@ import com.raytheon.edex.plugin.taf.common.TafRecord;
import com.raytheon.uf.common.pointdata.spatial.ObStation;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.pointdata.spatial.ObStationDao;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* The TAF parser accepts a potential TAF report and attempts to parse and
@ -69,6 +69,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 9/4/2008 1444 grichard Import constants from TafConstants class.
* Oct 21, 2008 1515 jkorman Added 30 Hour capability changes.
* Feb 27, 2013 1638 mschenke Moved ObStationDao to edex pointdata plugin
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
* </pre>
*
* @author jkorman
@ -151,10 +152,10 @@ public class TAFParser {
int currGroup = 0;
for (String grp : tafGroups) {
Calendar cStart = TimeTools.copy(validPeriod
.getStartDate());
Calendar cStop = TimeTools.copy(validPeriod
.getEndDate());
Calendar cStart = (Calendar) validPeriod.getStartDate()
.clone();
Calendar cStop = (Calendar) validPeriod.getEndDate()
.clone();
TafPeriod tPeriod = new TafPeriod(cStart, cStop);
ChangeGroup group = new ChangeGroup(grp, tPeriod);
@ -193,12 +194,12 @@ public class TAFParser {
period1 = group1.getTafChangePeriod();
period2 = group2.getTafChangePeriod();
period1.setEndDate(TimeTools.copy(period2
.getStartDate()));
period1.setEndDate((Calendar) period2
.getStartDate().clone());
}
period2.setEndDate(TimeTools.copy(validPeriod
.getEndDate()));
period2.setEndDate((Calendar) validPeriod.getEndDate()
.clone());
}
record.setChangeGroups(groupSet);
}
@ -316,7 +317,7 @@ public class TAFParser {
*/
private Calendar transformDate(String issueDateString, WMOHeader header) {
Calendar tDate = TimeTools.getSystemCalendar(header.getYear(),
Calendar tDate = TimeUtil.newGmtCalendar(header.getYear(),
header.getMonth(), header.getDay());
int maxDay = tDate.getActualMaximum(Calendar.DAY_OF_MONTH);

View file

@ -36,8 +36,8 @@ import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.esb.Headers;
import com.raytheon.edex.plugin.AbstractRecordSeparator;
import com.raytheon.edex.plugin.taf.TafDecoder;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
*
@ -52,6 +52,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* to account for corrected
* and amended records
* 9/4/2008 1444 grichard Move constants to TafConstants class.
* May 14, 2014 2536 bclement moved WMO Header to common
*
*
* </pre>
@ -150,7 +151,8 @@ public class TafSeparator extends AbstractRecordSeparator {
byte[] data = DecoderTools.cleanData(message);
if (data != null) {
wmoHeader = new WMOHeader(data, headers);
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
wmoHeader = new WMOHeader(data, fileName);
if (wmoHeader.isValid()) {
int dStart = wmoHeader.getMessageDataStart();

View file

@ -21,4 +21,5 @@ Export-Package: com.raytheon.edex.textdb.alarms,
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: com.raytheon.uf.common.message,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.common.wmo,
org.apache.commons.logging

View file

@ -24,10 +24,10 @@ import java.util.ArrayList;
import java.util.List;
import com.raytheon.uf.common.dataplugin.text.db.StateMatch;
import com.raytheon.uf.common.wmo.AFOSProductId;
import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
/**
* The dao implementation associated with the TextDao classes used for all

View file

@ -59,13 +59,13 @@ import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.wmo.AFOSProductId;
import com.raytheon.uf.edex.database.cluster.ClusterLockUtils;
import com.raytheon.uf.edex.database.cluster.ClusterTask;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.database.purge.PurgeLogger;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
/**
* The dao implementation associated with the TextDao classes used for all

View file

@ -42,10 +42,10 @@ import com.raytheon.uf.common.dataplugin.text.db.TextProductInfo;
import com.raytheon.uf.common.dataplugin.text.db.WatchWarn;
import com.raytheon.uf.common.message.Header;
import com.raytheon.uf.common.site.SiteMap;
import com.raytheon.uf.common.wmo.AFOSProductId;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.common.wmo.WMOTimeParser;
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;
/**
* Text Database.
@ -72,6 +72,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 18 Apr 2012 479 jkorman Modified to pad xxxid to 3 characters in queries.
* 23 May 2012 14952 rferrel Allow queries with refTime.
* Feb 18, 2014 2652 skorolev Corrected writeProduct for WMO header if archive is allowed. Deleted unused code.
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
* </pre>
*
* @author jkorman
@ -881,7 +882,7 @@ public class TextDB {
product.append(reportData);
Long writeTime = new Long(System.currentTimeMillis());
if (TimeTools.allowArchive() && header.getHeaderDate() != null) {
if (WMOTimeParser.allowArchive() && header.getHeaderDate() != null) {
Calendar c = header.getHeaderDate();
writeTime = new Long(c.getTimeInMillis());
}
@ -956,7 +957,8 @@ public class TextDB {
*/
public long writeProduct(AFOSProductId prodId, String reportData,
boolean operationalMode, Headers headers) {
WMOHeader header = new WMOHeader(reportData.getBytes(), headers);
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
WMOHeader header = new WMOHeader(reportData.getBytes(), fileName);
long retValue = -1;
@ -992,7 +994,8 @@ public class TextDB {
if (pieces.length > 1) {
pieces[0] += "\n"; // WMOHeader expects this
}
WMOHeader header = new WMOHeader(pieces[0].getBytes(), headers);
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
WMOHeader header = new WMOHeader(pieces[0].getBytes(), fileName);
// Need to construct an AFOSProductId from the productId
if (productId.length() <= 6) {

View file

@ -19,8 +19,8 @@
**/
package com.raytheon.edex.textdb.dbapi.impl;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.AFOSProductId;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
* TODO Add Description

View file

@ -20,6 +20,7 @@
package com.raytheon.uf.common.dataplugin.binlightning;
import java.util.Calendar;
import java.util.Date;
import javax.persistence.Access;
import javax.persistence.AccessType;
@ -46,7 +47,7 @@ import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
import com.raytheon.uf.common.datastorage.records.LongDataRecord;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.common.time.util.TimeUtil;
/**
* Record implementation for Binary Lightning plugin.
@ -80,6 +81,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Oct 22, 2013 2361 njensen Removed XML annotations
* Jan 21, 2014 2667 bclement renamed record's lightSource field to source
* May 14, 2014 2536 bclement removed TimeTools usage
*
* </pre>
*
@ -217,9 +219,9 @@ public class BinLightningRecord extends PersistablePluginDataObject implements
if ((startTimeMillis != Long.MAX_VALUE)
&& (stopTimeMillis != Long.MIN_VALUE)) {
persistTime = (startTimeMillis + stopTimeMillis) / 2;
setPersistenceTime(TimeTools.newCalendar(persistTime).getTime());
setPersistenceTime(new Date(persistTime));
} else {
setPersistenceTime(TimeTools.getSystemCalendar().getTime());
setPersistenceTime(TimeUtil.newGmtCalendar().getTime());
persistTime = getInsertTime().getTimeInMillis();
}
}
@ -252,7 +254,7 @@ public class BinLightningRecord extends PersistablePluginDataObject implements
if (insertIndex < obsTimes.length) {
long t1 = startTimeMillis;
Calendar c = TimeTools.getBaseCalendar(strike.getYear(),
Calendar c = TimeUtil.newGmtCalendar(strike.getYear(),
strike.getMonth(), strike.getDay());
c.set(Calendar.HOUR_OF_DAY, strike.getHour());
@ -277,10 +279,10 @@ public class BinLightningRecord extends PersistablePluginDataObject implements
insertIndex++;
// only update the times if they have changed!
if (t1 != startTimeMillis) {
startTime = TimeTools.newCalendar(startTimeMillis);
startTime = TimeUtil.newGmtCalendar(new Date(startTimeMillis));
}
if (t1 != stopTimeMillis) {
stopTime = TimeTools.newCalendar(stopTimeMillis);
stopTime = TimeUtil.newGmtCalendar(new Date(stopTimeMillis));
}
// updatePersistenceTime();

View file

@ -13,11 +13,11 @@ Import-Package: com.raytheon.uf.common.dataplugin.persist,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.serialization.annotations,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.edex.wmo.message,
com.raytheon.uf.common.wmo,
javax.persistence,
org.apache.commons.lang.builder
Export-Package: com.raytheon.uf.common.dataplugin.text;uses:="com.raytheon.uf.common.dataplugin.text.db,com.raytheon.uf.common.serialization",
com.raytheon.uf.common.dataplugin.text.alarms,
com.raytheon.uf.common.dataplugin.text.db;uses:="com.raytheon.uf.common.dataplugin.persist,com.raytheon.uf.edex.wmo.message,com.raytheon.uf.common.serialization",
com.raytheon.uf.common.dataplugin.text.db;uses:="com.raytheon.uf.common.dataplugin.persist,com.raytheon.uf.common.wmo,com.raytheon.uf.common.serialization",
com.raytheon.uf.common.dataplugin.text.request;uses:="com.raytheon.uf.common.serialization.comm"

View file

@ -24,8 +24,8 @@ import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.AFOSProductId;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
*

View file

@ -24,8 +24,8 @@ import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.AFOSProductId;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
*

View file

@ -40,11 +40,10 @@ import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Index;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.edex.wmo.message.AFOSProductId;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.AFOSProductId;
import com.raytheon.uf.common.wmo.WMOHeader;
/**
*
@ -59,6 +58,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* 17May2010 2187 cjeanbap Change class to be Abstract
* 27 May 2012 #647 dgilling Implement getIdentifier/setIdentifier.
* Nov 05, 2013 2499 rjpeter Fix generics.
* May 14, 2014 2536 bclement moved WMO Header to common, removed ISerializableObject
* </pre>
*
* @author jkorman
@ -69,7 +69,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
@XmlAccessorType(XmlAccessType.NONE)
@DynamicSerialize
public abstract class StdTextProduct extends
PersistableDataObject<StdTextProductId> implements ISerializableObject {
PersistableDataObject<StdTextProductId> {
private static final long serialVersionUID = 1L;

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.common.wmo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Common WMO
Bundle-SymbolicName: com.raytheon.uf.common.wmo
Bundle-Version: 1.14.0.qualifier
Bundle-Vendor: RAYTHEON
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: com.raytheon.uf.common.time;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174"
Export-Package: com.raytheon.uf.common.wmo

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wmo.message;
package com.raytheon.uf.common.wmo;
import java.io.Serializable;
@ -29,6 +29,7 @@ import java.io.Serializable;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 29, 2008 1538 jkorman Initial creation
* May 14, 2014 2536 bclement moved WMO Header to common
* </pre>
*
* @author jkorman

View file

@ -17,15 +17,12 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wmo.message;
package com.raytheon.uf.common.wmo;
import java.util.Calendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.raytheon.edex.esb.Headers;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
/**
* The WMOHeader extracts and parses the relevant wmo header information (listed
* below) from a wmo weather message. TTAAii CCCC YYGGgg (BBB) TT = Data type
@ -46,6 +43,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* 20071130 410 jkorman Changed bad copyright symbol.
* 20071203 410 jkorman JavaDoc complaints.
* Jul 10, 2009 2191 rjpeter Added getTtaaii.
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
* </pre>
*
* @author jkorman
@ -112,8 +110,9 @@ public class WMOHeader {
* Construct the header from a wmo message.
*
* @param messageData
* @param fileName
*/
public WMOHeader(byte[] messageData, Headers headers) {
public WMOHeader(byte[] messageData, String fileName) {
// Assume not valid until proven otherwise!
isValid = false;
if (messageData != null) {
@ -169,7 +168,7 @@ public class WMOHeader {
}
YYGGgg = wmoHeader.substring(hdrIndex, hdrIndex + DTGROUP_SIZE);
parseDateTime(YYGGgg);
headerDate = TimeTools.findDataTime(YYGGgg, headers);
headerDate = WMOTimeParser.findDataTime(YYGGgg, fileName);
// At this point headerDate will either be the current time (non-archive) or
// a time generated from the WMOHeader and filename dateStamp

View file

@ -17,13 +17,12 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wmo.message;
package com.raytheon.uf.common.wmo;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -31,17 +30,18 @@ import java.util.regex.Pattern;
*
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 12, 2009 jkorman Initial creation
*
* May 14, 2014 2536 bclement moved WMO Header to common
*
* </pre>
*
*
* @author jkorman
* @version 1.0
* @version 1.0
*/
public class WMOHeaderFinder {

View file

@ -17,12 +17,10 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wmo.message;
package com.raytheon.uf.common.wmo;
import java.io.Serializable;
import com.raytheon.edex.esb.Headers;
/**
* TODO Add Description
*
@ -34,6 +32,7 @@ import com.raytheon.edex.esb.Headers;
* ------------ ---------- ----------- --------------------------
* Jan 14, 2009 jkorman Initial creation
* Nov 08, 2013 2506 bgonzale Setting messageBody is done only through setter method.
* May 14, 2014 2536 bclement moved WMO Header to common, added init()
*
* </pre>
*
@ -66,8 +65,8 @@ public class WMOMessage implements Serializable {
*
* @param wmoMessage
*/
public WMOMessage(String wmoMessage, Headers headers) {
this(wmoMessage.getBytes(), headers);
public WMOMessage(String wmoMessage, String fileName) {
this(wmoMessage.getBytes(), fileName);
}
/**
@ -75,18 +74,35 @@ public class WMOMessage implements Serializable {
*
* @param wmoMessage
*/
public WMOMessage(byte[] wmoMessage, Headers headers) {
public WMOMessage(byte[] wmoMessage, String fileName) {
if (wmoMessage != null) {
WMOHeader header = new WMOHeader(wmoMessage, headers);
if (header.isValid()) {
wmoHeader = header;
WMOHeader header = new WMOHeader(wmoMessage, fileName);
init(header, wmoMessage);
}
}
int bodyLen = wmoMessage.length - header.getMessageDataStart();
byte[] messageBodyData = new byte[bodyLen];
System.arraycopy(wmoMessage, header.getMessageDataStart(),
messageBodyData, 0, bodyLen);
setMessageBody(messageBodyData);
}
/**
* @param wmoMessage
*/
public WMOMessage(byte[] wmoMessage) {
if (wmoMessage != null) {
WMOHeader header = new WMOHeader(wmoMessage);
init(header, wmoMessage);
}
}
/**
* @param header
* @param wmoMessage
*/
private void init(WMOHeader header, byte[] wmoMessage) {
if (header.isValid()) {
wmoHeader = header;
int bodyLen = wmoMessage.length - header.getMessageDataStart();
byte[] messageBodyData = new byte[bodyLen];
System.arraycopy(wmoMessage, header.getMessageDataStart(),
messageBodyData, 0, bodyLen);
setMessageBody(messageBodyData);
}
}

View file

@ -0,0 +1,379 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.wmo;
import java.text.ParseException;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.DataFormatException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.util.TimeUtil;
/**
* Static utilities for parsing dates/times from WMO products
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 13, 2014 2536 bclement Initial creation, moved from TimeTools
*
* </pre>
*
* @author bclement
* @version 1.0
*/
public class WMOTimeParser {
private static final IUFStatusHandler logger = UFStatus
.getHandler(WMOTimeParser.class);
/** Environment variable to indicate archived files. */
private static final String ALLOW_ARCHIVE_ENV = "ALLOW_ARCHIVE_DATA";
/**
* Time stamp that includes the receipt time format at the end of the file
* name: .YYYYMMDD or .YYYYMMDDHH
*/
private static final Pattern FILE_TIMESTAMP = Pattern
.compile("(.*\\.)(\\d{8}|\\d{10})$");
public static final Pattern WMO_TIMESTAMP = Pattern
.compile("([0-3][0-9])(\\d{2})(\\d{2})[Zz]?");
/**
* Get a calendar that expresses the current system time based on specified
* date information or the current service time if not allowing archive.
*
* Note that the month argument should be 1 based (e.g. January = 1) and the
* returned calendar will have the month be 0 based (e.g. January = 0).
*
* @param year
* Year to set.
* @param month
* @param day
* @param hour
* @param minute
* @return The current time as a GMT Calendar.
*/
private static final Calendar getSystemCalendar(int year, int month,
int day, int hour, int minute) {
Calendar retCal = TimeUtil.newGmtCalendar();
if (allowArchive()) {
if (isValidDate(year, month, day)) {
if (hour != -1) {
if (minute != -1) {
retCal.set(Calendar.YEAR, year);
retCal.set(Calendar.MONTH, month - 1);
retCal.set(Calendar.DAY_OF_MONTH, day);
retCal.set(Calendar.HOUR_OF_DAY, hour);
retCal.set(Calendar.MINUTE, minute);
retCal.set(Calendar.SECOND, 0);
retCal.set(Calendar.MILLISECOND, 0);
}
}
}
}
return retCal;
}
/**
* Get Calendar with the time based on the timestamp at the end of the
* fileName.
*
* @param fileName
* @return calendar
*/
public static final Calendar getSystemCalendar(String fileName) {
int year = -1;
int month = -1;
int day = -1;
int hour = -1;
if (fileName != null) {
Matcher matcher = FILE_TIMESTAMP.matcher(fileName);
if (matcher.find()) {
String yyyymmdd = matcher.group(2);
try {
year = Integer.parseInt(yyyymmdd.substring(0, 4));
month = Integer.parseInt(yyyymmdd.substring(4, 6));
day = Integer.parseInt(yyyymmdd.substring(6, 8));
if (yyyymmdd.length() < 10) {
hour = 0;
} else {
hour = Integer.parseInt(yyyymmdd.substring(8, 10));
}
} catch (NumberFormatException nfe) {
year = -1;
month = -1;
day = -1;
}
}
}
return getSystemCalendar(year, month, day, hour, 0);
}
/**
* Get the timestamp in the file name.
*
* @param fileName
* @return timestamp if it matches FILE_TIMESTAMP otherwise null
*/
public static final String getTimestamp(String fileName) {
String timestamp = null;
Matcher matcher = FILE_TIMESTAMP.matcher(fileName);
if (matcher.find()) {
timestamp = matcher.group(2);
}
return timestamp;
}
/**
* Converts a ddhhmm time group to a Calendar. Adjusts the calendar as
* follows: Any time group with a day (dd) in the future is set back one
* month.
*
* @param wmoDateStamp
* the time to convert
*
* @return the converted time
*
* @throws DataFormatException
* if an error occurs
*/
public static final Calendar findCurrentTime(String wmoDateStamp,
String fileName) throws DataFormatException {
Calendar refCal = getSystemCalendar(fileName);
try {
Matcher matcher = WMO_TIMESTAMP.matcher(wmoDateStamp);
if (matcher.matches()) {
int iDay = Integer.parseInt(matcher.group(1));
int iHour = Integer.parseInt(matcher.group(2));
int iMinute = Integer.parseInt(matcher.group(3));
refCal = adjustDayHourMinute(refCal, iDay, iHour, iMinute);
} else {
throw new ParseException(
"Invalid format - time does not match "
+ WMO_TIMESTAMP.pattern(), 0);
}
} catch (Exception e) {
throw new DataFormatException("Unable to find current time for "
+ wmoDateStamp + ", exception was " + e.toString());
}
return refCal;
}
/**
* Convert a string in ddhhmm format to a standard {@link Calendar} format
* where ddhhmm is the GMT format while the standard time is in Calendar
* format with Year and Month information. Usage: ddhhmm is the issue time
* whereas utcTime can be the MDN time. The former comes "after" the latter.
*
* @parm ddhhmm day-hour-minute in GMT
* @parm local Time UTC time in Calendar
*/
public static final Calendar findDataTime(String ddhhmm, String fileName) {
Calendar issueTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
try {
issueTime = findCurrentTime(ddhhmm, fileName);
} catch (DataFormatException e) {
logger.info(" Error in processing MND time; return current time ");
issueTime = null;
}
return issueTime;
}
/**
* Adjusts the calendar from the current date to the specified date. If the
* specified date is later than the current date, the calendar is "backed
* up" one month. In addition, the second and millisecond fields are set to
* zero.
*
* @param cal
* the calendar to adjust
* @param day
* the new day of month
* @param hour
* the new hour of day
* @param minute
* the new minute of the hour
*/
private static Calendar adjustDayHourMinute(Calendar cal, int wmoDay,
int wmoHour, int wmoMinute) {
if (cal != null) {
int cDay = cal.get(Calendar.DAY_OF_MONTH);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
// Range check hour/minute first. Have to wait for
// checking the day
if (isValidHour(wmoHour) && (isValidMinSec(wmoMinute))) {
Calendar lastMonth = (Calendar) cal.clone();
lastMonth.set(Calendar.DAY_OF_MONTH, 1);
lastMonth.add(Calendar.MONTH, -1);
// Get the maximum day of the current month from the reference
// calendar
int maxDayThisMonth = cal
.getActualMaximum(Calendar.DAY_OF_MONTH);
// Set the day to one so all add/subtracts work correctly
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, wmoHour);
cal.set(Calendar.MINUTE, wmoMinute);
if (wmoDay == 1) {
// the wmoDay is 1
// and the reference calendar is the last
// day of the month
if (cDay == maxDayThisMonth) {
// This is potentially next month's data received early
// Allow three hours into the next day
if (wmoHour < 3) {
// Advance to the next month
cal.add(Calendar.MONTH, 1);
// and set the hour, minute
}
}
} else if (wmoDay > cDay) {
// Is the wmoDay valid for this month?
if (wmoDay <= maxDayThisMonth) {
// First allow up to 3 hours into the next day
if ((cDay + 1) == wmoDay) {
// This is potentially next month's data received
// early. Allow three hours into the next day
if (wmoHour > 2) {
// Back up a month
cal.add(Calendar.MONTH, -1);
}
} else {
// Back up a month
cal.add(Calendar.MONTH, -1);
int mDay = cal
.getActualMaximum(Calendar.DAY_OF_MONTH);
if (mDay < wmoDay) {
cal.add(Calendar.MONTH, -1);
}
}
} else {
// The wmoDay is greater than the maximum number
// of days for the reference month. We can't back
// up one month, but can always back up two months.
cal.add(Calendar.MONTH, -2);
}
}
cal.set(Calendar.DAY_OF_MONTH, wmoDay);
} else {
// bad
cal = null;
}
}
return cal;
}
/**
* Is a specified date valid? This method checks an entire year, month, day
* timestamp.
*
* @param year
* The year to check.
* @param month
* Numeric value of the month.
* @param day
* Is the month valid?
* @return Is year, month, day timestamp valid.
*/
private static final boolean isValidDate(int year, int month, int day) {
boolean validDay = false;
if (day > -1) {
if (isValidYear(year)) {
if (isValidMonth(month)) {
Calendar c = TimeUtil.newGmtCalendar(year, month, 1);
int lastDay = c.getActualMaximum(Calendar.DAY_OF_MONTH) + 1;
validDay = (day < lastDay);
}
}
}
return validDay;
}
/**
* Is the year valid. This method supposes any positive year value as valid.
*
* @param year
* The year to check.
* @return Is the year valid?
*/
private static final boolean isValidYear(int year) {
return (year >= 0);
}
/**
* The the specified month of the year valid.
*
* @param month
* Numeric value of the month.
* @return Is the month valid?
*/
private static final boolean isValidMonth(int month) {
return ((month > 0) && (month <= 12));
}
/**
* Is the specified hour of the day valid? Range 0..23 inclusive.
*
* @param hour
* The hour to check.
* @return Is the hour valid?
*/
private static final boolean isValidHour(int hour) {
return ((hour > -1) && (hour < TimeUtil.HOURS_PER_DAY));
}
/**
* Is the specified minute/second valid? Range 0..59 inclusive.
*
* @param hour
* The minute/second to check.
* @return Is the minute/second valid?
*/
private static final boolean isValidMinSec(int value) {
return ((value > -1) && (value < TimeUtil.MINUTES_PER_HOUR));
}
/**
* Check to see if archive files are allowed.
*
* @return true when archive files are allowed
*/
public static boolean allowArchive() {
// This doesn't pick up the environment variable.
// return Boolean.getBoolean(ALLOW_ARCHIVE_ENV);
return "true".equalsIgnoreCase(System.getenv().get(ALLOW_ARCHIVE_ENV));
}
}

View file

@ -17,12 +17,10 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.wmo.message;
package com.raytheon.uf.common.wmo;
import java.util.Arrays;
import com.raytheon.edex.esb.Headers;
/**
* WMOMessage that handles XML. Specifically, removes data trailing the ending
* XML tag.
@ -34,6 +32,7 @@ import com.raytheon.edex.esb.Headers;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 8, 2013 2506 bgonzale Initial creation
* May 14, 2014 2536 bclement moved WMO Header to common, added XmlWMOMessage(byte[])
*
* </pre>
*
@ -43,6 +42,8 @@ import com.raytheon.edex.esb.Headers;
public class XmlWMOMessage extends WMOMessage {
private static final long serialVersionUID = -5370011261840245750L;
/**
* Default Constructor.
*/
@ -51,18 +52,25 @@ public class XmlWMOMessage extends WMOMessage {
/**
* @param wmoMessage
* @param headers
* @param fileName
*/
public XmlWMOMessage(String wmoMessage, Headers headers) {
super(wmoMessage, headers);
public XmlWMOMessage(String wmoMessage, String fileName) {
super(wmoMessage, fileName);
}
/**
* @param wmoMessage
* @param headers
* @param fileName
*/
public XmlWMOMessage(byte[] wmoMessage, Headers headers) {
super(wmoMessage, headers);
public XmlWMOMessage(byte[] wmoMessage, String fileName) {
super(wmoMessage, fileName);
}
/**
* @param wmoMessage
*/
public XmlWMOMessage(byte[] wmoMessage) {
super(wmoMessage);
}
/**

View file

@ -13,4 +13,5 @@ Require-Bundle: com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
com.raytheon.uf.edex.decodertools;bundle-version="1.0.0"
Export-Package: com.raytheon.uf.edex.bufrtools
Import-Package: com.raytheon.edex.esb,
com.raytheon.uf.common.wmo,
org.apache.commons.logging

View file

@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.esb.Headers;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDocument;
import com.raytheon.uf.edex.decodertools.bufr.BUFRFile;
@ -34,7 +35,6 @@ import com.raytheon.uf.edex.decodertools.bufr.descriptors.IDescriptorFactoryDele
import com.raytheon.uf.edex.decodertools.bufr.descriptors.IDescriptorFactorySelector;
import com.raytheon.uf.edex.decodertools.bufr.packets.BUFRSublistPacket;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Abstract base class for implementing BUFR data decoders using subclasses of
@ -49,6 +49,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 19, 2009 2519 jkorman Initial creation
* May 14, 2014 2536 bclement moved WMO Header to common
*
* </pre>
*
@ -101,7 +102,9 @@ public abstract class AbstractBUFRDecoder implements IDescriptorFactorySelector
logger.debug(traceId + " - Decoding data");
try {
if (data != null && data.length > 0) {
wmoHeader = new WMOHeader(data, headers);
String fileName = (String) headers
.get(WMOHeader.INGEST_FILE_NAME);
wmoHeader = new WMOHeader(data, fileName);
if ((wmoHeader != null) && (wmoHeader.isValid())) {
int start = wmoHeader.getMessageDataStart();

View file

@ -31,16 +31,16 @@ import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.pointdata.PointDataDescription;
import com.raytheon.uf.common.pointdata.PointDataView;
import com.raytheon.uf.common.pointdata.PointDataDescription.Type;
import com.raytheon.uf.common.pointdata.PointDataView;
import com.raytheon.uf.common.wmo.WMOHeader;
import com.raytheon.uf.edex.decodertools.bufr.BUFRDataDocument;
import com.raytheon.uf.edex.decodertools.bufr.packets.IBUFRDataPacket;
import com.raytheon.uf.edex.pointdata.PointDataPluginDao;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
/**
* Abstract base class for implementing data adapters for creating specific
* subclasses of PluginDataObject from BUFR data.
* subclasses of PluginDataObject from BUFR data.
*
*
* <pre>
@ -48,6 +48,7 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 20090629 2519 jkorman Initial implementation.
* May 14, 2014 2536 bclement moved WMO Header to common, added breaks/default to switch
*
* </pre>
*
@ -217,32 +218,34 @@ public abstract class BUFRPointDataAdapter<T extends PluginDataObject> {
Object o = packet.getValue();
if(o != null) {
switch (t) {
case STRING : {
case STRING:
if(o instanceof String) {
view.setString(parmName,(String) o, index);
}
}
case INT : {
break;
case INT:
if(o instanceof Double) {
view.setInt(parmName,((Double) o).intValue(), index);
} else if(o instanceof Long) {
view.setInt(parmName,((Long) o).intValue(), index);
}
}
case LONG : {
break;
case LONG:
if(o instanceof Double) {
view.setLong(parmName,((Double) o).longValue(), index);
} else if(o instanceof Long) {
view.setLong(parmName,(Long) o, index);
}
}
case FLOAT : {
break;
case FLOAT:
if(o instanceof Double) {
view.setFloat(parmName,((Double) o).floatValue(), index);
} else if(o instanceof Long) {
view.setFloat(parmName,((Long) o).floatValue(), index);
}
}
break;
default:
logger.warn("Unsupported point data view type: " + t);
}
}
}

View file

@ -140,4 +140,11 @@
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.common.wmo"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>

View file

@ -77,3 +77,4 @@ Export-Package: com.raytheon.uf.edex.datadelivery.retrieval;
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.datadelivery.registry",
com.raytheon.uf.edex.datadelivery.retrieval.wfs
Import-Package: com.raytheon.uf.common.wmo

View file

@ -21,13 +21,12 @@ package com.raytheon.uf.edex.datadelivery.retrieval.handlers;
import javax.xml.bind.JAXBException;
import com.raytheon.edex.esb.Headers;
import com.raytheon.uf.common.datadelivery.registry.Coverage;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.wmo.WMOMessage;
import com.raytheon.uf.common.wmo.XmlWMOMessage;
import com.raytheon.uf.edex.datadelivery.retrieval.opendap.OpenDapRetrievalResponse;
import com.raytheon.uf.edex.datadelivery.retrieval.wfs.WfsRetrievalResponse;
import com.raytheon.uf.edex.wmo.message.WMOMessage;
import com.raytheon.uf.edex.wmo.message.XmlWMOMessage;
/**
* Deserializes the retrieved data in a retrievalQueue.
@ -46,6 +45,7 @@ import com.raytheon.uf.edex.wmo.message.XmlWMOMessage;
* Trim content after last xml tag during
* marshaling from xml.
* Jan 30, 2014 2686 dhladky refactor of retrieval.
* May 14, 2014 2536 bclement moved WMO Header to common
*
* </pre>
*
@ -83,7 +83,7 @@ public class DeserializeRetrievedDataFromIngest implements IRetrievalsFinder {
if (xml == null) {
return null;
} else {
WMOMessage message = new XmlWMOMessage(xml, new Headers());
WMOMessage message = new XmlWMOMessage(xml.getBytes());
return (RetrievalResponseXml) jaxbManager.unmarshalFromXml(message
.getBodyText());
}

View file

@ -22,6 +22,6 @@ Export-Package: com.raytheon.uf.edex.decodertools.aircraft,
com.raytheon.uf.edex.decodertools.bufr.packets,
com.raytheon.uf.edex.decodertools.core,
com.raytheon.uf.edex.decodertools.core.filterimpl,
com.raytheon.uf.edex.decodertools.time,
com.raytheon.uf.edex.wmo.message
Import-Package: org.apache.commons.logging
com.raytheon.uf.edex.decodertools.time
Import-Package: com.raytheon.uf.common.wmo,
org.apache.commons.logging

View file

@ -22,7 +22,7 @@ package com.raytheon.uf.edex.decodertools.bufr;
import java.nio.ByteBuffer;
import java.util.Calendar;
import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.common.time.util.TimeUtil;
/**
* <pre>
@ -33,6 +33,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
* ------------ ---------- ----------- --------------------------
* 20071127 382 jkorman Initial Coding.
* 20080214 862 jkorman Factored datetime info from subclasses.
* May 14, 2014 2536 bclement removed TimeTools usage
* </pre>
*
* @author jkorman
@ -128,7 +129,7 @@ public abstract class BUFRSection1 extends BUFRSection {
* @return
*/
public Calendar getSectionDate() {
Calendar cal = TimeTools.getBaseCalendar(year, month, day);
Calendar cal = TimeUtil.newGmtCalendar(year, month, day);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);

View file

@ -21,7 +21,8 @@ package com.raytheon.uf.edex.decodertools.core;
import java.util.HashMap;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.WMOHeader;
/**

View file

@ -21,7 +21,8 @@ package com.raytheon.uf.edex.decodertools.core;
import java.io.Serializable;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.common.wmo.WMOHeader;
/**

View file

@ -20,19 +20,12 @@
package com.raytheon.uf.edex.decodertools.time;
import java.io.File;
import java.text.ParseException;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.DataFormatException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.edex.esb.Headers;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.edex.decodertools.core.DecoderTools;
/**
* TimeTools provides a set of mid level Calendar manipulation methods. The
@ -56,6 +49,7 @@ import com.raytheon.uf.edex.decodertools.core.DecoderTools;
* 20130219 1636 rferrel File timestamp can now be YYMMDD or YYMMDDHH.
* 20130912 2249 rferrel Added getWarningTimestamp method.
* 20140409 2907 njensen Deprecated duplicated functionality
* 20140514 2536 bclement moved WMO Header time parsing to WMOTimeParser
* </pre>
*
* @author jkorman
@ -63,16 +57,6 @@ import com.raytheon.uf.edex.decodertools.core.DecoderTools;
*/
public class TimeTools {
/** Environment variable to indicate archived files. */
private static final String ALLOW_ARCHIVE_ENV = "ALLOW_ARCHIVE_DATA";
/**
* Time stamp that includes the receipt time format at the end of the file
* name: .YYYYMMDD or .YYYYMMDDHH
*/
private static final Pattern FILE_TIMESTAMP = Pattern
.compile("(.*\\.)(\\d{8}|\\d{10})$");
/**
* Time stamp for a file name created by the Text Editor Dialog. This
* assumes the 10 digit following .wan is the warning's issue time in epoch
@ -90,8 +74,6 @@ public class TimeTools {
*/
private static Pattern FILE_WARNING_TIMESTAMP = null;
public static final Pattern WMO_TIMESTAMP = Pattern
.compile("([0-3][0-9])(\\d{2})(\\d{2})[Zz]?");
/**
* @deprecated use com.raytheon.uf.common.time.util.TimeUtil instead
@ -137,39 +119,6 @@ public class TimeTools {
private static ITimeService timeService = null;
private static final Log logger = LogFactory.getLog(TimeTools.class);
static interface ICheckAllowArchive {
boolean allowArchive();
}
/**
* Default class for checking for allowing archive.
*/
private static class CheckOSEnv implements ICheckAllowArchive {
@Override
public boolean allowArchive() {
// This doesn't pick up the environment variable.
// return Boolean.getBoolean(ALLOW_ARCHIVE_ENV);
return "true".equalsIgnoreCase(System.getenv().get(
ALLOW_ARCHIVE_ENV));
}
}
/** Allows the check on archive to be overridden for testing. */
static ICheckAllowArchive checkAllowArchive = new CheckOSEnv();
/**
* Check to see if archive files are allowed.
*
* @return true when archive files are allowed
*/
public static boolean allowArchive() {
return checkAllowArchive.allowArchive();
}
/**
* Get a calendar that expresses the current system time. If an ITimeService
* provider is registered, the time is retrieved from the service.
@ -198,110 +147,6 @@ public class TimeTools {
return retCal;
}
/**
* Get a calendar that expresses the current system time. With the month day
* and year of the file extension.
*
* Note that the month argument should be 1 based (e.g. January = 1) and the
* returned calendar will have the month be 0 based (e.g. January = 0).
*
* @return The current time as a GMT Calendar.
* @deprecated use com.raytheon.uf.common.time.util.TimeUtil instead
*/
@Deprecated
public static final Calendar getSystemCalendar(int year, int month, int day) {
return getSystemCalendar(year, month, day, 0, 0);
}
/**
* Get a calendar that expresses the current system time based on specified
* date information or the current service time if not allowing archive.
*
* Note that the month argument should be 1 based (e.g. January = 1) and the
* returned calendar will have the month be 0 based (e.g. January = 0).
*
* @param year
* Year to set.
* @param month
* @param day
* @param hour
* @param minute
* @return The current time as a GMT Calendar.
* @deprecated use com.raytheon.uf.common.time.util.TimeUtil instead
*/
@Deprecated
public static final Calendar getSystemCalendar(int year, int month,
int day, int hour, int minute) {
Calendar retCal = getSystemCalendar();
if (allowArchive()) {
if (isValidDate(year, month, day)) {
if (hour != -1) {
if (minute != -1) {
retCal.set(Calendar.YEAR, year);
retCal.set(Calendar.MONTH, month - 1);
retCal.set(Calendar.DAY_OF_MONTH, day);
retCal.set(Calendar.HOUR_OF_DAY, hour);
retCal.set(Calendar.MINUTE, minute);
retCal.set(Calendar.SECOND, 0);
retCal.set(Calendar.MILLISECOND, 0);
}
}
}
}
return retCal;
}
/**
* Get Calendar with the time based on the timestamp at the end of the
* fileName.
*
* @param fileName
* @return calendar
*/
public static final Calendar getSystemCalendar(String fileName) {
int year = -1;
int month = -1;
int day = -1;
int hour = -1;
if (fileName != null) {
Matcher matcher = FILE_TIMESTAMP.matcher(fileName);
if (matcher.find()) {
String yyyymmdd = matcher.group(2);
try {
year = Integer.parseInt(yyyymmdd.substring(0, 4));
month = Integer.parseInt(yyyymmdd.substring(4, 6));
day = Integer.parseInt(yyyymmdd.substring(6, 8));
if (yyyymmdd.length() < 10) {
hour = 0;
} else {
hour = Integer.parseInt(yyyymmdd.substring(8, 10));
}
} catch (NumberFormatException nfe) {
year = -1;
month = -1;
day = -1;
}
}
}
return getSystemCalendar(year, month, day, hour, 0);
}
/**
* Get the timestamp in the file name.
*
* @param fileName
* @return timestamp if it matches FILE_TIMESTAMP otherwise null
*/
public static final String getTimestamp(String fileName) {
String timestamp = null;
Matcher matcher = FILE_TIMESTAMP.matcher(fileName);
if (matcher.find()) {
timestamp = matcher.group(2);
}
return timestamp;
}
/**
* Get the time stamp of a warning file name based on the name generated by
* the TextEditorDialog.
@ -331,156 +176,6 @@ public class TimeTools {
return timestamp;
}
/**
* Converts a ddhhmm time group to a Calendar. Adjusts the calendar as
* follows: Any time group with a day (dd) in the future is set back one
* month.
*
* @param wmoDateStamp
* the time to convert
*
* @return the converted time
*
* @throws DataFormatException
* if an error occurs
*/
public static final Calendar findCurrentTime(String wmoDateStamp,
String fileName) throws DataFormatException {
Calendar refCal = getSystemCalendar(fileName);
try {
Matcher matcher = WMO_TIMESTAMP.matcher(wmoDateStamp);
if (matcher.matches()) {
int iDay = Integer.parseInt(matcher.group(1));
int iHour = Integer.parseInt(matcher.group(2));
int iMinute = Integer.parseInt(matcher.group(3));
refCal = adjustDayHourMinute(refCal, iDay, iHour, iMinute);
} else {
throw new ParseException(
"Invalid format - time does not match "
+ WMO_TIMESTAMP.pattern(), 0);
}
} catch (Exception e) {
throw new DataFormatException("Unable to find current time for "
+ wmoDateStamp + ", exception was " + e.toString());
}
return refCal;
}
/**
* Convert a string in ddhhmm format to a standard {@link Calendar} format
* where ddhhmm is the GMT format while the standard time is in Calendar
* format with Year and Month information. Usage: ddhhmm is the issue time
* whereas utcTime can be the MDN time. The former comes "after" the latter.
*
* @parm ddhhmm day-hour-minute in GMT
* @parm local Time UTC time in Calendar
*/
public static final Calendar findDataTime(String ddhhmm, Headers headers) {
Calendar issueTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
String fileName = null;
if (headers != null) {
fileName = (String) headers.get(DecoderTools.INGEST_FILE_NAME);
}
try {
issueTime = findCurrentTime(ddhhmm, fileName);
} catch (DataFormatException e) {
if (logger.isInfoEnabled()) {
logger.info(" Error in processing MND time; return current time ");
}
issueTime = null;
}
return issueTime;
}
/**
* Adjusts the calendar from the current date to the specified date. If the
* specified date is later than the current date, the calendar is "backed
* up" one month. In addition, the second and millisecond fields are set to
* zero.
*
* @param cal
* the calendar to adjust
* @param day
* the new day of month
* @param hour
* the new hour of day
* @param minute
* the new minute of the hour
*/
private static Calendar adjustDayHourMinute(Calendar cal, int wmoDay,
int wmoHour, int wmoMinute) {
if (cal != null) {
int cDay = cal.get(Calendar.DAY_OF_MONTH);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
// Range check hour/minute first. Have to wait for
// checking the day
if (isValidHour(wmoHour) && (isValidMinSec(wmoMinute))) {
Calendar lastMonth = copy(cal);
lastMonth.set(Calendar.DAY_OF_MONTH, 1);
lastMonth.add(Calendar.MONTH, -1);
// Get the maximum day of the current month from the reference
// calendar
int maxDayThisMonth = cal
.getActualMaximum(Calendar.DAY_OF_MONTH);
// Set the day to one so all add/subtracts work correctly
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, wmoHour);
cal.set(Calendar.MINUTE, wmoMinute);
if (wmoDay == 1) {
// the wmoDay is 1
// and the reference calendar is the last
// day of the month
if (cDay == maxDayThisMonth) {
// This is potentially next month's data received early
// Allow three hours into the next day
if (wmoHour < 3) {
// Advance to the next month
cal.add(Calendar.MONTH, 1);
// and set the hour, minute
}
}
} else if (wmoDay > cDay) {
// Is the wmoDay valid for this month?
if (wmoDay <= maxDayThisMonth) {
// First allow up to 3 hours into the next day
if ((cDay + 1) == wmoDay) {
// This is potentially next month's data received
// early. Allow three hours into the next day
if (wmoHour > 2) {
// Back up a month
cal.add(Calendar.MONTH, -1);
}
} else {
// Back up a month
cal.add(Calendar.MONTH, -1);
int mDay = cal
.getActualMaximum(Calendar.DAY_OF_MONTH);
if (mDay < wmoDay) {
cal.add(Calendar.MONTH, -1);
}
}
} else {
// The wmoDay is greater than the maximum number
// of days for the reference month. We can't back
// up one month, but can always back up two months.
cal.add(Calendar.MONTH, -2);
}
}
cal.set(Calendar.DAY_OF_MONTH, wmoDay);
} else {
// bad
cal = null;
}
}
return cal;
}
/**
* Set the time service. To clear an existing service, set a null reference.
*
@ -497,39 +192,7 @@ public class TimeTools {
return retService;
}
/**
* Create a Greenwich Mean Time calendar for a given base date at 0 hours,
* minutes and seconds on a specified year, month, and day.
*
* Note that the month argument should be 1 based (e.g. January = 1) and the
* returned calendar will have the month be 0 based (e.g. January = 0).
*
* @param year
* Calendar year.
* @param month
* Month of the year [1..12].
* @param day
* Day of the month [1..31] varies by month rules.
* @return
* @deprecated use com.raytheon.uf.common.time.util.TimeUtil instead
*/
@Deprecated
public static final Calendar getBaseCalendar(int year, int month, int day) {
Calendar calendar = null;
calendar = getSystemCalendar();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar;
}
/**
* Get a new GMT time-zone calendar set to a specified time in milliseconds.
@ -649,77 +312,6 @@ public class TimeTools {
return calendar;
}
/**
* Is the year valid. This method supposes any positive year value as valid.
*
* @param year
* The year to check.
* @return Is the year valid?
*/
public static final boolean isValidYear(int year) {
return (year >= 0);
}
/**
* The the specified month of the year valid.
*
* @param month
* Numeric value of the month.
* @return Is the month valid?
*/
public static final boolean isValidMonth(int month) {
return ((month > 0) && (month <= 12));
}
/**
* Is the specified hour of the day valid? Range 0..23 inclusive.
*
* @param hour
* The hour to check.
* @return Is the hour valid?
*/
public static final boolean isValidHour(int hour) {
return ((hour > -1) && (hour < HOURS_DAY));
}
/**
* Is the specified minute/second valid? Range 0..59 inclusive.
*
* @param hour
* The minute/second to check.
* @return Is the minute/second valid?
*/
public static final boolean isValidMinSec(int value) {
return ((value > -1) && (value < MINUTES_HOUR));
}
/**
* Is a specified date valid? This method checks an entire year, month, day
* timestamp.
*
* @param year
* The year to check.
* @param month
* Numeric value of the month.
* @param day
* Is the month valid?
* @return Is year, month, day timestamp valid.
*/
public static final boolean isValidDate(int year, int month, int day) {
boolean validDay = false;
if (day > -1) {
if (isValidYear(year)) {
if (isValidMonth(month)) {
Calendar c = getBaseCalendar(year, month, 1);
int lastDay = c.getActualMaximum(Calendar.DAY_OF_MONTH) + 1;
validDay = (day < lastDay);
}
}
}
return validDay;
}
/**
* Disable constructor.
*/

View file

@ -12,4 +12,5 @@ Require-Bundle: com.raytheon.edex.common;bundle-version="1.11.1",
javax.measure
Import-Package: com.raytheon.edex.plugin.obs.metar,
com.raytheon.uf.common.dataplugin.obs.metar,
com.raytheon.uf.common.wmo,
org.apache.commons.logging

Some files were not shown because too many files have changed in this diff Show more