Merge "Issue #2060 remove FFG post processor dependency on dataURI, other minor cleanups" into development
Former-commit-id: 5b4555f7e94bf952b6e2323685e53e4708a8039b
This commit is contained in:
commit
0a245df4f1
6 changed files with 59 additions and 48 deletions
|
@ -25,7 +25,6 @@ import java.util.List;
|
|||
import com.raytheon.edex.plugin.grib.exception.GribException;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridConstants;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand;
|
||||
import com.raytheon.uf.edex.database.plugin.PluginFactory;
|
||||
import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
||||
import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
|
||||
|
@ -43,6 +42,7 @@ import com.raytheon.uf.edex.plugin.grid.dao.GridDao;
|
|||
* Aug 31, 2010 5875 bphillip Initial Creation
|
||||
* Mar 26, 2013 1821 bsteffen Optimize FFG version query.
|
||||
* Oct 15, 2013 2473 bsteffen Remove deprecated method calls.
|
||||
* Apr 25, 2014 2060 njensen Remove dependency on grid dataURI column
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -57,13 +57,14 @@ public class FFGGribPostProcessor implements IDecoderPostProcessor {
|
|||
try {
|
||||
GridDao gribDao = (GridDao) PluginFactory.getInstance()
|
||||
.getPluginDao(GridConstants.GRID);
|
||||
record.setSecondaryId("%");
|
||||
record.setDataURI(null);
|
||||
|
||||
/*
|
||||
* All we want to do is check for pre-existing records, and if some
|
||||
* are found, increment the version number in the secondaryId so
|
||||
* it's not identified as a duplicate
|
||||
*/
|
||||
DatabaseQuery query = new DatabaseQuery(GridRecord.class);
|
||||
query.addReturnedField(GridConstants.SECONDARY_ID);
|
||||
// The dataURI constraint does the final selection but the other
|
||||
// constraints help the db optimize efficiently.
|
||||
query.addQueryParam(GridConstants.DATASET_ID, record.getDatasetId());
|
||||
query.addQueryParam(GridConstants.PARAMETER_ABBREVIATION, record
|
||||
.getParameter().getAbbreviation());
|
||||
|
@ -71,9 +72,21 @@ public class FFGGribPostProcessor implements IDecoderPostProcessor {
|
|||
.getId());
|
||||
query.addQueryParam(GridConstants.LOCATION_ID, record.getLocation()
|
||||
.getId());
|
||||
query.addQueryParam("dataURI", record.getDataURI(),
|
||||
QueryOperand.LIKE);
|
||||
query.addQueryParam("dataTime.refTime", record.getDataTime()
|
||||
.getRefTime());
|
||||
query.addQueryParam("dataTime.fcstTime", record.getDataTime()
|
||||
.getFcstTime());
|
||||
query.addQueryParam(GridConstants.ENSEMBLE_ID,
|
||||
record.getEnsembleId());
|
||||
List<?> result = gribDao.queryByCriteria(query);
|
||||
|
||||
/*
|
||||
* TODO this does not appear to be cluster safe, but we probably
|
||||
* dodge it due to the low frequency of this data arriving for the
|
||||
* same parameters, time, etc
|
||||
*/
|
||||
|
||||
// find the highest version number
|
||||
int maxVersion = -1;
|
||||
for (Object row : result) {
|
||||
String secondaryId = (String) row;
|
||||
|
@ -90,6 +103,7 @@ public class FFGGribPostProcessor implements IDecoderPostProcessor {
|
|||
}
|
||||
record.setSecondaryId("Version" + (maxVersion + 1));
|
||||
record.getInfo().setId(null);
|
||||
// clear out dataURI in case it was cached
|
||||
record.setDataURI(null);
|
||||
} catch (Exception e) {
|
||||
throw new GribException("Error decoding FFG grid", e);
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Map;
|
|||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.SI;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.JAXB;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
@ -39,9 +39,7 @@ import com.raytheon.uf.common.localization.ILocalizationFileObserver;
|
|||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.localization.exception.LocalizationException;
|
||||
import com.raytheon.uf.common.parameter.Parameter;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
@ -62,6 +60,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Mar 28, 2010 2874 bsteffen Initial creation
|
||||
* Apr 25, 2014 2060 njensen Use JAXB instead of JAXBManager
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
|
@ -93,31 +92,23 @@ public class TemperatureCorrectionPostProcessor implements
|
|||
}
|
||||
}
|
||||
|
||||
protected LocalizationFile readConfiguration() throws GribException {
|
||||
protected LocalizationFile readConfiguration() {
|
||||
LocalizationFile file = PathManagerFactory.getPathManager()
|
||||
.getStaticLocalizationFile(LOCALIZATON_LOCATION);
|
||||
Map<String, Double> paramThresholdMap = new HashMap<String, Double>(8);
|
||||
if (file != null && file.exists()) {
|
||||
JAXBManager manager = null;
|
||||
try {
|
||||
manager = new JAXBManager(TemperatureCorrectionParameters.class);
|
||||
|
||||
} catch (JAXBException e) {
|
||||
/* No hope of recovering */
|
||||
throw new GribException(
|
||||
"Error occured preparing to load temperate correction parameters.",
|
||||
e);
|
||||
}
|
||||
TemperatureCorrectionParameters params = null;
|
||||
try {
|
||||
params = file.jaxbUnmarshal(
|
||||
TemperatureCorrectionParameters.class, manager);
|
||||
} catch (LocalizationException e) {
|
||||
params = JAXB.unmarshal(file.getFile(),
|
||||
TemperatureCorrectionParameters.class);
|
||||
} catch (Exception e) {
|
||||
/* Some hope of recovering with a better file. */
|
||||
statusHandler
|
||||
.error("Error occured loading temperate correction parameters, verify the file is formatted correctly.",
|
||||
e);
|
||||
|
||||
}
|
||||
|
||||
if (params != null) {
|
||||
for (TemperatureCorrectionParameter param : params
|
||||
.getParameters()) {
|
||||
|
@ -134,7 +125,7 @@ public class TemperatureCorrectionPostProcessor implements
|
|||
public void fileUpdated(FileUpdatedMessage message) {
|
||||
try {
|
||||
readConfiguration();
|
||||
} catch (GribException e) {
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,9 @@ import java.io.InputStream;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.JAXB;
|
||||
|
||||
import com.raytheon.uf.common.localization.region.RegionSites.Region;
|
||||
import com.raytheon.uf.common.serialization.JAXBManager;
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
||||
|
@ -39,7 +38,8 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 30, 2014 mnash Initial creation
|
||||
* Jan 30, 2014 mnash Initial creation
|
||||
* Apr 25, 2014 2060 njensen Use JAXB instead of JAXBManager
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -89,16 +89,15 @@ public class RegionLookup {
|
|||
* @return
|
||||
*/
|
||||
private static RegionSites parseFile() {
|
||||
RegionSites sites = null;
|
||||
InputStream stream = RegionLookup.class
|
||||
.getResourceAsStream("/regions.xml");
|
||||
JAXBManager manager = SingleTypeJAXBManager
|
||||
.createWithoutException(RegionSites.class);
|
||||
try {
|
||||
return (RegionSites) manager.unmarshalFromInputStream(stream);
|
||||
} catch (SerializationException e) {
|
||||
sites = JAXB.unmarshal(stream, RegionSites.class);
|
||||
} catch (Exception e) {
|
||||
handler.error("Unable to unmarshal regions.xml file", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
return sites;
|
||||
}
|
||||
}
|
|
@ -58,6 +58,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Sep 30, 2013 2361 njensen Refactored for cleanliness
|
||||
* Nov 14, 2013 2361 njensen Added lazy init option, improved unmarshal error message
|
||||
* Apr 16, 2014 2928 rjpeter Updated marshalToStream to not close the stream.
|
||||
* Apr 25, 2014 2060 njensen Improved printout
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
|
@ -178,9 +179,11 @@ public class JAXBManager {
|
|||
if (jaxbContext == null) {
|
||||
long t0 = System.currentTimeMillis();
|
||||
jaxbContext = JAXBContext.newInstance(clazz);
|
||||
System.out.println("JAXB context with " + clazz.length
|
||||
+ " classes inited in: "
|
||||
+ (System.currentTimeMillis() - t0));
|
||||
if (clazz.length == 1) {
|
||||
System.out.println("JAXB context for "
|
||||
+ clazz[0].getSimpleName() + " inited in: "
|
||||
+ (System.currentTimeMillis() - t0) + "ms");
|
||||
}
|
||||
clazz = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.geotools.coverage.grid.GridGeometry2D;
|
|||
import org.geotools.geometry.DirectPosition2D;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridConstants;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialObject;
|
||||
|
@ -468,17 +469,18 @@ public class FreezingLevel {
|
|||
}
|
||||
|
||||
DatabaseQuery dbQuery = new DatabaseQuery(GridRecord.class);
|
||||
dbQuery.addQueryParam("info.datasetId", model);
|
||||
dbQuery.addQueryParam("info.parameter.abbreviation", paramName);
|
||||
dbQuery.addQueryParam("info.level.masterLevel.name", "MB");
|
||||
dbQuery.addQueryParam("info.level.levelonevalue", level);
|
||||
dbQuery.addQueryParam(GridConstants.DATASET_ID, model);
|
||||
dbQuery.addQueryParam(GridConstants.PARAMETER_ABBREVIATION, paramName);
|
||||
dbQuery.addQueryParam(GridConstants.MASTER_LEVEL_NAME, "MB");
|
||||
dbQuery.addQueryParam(GridConstants.LEVEL_ONE, level);
|
||||
dbQuery.addQueryParam("dataTime.refTime", refTime);
|
||||
dbQuery.addQueryParam("dataTime.fcstTime", 0);
|
||||
dbQuery.addOrder("dataTime.refTime", false);
|
||||
dbQuery.setMaxResults(1);
|
||||
|
||||
try {
|
||||
PluginDao dao = PluginFactory.getInstance().getPluginDao("grid");
|
||||
PluginDao dao = PluginFactory.getInstance().getPluginDao(
|
||||
GridConstants.GRID);
|
||||
List<?> list = dao.queryByCriteria(dbQuery);
|
||||
GridRecord result = null;
|
||||
if (list != null && !list.isEmpty()) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridConstants;
|
||||
import com.raytheon.uf.common.dataplugin.grid.GridRecord;
|
||||
import com.raytheon.uf.common.dataplugin.scan.ScanException;
|
||||
import com.raytheon.uf.common.monitor.scan.config.SCANConfigEnums.ScanTables;
|
||||
|
@ -140,11 +141,11 @@ public abstract class GridProduct extends ScanProduct {
|
|||
String parameter, String levelName, String levelOne, String levelTwo)
|
||||
throws ScanException {
|
||||
DatabaseQuery dbQuery = new DatabaseQuery(GridRecord.class);
|
||||
dbQuery.addQueryParam("info.datasetId", dataset);
|
||||
dbQuery.addQueryParam("info.parameter.abbreviation", parameter);
|
||||
dbQuery.addQueryParam("info.level.masterLevel.name", levelName);
|
||||
dbQuery.addQueryParam("info.level.levelonevalue", levelOne);
|
||||
dbQuery.addQueryParam("info.level.leveltwovalue", levelTwo);
|
||||
dbQuery.addQueryParam(GridConstants.DATASET_ID, dataset);
|
||||
dbQuery.addQueryParam(GridConstants.PARAMETER_ABBREVIATION, parameter);
|
||||
dbQuery.addQueryParam(GridConstants.MASTER_LEVEL_NAME, levelName);
|
||||
dbQuery.addQueryParam(GridConstants.LEVEL_ONE, levelOne);
|
||||
dbQuery.addQueryParam(GridConstants.LEVEL_TWO, levelTwo);
|
||||
dbQuery.addQueryParam("dataTime.refTime", new Date(SimulatedTime
|
||||
.getSystemTime().getMillis()
|
||||
- (interval * TimeUtil.MILLIS_PER_MINUTE)), ">");
|
||||
|
@ -153,7 +154,8 @@ public abstract class GridProduct extends ScanProduct {
|
|||
dbQuery.setMaxResults(1);
|
||||
|
||||
try {
|
||||
PluginDao dao = PluginFactory.getInstance().getPluginDao("grid");
|
||||
PluginDao dao = PluginFactory.getInstance().getPluginDao(
|
||||
GridConstants.GRID);
|
||||
List<?> list = dao.queryByCriteria(dbQuery);
|
||||
GridRecord result = null;
|
||||
if (list != null && !list.isEmpty()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue