Merge "Omaha #5166: Update logging to use SLF4J:shef" into omaha_16.2.2
Former-commit-id: 8082963e8622b5c805f1df1c6c1f9822f2a743a9
This commit is contained in:
commit
5849d054e8
13 changed files with 1167 additions and 1099 deletions
|
@ -30,5 +30,5 @@ Import-Package: com.raytheon.edex.plugin.obs,
|
|||
com.raytheon.uf.common.dataplugin.text.request,
|
||||
com.raytheon.uf.common.ohd,
|
||||
com.raytheon.uf.common.wmo,
|
||||
org.apache.commons.logging
|
||||
org.slf4j
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ import java.util.TimeZone;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.edex.plugin.shef.data.ShefData;
|
||||
import com.raytheon.edex.plugin.shef.data.ShefRecord;
|
||||
|
@ -132,6 +132,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* 09/18/2014 3627 mapeters Updated deprecated {@link TimeTools} usage.
|
||||
* 06/26/2015 17420 xwei Fix for : Application fails to act on defined locdatalimit range for parameter element SW
|
||||
* Aug 05, 2015 4486 rjpeter Changed Timestamp to Date.
|
||||
* Dec 16, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
* </pre>
|
||||
*
|
||||
* @author mduff
|
||||
|
@ -1098,7 +1099,7 @@ public class PostShef {
|
|||
*/
|
||||
public void logStats(String traceId, long totalTime) {
|
||||
if (this.perfLog) {
|
||||
Log perfLog = LogFactory.getLog("ShefPerfLog");
|
||||
Logger perfLog = LoggerFactory.getLogger("ShefPerfLog");
|
||||
perfLog.info("********************************");
|
||||
perfLog.info("Performance Stats: " + traceId);
|
||||
perfLog.info("Total Elapsed Time (ms): " + totalTime);
|
||||
|
@ -1158,7 +1159,7 @@ public class PostShef {
|
|||
}
|
||||
}
|
||||
|
||||
private void logIt(Log log, long value, String label) {
|
||||
private void logIt(Logger log, long value, String label) {
|
||||
if (value > 0) {
|
||||
log.info(value + label);
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.edex.plugin.shef.ShefSeparator;
|
||||
import com.raytheon.uf.common.dataplugin.shef.tables.Purgeproduct;
|
||||
|
@ -48,10 +48,11 @@ import com.raytheon.uf.edex.database.dao.DaoConfig;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 8, 2010 jkorman Initial creation
|
||||
* Mar 08, 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
|
||||
* Aug 05, 2015 4486 rjpeter Changed Timestamp to Date.
|
||||
* Dec 16, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -60,7 +61,7 @@ import com.raytheon.uf.edex.database.dao.DaoConfig;
|
|||
|
||||
public class PurgeText {
|
||||
/** The logger */
|
||||
private final Log log = LogFactory.getLog(getClass());
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private boolean storeText = false;
|
||||
|
||||
|
@ -130,9 +131,11 @@ public class PurgeText {
|
|||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(traceId + " - Error processing text data. ");
|
||||
String errorMsg = traceId + " - Error processing text data. ";
|
||||
if (log.isDebugEnabled()) {
|
||||
log.error(e);
|
||||
log.error(errorMsg, e);
|
||||
} else {
|
||||
log.error(errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,9 +188,11 @@ public class PurgeText {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(traceId + " - Error processing text data. ");
|
||||
String errorMsg = traceId + " - Error processing text data. ";
|
||||
if (log.isDebugEnabled()) {
|
||||
log.error(e);
|
||||
log.error(errorMsg, e);
|
||||
} else {
|
||||
log.error(errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,9 +271,11 @@ public class PurgeText {
|
|||
dao.saveOrUpdate(t);
|
||||
success = true;
|
||||
} catch (Exception e) {
|
||||
log.error("Error saving text ");
|
||||
String errorMsg = "Error saving text ";
|
||||
if (log.isDebugEnabled()) {
|
||||
log.error(e);
|
||||
log.error(errorMsg, e);
|
||||
} else {
|
||||
log.error(errorMsg);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
|
|
@ -25,8 +25,8 @@ import java.util.Calendar;
|
|||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.edex.plugin.shef.data.precip.PrecipRecord;
|
||||
import com.raytheon.uf.common.dataplugin.shef.tables.Dailypp;
|
||||
|
@ -48,15 +48,16 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 9/22 #1553 mnash Initial implementation of GagePP
|
||||
* 6/1/09 #2432 jsanchez Updated value magnitude for hourlypp/pc.
|
||||
* 26 Nov 2012 #15554 lbousaidi used obstime instead of system time in isNear12Z
|
||||
* routine.
|
||||
* 26 Nov 2012 #15554 lbousaidi used obstime instead of system time in isNear12Z
|
||||
* routine.
|
||||
* 4 Dec 2012 #15569 lbousaidi fixed daily pp value when token is set to USE_REVCODE
|
||||
* 02 Feb 2012 #15845 lbousaidi added check for data that comes in as -999
|
||||
* 07 May 2013 #15880 lbousaidi changed pPE parameter because it was inserting to the
|
||||
* wrong hour field.
|
||||
* 15 Sep 2014 #17129 lbousaidi add a fix for the top of hour issue for hourlypp.
|
||||
* 15 Sep 2014 #17129 lbousaidi add a fix for the top of hour issue for hourlypp.
|
||||
* 18 Sep 2014 #3627 mapeters Updated deprecated {@link TimeTools} usage.
|
||||
* 15 Jun 2015 #15039 lbousaidi add a fix to be able to post data to hour24.
|
||||
* 16 Dec 2015 #5166 kbisanz Update logging to use SLF4J
|
||||
* </pre>
|
||||
*
|
||||
* @author mnash
|
||||
|
@ -72,7 +73,7 @@ public class GagePP {
|
|||
private static final int GPP_SKIP_RECORD = 4;
|
||||
|
||||
private static final int GPP_BADRECORD = 3;
|
||||
|
||||
|
||||
private static final int DEFAULT_WINDOW_HOURS = 3;
|
||||
|
||||
public static final int MINIMUM_GPP_SLEEP_DURATION = 10;
|
||||
|
@ -97,7 +98,7 @@ public class GagePP {
|
|||
|
||||
private static final float MISSING_PRECIP = -9999;
|
||||
|
||||
private static Log logger = LogFactory.getLog(GagePP.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(GagePP.class);
|
||||
|
||||
private GagePPWrite gagePPWrite = null;
|
||||
|
||||
|
@ -106,7 +107,7 @@ public class GagePP {
|
|||
private short pHourSlot;
|
||||
|
||||
private short p6HourSlot;
|
||||
|
||||
|
||||
public GagePP() {
|
||||
}
|
||||
|
||||
|
@ -132,7 +133,6 @@ public class GagePP {
|
|||
String msgstr = "";
|
||||
String cur_key = "";
|
||||
|
||||
|
||||
Dailypp dailyPP = new Dailypp();
|
||||
|
||||
Hourlypp hourlyPP = new Hourlypp();
|
||||
|
@ -152,9 +152,9 @@ public class GagePP {
|
|||
Date btime = new Date();
|
||||
|
||||
int status = GPP_OK;
|
||||
|
||||
|
||||
logger.info("Processing records at " + btime);
|
||||
|
||||
|
||||
Calendar dt = TimeUtil.newGmtCalendar();
|
||||
dt.setTimeInMillis(rec.getObsTime().getTime());
|
||||
|
||||
|
@ -219,16 +219,16 @@ public class GagePP {
|
|||
/*
|
||||
* Determine which 6 hour slot to place the data value in.
|
||||
*/
|
||||
|
||||
short [] sHour = new short [] { p6HourSlot, };
|
||||
|
||||
short[] sHour = new short[] { p6HourSlot };
|
||||
status = gage_pp_6hour_slot(pOptions, dt, obstime_ytd, sHour,
|
||||
offset_code);
|
||||
|
||||
if(!dt.getTime().equals(rec.getObsTime())) {
|
||||
|
||||
if (!dt.getTime().equals(rec.getObsTime())) {
|
||||
rec.setObsTime(dt.getTime());
|
||||
dp = TimeUtil.newCalendar(dt);
|
||||
}
|
||||
|
||||
|
||||
p6HourSlot = sHour[0];
|
||||
break;
|
||||
|
||||
|
@ -317,12 +317,13 @@ public class GagePP {
|
|||
+ MISSING_PRECIP);
|
||||
value = MISSING_PRECIP;
|
||||
}
|
||||
/* This was added for KRF site that was getting missing values -999
|
||||
*
|
||||
/*
|
||||
* This was added for KRF site that was getting missing values
|
||||
* -999
|
||||
*/
|
||||
|
||||
if (value ==-99900.0) {
|
||||
value = MISSING_PRECIP;
|
||||
|
||||
if (value == -99900.0) {
|
||||
value = MISSING_PRECIP;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -331,7 +332,7 @@ public class GagePP {
|
|||
*/
|
||||
rec.setValue(Math.round((value)));
|
||||
}
|
||||
|
||||
|
||||
if ((Float) (rec.getValue()) != null && rec.getLocationId() != null) {
|
||||
prev_dur = rec.getShefDuration().getValue();
|
||||
status = GPP_OK;
|
||||
|
@ -354,8 +355,8 @@ public class GagePP {
|
|||
.getLocationId(),
|
||||
rec.getTypeSource().getCode(), rec.getValue(),
|
||||
obstime_ytd, '0', 'M');
|
||||
initialize_hourlypp(hourlyPP, rev_6hour_code,
|
||||
msgstr, rec, rec.getObsTime());
|
||||
initialize_hourlypp(hourlyPP, rev_6hour_code, msgstr,
|
||||
rec, rec.getObsTime());
|
||||
obstime_prev = obstime_ytd;
|
||||
break;
|
||||
|
||||
|
@ -402,18 +403,20 @@ public class GagePP {
|
|||
.getQualCode()));
|
||||
hourlyPP.setMinuteOffset(String
|
||||
.valueOf(offset_code[0]));
|
||||
|
||||
|
||||
rev_code = (short) ((rec.revision) ? 1 : 0);
|
||||
break;
|
||||
case 6:
|
||||
precip_val = (short) rec.getValue();
|
||||
PrecipUtils.set_6hour_slot_value(hourlyPP, p6HourSlot,
|
||||
precip_val);
|
||||
PrecipUtils.set_6hour_slot_value(hourlyPP,
|
||||
p6HourSlot, precip_val);
|
||||
hourlyPP.setSixhrqc(String.valueOf(rec
|
||||
.getQualCode()));
|
||||
hourlyPP.setSixhroffset(String.valueOf(offset_code[0]));
|
||||
|
||||
rev_6hour_code[p6HourSlot] = (short)((rec.revision) ? 1 : 0);
|
||||
hourlyPP.setSixhroffset(String
|
||||
.valueOf(offset_code[0]));
|
||||
|
||||
rev_6hour_code[p6HourSlot] = (short) ((rec.revision) ? 1
|
||||
: 0);
|
||||
break;
|
||||
case 24:
|
||||
dailyPP.setValue(Double.valueOf(rec.getValue()));
|
||||
|
@ -424,13 +427,13 @@ public class GagePP {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
if (rec.getDataDuration() == 24) {
|
||||
dailyPP.setValue(Double.valueOf(rec.getValue()));
|
||||
dailyPP.setQc(String.valueOf(rec.getQualCode()));
|
||||
rev_24hour_code = rec.revision;
|
||||
}
|
||||
if (rec.getDataDuration() == 24) {
|
||||
dailyPP.setValue(Double.valueOf(rec.getValue()));
|
||||
dailyPP.setQc(String.valueOf(rec.getQualCode()));
|
||||
rev_24hour_code = rec.revision;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Increment the count of total values. This should always
|
||||
|
@ -456,7 +459,6 @@ public class GagePP {
|
|||
+ rec.getObsTime() + ": Record skipped");
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -494,17 +496,18 @@ public class GagePP {
|
|||
case 1001:
|
||||
case 1006:
|
||||
status = GPP_OK;
|
||||
// PrecipUtils.set_6hour_slot_value(pHourlyPP, pHourSlot,
|
||||
// rec.getValue());
|
||||
// PrecipUtils.set_6hour_slot_value(pHourlyPP, pHourSlot,
|
||||
// rec.getValue());
|
||||
try {
|
||||
Short oneHourlyVal = PrecipUtils.get_hour_slot_value(pHourlyPP, pHourSlot);
|
||||
Short sixHourlyVal = PrecipUtils.get_6hour_slot_value(pHourlyPP, p6HourSlot);
|
||||
|
||||
gagePPWrite
|
||||
.gage_pp_write_rec(pHourlyPP, rec.getPhysicalElement()
|
||||
.getCode(), rec.getObsTime(), pOptions,
|
||||
rev_code, rev_6hour_code, oneHourlyVal,
|
||||
sixHourlyVal, rec.getQualCode(), rec.getQualifier());
|
||||
Short oneHourlyVal = PrecipUtils.get_hour_slot_value(pHourlyPP,
|
||||
pHourSlot);
|
||||
Short sixHourlyVal = PrecipUtils.get_6hour_slot_value(
|
||||
pHourlyPP, p6HourSlot);
|
||||
|
||||
gagePPWrite.gage_pp_write_rec(pHourlyPP, rec
|
||||
.getPhysicalElement().getCode(), rec.getObsTime(),
|
||||
pOptions, rev_code, rev_6hour_code, oneHourlyVal,
|
||||
sixHourlyVal, rec.getQualCode(), rec.getQualifier());
|
||||
} catch (Exception e) {
|
||||
logger.error("Unable to write to the database : " + e);
|
||||
status = GPP_ERROR;
|
||||
|
@ -528,7 +531,8 @@ public class GagePP {
|
|||
case 5004:
|
||||
|
||||
status = GagePPWrite.gage_pp_write_daily_rec(pDailyPP, pOptions,
|
||||
rec.getObsTime(), rev_24hour_code, rec.getQualCode(), rec.getQualifier());
|
||||
rec.getObsTime(), rev_24hour_code, rec.getQualCode(),
|
||||
rec.getQualifier());
|
||||
if (status == GPP_OK) {
|
||||
msgstr = String.format(" %s %s %d %s %s: %s; ",
|
||||
rec.getLocationId(), "PP", duration,
|
||||
|
@ -565,22 +569,22 @@ public class GagePP {
|
|||
int hour = dt.get(Calendar.HOUR_OF_DAY);
|
||||
|
||||
int minute = dt.get(Calendar.MINUTE);
|
||||
|
||||
|
||||
if (rec.getPhysicalElement().getCode().charAt(1) == 'C'
|
||||
&& minute >= MINUTES_PER_HOUR - pOptions.getIntpc()
|
||||
|| (rec.getPhysicalElement().getCode().charAt(1) == 'P'
|
||||
&& minute >= MINUTES_PER_HOUR - pOptions.getIntlppp())) {
|
||||
&& minute >= MINUTES_PER_HOUR - pOptions.getIntpc()
|
||||
|| (rec.getPhysicalElement().getCode().charAt(1) == 'P' && minute >= MINUTES_PER_HOUR
|
||||
- pOptions.getIntlppp())) {
|
||||
hour++;
|
||||
dt.add(Calendar.HOUR_OF_DAY, 1);
|
||||
rec.setObsTime(dt.getTime());
|
||||
}
|
||||
|
||||
|
||||
if (hour == 24 || hour == 0) {
|
||||
// hour = 24;
|
||||
dt.add(Calendar.DAY_OF_YEAR, -1);
|
||||
rec.setObsTime(dt.getTime());
|
||||
}
|
||||
|
||||
|
||||
pOffsetCode = PrecipUtils.get_offset_code(minute);
|
||||
pHourSlot = (short) hour;
|
||||
}
|
||||
|
@ -600,19 +604,18 @@ public class GagePP {
|
|||
short rev = (short) ((pPrecipRecord.revision) ? 1 : 0);
|
||||
|
||||
offset_code[0] = pOffsetCode;
|
||||
|
||||
|
||||
char qc = 'M';
|
||||
if (pHourlyPP.getHourlyQc() == null) {
|
||||
pHourlyPP.setHourlyQc("------------------------");
|
||||
}
|
||||
useValue = PrecipUtils.use_precip_value(pPrecipRecord.getValue(),
|
||||
precip_val, qc, pHourlyPP.getHourlyQc().charAt(hour - 1),
|
||||
'-', pOffsetCode, pOptions.getShef_duplicate()
|
||||
.name(), rev);
|
||||
'-', pOffsetCode, pOptions.getShef_duplicate().name(), rev);
|
||||
}
|
||||
return useValue;
|
||||
}
|
||||
|
||||
|
||||
private void initialize_hourlypp(Hourlypp pHourlyPP,
|
||||
short rev_6hour_code[], String msgstr,
|
||||
final PrecipRecord pPrecipRecord, Date obstime_ytd) {
|
||||
|
@ -639,7 +642,8 @@ public class GagePP {
|
|||
* @return
|
||||
*/
|
||||
private static boolean isNear12Z(final Date yearsec_ansi) {
|
||||
int ppp_ppd_window = appsDefaults.getInt("ppp_ppd_local_7am_window", DEFAULT_WINDOW_HOURS);
|
||||
int ppp_ppd_window = appsDefaults.getInt("ppp_ppd_local_7am_window",
|
||||
DEFAULT_WINDOW_HOURS);
|
||||
ppp_ppd_window *= SECONDS_PER_HOUR * 1000L;
|
||||
|
||||
// Observation time as a calendar
|
||||
|
@ -662,8 +666,8 @@ public class GagePP {
|
|||
lower_bound.setTimeInMillis(pStructTm.getTimeInMillis()
|
||||
- ppp_ppd_window);
|
||||
|
||||
return ((timeTObs.getTimeInMillis() >= lower_bound.getTimeInMillis())
|
||||
&& timeTObs.getTimeInMillis() <= upper_bound.getTimeInMillis());
|
||||
return ((timeTObs.getTimeInMillis() >= lower_bound.getTimeInMillis()) && timeTObs
|
||||
.getTimeInMillis() <= upper_bound.getTimeInMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -671,11 +675,11 @@ public class GagePP {
|
|||
*/
|
||||
private static int gage_pp_6hour_slot(final GagePPOptions pOptions,
|
||||
final Calendar ansi_obstime_year_sec, String ansi_date_year_day,
|
||||
short [] p6HourSlot, char[] p6HourOffsetCode) {
|
||||
short[] p6HourSlot, char[] p6HourOffsetCode) {
|
||||
|
||||
float ppq_window = pOptions.getIntppq();
|
||||
ppq_window *= SECONDS_PER_HOUR;
|
||||
|
||||
|
||||
int bottom_6_hour_period;
|
||||
int diff1;
|
||||
int diff2;
|
||||
|
@ -684,8 +688,8 @@ public class GagePP {
|
|||
int num_periods;
|
||||
int remainder;
|
||||
int top_6_hour_period;
|
||||
// Calendar num_seconds_since_00z = Calendar
|
||||
// .getInstance(SHEFTimezone.GMT_TIMEZONE);
|
||||
// Calendar num_seconds_since_00z = Calendar
|
||||
// .getInstance(SHEFTimezone.GMT_TIMEZONE);
|
||||
|
||||
int num_seconds_since_00z = (hour * SECONDS_PER_HOUR)
|
||||
+ (minute * SECONDS_PER_MINUTE);
|
||||
|
@ -753,9 +757,9 @@ public class GagePP {
|
|||
* Using the number of NUM_MINUTES_PER_6HOUR_OFFSET periods, get the
|
||||
* offset code.
|
||||
*/
|
||||
|
||||
|
||||
p6HourSlot[0]--;
|
||||
|
||||
|
||||
p6HourOffsetCode[0] = PrecipUtils.get_offset_code(num_periods);
|
||||
return GPP_OK;
|
||||
}
|
||||
|
@ -783,16 +787,14 @@ public class GagePP {
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static final void main(String [] args) {
|
||||
|
||||
public static final void main(String[] args) {
|
||||
|
||||
GagePPOptions pOptions = new GagePPOptions();
|
||||
pOptions.setIntlppp(2);
|
||||
pOptions.setIntpc(10);
|
||||
pOptions.setIntppq(2);
|
||||
pOptions.setIntuppp(2);
|
||||
|
||||
|
||||
Calendar obstime = Calendar.getInstance(TimeZone.getTimeZone("Zulu"));
|
||||
obstime.set(Calendar.YEAR, 2011);
|
||||
obstime.set(Calendar.MONTH, 4);
|
||||
|
@ -801,18 +803,18 @@ public class GagePP {
|
|||
obstime.set(Calendar.MINUTE, 0);
|
||||
obstime.set(Calendar.SECOND, 0);
|
||||
obstime.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
sdf.setTimeZone(SHEFTimezone.GMT_TIMEZONE);
|
||||
|
||||
String time = sdf.format(obstime.getTime());
|
||||
|
||||
short [] p6HourSlot = { 0 };
|
||||
|
||||
short[] p6HourSlot = { 0 };
|
||||
char[] p6HourOffsetCode = { ' ' };
|
||||
|
||||
gage_pp_6hour_slot(pOptions, obstime, time, p6HourSlot, p6HourOffsetCode);
|
||||
|
||||
gage_pp_6hour_slot(pOptions, obstime, time, p6HourSlot,
|
||||
p6HourOffsetCode);
|
||||
|
||||
System.out.println(p6HourSlot[0]);
|
||||
System.out.println(p6HourOffsetCode[0]);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ import java.util.Calendar;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.edex.plugin.shef.ohdlib.GagePPOptions.upd_action;
|
||||
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
|
||||
|
@ -56,6 +56,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* May 7, 2013 15880 lbousaidi changed minute_offset to offset in
|
||||
* in write_1_HourValue routine.
|
||||
* Sep 18, 2014 3627 mapeters Updated deprecated {@link TimeTools} usage.
|
||||
* Dec 16, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -64,8 +65,8 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
*/
|
||||
|
||||
public final class GagePPWrite {
|
||||
private static Log logger = LogFactory.getLog(GagePPWrite.class);
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(GagePPWrite.class);
|
||||
|
||||
private char hourly_qc[] = new char[PrecipUtils.NUM_HOURLY_SLOTS];
|
||||
|
||||
private char minute_offset[] = new char[PrecipUtils.NUM_HOURLY_SLOTS];
|
||||
|
@ -102,7 +103,6 @@ public final class GagePPWrite {
|
|||
double new_hourly_value, String obsdate, char zero_offset_code,
|
||||
char manual_qc_code) {
|
||||
|
||||
|
||||
Calendar dt = TimeUtil.newGmtCalendar();
|
||||
dt.setTimeInMillis(dtime.getTime());
|
||||
|
||||
|
@ -142,20 +142,19 @@ public final class GagePPWrite {
|
|||
|
||||
int status = 0;
|
||||
|
||||
if(precip1Hour != null) {
|
||||
status = write_1_HourValue(pHourlyPP, pe, obsDate,
|
||||
options, revision, precip1Hour,
|
||||
quality_code, qual);
|
||||
} else if(precip6Hour != null) {
|
||||
status = write_6_HourValue(pHourlyPP, pe, obsDate,
|
||||
options, revision_6hour, precip6Hour,
|
||||
quality_code, qual);
|
||||
if (precip1Hour != null) {
|
||||
status = write_1_HourValue(pHourlyPP, pe, obsDate, options,
|
||||
revision, precip1Hour, quality_code, qual);
|
||||
} else if (precip6Hour != null) {
|
||||
status = write_6_HourValue(pHourlyPP, pe, obsDate, options,
|
||||
revision_6hour, precip6Hour, quality_code, qual);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO : Write_1
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int write_1_HourValue(Hourlypp pHourlyPP, String pe, Date obsDate,
|
||||
|
@ -169,14 +168,14 @@ public final class GagePPWrite {
|
|||
Calendar c = getCalendar(obsDate);
|
||||
int min = c.get(Calendar.MINUTE);
|
||||
int hr = c.get(Calendar.HOUR_OF_DAY);
|
||||
|
||||
|
||||
String where = String.format(
|
||||
"WHERE lid='%s' AND ts='%s' AND obsdate ='%s'", id, ts,
|
||||
sdf.format(obsDate));
|
||||
|
||||
char minOff = PrecipUtils.get_offset_code(min);
|
||||
char qcc = 'Z'; // ShefQC.buildQcSymbol(qualityCode).charAt(0);
|
||||
if((qual != null)&&(qual.length() > 0)) {
|
||||
if ((qual != null) && (qual.length() > 0)) {
|
||||
qcc = qual.charAt(0);
|
||||
}
|
||||
|
||||
|
@ -186,11 +185,11 @@ public final class GagePPWrite {
|
|||
boolean isPC = ("PC".equalsIgnoreCase(pe));
|
||||
|
||||
IHourlyTS hourlyRec = getHourlyRecord(isPC, where);
|
||||
if(hourlyRec == null) {
|
||||
if (hourlyRec == null) {
|
||||
PersistableDataObject rec = null;
|
||||
String offset = new String(minute_offset);
|
||||
String qc = new String(hourly_qc);
|
||||
|
||||
|
||||
if (isPC) {
|
||||
Hourlypc pHourpc = new Hourlypc();
|
||||
HourlypcId pHid = new HourlypcId();
|
||||
|
@ -212,39 +211,39 @@ public final class GagePPWrite {
|
|||
pHourpp.setMinuteOffset(offset);
|
||||
pHourpp.setHourlyQc(qc);
|
||||
PrecipUtils.set_hour_slot_value(pHourpp, hr, newHourlyValue);
|
||||
|
||||
|
||||
pHourpp.setSixhroffset(new String(sixhr_offset));
|
||||
pHourpp.setSixhrqc(new String(sixhr_qc));
|
||||
|
||||
|
||||
rec = pHourpp;
|
||||
}
|
||||
status = update_gage_rec(rec);
|
||||
} else {
|
||||
boolean useValue = true;
|
||||
|
||||
|
||||
Short oldDataValue = PrecipUtils.get_hour_slot_value(hourlyRec, hr);
|
||||
Short newDataValue = null;
|
||||
|
||||
char [] oldOffset = hourlyRec.getMinuteOffset().toCharArray();
|
||||
char [] offset = new char [oldOffset.length];
|
||||
|
||||
char[] oldOffset = hourlyRec.getMinuteOffset().toCharArray();
|
||||
char[] offset = new char[oldOffset.length];
|
||||
System.arraycopy(oldOffset, 0, offset, 0, offset.length);
|
||||
|
||||
char [] oldQC = hourlyRec.getHourlyQc().toCharArray();
|
||||
char [] qc = new char [oldQC.length];
|
||||
|
||||
char[] oldQC = hourlyRec.getHourlyQc().toCharArray();
|
||||
char[] qc = new char[oldQC.length];
|
||||
System.arraycopy(oldQC, 0, qc, 0, qc.length);
|
||||
|
||||
if(newHourlyValue != null) {
|
||||
|
||||
if (newHourlyValue != null) {
|
||||
if (PrecipUtils.get_hour_slot_value(hourlyRec, hr) != null) {
|
||||
|
||||
int use_value = PrecipUtils.use_precip_value(newHourlyValue,
|
||||
oldDataValue, qcc, oldQC[hr], minOff,
|
||||
oldOffset[hr], options.getShef_duplicate().name(),
|
||||
revision);
|
||||
int use_value = PrecipUtils.use_precip_value(
|
||||
newHourlyValue, oldDataValue, qcc, oldQC[hr],
|
||||
minOff, oldOffset[hr], options.getShef_duplicate()
|
||||
.name(), revision);
|
||||
useValue = (use_value == 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(useValue) {
|
||||
|
||||
if (useValue) {
|
||||
newDataValue = newHourlyValue;
|
||||
|
||||
PrecipUtils.setMinOffset(offset, hr, minOff);
|
||||
|
@ -273,7 +272,7 @@ public final class GagePPWrite {
|
|||
PrecipUtils.set_hour_slot_value(pHourpp, hr, newDataValue);
|
||||
pHourpp.setMinuteOffset(new String(offset));
|
||||
pHourpp.setHourlyQc(new String(qc));
|
||||
|
||||
|
||||
rec = pHourpp;
|
||||
}
|
||||
status = update_gage_rec(rec);
|
||||
|
@ -284,6 +283,7 @@ public final class GagePPWrite {
|
|||
|
||||
/**
|
||||
* TODO : Write_6
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int write_6_HourValue(Hourlypp pHourlyPP, String pe, Date obsDate,
|
||||
|
@ -293,32 +293,30 @@ public final class GagePPWrite {
|
|||
|
||||
String id = pHourlyPP.getId().getLid();
|
||||
String ts = pHourlyPP.getId().getTs();
|
||||
|
||||
|
||||
Calendar c = getCalendar(obsDate);
|
||||
int min = c.get(Calendar.MINUTE);
|
||||
int hr = c.get(Calendar.HOUR_OF_DAY);
|
||||
|
||||
|
||||
String where = String.format(
|
||||
"WHERE lid='%s' AND ts='%s' AND obsdate ='%s'", id, ts,
|
||||
sdf.format(obsDate));
|
||||
|
||||
|
||||
char minOff = PrecipUtils.get_offset_code(min);
|
||||
char qcc = 'Z'; // ShefQC.buildQcSymbol(qualityCode).charAt(0);
|
||||
if((qual != null)&&(qual.length() > 0)) {
|
||||
if ((qual != null) && (qual.length() > 0)) {
|
||||
qcc = qual.charAt(0);
|
||||
}
|
||||
|
||||
|
||||
// hr = PrecipUtils.getSixHourSelector(hr);
|
||||
// find out which slot actually holds the data.
|
||||
for(int i = 0;i < 4;i++) {
|
||||
if(PrecipUtils.get_6hour_slot_value(pHourlyPP,i) != null) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (PrecipUtils.get_6hour_slot_value(pHourlyPP, i) != null) {
|
||||
hr = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sixhr_offset[hr] = minOff;
|
||||
sixhr_qc[hr] = qcc;
|
||||
|
||||
|
@ -337,65 +335,67 @@ public final class GagePPWrite {
|
|||
pHid.setTs(ts);
|
||||
pHid.setObsdate(obsDate);
|
||||
pHourpp.setId(pHid);
|
||||
|
||||
|
||||
pHourpp.setMinuteOffset(new String(minute_offset));
|
||||
pHourpp.setHourlyQc(new String(hourly_qc));
|
||||
|
||||
|
||||
pHourpp.setSixhroffset(new String(sixhr_offset));
|
||||
pHourpp.setSixhrqc(new String(sixhr_qc));
|
||||
PrecipUtils.set_6hour_slot_value(pHourpp, hr,
|
||||
value);
|
||||
PrecipUtils.set_6hour_slot_value(pHourpp, hr, value);
|
||||
rec = pHourpp;
|
||||
}
|
||||
status = update_gage_rec(rec);
|
||||
} else {
|
||||
Hourlypp pHourpp = (Hourlypp) hourlyRec;
|
||||
|
||||
|
||||
Short oldDataValue = PrecipUtils.get_6hour_slot_value(pHourpp, hr);
|
||||
Short newDataValue = null;
|
||||
|
||||
char [] oldOffset = pHourpp.getSixhroffset().toCharArray();
|
||||
char [] offset = new char [oldOffset.length];
|
||||
|
||||
char[] oldOffset = pHourpp.getSixhroffset().toCharArray();
|
||||
char[] offset = new char[oldOffset.length];
|
||||
System.arraycopy(oldOffset, 0, offset, 0, offset.length);
|
||||
|
||||
char [] oldQC = pHourpp.getSixhrqc().toCharArray();
|
||||
char [] qc = new char [oldQC.length];
|
||||
|
||||
char[] oldQC = pHourpp.getSixhrqc().toCharArray();
|
||||
char[] qc = new char[oldQC.length];
|
||||
System.arraycopy(oldQC, 0, qc, 0, qc.length);
|
||||
|
||||
|
||||
boolean useValue = true;
|
||||
// If the old value has been manually edited do not overwrite!
|
||||
if(PrecipUtils.isManualEdit(oldQC[hr]) && !PrecipUtils.isManualEdit(qcc)) {
|
||||
if (PrecipUtils.isManualEdit(oldQC[hr])
|
||||
&& !PrecipUtils.isManualEdit(qcc)) {
|
||||
useValue = false;
|
||||
} else {
|
||||
// if the existing offset on record is '-' we haven't written anything yet
|
||||
if(oldOffset[hr] == '-') {
|
||||
// if the existing offset on record is '-' we haven't written
|
||||
// anything yet
|
||||
if (oldOffset[hr] == '-') {
|
||||
useValue = true;
|
||||
} else {
|
||||
status = PrecipUtils.compare_offset_codes(oldOffset[hr], minOff);
|
||||
if(status > 0) {
|
||||
status = PrecipUtils.compare_offset_codes(oldOffset[hr],
|
||||
minOff);
|
||||
if (status > 0) {
|
||||
useValue = false;
|
||||
} else if (status == 0) {
|
||||
if(minOff == oldOffset[hr]) {
|
||||
if (minOff == oldOffset[hr]) {
|
||||
boolean rev = true;
|
||||
if(revision[hr] == 1) {
|
||||
if (revision[hr] == 1) {
|
||||
rev = false;
|
||||
}
|
||||
String updateAction = PrecipUtils
|
||||
.determine_update_action(
|
||||
options.getShef_duplicate()
|
||||
.name(), rev);
|
||||
.determine_update_action(options
|
||||
.getShef_duplicate().name(), rev);
|
||||
|
||||
if ((upd_action.DONT_UPDATE_ACTION
|
||||
.isAction(updateAction))
|
||||
|| ((upd_action.IF_DIFFERENT_UPDATE_ACTION
|
||||
.isAction(updateAction)) && (value.equals(oldDataValue)))) {
|
||||
.isAction(updateAction)) && (value
|
||||
.equals(oldDataValue)))) {
|
||||
useValue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(useValue) {
|
||||
if (useValue) {
|
||||
newDataValue = value;
|
||||
offset[hr] = minOff;
|
||||
qc[hr] = qcc;
|
||||
|
@ -411,37 +411,36 @@ public final class GagePPWrite {
|
|||
pHid.setObsdate(obsDate);
|
||||
pHourpp.setId(pHid);
|
||||
|
||||
PrecipUtils.set_6hour_slot_value(pHourpp, hr, newDataValue);
|
||||
PrecipUtils.set_6hour_slot_value(pHourpp, hr,
|
||||
newDataValue);
|
||||
pHourpp.setSixhroffset(new String(offset));
|
||||
pHourpp.setSixhrqc(new String(qc));
|
||||
|
||||
|
||||
rec = pHourpp;
|
||||
}
|
||||
status = update_gage_rec(rec);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
private Calendar getCalendar(Date obsDate) {
|
||||
Calendar dt = TimeUtil.newGmtCalendar();
|
||||
dt.setTime(obsDate);
|
||||
|
||||
|
||||
// int hr = dt.get(Calendar.HOUR_OF_DAY);
|
||||
// if (hr == 0) {
|
||||
// hr = 24;
|
||||
// dt.add(Calendar.HOUR_OF_DAY, -1);
|
||||
// obsDate = dt.getTime();
|
||||
// }
|
||||
// int hr = dt.get(Calendar.HOUR_OF_DAY);
|
||||
// if (hr == 0) {
|
||||
// hr = 24;
|
||||
// dt.add(Calendar.HOUR_OF_DAY, -1);
|
||||
// obsDate = dt.getTime();
|
||||
// }
|
||||
return dt;
|
||||
}
|
||||
|
||||
|
||||
private IHourlyTS getHourlyRecord(boolean isPC, String where) {
|
||||
IHourlyTS rec = null;
|
||||
|
||||
|
||||
if (isPC) {
|
||||
List<Hourlypc> hour_PC_old = PrecipUtils.getHourlyPC(where);
|
||||
if (hour_PC_old.size() >= 1) {
|
||||
|
@ -453,7 +452,7 @@ public final class GagePPWrite {
|
|||
rec = hour_PP_old.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return rec;
|
||||
}
|
||||
|
||||
|
@ -493,8 +492,8 @@ public final class GagePPWrite {
|
|||
Date endtime = dt.getTime();
|
||||
|
||||
String qcsym = "Z"; // ShefQC.buildQcSymbol(quality_code);
|
||||
if((qual != null)&&(qual.length() > 0)) {
|
||||
qcsym = qual.substring(0,1);
|
||||
if ((qual != null) && (qual.length() > 0)) {
|
||||
qcsym = qual.substring(0, 1);
|
||||
}
|
||||
String id = pDailyPP.getId().getLid();
|
||||
String ts = pDailyPP.getId().getTs();
|
||||
|
@ -557,7 +556,7 @@ public final class GagePPWrite {
|
|||
*/
|
||||
public static int update_gage_rec(PersistableDataObject rec) {
|
||||
int status = -1;
|
||||
if(rec != null) {
|
||||
if (rec != null) {
|
||||
try {
|
||||
CoreDao dao = new CoreDao(DaoConfig.forDatabase("ihfs"));
|
||||
try {
|
||||
|
@ -574,281 +573,276 @@ public final class GagePPWrite {
|
|||
}
|
||||
|
||||
// ------------------ exit here
|
||||
|
||||
|
||||
|
||||
// int is_pc = 0;
|
||||
//
|
||||
// String id = pHourlyPP.getId().getLid();
|
||||
// String ts = pHourlyPP.getId().getTs();
|
||||
//
|
||||
//
|
||||
//
|
||||
// // Date dto = obsdate;
|
||||
// Calendar dt = TimeTools.getSystemCalendar();
|
||||
// dt.setTime(obsDate);
|
||||
// String obstime = sdf.format(obsDate);
|
||||
//
|
||||
// int hr = dt.get(Calendar.HOUR_OF_DAY);
|
||||
// if (hr == 0) {
|
||||
// hr = 24;
|
||||
// dt.add(Calendar.HOUR_OF_DAY, -1);
|
||||
// obstime = sdf.format(dt.getTime());
|
||||
// obsDate = dt.getTime();
|
||||
// }
|
||||
// int min = dt.get(Calendar.MINUTE);
|
||||
//
|
||||
// GagePPOptions opts = options;
|
||||
//
|
||||
// char sixhroffset = PrecipUtils.get_offset_code(min);
|
||||
// char sixhrqc = ShefQC.buildQcSymbol(quality_code).charAt(0);
|
||||
// char minoff = sixhroffset;
|
||||
// char qcc = sixhrqc;
|
||||
//
|
||||
// hourly_rec = null;
|
||||
//
|
||||
// String where = String
|
||||
// .format("WHERE lid='%s' AND ts='%s' AND obsdate ='%s'", id, ts,
|
||||
// obstime);
|
||||
//
|
||||
// int six = PrecipUtils.getSixHourSelector(hr);
|
||||
//
|
||||
// if ("PC".equalsIgnoreCase(pe)) {
|
||||
// is_pc = 1;
|
||||
// }
|
||||
// if (is_pc == 1) {
|
||||
// List<Hourlypc> hour_PC_old = PrecipUtils.getHourlyPC(where);
|
||||
// if (hour_PC_old.size() >= 1) {
|
||||
// hourly_rec = hour_PC_old.get(0);
|
||||
// }
|
||||
// } else {
|
||||
// List<Hourlypp> hour_PP_old = PrecipUtils.getHourlyPP(where);
|
||||
// if (hour_PP_old.size() >= 1) {
|
||||
// hourly_rec = hour_PP_old.get(0);
|
||||
// }
|
||||
// }
|
||||
|
||||
// int is_pc = 0;
|
||||
//
|
||||
// String id = pHourlyPP.getId().getLid();
|
||||
// String ts = pHourlyPP.getId().getTs();
|
||||
//
|
||||
//
|
||||
//
|
||||
// // Date dto = obsdate;
|
||||
// Calendar dt = TimeTools.getSystemCalendar();
|
||||
// dt.setTime(obsDate);
|
||||
// String obstime = sdf.format(obsDate);
|
||||
//
|
||||
// int hr = dt.get(Calendar.HOUR_OF_DAY);
|
||||
// if (hr == 0) {
|
||||
// hr = 24;
|
||||
// dt.add(Calendar.HOUR_OF_DAY, -1);
|
||||
// obstime = sdf.format(dt.getTime());
|
||||
// obsDate = dt.getTime();
|
||||
// }
|
||||
// int min = dt.get(Calendar.MINUTE);
|
||||
//
|
||||
// GagePPOptions opts = options;
|
||||
//
|
||||
// char sixhroffset = PrecipUtils.get_offset_code(min);
|
||||
// char sixhrqc = ShefQC.buildQcSymbol(quality_code).charAt(0);
|
||||
// char minoff = sixhroffset;
|
||||
// char qcc = sixhrqc;
|
||||
//
|
||||
// hourly_rec = null;
|
||||
//
|
||||
// String where = String
|
||||
// .format("WHERE lid='%s' AND ts='%s' AND obsdate ='%s'", id, ts,
|
||||
// obstime);
|
||||
//
|
||||
// int six = PrecipUtils.getSixHourSelector(hr);
|
||||
//
|
||||
// if ("PC".equalsIgnoreCase(pe)) {
|
||||
// is_pc = 1;
|
||||
// }
|
||||
// if (is_pc == 1) {
|
||||
// List<Hourlypc> hour_PC_old = PrecipUtils.getHourlyPC(where);
|
||||
// if (hour_PC_old.size() >= 1) {
|
||||
// hourly_rec = hour_PC_old.get(0);
|
||||
// }
|
||||
// } else {
|
||||
// List<Hourlypp> hour_PP_old = PrecipUtils.getHourlyPP(where);
|
||||
// if (hour_PP_old.size() >= 1) {
|
||||
// hourly_rec = hour_PP_old.get(0);
|
||||
// }
|
||||
// }
|
||||
// if (hourly_rec == null) {
|
||||
// minute_offset[hr - 1] = minoff;
|
||||
// hourly_qc[hr - 1] = qcc;
|
||||
// sixhr_offset[six] = sixhroffset;
|
||||
// sixhr_qc[six] = sixhrqc;
|
||||
//
|
||||
// if (is_pc == 1) {
|
||||
// Hourlypc pHourpc = new Hourlypc();
|
||||
// HourlypcId pHid = new HourlypcId();
|
||||
// pHid.setLid(id);
|
||||
// pHid.setTs(ts);
|
||||
// pHid.setObsdate(obsDate);
|
||||
// pHourpc.setId(pHid);
|
||||
// if(new_hourly_value != null) {
|
||||
// pHourpc.setMinuteOffset(new String(minute_offset));
|
||||
// pHourpc.setHourlyQc(new String(hourly_qc));
|
||||
// PrecipUtils.set_hour_slot_value(pHourpc, hr, new_hourly_value);
|
||||
// status = update_gage_rec(pHourpc);
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// Hourlypp pHourpp = new Hourlypp();
|
||||
// HourlyppId pHid = new HourlyppId();
|
||||
// pHid.setLid(id);
|
||||
// pHid.setTs(ts);
|
||||
// pHid.setObsdate(obsDate);
|
||||
// pHourpp.setId(pHid);
|
||||
// boolean performWrite = false;
|
||||
// if(new_hourly_value != null) {
|
||||
// pHourpp.setMinuteOffset(String.valueOf(minute_offset));
|
||||
// pHourpp.setHourlyQc(String.valueOf(hourly_qc));
|
||||
// PrecipUtils.set_hour_slot_value(pHourpp, hr, new_hourly_value);
|
||||
// performWrite = true;
|
||||
// }
|
||||
// if(pp_value != null) {
|
||||
// pHourpp.setSixhroffset(String.valueOf(sixhr_offset));
|
||||
// pHourpp.setSixhrqc(String.valueOf(sixhr_qc));
|
||||
// PrecipUtils.set_6hour_slot_value(pHourpp, six + 1, pp_value);
|
||||
// performWrite = true;
|
||||
// }
|
||||
// if(performWrite) {
|
||||
// status = update_gage_rec(pHourpp);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// Short old_hr_value = -7700;
|
||||
// Short hr_value = -7700;
|
||||
//
|
||||
// char offset[] = new char[PrecipUtils.NUM_HOURLY_SLOTS];
|
||||
// System.arraycopy(minute_offset, 0, offset, 0, PrecipUtils.NUM_HOURLY_SLOTS);
|
||||
//
|
||||
// char old_offset[] = new char[PrecipUtils.NUM_HOURLY_SLOTS];
|
||||
// String mOff = hourly_rec.getMinuteOffset();
|
||||
// if(mOff != null) {
|
||||
// old_offset = mOff.toCharArray();
|
||||
// } else {
|
||||
// Arrays.fill(old_offset, '-');
|
||||
// }
|
||||
// char prev_offset = old_offset[hr - 1];
|
||||
//
|
||||
// char qc[] = new char[PrecipUtils.NUM_HOURLY_SLOTS];
|
||||
// qc = hourly_qc;
|
||||
//
|
||||
// char old_qc[] = hourly_rec.getHourlyQc().toCharArray();
|
||||
// char prev_qc = old_qc[hr - 1];
|
||||
//
|
||||
// Short six_hr_slot_val = -7700;
|
||||
// Short old_six_hr_val = -7700;
|
||||
//
|
||||
// char old_sixhroffset[] = new char[PrecipUtils.NUM_6HOURLY_SLOTS];
|
||||
// Arrays.fill(old_sixhroffset, '-');
|
||||
//
|
||||
// char old_six_qc[] = new char[PrecipUtils.NUM_6HOURLY_SLOTS];
|
||||
// Arrays.fill(old_six_qc, '-');
|
||||
//
|
||||
// char six_hr_qc[] = new char[PrecipUtils.NUM_6HOURLY_SLOTS];
|
||||
// System.arraycopy(sixhr_qc, 0, six_hr_qc, 0, PrecipUtils.NUM_6HOURLY_SLOTS);
|
||||
//
|
||||
//
|
||||
// char prev_sixhroff = ' ';
|
||||
// char prev_sixqc = ' ';
|
||||
//
|
||||
// int use_value = 1;
|
||||
// if(new_hourly_value != null) {
|
||||
// if (PrecipUtils.get_hour_slot_value(hourly_rec, hr) != null) {
|
||||
// old_hr_value = PrecipUtils.get_hour_slot_value(hourly_rec, hr);
|
||||
//
|
||||
// use_value = PrecipUtils.use_precip_value(new_hourly_value,
|
||||
// old_hr_value, qcc, prev_qc, minute_offset[hr - 1],
|
||||
// prev_offset, opts.getShef_duplicate().name(),
|
||||
// revision[hr - 1]);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (use_value == 1) {
|
||||
// hr_value = new_hourly_value;
|
||||
// offset = old_offset;
|
||||
// offset[hr - 1] = minoff;
|
||||
// qc = old_qc;
|
||||
// qc[hr - 1] = qcc;
|
||||
// } else {
|
||||
// hr_value = old_hr_value;
|
||||
// offset = old_offset;
|
||||
// qc = old_qc;
|
||||
// }
|
||||
//
|
||||
// Hourlypp hpp = null;
|
||||
//
|
||||
// if (use_value == 1) {
|
||||
// if (is_pc == 0) {
|
||||
// if (hourly_rec instanceof Hourlypp) {
|
||||
// hpp = (Hourlypp) hourly_rec;
|
||||
// }
|
||||
// if (hpp != null) {
|
||||
// if (hpp.getSixhroffset() != null) {
|
||||
// old_sixhroffset = hpp.getSixhroffset()
|
||||
// .toCharArray();
|
||||
// }
|
||||
// if (hpp.getSixhrqc() != null) {
|
||||
// old_six_qc = hpp.getSixhrqc().toCharArray();
|
||||
// }
|
||||
// Short sixval = PrecipUtils.get_6hour_slot_value(hpp,
|
||||
// six + 1);
|
||||
// prev_sixhroff = old_sixhroffset[six];
|
||||
// prev_sixqc = old_six_qc[six];
|
||||
//
|
||||
// if (sixval != null) {
|
||||
// if (PrecipUtils.isManualEdit(prev_sixqc)
|
||||
// && PrecipUtils.isManualEdit(sixhrqc)) {
|
||||
// use_value = 0;
|
||||
// } else {
|
||||
// status = PrecipUtils.compare_offset_codes(
|
||||
// sixhr_offset[six], prev_sixhroff);
|
||||
//
|
||||
// if (status > 0) {
|
||||
// use_value = 0;
|
||||
// } else if ((status == 0)
|
||||
// && (sixhroffset == prev_sixhroff)) {
|
||||
// boolean rev = true;
|
||||
// if (revision_6hour[six] == 0) {
|
||||
// rev = false;
|
||||
// }
|
||||
// String update_action = PrecipUtils
|
||||
// .determine_update_action(
|
||||
// options.getShef_duplicate()
|
||||
// .name(), rev);
|
||||
//
|
||||
// if ((upd_action.DONT_UPDATE_ACTION
|
||||
// .isAction(update_action))
|
||||
// || ((upd_action.IF_DIFFERENT_UPDATE_ACTION
|
||||
// .isAction(update_action)) && (pp_value == old_six_hr_val))) {
|
||||
// use_value = 0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (use_value == 1) {
|
||||
// six_hr_slot_val = pp_value;
|
||||
// sixhr_offset = old_sixhroffset;
|
||||
// sixhr_offset[six] = sixhroffset;
|
||||
// six_hr_qc = old_six_qc;
|
||||
// six_hr_qc[six] = sixhrqc;
|
||||
//
|
||||
// } else {
|
||||
// if (old_six_hr_val == -7700) {
|
||||
// old_six_hr_val = null;
|
||||
// }
|
||||
// six_hr_slot_val = old_six_hr_val;
|
||||
// sixhr_offset = old_sixhroffset;
|
||||
// six_hr_qc = old_six_qc;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (is_pc == 1) {
|
||||
// Hourlypc pHourpc = (Hourlypc) hourly_rec;
|
||||
// HourlypcId pHid = new HourlypcId();
|
||||
// pHid.setLid(pHourpc.getLid());
|
||||
// pHid.setTs(pHourpc.getTs());
|
||||
// pHid.setObsdate(obsDate);
|
||||
// pHourpc.setId(pHid);
|
||||
// // Only write out the data if there is a value!
|
||||
// if(hr_value != null) {
|
||||
// PrecipUtils.set_hour_slot_value(pHourpc, hr, hr_value);
|
||||
// pHourpc.setMinuteOffset(String.valueOf(offset));
|
||||
// pHourpc.setHourlyQc(String.valueOf(qc));
|
||||
//
|
||||
// status = update_gage_rec(pHourpc);
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// Hourlypp pHourpp = hpp;
|
||||
// HourlyppId pHid = new HourlyppId();
|
||||
// pHid.setLid(pHourpp.getLid());
|
||||
// pHid.setTs(pHourpp.getTs());
|
||||
// pHid.setObsdate(obsDate);
|
||||
// pHourpp.setId(pHid);
|
||||
// boolean performWrite = false;
|
||||
// if(hr_value != null) {
|
||||
// PrecipUtils.set_hour_slot_value(pHourpp, hr, hr_value);
|
||||
// pHourpp.setMinuteOffset(String.valueOf(offset));
|
||||
// pHourpp.setHourlyQc(String.valueOf(qc));
|
||||
// performWrite = true;
|
||||
// }
|
||||
// if(six_hr_slot_val != null) {
|
||||
// PrecipUtils.set_hour_slot_value(pHourpp, six + 1, six_hr_slot_val);
|
||||
// pHourpp.setSixhroffset(String.valueOf(sixhr_offset));
|
||||
// pHourpp.setSixhrqc(String.valueOf(six_hr_qc));
|
||||
// performWrite = true;
|
||||
// }
|
||||
// if(performWrite) {
|
||||
// status = update_gage_rec(pHourpp);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (hourly_rec == null) {
|
||||
// minute_offset[hr - 1] = minoff;
|
||||
// hourly_qc[hr - 1] = qcc;
|
||||
// sixhr_offset[six] = sixhroffset;
|
||||
// sixhr_qc[six] = sixhrqc;
|
||||
//
|
||||
// if (is_pc == 1) {
|
||||
// Hourlypc pHourpc = new Hourlypc();
|
||||
// HourlypcId pHid = new HourlypcId();
|
||||
// pHid.setLid(id);
|
||||
// pHid.setTs(ts);
|
||||
// pHid.setObsdate(obsDate);
|
||||
// pHourpc.setId(pHid);
|
||||
// if(new_hourly_value != null) {
|
||||
// pHourpc.setMinuteOffset(new String(minute_offset));
|
||||
// pHourpc.setHourlyQc(new String(hourly_qc));
|
||||
// PrecipUtils.set_hour_slot_value(pHourpc, hr, new_hourly_value);
|
||||
// status = update_gage_rec(pHourpc);
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
// Hourlypp pHourpp = new Hourlypp();
|
||||
// HourlyppId pHid = new HourlyppId();
|
||||
// pHid.setLid(id);
|
||||
// pHid.setTs(ts);
|
||||
// pHid.setObsdate(obsDate);
|
||||
// pHourpp.setId(pHid);
|
||||
// boolean performWrite = false;
|
||||
// if(new_hourly_value != null) {
|
||||
// pHourpp.setMinuteOffset(String.valueOf(minute_offset));
|
||||
// pHourpp.setHourlyQc(String.valueOf(hourly_qc));
|
||||
// PrecipUtils.set_hour_slot_value(pHourpp, hr, new_hourly_value);
|
||||
// performWrite = true;
|
||||
// }
|
||||
// if(pp_value != null) {
|
||||
// pHourpp.setSixhroffset(String.valueOf(sixhr_offset));
|
||||
// pHourpp.setSixhrqc(String.valueOf(sixhr_qc));
|
||||
// PrecipUtils.set_6hour_slot_value(pHourpp, six + 1, pp_value);
|
||||
// performWrite = true;
|
||||
// }
|
||||
// if(performWrite) {
|
||||
// status = update_gage_rec(pHourpp);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// Short old_hr_value = -7700;
|
||||
// Short hr_value = -7700;
|
||||
//
|
||||
// char offset[] = new char[PrecipUtils.NUM_HOURLY_SLOTS];
|
||||
// System.arraycopy(minute_offset, 0, offset, 0, PrecipUtils.NUM_HOURLY_SLOTS);
|
||||
//
|
||||
// char old_offset[] = new char[PrecipUtils.NUM_HOURLY_SLOTS];
|
||||
// String mOff = hourly_rec.getMinuteOffset();
|
||||
// if(mOff != null) {
|
||||
// old_offset = mOff.toCharArray();
|
||||
// } else {
|
||||
// Arrays.fill(old_offset, '-');
|
||||
// }
|
||||
// char prev_offset = old_offset[hr - 1];
|
||||
//
|
||||
// char qc[] = new char[PrecipUtils.NUM_HOURLY_SLOTS];
|
||||
// qc = hourly_qc;
|
||||
//
|
||||
// char old_qc[] = hourly_rec.getHourlyQc().toCharArray();
|
||||
// char prev_qc = old_qc[hr - 1];
|
||||
//
|
||||
// Short six_hr_slot_val = -7700;
|
||||
// Short old_six_hr_val = -7700;
|
||||
//
|
||||
// char old_sixhroffset[] = new char[PrecipUtils.NUM_6HOURLY_SLOTS];
|
||||
// Arrays.fill(old_sixhroffset, '-');
|
||||
//
|
||||
// char old_six_qc[] = new char[PrecipUtils.NUM_6HOURLY_SLOTS];
|
||||
// Arrays.fill(old_six_qc, '-');
|
||||
//
|
||||
// char six_hr_qc[] = new char[PrecipUtils.NUM_6HOURLY_SLOTS];
|
||||
// System.arraycopy(sixhr_qc, 0, six_hr_qc, 0, PrecipUtils.NUM_6HOURLY_SLOTS);
|
||||
//
|
||||
//
|
||||
// char prev_sixhroff = ' ';
|
||||
// char prev_sixqc = ' ';
|
||||
//
|
||||
// int use_value = 1;
|
||||
// if(new_hourly_value != null) {
|
||||
// if (PrecipUtils.get_hour_slot_value(hourly_rec, hr) != null) {
|
||||
// old_hr_value = PrecipUtils.get_hour_slot_value(hourly_rec, hr);
|
||||
//
|
||||
// use_value = PrecipUtils.use_precip_value(new_hourly_value,
|
||||
// old_hr_value, qcc, prev_qc, minute_offset[hr - 1],
|
||||
// prev_offset, opts.getShef_duplicate().name(),
|
||||
// revision[hr - 1]);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (use_value == 1) {
|
||||
// hr_value = new_hourly_value;
|
||||
// offset = old_offset;
|
||||
// offset[hr - 1] = minoff;
|
||||
// qc = old_qc;
|
||||
// qc[hr - 1] = qcc;
|
||||
// } else {
|
||||
// hr_value = old_hr_value;
|
||||
// offset = old_offset;
|
||||
// qc = old_qc;
|
||||
// }
|
||||
//
|
||||
// Hourlypp hpp = null;
|
||||
//
|
||||
// if (use_value == 1) {
|
||||
// if (is_pc == 0) {
|
||||
// if (hourly_rec instanceof Hourlypp) {
|
||||
// hpp = (Hourlypp) hourly_rec;
|
||||
// }
|
||||
// if (hpp != null) {
|
||||
// if (hpp.getSixhroffset() != null) {
|
||||
// old_sixhroffset = hpp.getSixhroffset()
|
||||
// .toCharArray();
|
||||
// }
|
||||
// if (hpp.getSixhrqc() != null) {
|
||||
// old_six_qc = hpp.getSixhrqc().toCharArray();
|
||||
// }
|
||||
// Short sixval = PrecipUtils.get_6hour_slot_value(hpp,
|
||||
// six + 1);
|
||||
// prev_sixhroff = old_sixhroffset[six];
|
||||
// prev_sixqc = old_six_qc[six];
|
||||
//
|
||||
// if (sixval != null) {
|
||||
// if (PrecipUtils.isManualEdit(prev_sixqc)
|
||||
// && PrecipUtils.isManualEdit(sixhrqc)) {
|
||||
// use_value = 0;
|
||||
// } else {
|
||||
// status = PrecipUtils.compare_offset_codes(
|
||||
// sixhr_offset[six], prev_sixhroff);
|
||||
//
|
||||
// if (status > 0) {
|
||||
// use_value = 0;
|
||||
// } else if ((status == 0)
|
||||
// && (sixhroffset == prev_sixhroff)) {
|
||||
// boolean rev = true;
|
||||
// if (revision_6hour[six] == 0) {
|
||||
// rev = false;
|
||||
// }
|
||||
// String update_action = PrecipUtils
|
||||
// .determine_update_action(
|
||||
// options.getShef_duplicate()
|
||||
// .name(), rev);
|
||||
//
|
||||
// if ((upd_action.DONT_UPDATE_ACTION
|
||||
// .isAction(update_action))
|
||||
// || ((upd_action.IF_DIFFERENT_UPDATE_ACTION
|
||||
// .isAction(update_action)) && (pp_value == old_six_hr_val))) {
|
||||
// use_value = 0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (use_value == 1) {
|
||||
// six_hr_slot_val = pp_value;
|
||||
// sixhr_offset = old_sixhroffset;
|
||||
// sixhr_offset[six] = sixhroffset;
|
||||
// six_hr_qc = old_six_qc;
|
||||
// six_hr_qc[six] = sixhrqc;
|
||||
//
|
||||
// } else {
|
||||
// if (old_six_hr_val == -7700) {
|
||||
// old_six_hr_val = null;
|
||||
// }
|
||||
// six_hr_slot_val = old_six_hr_val;
|
||||
// sixhr_offset = old_sixhroffset;
|
||||
// six_hr_qc = old_six_qc;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (is_pc == 1) {
|
||||
// Hourlypc pHourpc = (Hourlypc) hourly_rec;
|
||||
// HourlypcId pHid = new HourlypcId();
|
||||
// pHid.setLid(pHourpc.getLid());
|
||||
// pHid.setTs(pHourpc.getTs());
|
||||
// pHid.setObsdate(obsDate);
|
||||
// pHourpc.setId(pHid);
|
||||
// // Only write out the data if there is a value!
|
||||
// if(hr_value != null) {
|
||||
// PrecipUtils.set_hour_slot_value(pHourpc, hr, hr_value);
|
||||
// pHourpc.setMinuteOffset(String.valueOf(offset));
|
||||
// pHourpc.setHourlyQc(String.valueOf(qc));
|
||||
//
|
||||
// status = update_gage_rec(pHourpc);
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// Hourlypp pHourpp = hpp;
|
||||
// HourlyppId pHid = new HourlyppId();
|
||||
// pHid.setLid(pHourpp.getLid());
|
||||
// pHid.setTs(pHourpp.getTs());
|
||||
// pHid.setObsdate(obsDate);
|
||||
// pHourpp.setId(pHid);
|
||||
// boolean performWrite = false;
|
||||
// if(hr_value != null) {
|
||||
// PrecipUtils.set_hour_slot_value(pHourpp, hr, hr_value);
|
||||
// pHourpp.setMinuteOffset(String.valueOf(offset));
|
||||
// pHourpp.setHourlyQc(String.valueOf(qc));
|
||||
// performWrite = true;
|
||||
// }
|
||||
// if(six_hr_slot_val != null) {
|
||||
// PrecipUtils.set_hour_slot_value(pHourpp, six + 1, six_hr_slot_val);
|
||||
// pHourpp.setSixhroffset(String.valueOf(sixhr_offset));
|
||||
// pHourpp.setSixhrqc(String.valueOf(six_hr_qc));
|
||||
// performWrite = true;
|
||||
// }
|
||||
// if(performWrite) {
|
||||
// status = update_gage_rec(pHourpp);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.edex.plugin.shef.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.edex.plugin.shef.data.QC;
|
||||
import com.raytheon.uf.common.dataplugin.shef.util.ShefConstants;
|
||||
|
@ -32,7 +32,8 @@ import com.raytheon.uf.common.dataplugin.shef.util.ShefConstants;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 05/02/2008 387 M. Duff Initial Creation.
|
||||
* May 02, 2008 387 M. Duff Initial Creation.
|
||||
* Dec 16, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -41,119 +42,120 @@ import com.raytheon.uf.common.dataplugin.shef.util.ShefConstants;
|
|||
*/
|
||||
|
||||
public class BitUtils {
|
||||
/** The logger */
|
||||
private static final Log log = LogFactory.getLog("com.raytheon.edex.plugin.shef.util");
|
||||
/** The logger */
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger("com.raytheon.edex.plugin.shef.util");
|
||||
|
||||
/**
|
||||
* Check if the specified bit of the quality code is set.
|
||||
*
|
||||
* @param bitPosition
|
||||
* position of the bit to check
|
||||
* @param qualityCode
|
||||
* the code to check
|
||||
* @return true if bit is set
|
||||
*/
|
||||
public static boolean checkQcBit(long bitPosition, long qualityCode) {
|
||||
boolean returnVal = false;
|
||||
/**
|
||||
* Check if the specified bit of the quality code is set.
|
||||
*
|
||||
* @param bitPosition
|
||||
* position of the bit to check
|
||||
* @param qualityCode
|
||||
* the code to check
|
||||
* @return true if bit is set
|
||||
*/
|
||||
public static boolean checkQcBit(long bitPosition, long qualityCode) {
|
||||
boolean returnVal = false;
|
||||
|
||||
/*
|
||||
* Variable used to set a specific bit in bit string to 1; initialized
|
||||
* as 0000000000000000 0000000000000001
|
||||
*/
|
||||
int mask = 1;
|
||||
long bitwise_AND_result;
|
||||
/*
|
||||
* Variable used to set a specific bit in bit string to 1; initialized
|
||||
* as 0000000000000000 0000000000000001
|
||||
*/
|
||||
int mask = 1;
|
||||
long bitwise_AND_result;
|
||||
|
||||
/*
|
||||
* The mask is employed to set a specific bit to the value of 1 in a
|
||||
* 32-bit string while the value of the other bits. The mask is
|
||||
* leftwardly shifted to the bit position of the bit being checked.
|
||||
*/
|
||||
mask = mask << bitPosition;
|
||||
/*
|
||||
* The mask is employed to set a specific bit to the value of 1 in a
|
||||
* 32-bit string while the value of the other bits. The mask is
|
||||
* leftwardly shifted to the bit position of the bit being checked.
|
||||
*/
|
||||
mask = mask << bitPosition;
|
||||
|
||||
/*
|
||||
* To check the setting of the specified bit, the mask variable is
|
||||
* compared to the bit string of quality control variable. The end
|
||||
* result yields an integer value.
|
||||
*/
|
||||
bitwise_AND_result = qualityCode & mask;
|
||||
/*
|
||||
* To check the setting of the specified bit, the mask variable is
|
||||
* compared to the bit string of quality control variable. The end
|
||||
* result yields an integer value.
|
||||
*/
|
||||
bitwise_AND_result = qualityCode & mask;
|
||||
|
||||
/*
|
||||
* The following conditional block checks the setting of the specified
|
||||
* bit. The check determined by the return value of the bitwise AND
|
||||
* operation. If the return value is greater than zero (0), the
|
||||
* specified bit is set.
|
||||
*/
|
||||
/*
|
||||
* The following conditional block checks the setting of the specified
|
||||
* bit. The check determined by the return value of the bitwise AND
|
||||
* operation. If the return value is greater than zero (0), the
|
||||
* specified bit is set.
|
||||
*/
|
||||
|
||||
if (bitwise_AND_result > 0) {
|
||||
returnVal = true;
|
||||
} else {
|
||||
returnVal = false;
|
||||
}
|
||||
if (bitwise_AND_result > 0) {
|
||||
returnVal = true;
|
||||
} else {
|
||||
returnVal = false;
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the QC bits
|
||||
*
|
||||
* @param qc - The QC object
|
||||
* @return Status - -1 for invalid, 1 for valid
|
||||
*/
|
||||
public static long setQcBit(QC qc) {
|
||||
/*
|
||||
* Variable used to set a specific bit in bit string to 1; initialized as
|
||||
* 0000000000000000 0000000000000001
|
||||
*/
|
||||
long mask = 1;
|
||||
long bitwise_inclusive_OR_result;
|
||||
long bitwise_AND_result;
|
||||
long status;
|
||||
/**
|
||||
* Sets the QC bits
|
||||
*
|
||||
* @param qc
|
||||
* - The QC object
|
||||
* @return Status - -1 for invalid, 1 for valid
|
||||
*/
|
||||
public static long setQcBit(QC qc) {
|
||||
/*
|
||||
* Variable used to set a specific bit in bit string to 1; initialized
|
||||
* as 0000000000000000 0000000000000001
|
||||
*/
|
||||
long mask = 1;
|
||||
long bitwise_inclusive_OR_result;
|
||||
long bitwise_AND_result;
|
||||
long status;
|
||||
|
||||
|
||||
/* Ensure that a valid bit position is requested. */
|
||||
|
||||
if (qc.getBitPosition() < ShefConstants.SIGN_QC) {
|
||||
status = ShefConstants.VALID_QC_REQUEST;
|
||||
|
||||
|
||||
/* if setting the bit ON */
|
||||
|
||||
if (qc.getSetting() == 1) {
|
||||
|
||||
/*
|
||||
* The mask is employed to set a specific bit to the value of 1 in a
|
||||
* 32-bit string while hiding the value of the other bits. The mask is
|
||||
* leftwardly shifted to the bit position of the bit being referenced.
|
||||
*/
|
||||
/* Ensure that a valid bit position is requested. */
|
||||
|
||||
mask = mask << qc.getBitPosition();
|
||||
|
||||
if (qc.getBitPosition() < ShefConstants.SIGN_QC) {
|
||||
status = ShefConstants.VALID_QC_REQUEST;
|
||||
|
||||
/*
|
||||
* The bitwise inclusive OR operation is used to set the specified bit.
|
||||
* Upon completion, the bit is written to qualityCode memory location.
|
||||
*/
|
||||
/* if setting the bit ON */
|
||||
|
||||
bitwise_inclusive_OR_result = qc.getQualityCode() | mask;
|
||||
if (qc.getSetting() == 1) {
|
||||
|
||||
qc.setQualityCode(bitwise_inclusive_OR_result);
|
||||
} else {
|
||||
/*
|
||||
* if setting the bit OFF. first build a mask that has all ones except for
|
||||
* the bit in question, then AND the mask with the existing value to turn
|
||||
* off the single bit.
|
||||
*/
|
||||
/*
|
||||
* The mask is employed to set a specific bit to the value of 1
|
||||
* in a 32-bit string while hiding the value of the other bits.
|
||||
* The mask is leftwardly shifted to the bit position of the bit
|
||||
* being referenced.
|
||||
*/
|
||||
|
||||
mask = ShefConstants.ALL_ONES ^ (mask << qc.getBitPosition());
|
||||
|
||||
bitwise_AND_result = qc.getQualityCode() & mask;
|
||||
|
||||
qc.setQualityCode(bitwise_AND_result);
|
||||
}
|
||||
} else {
|
||||
log.warn("Invalid request made in setQcBit() Method.");
|
||||
status = ShefConstants.INVALID_QC_REQUEST;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
mask = mask << qc.getBitPosition();
|
||||
|
||||
/*
|
||||
* The bitwise inclusive OR operation is used to set the
|
||||
* specified bit. Upon completion, the bit is written to
|
||||
* qualityCode memory location.
|
||||
*/
|
||||
|
||||
bitwise_inclusive_OR_result = qc.getQualityCode() | mask;
|
||||
|
||||
qc.setQualityCode(bitwise_inclusive_OR_result);
|
||||
} else {
|
||||
/*
|
||||
* if setting the bit OFF. first build a mask that has all ones
|
||||
* except for the bit in question, then AND the mask with the
|
||||
* existing value to turn off the single bit.
|
||||
*/
|
||||
|
||||
mask = ShefConstants.ALL_ONES ^ (mask << qc.getBitPosition());
|
||||
|
||||
bitwise_AND_result = qc.getQualityCode() & mask;
|
||||
|
||||
qc.setQualityCode(bitwise_AND_result);
|
||||
}
|
||||
} else {
|
||||
log.warn("Invalid request made in setQcBit() Method.");
|
||||
status = ShefConstants.INVALID_QC_REQUEST;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ package com.raytheon.edex.plugin.shef.util;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.edex.plugin.shef.data.ShefData;
|
||||
import com.raytheon.edex.plugin.shef.data.ShefRecord;
|
||||
|
@ -38,8 +38,9 @@ import com.raytheon.uf.common.dataplugin.shef.util.ShefConstants;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 05/02/2008 387 M. Duff Initial Creation.
|
||||
* 05/02/2008 387 M. Duff Initial Creation.
|
||||
* 10/16/2008 1548 jelkins Integrated ParameterCode Types
|
||||
* 12/16/2015 5166 kbisanz Update logging to use SLF4J
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -49,13 +50,14 @@ import com.raytheon.uf.common.dataplugin.shef.util.ShefConstants;
|
|||
|
||||
public class PrecipitationUtils {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PrecipitationUtils.class);
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(PrecipitationUtils.class);
|
||||
|
||||
/**
|
||||
* Returns the precipitation index.
|
||||
*
|
||||
* @param pe -
|
||||
* the physical element
|
||||
* @param pe
|
||||
* - the physical element
|
||||
* @return the index (0, 1, 2, or 3)
|
||||
*/
|
||||
public static int getPrecipitationIndex(PhysicalElement pe) {
|
||||
|
@ -94,8 +96,8 @@ public class PrecipitationUtils {
|
|||
|
||||
PrecipRecordStorage.getStorage().incrementRecordCount();
|
||||
|
||||
if(log.isDebugEnabled()) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
|
||||
PrecipRecord record = new PrecipRecord(shefData);
|
||||
record.setProductId(productId);
|
||||
record.setProductTime(productTime);
|
||||
|
|
|
@ -23,313 +23,316 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 9, 2010 jkorman Initial creation
|
||||
*
|
||||
* Feb 9, 2010 jkorman Initial creation
|
||||
* Dec 16, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author jkorman
|
||||
* @version 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SHEFErrors {
|
||||
|
||||
|
||||
public enum HANDLERS {
|
||||
DEBUG, WARNING, ERROR;
|
||||
}
|
||||
|
||||
private static final String [] LOG_MSGS = {
|
||||
"00 Reserved",
|
||||
"Intentionally left blank",
|
||||
"Two digits are required in date or time group",
|
||||
"An expected parameter code is missing",
|
||||
"File read error while accessing data file",
|
||||
"No dot in column 1 when looking for new message",
|
||||
"Dot found but not in column 1 of new message",
|
||||
"Unknown message type, looking for .A, .B, or .E",
|
||||
"Bad char in message type format (or missing blank delimiter)",
|
||||
"Last message format was different from this continuation messg",
|
||||
// 10
|
||||
"Last message was NOT a revision unlike this continuation messg",
|
||||
"Last message had an error so cannot continue",
|
||||
"No positional data or no blank before it",
|
||||
"Bad character in station id",
|
||||
"Station id has more than 8 characters",
|
||||
"Bad number in positional data date group",
|
||||
"Incorrect number in date group",
|
||||
"Incorrect number in time group",
|
||||
"Missing blank char in positional data",
|
||||
"Bad creation date",
|
||||
// 20
|
||||
"Bad date code letter after the character \"D\"", // 20
|
||||
"Unknown data qualifier, data value is lost", // 21
|
||||
"Unknown data units code (need S or E)", // 22
|
||||
"Unknown duration code (need S,N,H,D,M,Y)", // 23
|
||||
"Bad 2-digit number following duration code", // 24
|
||||
"Unknown time interval code (need Y,M,D,H,N,S,E)", // 25
|
||||
"Bad 2-digit number following time interval code", // 26
|
||||
"Bad character after \"DR\" (relative date code)", // 27
|
||||
"Bad 1- or 2-digit number in relative date code", // 28
|
||||
"Bad character in parameter code", // 29
|
||||
// 30
|
||||
"Bad parameter code calls for send code",
|
||||
"Trace for code other than PP, PC, PY, SD, SF, SW",
|
||||
"Variable duration not defined",
|
||||
"Bad character where delimiter is expected",
|
||||
"Non-existent value for given type and source parameter code",
|
||||
"ZULU, DR, or DI has send code QY, PY, or HY",
|
||||
"Forecast data given without creation date",
|
||||
"No value given after parameter code and before slash or eol",
|
||||
"Explicit date for codes DRE or DIE is not the end-of-month",
|
||||
"Year not in good range (1753-2199)",
|
||||
// 40
|
||||
"Exceeded limit of data items",
|
||||
"Too many data items for given .B format",
|
||||
"Not enough data items for given .B format",
|
||||
"Cannot adjust forecast date to Zulu time",
|
||||
"Time between 0200 & 0259 on day changing from standard to daylight",
|
||||
"No time increment specified (use DI code)",
|
||||
"No \".END\" message for previous “.B” format",
|
||||
"ID requires 3 to 8 characters",
|
||||
"For daylight savings time, check Apr or Oct for 1976 thru 2040 only",
|
||||
"Bad character in the message",
|
||||
// 50
|
||||
"Missing parameter code",
|
||||
"Bad value chars (or missing delimiter), data may be lost",
|
||||
"Bad character in data field",
|
||||
"\"?\" not accepted for missing, use \"M\" or \"+\"",
|
||||
"Parameter code is too long or too short",
|
||||
"Missing delimiter between data type fields",
|
||||
"Missing delimiter after data type field",
|
||||
"Should use \"/\" after date, time, or other D-code; before data",
|
||||
"Parm codes PP and PC require decimal value",
|
||||
"Abort, cannot read \"shefparm\" file correctly",
|
||||
// 60
|
||||
"Non-existent value for given duration parameter code",
|
||||
"Non-existent value for given extremum parameter code",
|
||||
"Non-existent value for given conversion factor parameter code",
|
||||
"Non-existent value for given probability parameter code",
|
||||
"Parameter code too short or field misinterpreted as parameter code",
|
||||
"Comma not allowed in data field, data value is lost",
|
||||
"Date check for yr-mo-da shows bad date",
|
||||
"No data on line identified with a message type format",
|
||||
"An unexpected \".END\" message was encountered",
|
||||
"BUMMER!!! Maximum number of errors reached, abort message",
|
||||
// 70
|
||||
"Cannot output to binary shefpars file",
|
||||
"Cannot access “PE conversion factors” from the \"shefparm\" file",
|
||||
"Cannot access “send codes” from the \"shefparm\" file",
|
||||
"Cannot access “duration codes” from the \"shefparm\" file",
|
||||
"Cannot access “type/source codes” from the \"shefparm\" file",
|
||||
"Cannot access “extremum codes” from the \"shefparm\" file",
|
||||
"Cannot access “probability codes” from the \"shefparm\" file",
|
||||
"Cannot read \"SHEFPARM\" file!!!!!",
|
||||
"Bad character in data value, data value is lost",
|
||||
"Julian day should be written with 3 digits",
|
||||
// 80
|
||||
"Too many digits in date group!",
|
||||
"Too many characters in quotes",
|
||||
"Data line found before completing .B format line(s)",
|
||||
"Missing slash delimiter or bad time zone code",
|
||||
"Too many chars in qualifier code, data value is lost",
|
||||
"Bad data qualifier, rest of format is lost",
|
||||
"Retained comment found without a data value, comment is lost",
|
||||
"Unexpected slash found after parameter code, before data value",
|
||||
"Cannot access “qualifier codes” from the \"shefparm\" file",
|
||||
"Intentionally left blank",
|
||||
// 90
|
||||
"Unknown error number given",
|
||||
"91 Reserved",
|
||||
"92 Reserved",
|
||||
"93 Reserved",
|
||||
"94 Reserved",
|
||||
"95 Reserved",
|
||||
"96 Reserved",
|
||||
"97 Reserved",
|
||||
"98 Reserved",
|
||||
"99 Reserved",
|
||||
// 100
|
||||
"Observation time expected but not found", // 100
|
||||
"PEDTSEP redeclared in E record data", // 101
|
||||
"Too many digits in DI code", // 102
|
||||
"Too many digits in DR code", // 103
|
||||
"Too many digits in DV code", // 104
|
||||
|
||||
private static final String[] LOG_MSGS = {
|
||||
"00 Reserved",
|
||||
"Intentionally left blank",
|
||||
"Two digits are required in date or time group",
|
||||
"An expected parameter code is missing",
|
||||
"File read error while accessing data file",
|
||||
"No dot in column 1 when looking for new message",
|
||||
"Dot found but not in column 1 of new message",
|
||||
"Unknown message type, looking for .A, .B, or .E",
|
||||
"Bad char in message type format (or missing blank delimiter)",
|
||||
"Last message format was different from this continuation messg",
|
||||
// 10
|
||||
"Last message was NOT a revision unlike this continuation messg",
|
||||
"Last message had an error so cannot continue",
|
||||
"No positional data or no blank before it",
|
||||
"Bad character in station id",
|
||||
"Station id has more than 8 characters",
|
||||
"Bad number in positional data date group",
|
||||
"Incorrect number in date group",
|
||||
"Incorrect number in time group",
|
||||
"Missing blank char in positional data",
|
||||
"Bad creation date",
|
||||
// 20
|
||||
"Bad date code letter after the character \"D\"", // 20
|
||||
"Unknown data qualifier, data value is lost", // 21
|
||||
"Unknown data units code (need S or E)", // 22
|
||||
"Unknown duration code (need S,N,H,D,M,Y)", // 23
|
||||
"Bad 2-digit number following duration code", // 24
|
||||
"Unknown time interval code (need Y,M,D,H,N,S,E)", // 25
|
||||
"Bad 2-digit number following time interval code", // 26
|
||||
"Bad character after \"DR\" (relative date code)", // 27
|
||||
"Bad 1- or 2-digit number in relative date code", // 28
|
||||
"Bad character in parameter code", // 29
|
||||
// 30
|
||||
"Bad parameter code calls for send code",
|
||||
"Trace for code other than PP, PC, PY, SD, SF, SW",
|
||||
"Variable duration not defined",
|
||||
"Bad character where delimiter is expected",
|
||||
"Non-existent value for given type and source parameter code",
|
||||
"ZULU, DR, or DI has send code QY, PY, or HY",
|
||||
"Forecast data given without creation date",
|
||||
"No value given after parameter code and before slash or eol",
|
||||
"Explicit date for codes DRE or DIE is not the end-of-month",
|
||||
"Year not in good range (1753-2199)",
|
||||
// 40
|
||||
"Exceeded limit of data items",
|
||||
"Too many data items for given .B format",
|
||||
"Not enough data items for given .B format",
|
||||
"Cannot adjust forecast date to Zulu time",
|
||||
"Time between 0200 & 0259 on day changing from standard to daylight",
|
||||
"No time increment specified (use DI code)",
|
||||
"No \".END\" message for previous “.B” format",
|
||||
"ID requires 3 to 8 characters",
|
||||
"For daylight savings time, check Apr or Oct for 1976 thru 2040 only",
|
||||
"Bad character in the message",
|
||||
// 50
|
||||
"Missing parameter code",
|
||||
"Bad value chars (or missing delimiter), data may be lost",
|
||||
"Bad character in data field",
|
||||
"\"?\" not accepted for missing, use \"M\" or \"+\"",
|
||||
"Parameter code is too long or too short",
|
||||
"Missing delimiter between data type fields",
|
||||
"Missing delimiter after data type field",
|
||||
"Should use \"/\" after date, time, or other D-code; before data",
|
||||
"Parm codes PP and PC require decimal value",
|
||||
"Abort, cannot read \"shefparm\" file correctly",
|
||||
// 60
|
||||
"Non-existent value for given duration parameter code",
|
||||
"Non-existent value for given extremum parameter code",
|
||||
"Non-existent value for given conversion factor parameter code",
|
||||
"Non-existent value for given probability parameter code",
|
||||
"Parameter code too short or field misinterpreted as parameter code",
|
||||
"Comma not allowed in data field, data value is lost",
|
||||
"Date check for yr-mo-da shows bad date",
|
||||
"No data on line identified with a message type format",
|
||||
"An unexpected \".END\" message was encountered",
|
||||
"BUMMER!!! Maximum number of errors reached, abort message",
|
||||
// 70
|
||||
"Cannot output to binary shefpars file",
|
||||
"Cannot access “PE conversion factors” from the \"shefparm\" file",
|
||||
"Cannot access “send codes” from the \"shefparm\" file",
|
||||
"Cannot access “duration codes” from the \"shefparm\" file",
|
||||
"Cannot access “type/source codes” from the \"shefparm\" file",
|
||||
"Cannot access “extremum codes” from the \"shefparm\" file",
|
||||
"Cannot access “probability codes” from the \"shefparm\" file",
|
||||
"Cannot read \"SHEFPARM\" file!!!!!",
|
||||
"Bad character in data value, data value is lost",
|
||||
"Julian day should be written with 3 digits",
|
||||
// 80
|
||||
"Too many digits in date group!",
|
||||
"Too many characters in quotes",
|
||||
"Data line found before completing .B format line(s)",
|
||||
"Missing slash delimiter or bad time zone code",
|
||||
"Too many chars in qualifier code, data value is lost",
|
||||
"Bad data qualifier, rest of format is lost",
|
||||
"Retained comment found without a data value, comment is lost",
|
||||
"Unexpected slash found after parameter code, before data value",
|
||||
"Cannot access “qualifier codes” from the \"shefparm\" file",
|
||||
"Intentionally left blank",
|
||||
// 90
|
||||
"Unknown error number given",
|
||||
"91 Reserved",
|
||||
"92 Reserved",
|
||||
"93 Reserved",
|
||||
"94 Reserved",
|
||||
"95 Reserved",
|
||||
"96 Reserved",
|
||||
"97 Reserved",
|
||||
"98 Reserved",
|
||||
"99 Reserved",
|
||||
// 100
|
||||
"Observation time expected but not found", // 100
|
||||
"PEDTSEP redeclared in E record data", // 101
|
||||
"Too many digits in DI code", // 102
|
||||
"Too many digits in DR code", // 103
|
||||
"Too many digits in DV code", // 104
|
||||
};
|
||||
|
||||
// public static final int LOG_000 = 0;
|
||||
// public static final int LOG_001 = 1;
|
||||
// public static final int LOG_002 = 2;
|
||||
// public static final int LOG_003 = 3;
|
||||
// public static final int LOG_004 = 4;
|
||||
// public static final int LOG_005 = 5;
|
||||
// public static final int LOG_006 = 6;
|
||||
// public static final int LOG_007 = 7;
|
||||
// public static final int LOG_008 = 8;
|
||||
// public static final int LOG_009 = 9;
|
||||
//
|
||||
// public static final int LOG_010 = 10;
|
||||
// public static final int LOG_011 = 11;
|
||||
// public static final int LOG_012 = 12;
|
||||
// public static final int LOG_013 = 13;
|
||||
// public static final int LOG_014 = 14;
|
||||
// public static final int LOG_015 = 15;
|
||||
// public static final int LOG_016 = 16;
|
||||
// public static final int LOG_017 = 17;
|
||||
// public static final int LOG_018 = 18;
|
||||
// public static final int LOG_019 = 19;
|
||||
//
|
||||
// public static final int LOG_020 = 20;
|
||||
// public static final int LOG_021 = 21;
|
||||
// public static final int LOG_022 = 22;
|
||||
// public static final int LOG_023 = 23;
|
||||
// public static final int LOG_024 = 24;
|
||||
// public static final int LOG_025 = 25;
|
||||
// public static final int LOG_026 = 26;
|
||||
// public static final int LOG_027 = 27;
|
||||
// public static final int LOG_028 = 28;
|
||||
// public static final int LOG_029 = 29;
|
||||
//
|
||||
// public static final int LOG_030 = 30;
|
||||
// public static final int LOG_031 = 31;
|
||||
// public static final int LOG_032 = 32;
|
||||
// public static final int LOG_033 = 33;
|
||||
// public static final int LOG_034 = 34;
|
||||
// public static final int LOG_035 = 35;
|
||||
// public static final int LOG_036 = 36;
|
||||
// public static final int LOG_037 = 37;
|
||||
// public static final int LOG_038 = 38;
|
||||
// public static final int LOG_039 = 39;
|
||||
//
|
||||
// public static final int LOG_040 = 40;
|
||||
// public static final int LOG_041 = 41;
|
||||
// public static final int LOG_042 = 42;
|
||||
// public static final int LOG_043 = 43;
|
||||
// public static final int LOG_044 = 44;
|
||||
// public static final int LOG_045 = 45;
|
||||
// public static final int LOG_046 = 46;
|
||||
// public static final int LOG_047 = 47;
|
||||
// public static final int LOG_048 = 48;
|
||||
// public static final int LOG_049 = 49;
|
||||
//
|
||||
// public static final int LOG_050 = 50;
|
||||
// public static final int LOG_051 = 51;
|
||||
// public static final int LOG_052 = 52;
|
||||
// public static final int LOG_053 = 53;
|
||||
// public static final int LOG_054 = 54;
|
||||
// public static final int LOG_055 = 55;
|
||||
// public static final int LOG_056 = 56;
|
||||
// public static final int LOG_057 = 57;
|
||||
// public static final int LOG_058 = 58;
|
||||
// public static final int LOG_059 = 59;
|
||||
//
|
||||
// public static final int LOG_060 = 60;
|
||||
// public static final int LOG_061 = 61;
|
||||
// public static final int LOG_062 = 62;
|
||||
// public static final int LOG_063 = 63;
|
||||
// public static final int LOG_064 = 64;
|
||||
// public static final int LOG_065 = 65;
|
||||
// public static final int LOG_066 = 66;
|
||||
// public static final int LOG_067 = 67;
|
||||
// public static final int LOG_068 = 68;
|
||||
// public static final int LOG_069 = 69;
|
||||
//
|
||||
// public static final int LOG_070 = 70;
|
||||
// public static final int LOG_071 = 71;
|
||||
// public static final int LOG_072 = 72;
|
||||
// public static final int LOG_073 = 73;
|
||||
// public static final int LOG_074 = 74;
|
||||
// public static final int LOG_075 = 75;
|
||||
// public static final int LOG_076 = 76;
|
||||
// public static final int LOG_077 = 77;
|
||||
// public static final int LOG_078 = 78;
|
||||
// public static final int LOG_079 = 79;
|
||||
//
|
||||
// public static final int LOG_080 = 80;
|
||||
// public static final int LOG_081 = 81;
|
||||
// public static final int LOG_082 = 82;
|
||||
// public static final int LOG_083 = 83;
|
||||
// public static final int LOG_084 = 84;
|
||||
// public static final int LOG_085 = 85;
|
||||
// public static final int LOG_086 = 86;
|
||||
// public static final int LOG_087 = 87;
|
||||
// public static final int LOG_088 = 88;
|
||||
// public static final int LOG_089 = 89;
|
||||
//
|
||||
// public static final int LOG_090 = 90;
|
||||
// public static final int LOG_091 = 91;
|
||||
// public static final int LOG_092 = 92;
|
||||
// public static final int LOG_093 = 93;
|
||||
// public static final int LOG_094 = 94;
|
||||
// public static final int LOG_095 = 95;
|
||||
// public static final int LOG_096 = 96;
|
||||
// public static final int LOG_097 = 97;
|
||||
// public static final int LOG_098 = 98;
|
||||
// public static final int LOG_099 = 99;
|
||||
//
|
||||
// public static final int LOG_100 = 100;
|
||||
// public static final int LOG_101 = 101;
|
||||
// public static final int LOG_102 = 102;
|
||||
// public static final int LOG_103 = 103;
|
||||
// public static final int LOG_104 = 104;
|
||||
|
||||
// public static final int LOG_000 = 0;
|
||||
// public static final int LOG_001 = 1;
|
||||
// public static final int LOG_002 = 2;
|
||||
// public static final int LOG_003 = 3;
|
||||
// public static final int LOG_004 = 4;
|
||||
// public static final int LOG_005 = 5;
|
||||
// public static final int LOG_006 = 6;
|
||||
// public static final int LOG_007 = 7;
|
||||
// public static final int LOG_008 = 8;
|
||||
// public static final int LOG_009 = 9;
|
||||
//
|
||||
// public static final int LOG_010 = 10;
|
||||
// public static final int LOG_011 = 11;
|
||||
// public static final int LOG_012 = 12;
|
||||
// public static final int LOG_013 = 13;
|
||||
// public static final int LOG_014 = 14;
|
||||
// public static final int LOG_015 = 15;
|
||||
// public static final int LOG_016 = 16;
|
||||
// public static final int LOG_017 = 17;
|
||||
// public static final int LOG_018 = 18;
|
||||
// public static final int LOG_019 = 19;
|
||||
//
|
||||
// public static final int LOG_020 = 20;
|
||||
// public static final int LOG_021 = 21;
|
||||
// public static final int LOG_022 = 22;
|
||||
// public static final int LOG_023 = 23;
|
||||
// public static final int LOG_024 = 24;
|
||||
// public static final int LOG_025 = 25;
|
||||
// public static final int LOG_026 = 26;
|
||||
// public static final int LOG_027 = 27;
|
||||
// public static final int LOG_028 = 28;
|
||||
// public static final int LOG_029 = 29;
|
||||
//
|
||||
// public static final int LOG_030 = 30;
|
||||
// public static final int LOG_031 = 31;
|
||||
// public static final int LOG_032 = 32;
|
||||
// public static final int LOG_033 = 33;
|
||||
// public static final int LOG_034 = 34;
|
||||
// public static final int LOG_035 = 35;
|
||||
// public static final int LOG_036 = 36;
|
||||
// public static final int LOG_037 = 37;
|
||||
// public static final int LOG_038 = 38;
|
||||
// public static final int LOG_039 = 39;
|
||||
//
|
||||
// public static final int LOG_040 = 40;
|
||||
// public static final int LOG_041 = 41;
|
||||
// public static final int LOG_042 = 42;
|
||||
// public static final int LOG_043 = 43;
|
||||
// public static final int LOG_044 = 44;
|
||||
// public static final int LOG_045 = 45;
|
||||
// public static final int LOG_046 = 46;
|
||||
// public static final int LOG_047 = 47;
|
||||
// public static final int LOG_048 = 48;
|
||||
// public static final int LOG_049 = 49;
|
||||
//
|
||||
// public static final int LOG_050 = 50;
|
||||
// public static final int LOG_051 = 51;
|
||||
// public static final int LOG_052 = 52;
|
||||
// public static final int LOG_053 = 53;
|
||||
// public static final int LOG_054 = 54;
|
||||
// public static final int LOG_055 = 55;
|
||||
// public static final int LOG_056 = 56;
|
||||
// public static final int LOG_057 = 57;
|
||||
// public static final int LOG_058 = 58;
|
||||
// public static final int LOG_059 = 59;
|
||||
//
|
||||
// public static final int LOG_060 = 60;
|
||||
// public static final int LOG_061 = 61;
|
||||
// public static final int LOG_062 = 62;
|
||||
// public static final int LOG_063 = 63;
|
||||
// public static final int LOG_064 = 64;
|
||||
// public static final int LOG_065 = 65;
|
||||
// public static final int LOG_066 = 66;
|
||||
// public static final int LOG_067 = 67;
|
||||
// public static final int LOG_068 = 68;
|
||||
// public static final int LOG_069 = 69;
|
||||
//
|
||||
// public static final int LOG_070 = 70;
|
||||
// public static final int LOG_071 = 71;
|
||||
// public static final int LOG_072 = 72;
|
||||
// public static final int LOG_073 = 73;
|
||||
// public static final int LOG_074 = 74;
|
||||
// public static final int LOG_075 = 75;
|
||||
// public static final int LOG_076 = 76;
|
||||
// public static final int LOG_077 = 77;
|
||||
// public static final int LOG_078 = 78;
|
||||
// public static final int LOG_079 = 79;
|
||||
//
|
||||
// public static final int LOG_080 = 80;
|
||||
// public static final int LOG_081 = 81;
|
||||
// public static final int LOG_082 = 82;
|
||||
// public static final int LOG_083 = 83;
|
||||
// public static final int LOG_084 = 84;
|
||||
// public static final int LOG_085 = 85;
|
||||
// public static final int LOG_086 = 86;
|
||||
// public static final int LOG_087 = 87;
|
||||
// public static final int LOG_088 = 88;
|
||||
// public static final int LOG_089 = 89;
|
||||
//
|
||||
// public static final int LOG_090 = 90;
|
||||
// public static final int LOG_091 = 91;
|
||||
// public static final int LOG_092 = 92;
|
||||
// public static final int LOG_093 = 93;
|
||||
// public static final int LOG_094 = 94;
|
||||
// public static final int LOG_095 = 95;
|
||||
// public static final int LOG_096 = 96;
|
||||
// public static final int LOG_097 = 97;
|
||||
// public static final int LOG_098 = 98;
|
||||
// public static final int LOG_099 = 99;
|
||||
//
|
||||
// public static final int LOG_100 = 100;
|
||||
// public static final int LOG_101 = 101;
|
||||
// public static final int LOG_102 = 102;
|
||||
// public static final int LOG_103 = 103;
|
||||
// public static final int LOG_104 = 104;
|
||||
|
||||
public static final boolean LOGOUT = false;
|
||||
|
||||
public static final boolean STDOUT = true;
|
||||
|
||||
private static final String ERR_FMT = "ERROR %20s %03d %s";
|
||||
private static final String ERR_FMT = "ERROR %20s %03d %s";
|
||||
|
||||
private static final String ERROR_FMT = "ERROR %03d %s";
|
||||
|
||||
private static final String WRN_FMT = "WARNG %20s %03d %s";
|
||||
private static final String WARN_FMT = "WARNG %03d %s";
|
||||
private static final String WRN_FMT = "WARNG %20s %03d %s";
|
||||
|
||||
private static final String WARN_FMT = "WARNG %03d %s";
|
||||
|
||||
private static final String DBG_FMT = "DEBUG %20s %03d %s";
|
||||
|
||||
private static final String DEBUG_FMT = "DEBUG %03d %s";
|
||||
|
||||
private static final String DBG_FMT = "DEBUG %20s %03d %s";
|
||||
private static final String DEBUG_FMT = "DEBUG %03d %s";
|
||||
|
||||
|
||||
private static SHEFErrors instance;
|
||||
|
||||
private Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private Map<Class<?>,Log> loggers;
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private Map<Class<?>, Logger> loggers;
|
||||
|
||||
private boolean stdOut = LOGOUT;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private SHEFErrors() {
|
||||
loggers = new HashMap<Class<?>,Log>();
|
||||
loggers = new HashMap<Class<?>, Logger>();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static void ensureMap() {
|
||||
if(instance == null) {
|
||||
if (instance == null) {
|
||||
instance = new SHEFErrors();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param clazz Class that is requesting a logger registration.
|
||||
* @param clazz
|
||||
* Class that is requesting a logger registration.
|
||||
*/
|
||||
public static SHEFErrors registerLogger(Class<?> clazz) {
|
||||
ensureMap();
|
||||
if(clazz != null) {
|
||||
instance.loggers.put(clazz,LogFactory.getLog(clazz));
|
||||
if (clazz != null) {
|
||||
instance.loggers.put(clazz, LoggerFactory.getLogger(clazz));
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
@ -340,9 +343,9 @@ public class SHEFErrors {
|
|||
* @param errorCode
|
||||
*/
|
||||
public void error(Class<?> clazz, int errorCode) {
|
||||
error(clazz,errorCode,(Throwable) null);
|
||||
error(clazz, errorCode, (Throwable) null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param clazz
|
||||
|
@ -350,22 +353,25 @@ public class SHEFErrors {
|
|||
* @param t
|
||||
*/
|
||||
public void error(Class<?> clazz, int errorCode, Throwable t) {
|
||||
Log log = loggers.get(clazz);
|
||||
if(log == null) {
|
||||
Logger log = loggers.get(clazz);
|
||||
if (log == null) {
|
||||
setOutMode(STDOUT);
|
||||
}
|
||||
if((errorCode >= LOG_MSGS.length) || (errorCode < 0)) {
|
||||
if(stdOut) {
|
||||
System.out.println("Invalid SHEF errorCode [" + errorCode + "]");
|
||||
if ((errorCode >= LOG_MSGS.length) || (errorCode < 0)) {
|
||||
if (stdOut) {
|
||||
System.out
|
||||
.println("Invalid SHEF errorCode [" + errorCode + "]");
|
||||
} else {
|
||||
logger.error("Invalid SHEF errorCode [" + errorCode + "]");
|
||||
}
|
||||
} else {
|
||||
if(stdOut) {
|
||||
System.out.println(String.format(ERR_FMT,new Date().toString(),errorCode,LOG_MSGS[errorCode]));
|
||||
if (stdOut) {
|
||||
System.out.println(String.format(ERR_FMT,
|
||||
new Date().toString(), errorCode, LOG_MSGS[errorCode]));
|
||||
} else {
|
||||
String err = String.format(ERROR_FMT,errorCode, LOG_MSGS[errorCode]);
|
||||
if(t == null) {
|
||||
String err = String.format(ERROR_FMT, errorCode,
|
||||
LOG_MSGS[errorCode]);
|
||||
if (t == null) {
|
||||
log.error(err);
|
||||
} else {
|
||||
log.error(err, t);
|
||||
|
@ -381,7 +387,7 @@ public class SHEFErrors {
|
|||
* @param t
|
||||
*/
|
||||
public void error(Class<?> clazz, String message) {
|
||||
error(clazz,message,(Throwable) null);
|
||||
error(clazz, message, (Throwable) null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -391,12 +397,13 @@ public class SHEFErrors {
|
|||
* @param t
|
||||
*/
|
||||
public void error(Class<?> clazz, String message, Throwable t) {
|
||||
Log log = loggers.get(clazz);
|
||||
Logger log = loggers.get(clazz);
|
||||
if (log == null) {
|
||||
setOutMode(STDOUT);
|
||||
}
|
||||
if (stdOut) {
|
||||
System.out.println("ERROR " + new Date().toString() + " " + message);
|
||||
System.out
|
||||
.println("ERROR " + new Date().toString() + " " + message);
|
||||
} else {
|
||||
if (t == null) {
|
||||
log.error(message);
|
||||
|
@ -406,14 +413,13 @@ public class SHEFErrors {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param clazz
|
||||
* @param errorCode
|
||||
*/
|
||||
public void warning(Class<?> clazz, int errorCode) {
|
||||
warning(clazz,errorCode,(Throwable) null);
|
||||
warning(clazz, errorCode, (Throwable) null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -423,22 +429,25 @@ public class SHEFErrors {
|
|||
* @param t
|
||||
*/
|
||||
public void warning(Class<?> clazz, int errorCode, Throwable t) {
|
||||
Log log = loggers.get(clazz);
|
||||
if(log == null) {
|
||||
Logger log = loggers.get(clazz);
|
||||
if (log == null) {
|
||||
setOutMode(STDOUT);
|
||||
}
|
||||
if((errorCode >= LOG_MSGS.length) || (errorCode < 0)) {
|
||||
if(stdOut) {
|
||||
System.out.println("Invalid SHEF errorCode [" + errorCode + "]");
|
||||
if ((errorCode >= LOG_MSGS.length) || (errorCode < 0)) {
|
||||
if (stdOut) {
|
||||
System.out
|
||||
.println("Invalid SHEF errorCode [" + errorCode + "]");
|
||||
} else {
|
||||
logger.error("Invalid SHEF errorCode [" + errorCode + "]");
|
||||
}
|
||||
} else {
|
||||
if(stdOut) {
|
||||
System.out.println(String.format(WRN_FMT,new Date().toString(),errorCode,LOG_MSGS[errorCode]));
|
||||
if (stdOut) {
|
||||
System.out.println(String.format(WRN_FMT,
|
||||
new Date().toString(), errorCode, LOG_MSGS[errorCode]));
|
||||
} else {
|
||||
String err = String.format(WARN_FMT,errorCode, LOG_MSGS[errorCode]);
|
||||
if(t == null) {
|
||||
String err = String.format(WARN_FMT, errorCode,
|
||||
LOG_MSGS[errorCode]);
|
||||
if (t == null) {
|
||||
log.info(err);
|
||||
} else {
|
||||
log.info(err, t);
|
||||
|
@ -454,7 +463,7 @@ public class SHEFErrors {
|
|||
* @param t
|
||||
*/
|
||||
public void warning(Class<?> clazz, String message) {
|
||||
warning(clazz,message,(Throwable) null);
|
||||
warning(clazz, message, (Throwable) null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -464,12 +473,13 @@ public class SHEFErrors {
|
|||
* @param t
|
||||
*/
|
||||
public void warning(Class<?> clazz, String message, Throwable t) {
|
||||
Log log = loggers.get(clazz);
|
||||
Logger log = loggers.get(clazz);
|
||||
if (log == null) {
|
||||
setOutMode(STDOUT);
|
||||
}
|
||||
if (stdOut) {
|
||||
System.out.println("WARNG " + new Date().toString() + " " + message);
|
||||
System.out
|
||||
.println("WARNG " + new Date().toString() + " " + message);
|
||||
} else {
|
||||
if (t == null) {
|
||||
log.info(message);
|
||||
|
@ -486,12 +496,13 @@ public class SHEFErrors {
|
|||
* @param t
|
||||
*/
|
||||
public void debug(Class<?> clazz, String data) {
|
||||
Log log = loggers.get(clazz);
|
||||
Logger log = loggers.get(clazz);
|
||||
if (log == null) {
|
||||
setOutMode(STDOUT);
|
||||
}
|
||||
if (stdOut) {
|
||||
System.out.println(String.format("DEBUG %20s %s", new Date().toString(),data));
|
||||
System.out.println(String.format("DEBUG %20s %s",
|
||||
new Date().toString(), data));
|
||||
} else {
|
||||
log.debug(String.format("DEBUG %s", data));
|
||||
}
|
||||
|
@ -504,12 +515,13 @@ public class SHEFErrors {
|
|||
* @param t
|
||||
*/
|
||||
public void debug(Class<?> clazz, String message, Throwable t) {
|
||||
Log log = loggers.get(clazz);
|
||||
Logger log = loggers.get(clazz);
|
||||
if (log == null) {
|
||||
setOutMode(STDOUT);
|
||||
}
|
||||
if (stdOut) {
|
||||
System.out.println("DEBUG " + new Date().toString() + " " + message);
|
||||
System.out
|
||||
.println("DEBUG " + new Date().toString() + " " + message);
|
||||
} else {
|
||||
if (t == null) {
|
||||
log.info(message);
|
||||
|
@ -526,17 +538,18 @@ public class SHEFErrors {
|
|||
* @param t
|
||||
*/
|
||||
public void debug(Class<?> clazz, Throwable t) {
|
||||
Log log = loggers.get(clazz);
|
||||
Logger log = loggers.get(clazz);
|
||||
if (log == null) {
|
||||
setOutMode(STDOUT);
|
||||
}
|
||||
if (stdOut) {
|
||||
System.out.println("DEBUG " + new Date().toString() + " " + t.getMessage());
|
||||
System.out.println("DEBUG " + new Date().toString() + " "
|
||||
+ t.getMessage());
|
||||
} else {
|
||||
if (t == null) {
|
||||
log.info(t);
|
||||
log.info("No error", t);
|
||||
} else {
|
||||
log.info(t);
|
||||
log.info(t.getLocalizedMessage(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -547,7 +560,7 @@ public class SHEFErrors {
|
|||
* @param errorCode
|
||||
*/
|
||||
public void debug(Class<?> clazz, int errorCode) {
|
||||
debug(clazz,errorCode,(Throwable) null);
|
||||
debug(clazz, errorCode, (Throwable) null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -557,22 +570,25 @@ public class SHEFErrors {
|
|||
* @param t
|
||||
*/
|
||||
public void debug(Class<?> clazz, int errorCode, Throwable t) {
|
||||
Log log = loggers.get(clazz);
|
||||
if(log == null) {
|
||||
Logger log = loggers.get(clazz);
|
||||
if (log == null) {
|
||||
setOutMode(STDOUT);
|
||||
}
|
||||
if((errorCode >= LOG_MSGS.length) || (errorCode < 0)) {
|
||||
if(stdOut) {
|
||||
System.out.println("Invalid SHEF errorCode [" + errorCode + "]");
|
||||
if ((errorCode >= LOG_MSGS.length) || (errorCode < 0)) {
|
||||
if (stdOut) {
|
||||
System.out
|
||||
.println("Invalid SHEF errorCode [" + errorCode + "]");
|
||||
} else {
|
||||
logger.error("Invalid SHEF errorCode [" + errorCode + "]");
|
||||
}
|
||||
} else {
|
||||
if(stdOut) {
|
||||
System.out.println(String.format(DBG_FMT,new Date().toString(),errorCode,LOG_MSGS[errorCode]));
|
||||
if (stdOut) {
|
||||
System.out.println(String.format(DBG_FMT,
|
||||
new Date().toString(), errorCode, LOG_MSGS[errorCode]));
|
||||
} else {
|
||||
String err = String.format(DEBUG_FMT,errorCode, LOG_MSGS[errorCode]);
|
||||
if(t == null) {
|
||||
String err = String.format(DEBUG_FMT, errorCode,
|
||||
LOG_MSGS[errorCode]);
|
||||
if (t == null) {
|
||||
log.info(err);
|
||||
} else {
|
||||
log.info(err, t);
|
||||
|
@ -580,9 +596,9 @@ public class SHEFErrors {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setOutMode(boolean mode) {
|
||||
stdOut = mode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
|
@ -43,7 +43,8 @@ import com.raytheon.uf.common.localization.PathManagerFactory;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 04/18/2008 387 M. Duff Initial Version.
|
||||
* Apr 18, 2008 387 M. Duff Initial Version.
|
||||
* Dec 16, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -52,8 +53,9 @@ import com.raytheon.uf.common.localization.PathManagerFactory;
|
|||
*/
|
||||
|
||||
public class ShefParm {
|
||||
static {
|
||||
log = LogFactory.getLog(com.raytheon.edex.plugin.shef.util.ShefParm.class);
|
||||
static {
|
||||
log = LoggerFactory
|
||||
.getLogger(com.raytheon.edex.plugin.shef.util.ShefParm.class);
|
||||
physicalElementConversion = new HashMap<String, Double>();
|
||||
durationCodeValues = new HashMap<String, Short>();
|
||||
typeSourceCodes = new HashMap<String, Integer>();
|
||||
|
@ -62,110 +64,128 @@ public class ShefParm {
|
|||
sendCodesDuration = new HashMap<String, String>();
|
||||
dataQualifierCodes = new HashMap<String, Integer>();
|
||||
MAX_ERRORS = 0;
|
||||
populate();
|
||||
}
|
||||
|
||||
private static Map<String, Double> physicalElementConversion;
|
||||
private static Map<String, Short> durationCodeValues;
|
||||
private static Map<String, Integer> typeSourceCodes;
|
||||
private static Map<String, Integer> extremumCodes;
|
||||
private static Map<String, Float> probabilityCodeValues;
|
||||
private static Map<String, String> sendCodesDuration;
|
||||
private static Map<String, Integer> dataQualifierCodes;
|
||||
private static int MAX_ERRORS;
|
||||
private static final Log log;
|
||||
populate();
|
||||
}
|
||||
|
||||
private static Map<String, Double> physicalElementConversion;
|
||||
|
||||
private static Map<String, Short> durationCodeValues;
|
||||
|
||||
private static Map<String, Integer> typeSourceCodes;
|
||||
|
||||
private static Map<String, Integer> extremumCodes;
|
||||
|
||||
private static Map<String, Float> probabilityCodeValues;
|
||||
|
||||
private static Map<String, String> sendCodesDuration;
|
||||
|
||||
private static Map<String, Integer> dataQualifierCodes;
|
||||
|
||||
private static int MAX_ERRORS;
|
||||
|
||||
private static final Logger log;
|
||||
|
||||
private static final String PLUGIN_NAME = "shef";
|
||||
|
||||
private static final String PROPFILE_NAME = "SHEFPARM";
|
||||
|
||||
|
||||
private static int fileSection = 0;
|
||||
|
||||
/**
|
||||
* Get a Physical Element conversion factor
|
||||
*
|
||||
* @param key - Physical Element
|
||||
* @return - the conversion factor
|
||||
*/
|
||||
public static Double getPhysicalElementConversionFactor(String key) {
|
||||
return physicalElementConversion.get(key);
|
||||
}
|
||||
* Get a Physical Element conversion factor
|
||||
*
|
||||
* @param key
|
||||
* - Physical Element
|
||||
* @return - the conversion factor
|
||||
*/
|
||||
public static Double getPhysicalElementConversionFactor(String key) {
|
||||
return physicalElementConversion.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Duration Code value
|
||||
*
|
||||
* @param key
|
||||
* - Duration Code
|
||||
* @return - the Duration Code value
|
||||
*/
|
||||
public static Short getDurationCodeValue(String key) {
|
||||
return durationCodeValues.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the Type Source Code
|
||||
*
|
||||
* @param key
|
||||
* - Type Source
|
||||
* @return - 1 if valid code, null if invalid
|
||||
*/
|
||||
public static Integer getTypeSourceCode(String key) {
|
||||
return typeSourceCodes.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the Extremum Code
|
||||
*
|
||||
* @param key
|
||||
* - Extremum Code
|
||||
* @return - 1 if valid code, null if invalid
|
||||
*/
|
||||
public static Integer getExtremumCode(String key) {
|
||||
return extremumCodes.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Probability Code Value
|
||||
*
|
||||
* @param key
|
||||
* - Probability Code
|
||||
* @return - Probability Code's value
|
||||
*/
|
||||
public static Float getProbabilityCodeValue(String key) {
|
||||
return probabilityCodeValues.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Send Code or Duration default value for these special cases
|
||||
*
|
||||
* @param key
|
||||
* - Code
|
||||
* @return - Default Values
|
||||
*/
|
||||
public static String getSendCodeDurationDefaults(String key) {
|
||||
return sendCodesDuration.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the Data Qualifier Code
|
||||
*
|
||||
* @param key
|
||||
* - Extremum Code
|
||||
* @return - 1 if valid code, null if invalid
|
||||
*/
|
||||
public static Integer getDataQualifierCodes(String key) {
|
||||
return dataQualifierCodes.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum number of errors defined
|
||||
*
|
||||
* @return - the maximum number of errors
|
||||
*/
|
||||
public static Integer getMaxErrors() {
|
||||
return MAX_ERRORS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the values from the file.
|
||||
*/
|
||||
private static void populate() {
|
||||
|
||||
/**
|
||||
* Get a Duration Code value
|
||||
*
|
||||
* @param key - Duration Code
|
||||
* @return - the Duration Code value
|
||||
*/
|
||||
public static Short getDurationCodeValue(String key) {
|
||||
return durationCodeValues.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the Type Source Code
|
||||
*
|
||||
* @param key - Type Source
|
||||
* @return - 1 if valid code, null if invalid
|
||||
*/
|
||||
public static Integer getTypeSourceCode(String key) {
|
||||
return typeSourceCodes.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the Extremum Code
|
||||
*
|
||||
* @param key - Extremum Code
|
||||
* @return - 1 if valid code, null if invalid
|
||||
*/
|
||||
public static Integer getExtremumCode(String key) {
|
||||
return extremumCodes.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Probability Code Value
|
||||
*
|
||||
* @param key - Probability Code
|
||||
* @return - Probability Code's value
|
||||
*/
|
||||
public static Float getProbabilityCodeValue(String key) {
|
||||
return probabilityCodeValues.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Send Code or Duration default value for these special cases
|
||||
*
|
||||
* @param key - Code
|
||||
* @return - Default Values
|
||||
*/
|
||||
public static String getSendCodeDurationDefaults(String key) {
|
||||
return sendCodesDuration.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the Data Qualifier Code
|
||||
*
|
||||
* @param key - Extremum Code
|
||||
* @return - 1 if valid code, null if invalid
|
||||
*/
|
||||
public static Integer getDataQualifierCodes(String key) {
|
||||
return dataQualifierCodes.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum number of errors defined
|
||||
*
|
||||
* @return - the maximum number of errors
|
||||
*/
|
||||
public static Integer getMaxErrors() {
|
||||
return MAX_ERRORS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the values from the file.
|
||||
*/
|
||||
private static void populate() {
|
||||
|
||||
PathManager pathMgr = (PathManager) PathManagerFactory.getPathManager();
|
||||
|
||||
LocalizationContext ctx = pathMgr.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.BASE);
|
||||
LocalizationContext ctx = pathMgr.getContext(
|
||||
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE);
|
||||
File baseDir = pathMgr.getFile(ctx, PLUGIN_NAME);
|
||||
File srcFile = new File(baseDir, PROPFILE_NAME);
|
||||
|
||||
|
@ -181,31 +201,31 @@ public class ShefParm {
|
|||
ioe.printStackTrace();
|
||||
log.error("Error loading " + PROPFILE_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
private static String expandPE(String pe) {
|
||||
// 0123456
|
||||
// ADZZZZZ
|
||||
StringBuilder peCode = new StringBuilder("--IRZZ");
|
||||
if((pe != null)&&(pe.length() >= 2)) {
|
||||
for(int i = 0;i < pe.length() && (i < peCode.length());i++) {
|
||||
peCode.setCharAt(i,pe.charAt(i));
|
||||
}
|
||||
}
|
||||
char z4 = peCode.charAt(3);
|
||||
}
|
||||
|
||||
private static String expandPE(String pe) {
|
||||
// 0123456
|
||||
// ADZZZZZ
|
||||
StringBuilder peCode = new StringBuilder("--IRZZ");
|
||||
if ((pe != null) && (pe.length() >= 2)) {
|
||||
for (int i = 0; i < pe.length() && (i < peCode.length()); i++) {
|
||||
peCode.setCharAt(i, pe.charAt(i));
|
||||
}
|
||||
}
|
||||
char z4 = peCode.charAt(3);
|
||||
char z5 = peCode.charAt(5);
|
||||
if('Z' == z4) {
|
||||
if('Z' == z5) {
|
||||
peCode.setCharAt(3, 'R');
|
||||
} else {
|
||||
// FIXME: This is an error
|
||||
}
|
||||
}
|
||||
|
||||
return peCode.toString();
|
||||
}
|
||||
|
||||
private static void processLine(String line) {
|
||||
if ('Z' == z4) {
|
||||
if ('Z' == z5) {
|
||||
peCode.setCharAt(3, 'R');
|
||||
} else {
|
||||
// FIXME: This is an error
|
||||
}
|
||||
}
|
||||
|
||||
return peCode.toString();
|
||||
}
|
||||
|
||||
private static void processLine(String line) {
|
||||
String[] pair = null;
|
||||
if (line.startsWith("$")) {
|
||||
return;
|
||||
|
@ -223,28 +243,24 @@ public class ShefParm {
|
|||
switch (fileSection) {
|
||||
case 1:
|
||||
pair = line.split("\\s+");
|
||||
physicalElementConversion.put(pair[0], Double
|
||||
.parseDouble(pair[1]));
|
||||
physicalElementConversion.put(pair[0],
|
||||
Double.parseDouble(pair[1]));
|
||||
break;
|
||||
case 2:
|
||||
pair = line.split("\\s+");
|
||||
durationCodeValues.put(pair[0], Short
|
||||
.parseShort(pair[1]));
|
||||
durationCodeValues.put(pair[0], Short.parseShort(pair[1]));
|
||||
break;
|
||||
case 3:
|
||||
pair = line.split("\\s+");
|
||||
typeSourceCodes.put(pair[0], Integer
|
||||
.parseInt(pair[1]));
|
||||
typeSourceCodes.put(pair[0], Integer.parseInt(pair[1]));
|
||||
break;
|
||||
case 4:
|
||||
pair = line.split("\\s+");
|
||||
extremumCodes.put(pair[0], Integer
|
||||
.parseInt(pair[1]));
|
||||
extremumCodes.put(pair[0], Integer.parseInt(pair[1]));
|
||||
break;
|
||||
case 5:
|
||||
pair = line.split("\\s+");
|
||||
probabilityCodeValues.put(pair[0], Float
|
||||
.parseFloat(pair[1]));
|
||||
probabilityCodeValues.put(pair[0], Float.parseFloat(pair[1]));
|
||||
break;
|
||||
case 6:
|
||||
pair = line.split("\\s+");
|
||||
|
@ -261,10 +277,9 @@ public class ShefParm {
|
|||
}
|
||||
}
|
||||
|
||||
public static final void main(String [] args) {
|
||||
|
||||
|
||||
String s = expandPE("ADZZZZZ");
|
||||
System.out.println(s);
|
||||
}
|
||||
public static final void main(String[] args) {
|
||||
|
||||
String s = expandPE("ADZZZZZ");
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.edex.decodertools.core.filterimpl.AbstractFilterElement;
|
||||
import com.raytheon.uf.edex.decodertools.core.filterimpl.AbstractObsFilter;
|
||||
|
@ -53,6 +53,7 @@ import com.raytheon.uf.edex.decodertools.core.filterimpl.WMOHeaderFilterElement;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 28, 2015 4783 bkowal Initial creation
|
||||
* Dec 16, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -72,7 +73,7 @@ public abstract class AbstractShefFilter {
|
|||
|
||||
public static final String FILTERS_DIR = "plugin-filters";
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private String filterConfigFile = null;
|
||||
|
||||
|
@ -180,4 +181,4 @@ public abstract class AbstractShefFilter {
|
|||
protected abstract void createDummyFilter();
|
||||
|
||||
public abstract PluginDataObject[] filter(PluginDataObject[] reports);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.edex.esb.Headers;
|
||||
import com.raytheon.edex.transform.shef.obs.ObsToSHEFOptions;
|
||||
|
@ -55,6 +55,7 @@ import com.raytheon.uf.common.wmo.WMOTimeParser;
|
|||
* May 14, 2014 2536 bclement moved WMO Header to common, removed TimeTools usage
|
||||
* Jul 01, 2015 16903 lbousaidi added routine for synoptic data
|
||||
* Oct 29, 2015 4783 bkowal Made {@link #metar2ShefOptions} protected.
|
||||
* Dec 16, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -73,17 +74,17 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
private final String WMO_HEADER_FMT;
|
||||
|
||||
private static final String ARCHIVE_FORMAT = "%s_%04d";
|
||||
|
||||
|
||||
// Note that the nuber of digits must agree with ARCHIVE_FORMAT
|
||||
private static final int MAX_ARCHIVE_SEQUENCE = 10000;
|
||||
|
||||
|
||||
private static final String WMO_MSG_SEQ_FMT = "%03d";
|
||||
|
||||
|
||||
// WMO Sequence number range from 001..999
|
||||
private static final int MAX_WMO_MSG_SEQ = 1000;
|
||||
|
||||
|
||||
public static final String METAR_2_SHEF_NNN = "MTR";
|
||||
|
||||
|
||||
public static final String METAR_2_SHEF_OPT = "metar2shef_options";
|
||||
|
||||
public static final String SHEF_A_RECORD = ".A";
|
||||
|
@ -103,7 +104,7 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
public static final String SHEF_OBS_BASISTIME_FMT = "/DC%1$ty%1$tm%1$td%1$tH%1$tM";
|
||||
|
||||
public static final String OPT_ARC_ENABLE = "archive_enable";
|
||||
|
||||
|
||||
public static final String OPT_SHEF_ARC_DIR = "archive_shefdata_dir";
|
||||
|
||||
// ***********************
|
||||
|
@ -114,7 +115,7 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
// ***********************
|
||||
// Exposed properties
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private String serviceName = null;
|
||||
|
||||
|
@ -127,24 +128,28 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
protected String metar2ShefOptions = null;
|
||||
|
||||
private boolean archiveEnabled = false;
|
||||
|
||||
|
||||
private String shefArchiveDir = null;
|
||||
|
||||
private File shefArchiveFileDir = null;
|
||||
|
||||
|
||||
protected ObsToSHEFOptions options = null;
|
||||
|
||||
private static AtomicInteger sequenceNumber = new AtomicInteger();
|
||||
|
||||
protected static AtomicInteger msgSequence = new AtomicInteger();
|
||||
|
||||
// ************************************************************
|
||||
|
||||
/**
|
||||
* Create the common transformer.
|
||||
* @param cmdLine Command line options that may be used if these
|
||||
* options are not present in the Apps_defaults.
|
||||
* @param headerFmt The specific WMO header format string to be used
|
||||
* when constructing a WMO header for a particular subclass.
|
||||
*
|
||||
* @param cmdLine
|
||||
* Command line options that may be used if these options are not
|
||||
* present in the Apps_defaults.
|
||||
* @param headerFmt
|
||||
* The specific WMO header format string to be used when
|
||||
* constructing a WMO header for a particular subclass.
|
||||
*/
|
||||
public AbstractShefTransformer(String cmdLine, String headerFmt) {
|
||||
|
||||
|
@ -169,8 +174,8 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
throws TransformerException {
|
||||
String cmdLine = AppsDefaults.getInstance().getToken(METAR_2_SHEF_OPT,
|
||||
null);
|
||||
if(options != null) {
|
||||
if(cmdLine != null) {
|
||||
if (options != null) {
|
||||
if (cmdLine != null) {
|
||||
if (!cmdLine.equals(metar2ShefOptions)) {
|
||||
metar2ShefOptions = cmdLine;
|
||||
options.updateCommandLine(cmdLine);
|
||||
|
@ -179,7 +184,7 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
options.updateOptions();
|
||||
}
|
||||
configureArchiveDir();
|
||||
|
||||
|
||||
return transformReport(report, headers);
|
||||
}
|
||||
|
||||
|
@ -190,7 +195,7 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
*/
|
||||
public static Iterator<?> iterate(PluginDataObject[] objects) {
|
||||
Iterator<PluginDataObject> it = null;
|
||||
if ((objects != null)&&(objects.length > 0)) {
|
||||
if ((objects != null) && (objects.length > 0)) {
|
||||
List<PluginDataObject> obj = Arrays.asList(objects);
|
||||
if (obj != null) {
|
||||
it = obj.iterator();
|
||||
|
@ -219,16 +224,21 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
|
||||
/**
|
||||
* Transform the input report to a SHEF encoded report.
|
||||
* @param report A report to transform.
|
||||
*
|
||||
* @param report
|
||||
* A report to transform.
|
||||
* @return The encoded SHEF report.
|
||||
* @throws TransformerException An error occurred during proccessing.
|
||||
* @throws TransformerException
|
||||
* An error occurred during proccessing.
|
||||
*/
|
||||
protected abstract byte[] transformReport(T report, Headers headers)
|
||||
throws TransformerException;
|
||||
|
||||
/**
|
||||
* Create a new buffer containing the opening stanza of a WMO bulletin.
|
||||
* @param sequenceId Abuffer
|
||||
*
|
||||
* @param sequenceId
|
||||
* Abuffer
|
||||
* @param report
|
||||
* @return
|
||||
*/
|
||||
|
@ -250,15 +260,15 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
String stationId, Headers headers, WMOHeader hdr) {
|
||||
|
||||
Calendar c = null;
|
||||
|
||||
if((hdr != null)&&(headers != null)) {
|
||||
|
||||
if ((hdr != null) && (headers != null)) {
|
||||
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
|
||||
c = WMOTimeParser.findDataTime(hdr.getYYGGgg(), fileName);
|
||||
} else {
|
||||
c = TimeUtil.newGmtCalendar();
|
||||
}
|
||||
buffer.append(String.format(WMO_HEADER_FMT, stationId, c));
|
||||
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -273,17 +283,18 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
String stationId, Headers headers, String hdr) {
|
||||
|
||||
Calendar c = null;
|
||||
|
||||
if((hdr != null)&&(headers != null)) {
|
||||
|
||||
if ((hdr != null) && (headers != null)) {
|
||||
String fileName = (String) headers.get(WMOHeader.INGEST_FILE_NAME);
|
||||
c = WMOTimeParser.findDataTime(hdr, fileName);
|
||||
} else {
|
||||
c = TimeUtil.newGmtCalendar();
|
||||
}
|
||||
buffer.append(String.format(WMO_HEADER_FMT, stationId, c));
|
||||
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param buffer
|
||||
|
@ -396,7 +407,8 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
|
||||
/**
|
||||
* Get the state of the archive enabled flag. This value follows
|
||||
* AppsDefaults:archive_enable.
|
||||
* AppsDefaults:archive_enable.
|
||||
*
|
||||
* @return The archive enabled state.
|
||||
*/
|
||||
private boolean isArchiveEnabled() {
|
||||
|
@ -405,12 +417,13 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
|
||||
/**
|
||||
* Get the shef archive file directory if it exists.
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private File getShefArchiveFileDir() {
|
||||
return shefArchiveFileDir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -428,28 +441,33 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
|
||||
/**
|
||||
* Write an encoded SHEF observation to a specified archive directory.
|
||||
* @param shefObs The SHEF encoded data to archive.
|
||||
* @param fileName The base filename.
|
||||
*
|
||||
* @param shefObs
|
||||
* The SHEF encoded data to archive.
|
||||
* @param fileName
|
||||
* The base filename.
|
||||
*/
|
||||
protected void archiveSHEFObs(String shefObs, String fileName) {
|
||||
if(isArchiveEnabled()) {
|
||||
if (isArchiveEnabled()) {
|
||||
File arcFile = getShefArchiveFileDir();
|
||||
if(arcFile != null) {
|
||||
String fName = String.format(ARCHIVE_FORMAT, fileName, getSequenceNumber());
|
||||
if (arcFile != null) {
|
||||
String fName = String.format(ARCHIVE_FORMAT, fileName,
|
||||
getSequenceNumber());
|
||||
File outFile = new File(arcFile, fName);
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fos = new FileOutputStream(outFile);
|
||||
fos.write(shefObs.getBytes());
|
||||
fos.flush();
|
||||
} catch(IOException ioe) {
|
||||
} catch (IOException ioe) {
|
||||
logger.error("Could not archive data " + fName);
|
||||
} finally {
|
||||
if(fos != null) {
|
||||
if (fos != null) {
|
||||
try {
|
||||
fos.close();
|
||||
} catch(IOException ioe) {
|
||||
logger.error("Could not close archive file " + fName);
|
||||
} catch (IOException ioe) {
|
||||
logger.error("Could not close archive file "
|
||||
+ fName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -458,9 +476,10 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the next sequence number.
|
||||
*
|
||||
* @return The sequence number.
|
||||
*/
|
||||
private synchronized int getSequenceNumber() {
|
||||
|
@ -471,6 +490,7 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
|
||||
/**
|
||||
* Get the next message sequence number.
|
||||
*
|
||||
* @return The message sequence number.
|
||||
*/
|
||||
private synchronized int getMsgSequenceNumber() {
|
||||
|
@ -562,4 +582,4 @@ public abstract class AbstractShefTransformer<T extends PluginDataObject>
|
|||
OPT_SHEF_ARC_DIR));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ import com.raytheon.uf.edex.decodertools.core.IDecoderConstants;
|
|||
* into ihfs database
|
||||
* Oct 28, 2015 4783 bkowal Allow {@link SynopticToShefRun}s to override the
|
||||
* default configuration.
|
||||
* Dec 16, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -194,7 +195,8 @@ public class SMToShefTransformer extends AbstractShefTransformer<ObsCommon> {
|
|||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.error(
|
||||
"Error transforming input report to SHEF encoded report", e);
|
||||
} finally {
|
||||
if (result == null) {
|
||||
result = new byte[0];
|
||||
|
@ -310,4 +312,4 @@ public class SMToShefTransformer extends AbstractShefTransformer<ObsCommon> {
|
|||
}
|
||||
matchMap.putAll(reportMatchMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ import java.util.StringTokenizer;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
|
@ -59,6 +59,7 @@ import com.raytheon.uf.common.localization.PathManagerFactory;
|
|||
* AWIPS2 DR Work
|
||||
* 20120918 1185 jkorman Added save to archive capability.
|
||||
* Aug 08, 2013 16408 wkwock Added get configuration file name function
|
||||
* Dec 16, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -176,8 +177,9 @@ public class ObsToSHEFOptions {
|
|||
public static final String OPT_CENTURY = "optCentury";
|
||||
|
||||
public static final String OPT_NO_HR_TRACE = "optNoHourTrace";
|
||||
|
||||
private String cfgFileName=null;
|
||||
|
||||
private String cfgFileName = null;
|
||||
|
||||
// private static class PCReset {
|
||||
//
|
||||
// private final String stationId;
|
||||
|
@ -336,8 +338,8 @@ public class ObsToSHEFOptions {
|
|||
Boolean.class));
|
||||
// -sw
|
||||
// switch source of PEDTSEP from 'Z' to 'V' for testing METAR
|
||||
CMDS.put("-sw", new CmdLineData("-sw", OPT_TYPE_SRC_V, 0,
|
||||
Boolean.class));
|
||||
CMDS.put("-sw",
|
||||
new CmdLineData("-sw", OPT_TYPE_SRC_V, 0, Boolean.class));
|
||||
// -strip
|
||||
// convert bad ascii values to blanks
|
||||
CMDS.put("-strip", new CmdLineData("-strip", OPT_STRIP, 0,
|
||||
|
@ -359,13 +361,14 @@ public class ObsToSHEFOptions {
|
|||
// -y2k
|
||||
// output century in SHEF output
|
||||
CMDS.put("-y2k", new CmdLineData("-y2k", OPT_CENTURY, 0, Boolean.class));
|
||||
|
||||
|
||||
// -notrace
|
||||
// turn off trace precip for 1 hour data.
|
||||
CMDS.put("-notrace", new CmdLineData("-notrace", OPT_NO_HR_TRACE, 0, Boolean.class));
|
||||
CMDS.put("-notrace", new CmdLineData("-notrace", OPT_NO_HR_TRACE, 0,
|
||||
Boolean.class));
|
||||
}
|
||||
|
||||
private Log logger = LogFactory.getLog(getClass());
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private Map<String, Object> options = new HashMap<String, Object>();
|
||||
|
||||
|
@ -405,25 +408,26 @@ public class ObsToSHEFOptions {
|
|||
initOptions();
|
||||
parseCommandLine(cmdLine);
|
||||
if (useLocalized) {
|
||||
if (cfgFileName==null){
|
||||
readConfig(METAR_CFG, optConfigContext);
|
||||
} else {
|
||||
readConfig(cfgFileName, optConfigContext);
|
||||
}
|
||||
if (cfgFileName == null) {
|
||||
readConfig(METAR_CFG, optConfigContext);
|
||||
} else {
|
||||
readConfig(cfgFileName, optConfigContext);
|
||||
}
|
||||
}
|
||||
localized = useLocalized;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cmdLine
|
||||
*/
|
||||
public ObsToSHEFOptions(String configFileName, String cmdLine, boolean useLocalized) {
|
||||
cfgFileName = configFileName;
|
||||
public ObsToSHEFOptions(String configFileName, String cmdLine,
|
||||
boolean useLocalized) {
|
||||
cfgFileName = configFileName;
|
||||
initOptions();
|
||||
parseCommandLine(cmdLine);
|
||||
if (useLocalized) {
|
||||
readConfig(cfgFileName, optConfigContext);
|
||||
readConfig(cfgFileName, optConfigContext);
|
||||
}
|
||||
localized = useLocalized;
|
||||
}
|
||||
|
@ -552,12 +556,13 @@ public class ObsToSHEFOptions {
|
|||
|
||||
/**
|
||||
* -l SHEF TS for ASOS stations = RO, TS for all other sites = RV
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isOptASOS_TS() {
|
||||
return (Boolean) options.get(OPT_ASOS_TS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* -log turn on log for current product and observation
|
||||
*
|
||||
|
@ -644,25 +649,25 @@ public class ObsToSHEFOptions {
|
|||
public boolean isOptDecodePrecipAt12Z() {
|
||||
return (Boolean) options.get(OPT_DECODE_12Z_PRECIP);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* -sw
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isOptTypeSrcV() {
|
||||
return (Boolean) options.get(OPT_TYPE_SRC_V);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* -pct
|
||||
* -pct
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Integer getOptPCT() {
|
||||
return (Integer) options.get(OPT_PCT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* -q1 output wind direction in hundreds & not tens
|
||||
*
|
||||
|
@ -729,14 +734,14 @@ public class ObsToSHEFOptions {
|
|||
}
|
||||
|
||||
/**
|
||||
* -notrace
|
||||
* -notrace
|
||||
*
|
||||
* @return Should trace precip not be reported for hourly metars.
|
||||
*/
|
||||
public boolean isOptNoTrace() {
|
||||
return (Boolean) options.get(OPT_NO_HR_TRACE);
|
||||
}
|
||||
|
||||
|
||||
// *****************************************************
|
||||
|
||||
/**
|
||||
|
@ -855,10 +860,10 @@ public class ObsToSHEFOptions {
|
|||
*/
|
||||
public void updateOptions() {
|
||||
if (loaded && localized) {
|
||||
if (cfgFileName==null) {
|
||||
if (cfgFileName == null) {
|
||||
readConfig(METAR_CFG, optConfigContext);
|
||||
} else {
|
||||
readConfig(cfgFileName, optConfigContext);
|
||||
readConfig(cfgFileName, optConfigContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -888,13 +893,14 @@ public class ObsToSHEFOptions {
|
|||
if (SITE_CONTEXT.equals(optConfigContext)) {
|
||||
// Retry from a base context.
|
||||
optConfigContext = BASE_CONTEXT;
|
||||
if (cfgFileName==null) {
|
||||
readConfig(METAR_CFG, optConfigContext);
|
||||
}else{
|
||||
readConfig(cfgFileName, optConfigContext);
|
||||
if (cfgFileName == null) {
|
||||
readConfig(METAR_CFG, optConfigContext);
|
||||
} else {
|
||||
readConfig(cfgFileName, optConfigContext);
|
||||
}
|
||||
} else {
|
||||
logger.warn("Uanble to read file "+cfgFileName);
|
||||
logger.warn("Uanble to read file "
|
||||
+ cfgFileName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -994,13 +1000,13 @@ public class ObsToSHEFOptions {
|
|||
}
|
||||
|
||||
public void setCfgFileName(String fileName) {
|
||||
cfgFileName=fileName;
|
||||
cfgFileName = fileName;
|
||||
}
|
||||
|
||||
public String getCfgFileName () {
|
||||
return cfgFileName;
|
||||
|
||||
public String getCfgFileName() {
|
||||
return cfgFileName;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
Loading…
Add table
Reference in a new issue