Merge "Issue #185 change LevelFactory to throw exceptions when there is no network connection so that everything can be reinitialized when the connection is restored.." into 4-Thin_Client

Former-commit-id: cc1cf725b7 [formerly 48179dbabb5cd5a60c345ad0bdd8bda9fdcf9bd9]
Former-commit-id: 5f7b1e87b4
This commit is contained in:
Nate Jensen 2012-01-30 16:45:56 -06:00 committed by Gerrit Code Review
commit b85da11f1b
60 changed files with 1103 additions and 482 deletions

View file

@ -20,6 +20,7 @@ Import-Package: com.raytheon.edex.meteoLib,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.pointdata.spatial,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.status,
com.raytheon.uf.common.time,
com.raytheon.uf.viz.core.alerts,
com.raytheon.uf.viz.core.catalog,

View file

@ -39,14 +39,19 @@ import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
import com.raytheon.uf.common.datastorage.records.LongDataRecord;
import com.raytheon.uf.common.datastorage.records.StringDataRecord;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.catalog.ScriptCreator;
import com.raytheon.uf.viz.core.comm.Loader;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.derivparam.library.DerivedParameterGenerator;
import com.raytheon.viz.pointdata.util.PointDataCubeAdapter;
import com.raytheon.viz.pointdata.util.AbstractPointDataInventory;
import com.raytheon.viz.pointdata.util.PointDataCubeAdapter;
public class ACARSSoundingDataCubeAdapter extends PointDataCubeAdapter {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ACARSSoundingDataCubeAdapter.class);
protected static final String REFTIME = AcarsSoundingInventory.REFTIME;
@ -101,11 +106,16 @@ public class ACARSSoundingDataCubeAdapter extends PointDataCubeAdapter {
@Override
public void initInventory() {
derParLibrary = DerivedParameterGenerator.getDerParLibrary();
if (inventory == null) {
AbstractPointDataInventory pointInventory = new AcarsSoundingInventory();
pointInventory.initTree(derParLibrary);
this.inventory = pointInventory;
try {
pointInventory.initTree(DerivedParameterGenerator
.getDerParLibrary());
this.inventory = pointInventory;
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
}

View file

@ -27,13 +27,13 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.Activator;
import com.raytheon.uf.viz.core.status.StatusConstants;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
/**
* Class defines a database level
@ -55,7 +55,9 @@ import com.raytheon.uf.viz.core.status.StatusConstants;
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class DatabaseLevelMapping {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(DatabaseLevelMapping.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(DatabaseLevelMapping.class);
@XmlAttribute
private String levelName = null;
@ -100,7 +102,7 @@ public class DatabaseLevelMapping {
this.unit = unit;
}
public List<Level> getLevels() {
public List<Level> getLevels() throws VizCommunicationException {
String[] levelOneValues = new String[0];
String[] levelTwoValues = new String[0];
@ -143,12 +145,16 @@ public class DatabaseLevelMapping {
}
// handle any aliasing etc
Level level = LevelFactory.getInstance().getLevel(levelName, lvl1,
lvl2, unit);
if (level != null) {
rval.add(level);
try {
Level level = LevelFactory.getInstance().getLevel(levelName,
lvl1, lvl2, unit);
if (level != null) {
rval.add(level);
}
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
}
return rval;

View file

@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
/**
* Class defines a mapping from a display level to one or more database levels.
@ -38,14 +39,14 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 11/01/2007 #518 S.Manoj Initial version
* 11/16/2009 #3120 rjpeter Modifed to better integrate with level framework.
* 11/21/2009 #3576 rjpeter Added group
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 11/01/2007 #518 S.Manoj Initial version
* 11/16/2009 #3120 rjpeter Modifed to better integrate with level framework.
* 11/21/2009 #3576 rjpeter Added group
*
* &#064;author smanoj
* @version 1.0
*/
@ -118,12 +119,13 @@ public class LevelMapping implements ISerializableObject {
this.databaseLevels = databaseLevels;
}
public List<Level> getLevels() {
public List<Level> getLevels() throws VizCommunicationException {
if (levelList == null) {
levelList = new ArrayList<Level>();
List<Level> levelList = new ArrayList<Level>();
for (DatabaseLevelMapping mapping : databaseLevels) {
levelList.addAll(mapping.getLevels());
}
this.levelList = levelList;
}
return levelList;

View file

@ -35,6 +35,7 @@ import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
/**
* Factory for getting level mappings
@ -56,15 +57,22 @@ public class LevelMappingFactory {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(LevelMappingFactory.class);
private static LevelMappingFactory instance = new LevelMappingFactory();
private static LevelMappingFactory instance = null;
private Map<String, LevelMapping> keyToLevelMappings = new HashMap<String, LevelMapping>();
private boolean levelToLevelMappingsInitialized = false;
private Map<Level, LevelMapping> levelToLevelMappings = new HashMap<Level, LevelMapping>();
private boolean groupToMasterLevelsInitialized = false;
private Map<String, Map<MasterLevel, Set<Level>>> groupToMasterLevels = new HashMap<String, Map<MasterLevel, Set<Level>>>();
public static LevelMappingFactory getInstance() {
public synchronized static LevelMappingFactory getInstance() {
if (instance == null) {
instance = new LevelMappingFactory();
}
return instance;
}
@ -96,47 +104,6 @@ public class LevelMappingFactory {
}
}
for (LevelMapping mapping : keyToLevelMappings.values()) {
String group = mapping.getGroup();
Map<MasterLevel, Set<Level>> masterLevels = null;
if (group != null) {
masterLevels = groupToMasterLevels.get(mapping.getGroup());
if (masterLevels == null) {
masterLevels = new HashMap<MasterLevel, Set<Level>>();
groupToMasterLevels.put(group, masterLevels);
}
}
for (Level l : mapping.getLevels()) {
if (levelToLevelMappings.containsKey(l)) {
LevelMapping oldMapping = levelToLevelMappings.get(l);
// Only replace the old level mapping if we have less
// levels than the old mapping
// This should cause the most specific mapping to be
// used
if (mapping.getLevels().size() < oldMapping.getLevels()
.size()) {
levelToLevelMappings.put(l, mapping);
}
} else {
levelToLevelMappings.put(l, mapping);
}
// populate grouping map
if (masterLevels != null) {
MasterLevel ml = l.getMasterLevel();
Set<Level> levels = masterLevels.get(ml);
if (levels == null) {
levels = new HashSet<Level>();
masterLevels.put(ml, levels);
}
levels.add(l);
}
}
}
}
long finish = System.currentTimeMillis();
System.out.println("LevelMappingFactory initialization took ["
@ -147,7 +114,11 @@ public class LevelMappingFactory {
return keyToLevelMappings.get(key);
}
public LevelMapping getLevelMappingForLevel(Level level) {
public LevelMapping getLevelMappingForLevel(Level level)
throws VizCommunicationException {
if (!levelToLevelMappingsInitialized) {
initializeLevelToLevelMappings();
}
return levelToLevelMappings.get(level);
}
@ -155,11 +126,75 @@ public class LevelMappingFactory {
return keyToLevelMappings.values();
}
public Set<Level> getAllLevels() {
public Set<Level> getAllLevels() throws VizCommunicationException {
if (!levelToLevelMappingsInitialized) {
initializeLevelToLevelMappings();
}
return levelToLevelMappings.keySet();
}
public Map<MasterLevel, Set<Level>> getLevelMapForGroup(String group) {
public Map<MasterLevel, Set<Level>> getLevelMapForGroup(String group)
throws VizCommunicationException {
if (!groupToMasterLevelsInitialized) {
initializeGroupToMasterLevels();
}
return groupToMasterLevels.get(group);
}
private void initializeLevelToLevelMappings()
throws VizCommunicationException {
for (LevelMapping mapping : keyToLevelMappings.values()) {
String group = mapping.getGroup();
for (Level l : mapping.getLevels()) {
if (levelToLevelMappings.containsKey(l)) {
LevelMapping oldMapping = levelToLevelMappings.get(l);
// Only replace the old level mapping if we have less
// levels than the old mapping
// This should cause the most specific mapping to be
// used
if (mapping.getLevels().size() < oldMapping.getLevels()
.size()) {
levelToLevelMappings.put(l, mapping);
}
} else {
levelToLevelMappings.put(l, mapping);
}
}
}
levelToLevelMappingsInitialized = true;
}
private void initializeGroupToMasterLevels()
throws VizCommunicationException {
for (LevelMapping mapping : keyToLevelMappings.values()) {
String group = mapping.getGroup();
Map<MasterLevel, Set<Level>> masterLevels = null;
if (group != null) {
masterLevels = groupToMasterLevels.get(mapping.getGroup());
if (masterLevels == null) {
masterLevels = new HashMap<MasterLevel, Set<Level>>();
groupToMasterLevels.put(group, masterLevels);
}
}
for (Level l : mapping.getLevels()) {
// populate grouping map
if (masterLevels != null) {
MasterLevel ml = l.getMasterLevel();
Set<Level> levels = masterLevels.get(ml);
if (levels == null) {
levels = new HashSet<Level>();
masterLevels.put(ml, levels);
}
levels.add(l);
}
}
}
groupToMasterLevelsInitialized = true;
}
}

View file

@ -22,6 +22,7 @@ package com.raytheon.uf.viz.core.level;
import java.util.HashMap;
import java.util.Map;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelContainer;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
@ -37,6 +38,7 @@ import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
@ -45,11 +47,14 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
.getHandler(LevelRetrievalAdapter.class);
@Override
public Level getLevel(GetLevelRequest request) {
public Level getLevel(GetLevelRequest request)
throws CommunicationException {
Level rval = null;
try {
rval = (Level) ThriftClient.sendRequest(request);
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred retrieving level information from server.",
@ -60,11 +65,14 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
}
@Override
public Level getLevel(GetLevelByIdRequest request) {
public Level getLevel(GetLevelByIdRequest request)
throws CommunicationException {
Level rval = null;
try {
rval = (Level) ThriftClient.sendRequest(request);
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred retrieving level information from server.",
@ -75,10 +83,13 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
}
@Override
public MasterLevel getMasterLevel(GetMasterLevelRequest request) {
public MasterLevel getMasterLevel(GetMasterLevelRequest request)
throws CommunicationException {
MasterLevel rval = null;
try {
rval = (MasterLevel) ThriftClient.sendRequest(request);
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred retrieving level information from server.",
@ -89,10 +100,13 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
@Override
public LevelContainer getAllLevelsForMasterLevel(
GetAllLevelsForMasterLevelRequest request) {
GetAllLevelsForMasterLevelRequest request)
throws CommunicationException {
LevelContainer rval = null;
try {
rval = (LevelContainer) ThriftClient.sendRequest(request);
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred retrieving level information from server.",
@ -102,7 +116,7 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
}
@Override
public LevelContainer getAllLevels() {
public LevelContainer getAllLevels() throws CommunicationException {
LevelContainer rval = null;
DbQueryRequest query = new DbQueryRequest();
query.setConstraints(new HashMap<String, RequestConstraint>());
@ -114,6 +128,8 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
for (Map<String, Object> result : resp.getResults()) {
rval.add((Level) result.get(null));
}
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred retrieving level information from server.",
@ -123,7 +139,8 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
}
@Override
public MasterLevelContainer getAllMasterLevels() {
public MasterLevelContainer getAllMasterLevels()
throws CommunicationException {
MasterLevelContainer rval = null;
DbQueryRequest query = new DbQueryRequest();
query.setConstraints(new HashMap<String, RequestConstraint>());
@ -135,6 +152,8 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
for (Map<String, Object> result : resp.getResults()) {
rval.add((MasterLevel) result.get(null));
}
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler
.handle(Priority.PROBLEM,

View file

@ -29,10 +29,12 @@ import java.util.TreeSet;
import javax.measure.unit.Unit;
import javax.measure.unit.UnitFormat;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.CompareType;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
/**
* Level utilities
@ -62,14 +64,24 @@ public class LevelUtilities {
}
}
public static boolean isPressureLevel(long levelId) {
return isPressureLevel(LevelFactory.getInstance().getLevel(levelId)
.getMasterLevel());
public static boolean isPressureLevel(long levelId)
throws VizCommunicationException {
try {
return isPressureLevel(LevelFactory.getInstance().getLevel(levelId)
.getMasterLevel());
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
}
public static boolean isPressureLevel(String masterLevelName) {
return isPressureLevel(LevelFactory.getInstance().getMasterLevel(
masterLevelName));
public static boolean isPressureLevel(String masterLevelName)
throws VizCommunicationException {
try {
return isPressureLevel(LevelFactory.getInstance().getMasterLevel(
masterLevelName));
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
}
public static boolean isPressureLevel(Level level) {
@ -89,9 +101,10 @@ public class LevelUtilities {
*
* @param masterLevelName
* @return
* @throws CommunicationException
*/
public synchronized static NavigableSet<Level> getOrderedSetOfStandardLevels(
String masterLevelName) {
String masterLevelName) throws VizCommunicationException {
if (masterLevelToOrderedSet == null) {
Comparator<Level> levelComparator = new Comparator<Level>() {
@ -108,7 +121,7 @@ public class LevelUtilities {
}
};
masterLevelToOrderedSet = new HashMap<String, NavigableSet<Level>>();
Map<String, NavigableSet<Level>> masterLevelToOrderedSet = new HashMap<String, NavigableSet<Level>>();
for (Level level : LevelMappingFactory.getInstance().getAllLevels()) {
NavigableSet<Level> levels = masterLevelToOrderedSet.get(level
.getMasterLevel().getName());
@ -118,12 +131,18 @@ public class LevelUtilities {
.getName(), levels);
}
if (level.isRangeLevel()) {
levels.add(level.getUpperLevel());
levels.add(level.getLowerLevel());
try {
levels.add(level.getUpperLevel());
levels.add(level.getLowerLevel());
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
} else {
levels.add(level);
}
}
LevelUtilities.masterLevelToOrderedSet = masterLevelToOrderedSet;
}
return masterLevelToOrderedSet.get(masterLevelName);

View file

@ -1,5 +1,6 @@
package com.raytheon.uf.viz.core.requests;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@ -12,6 +13,7 @@ import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest;
import com.raytheon.uf.common.auth.resp.SuccessfulExecution;
import com.raytheon.uf.common.auth.resp.UserNotAuthenticated;
import com.raytheon.uf.common.auth.resp.UserNotAuthorized;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.comm.HttpClient;
import com.raytheon.uf.common.comm.NetworkStatistics;
import com.raytheon.uf.common.serialization.SerializationException;
@ -23,6 +25,7 @@ import com.raytheon.uf.common.serialization.comm.response.ServerErrorResponse;
import com.raytheon.uf.common.serialization.comm.util.ExceptionWrapper;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
@ -311,6 +314,12 @@ public class ThriftClient {
// Log request stats
stats.log(request.getClass().getSimpleName(), message.length,
responseLen);
} catch (IOException e) {
throw new VizCommunicationException(
"unable to post request to server", e);
} catch (CommunicationException e) {
throw new VizCommunicationException(
"unable to post request to server", e);
} catch (Exception e) {
throw new VizException("unable to post request to server", e);
}

View file

@ -245,19 +245,23 @@ public class PointDataTimeSeriesAdapter extends
// The level mapping for surface has way to much junk in it.
return level;
}
LevelMapping mapping = LevelMappingFactory.getInstance()
.getLevelMappingForKey(resourceData.getLevelKey());
for (Level l : mapping.getLevels()) {
if (LevelUtilities.isPressureLevel(l)) {
try {
level = new SingleLevel(l.getMasterLevel().getName());
level.setValue(l.getLevelonevalue());
break;
} catch (IllegalArgumentException e) {
level = new SingleLevel("SURFACE");
level.setValue(0.0);
try {
LevelMapping mapping = LevelMappingFactory.getInstance()
.getLevelMappingForKey(resourceData.getLevelKey());
for (Level l : mapping.getLevels()) {
if (LevelUtilities.isPressureLevel(l)) {
try {
level = new SingleLevel(l.getMasterLevel().getName());
level.setValue(l.getLevelonevalue());
break;
} catch (IllegalArgumentException e) {
level = new SingleLevel("SURFACE");
level.setValue(0.0);
}
}
}
} catch (VizException e) {
// return the default
}
return level;
}

View file

@ -13,6 +13,7 @@ Bundle-ActivationPolicy: lazy
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
Import-Package: com.raytheon.edex.meteoLib,
com.raytheon.edex.util,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.persist,

View file

@ -22,6 +22,7 @@ package com.raytheon.uf.viz.derivparam.inv;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
@ -32,6 +33,7 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.concurrent.BlockingQueue;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.derivparam.tree.AbstractNode;
@ -43,6 +45,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.level.LevelUtilities;
@ -179,9 +182,12 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
* tree and populates it with available derived parameters based on what is
* available from the base parameters.
*
* @throws VizException
*
*
*/
public synchronized void initTree(Map<String, DerivParamDesc> derParLibrary) {
public synchronized void initTree(Map<String, DerivParamDesc> derParLibrary)
throws VizException {
DerivedParameterGenerator.registerUpdateListener(this);
if (derParLibrary == null) {
this.derParLibrary = new HashMap<String, DerivParamDesc>(0);
@ -189,7 +195,8 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
this.derParLibrary = derParLibrary;
}
long startTime = System.currentTimeMillis();
DataTree newTree = createBaseTree();
DataTree newTree = null;
newTree = createBaseTree();
if (newTree == null) {
return;
}
@ -198,7 +205,13 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
allLevels = null;
dataTree = newTree;
for (SourceNode sourceNode : dataTree.getSourceNodes().values()) {
doSupplement(sourceNode);
try {
doSupplement(sourceNode);
} catch (VizCommunicationException e) {
// TODO need to recover from this
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
for (ParameterNode parameterNode : sourceNode.getChildNodes()
.values()) {
String value = parameterNode.getValue();
@ -216,7 +229,11 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
@Override
public void updateDerParLibrary(Map<String, DerivParamDesc> derParLibrary) {
initTree(derParLibrary);
try {
initTree(derParLibrary);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
public String getParameterUnit(String source, String parameter) {
@ -254,8 +271,10 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
* Resolve any Supplement Derived Parameters.
*
* @param sNode
* @throws VizCommunicationException
*/
private void doSupplement(SourceNode sNode) {
private void doSupplement(SourceNode sNode)
throws VizCommunicationException {
Set<StackEntry> nodata = new HashSet<StackEntry>();
Deque<StackEntry> stack = new ArrayDeque<StackEntry>();
for (DerivParamDesc desc : derParLibrary.values()) {
@ -300,7 +319,7 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
}
}
protected abstract DataTree createBaseTree();
protected abstract DataTree createBaseTree() throws VizException;
/**
* Handle a query for a time agnostic node.
@ -320,7 +339,7 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
protected Collection<String> getAllSources() {
if (allSources == null) {
if (dataTree == null) {
return null;
return Collections.emptyList();
} else {
return new ArrayList<String>(dataTree.getSources());
}
@ -452,10 +471,18 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
* See get allSources, same function but for levels
*
* @return
* @throws VizCommunicationException
*/
protected Collection<Level> getAllLevels() {
if (allLevels == null) {
return LevelMappingFactory.getInstance().getAllLevels();
try {
return LevelMappingFactory.getInstance().getAllLevels();
} catch (VizCommunicationException e) {
// TODO recover from this.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
return Collections.emptyList();
}
} else {
return allLevels;
}
@ -605,8 +632,13 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
Level level = lit.next();
AbstractRequestableLevelNode result = null;
if (derive) {
result = resolveNode(node, param, level, stack,
nodata);
try {
result = resolveNode(node, param, level, stack,
nodata);
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
} else {
ParameterNode pNode = node.getChildNode(param);
result = (AbstractRequestableLevelNode) (pNode == null ? null
@ -654,11 +686,17 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
List<AbstractRequestableLevelNode> choices = new ArrayList<AbstractRequestableLevelNode>();
for (String aliasModel : sourceAliases
.get(source)) {
AbstractRequestableLevelNode alias;
AbstractRequestableLevelNode alias = null;
if (derive) {
alias = resolveNode(
dataTree.getSourceNode(aliasModel),
param, level, stack, nodata);
try {
alias = resolveNode(
dataTree.getSourceNode(aliasModel),
param, level, stack, nodata);
} catch (VizCommunicationException e) {
statusHandler.handle(
Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
} else {
ParameterNode pNode = node
.getChildNode(param);
@ -722,10 +760,12 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
* @param stack
* @param nodata
* @return
* @throws VizCommunicationException
*/
protected synchronized AbstractRequestableLevelNode resolveNode(
SourceNode sourceNode, String param, Level level,
Deque<StackEntry> stack, Set<StackEntry> nodata) {
Deque<StackEntry> stack, Set<StackEntry> nodata)
throws VizCommunicationException {
ParameterNode pNode = sourceNode.getChildNode(param);
LevelNode lNode = pNode == null ? null : pNode.getChildNode(Long
.toString(level.getId()));
@ -861,8 +901,14 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
}// method loop
}
if (level.isRangeLevel()) {
Level upperLevel = level.getUpperLevel();
Level lowerLevel = level.getLowerLevel();
Level upperLevel;
Level lowerLevel;
try {
upperLevel = level.getUpperLevel();
lowerLevel = level.getLowerLevel();
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
List<AbstractRequestableLevelNode> nodes = new ArrayList<AbstractRequestableLevelNode>();
int endCount = 0;
@ -956,10 +1002,11 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
* @param nodata
* @return Should be Either some IStaticData or an
* AbstractRequestableLevelNode
* @throws VizCommunicationException
*/
private synchronized Object resolveField(SourceNode sourceNode,
Level level, IDerivParamField ifield, Deque<StackEntry> stack,
Set<StackEntry> nodata) {
Set<StackEntry> nodata) throws VizCommunicationException {
// process the next field
if (ifield.getClass() == DerivParamConstantField.class) {
return new FloatRequestableData(
@ -1004,10 +1051,14 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
if (type == null) {
fieldLevel = level;
} else if (level.isRangeLevel()) {
if (type == LevelType.Upper) {
fieldLevel = level.getUpperLevel();
} else {
fieldLevel = level.getLowerLevel();
try {
if (type == LevelType.Upper) {
fieldLevel = level.getUpperLevel();
} else {
fieldLevel = level.getLowerLevel();
}
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
} else {
SortedSet<Level> levels = null;
@ -1067,7 +1118,7 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
protected abstract LevelNode getCubeNode(SourceNode sNode,
DerivParamField field, Deque<StackEntry> stack,
Set<StackEntry> nodata);
Set<StackEntry> nodata) throws VizCommunicationException;
protected abstract AbstractDerivedLevelNode getImportNode(
AbstractRequestableData nodeToImport, SourceNode destSourceNode,

View file

@ -29,6 +29,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.adapters.UnitAdapter;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.level.LevelMapping;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
@ -82,14 +83,14 @@ public class DerivParamField implements ISerializableObject, IDerivParamField {
this.param = param;
}
public LevelMapping getLevelMapping() {
public LevelMapping getLevelMapping() throws VizCommunicationException {
if (levelType == null && level != null) {
setLevel(level);
}
return levelMapping;
}
public LevelType getLevelType() {
public LevelType getLevelType() throws VizCommunicationException {
if (levelType == null && level != null) {
setLevel(level);
}
@ -125,8 +126,9 @@ public class DerivParamField implements ISerializableObject, IDerivParamField {
* @param level
* @return true upon success, false if the token is not recognized, in which
* case levelType and levelMapping will both be reset to null
* @throws VizCommunicationException
*/
public boolean setLevel(String level) {
public boolean setLevel(String level) throws VizCommunicationException {
levelType = LevelType.parseLevel(level);
if (levelType == LevelType.LevelMapping) {
levelMapping = LevelMappingFactory.getInstance()

View file

@ -38,9 +38,8 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.status.StatusConstants;
import com.raytheon.uf.viz.derivparam.Activator;
/**
* Metadata about a derived parameter method.
@ -61,7 +60,8 @@ import com.raytheon.uf.viz.derivparam.Activator;
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class DerivParamMethod implements ISerializableObject {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(DerivParamMethod.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(DerivParamMethod.class);
public enum FrameworkMethod {
ALIAS, MODELRUN, TIMERANGE, OR, UNION, SUPPLEMENT, IMPORT, NODERIVATION;
@ -149,7 +149,7 @@ public class DerivParamMethod implements ISerializableObject {
fields.add(field);
}
public Set<Level> getValidLevels() {
public Set<Level> getValidLevels() throws VizCommunicationException {
if (validLevels == null && levels != null && levels.length() > 0) {
ValidLevelGenerator lvlGen = new ValidLevelGenerator();
validLevels = lvlGen.generateLevels(levels);
@ -253,13 +253,13 @@ public class DerivParamMethod implements ISerializableObject {
tmp.append(pFieldTokens[k]);
}
statusHandler.handle(
Priority.SIGNIFICANT,
"Derived parameter ["
+ "field ["
+ field.getParam()
+ "], contains unknown parameter modifier ["
+ tmp.toString() + "]");
statusHandler
.handle(Priority.SIGNIFICANT,
"Derived parameter ["
+ "field ["
+ field.getParam()
+ "], contains unknown parameter modifier ["
+ tmp.toString() + "]");
}
}
}

View file

@ -28,10 +28,12 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.CompareType;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.level.LevelMapping;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
@ -72,7 +74,7 @@ public class ValidLevelGenerator {
}
public Set<Level> generateLevels(String validLevelsString)
throws IllegalArgumentException {
throws IllegalArgumentException, VizCommunicationException {
masterLevels = new HashMap<MasterLevel, Set<Level>>();
validLevels = new HashSet<Level>();
masterLevelsHandled = new HashSet<MasterLevel>();
@ -121,7 +123,11 @@ public class ValidLevelGenerator {
if (tokensToProcess.size() > 0) {
for (String token : tokensToProcess) {
processLevelToken(token);
try {
processLevelToken(token);
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
}
} else {
for (Set<Level> levels : masterLevels.values()) {
@ -133,7 +139,8 @@ public class ValidLevelGenerator {
return validLevels;
}
private void processLevelToken(String token) {
private void processLevelToken(String token)
throws VizCommunicationException, CommunicationException {
boolean negate = token.charAt(0) == '!';
int rangeIndex = token.indexOf('>');
@ -318,7 +325,8 @@ public class ValidLevelGenerator {
}
}
private Type determineType(String token) {
private Type determineType(String token) throws CommunicationException,
VizCommunicationException {
Type rval = null;
LevelMapping mapping = lmf.getLevelMappingForKey(token);

View file

@ -27,8 +27,10 @@ Require-Bundle: org.eclipse.ui,
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.viz.objectiveanalysis.rsc
Import-Package: com.raytheon.uf.common.dataplugin.grib.spatial.projections,
Import-Package: com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.radar,
com.raytheon.uf.viz.derivparam.library,
com.raytheon.uf.viz.derivparam.tree,
com.raytheon.viz.ui,

View file

@ -27,18 +27,20 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.style.level.SingleLevel;
import com.raytheon.uf.viz.core.style.level.Level.LevelType;
import com.raytheon.uf.viz.core.style.level.SingleLevel;
/**
* Resource Data for Objective Analysis
@ -161,8 +163,8 @@ public class OAResourceData extends AbstractRequestableResourceData {
throw new UnsupportedOperationException("Unsupported level for OA "
+ levelKey);
}
level.setValue(Double.parseDouble(levelKey.substring(0, levelKey
.length() - 2)));
level.setValue(Double.parseDouble(levelKey.substring(0,
levelKey.length() - 2)));
return level;
}
@ -194,7 +196,12 @@ public class OAResourceData extends AbstractRequestableResourceData {
DataTime[] times = super.getAvailableTimes();
if (this.levelKey.equals(ALL_TILTS)) {
LevelFactory factory = LevelFactory.getInstance();
MasterLevel ml = factory.getMasterLevel("TILT");
MasterLevel ml;
try {
ml = factory.getMasterLevel("TILT");
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
Set<Level> allLevels = LevelMappingFactory.getInstance()
.getAllLevels();
List<Level> levels = new ArrayList<Level>();

View file

@ -32,6 +32,7 @@ Export-Package: com.raytheon.viz.grid,
com.raytheon.viz.grid.xml
Import-Package: com.raytheon.edex.scriptfactory,
com.raytheon.uf.common.colormap,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.grib.exception,
com.raytheon.uf.common.dataplugin.grib.request,
@ -47,6 +48,7 @@ Import-Package: com.raytheon.edex.scriptfactory,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.time,
com.raytheon.uf.common.topo,
com.raytheon.uf.viz.d2d.core.map,
com.raytheon.uf.viz.d2d.core.time,
com.raytheon.uf.viz.derivparam,
com.raytheon.uf.viz.derivparam.data,

View file

@ -33,12 +33,16 @@ import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.grib.util.GribModelLookup;
import com.raytheon.uf.common.dataplugin.grib.util.GridModel;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
import com.raytheon.uf.viz.core.rsc.DisplayType;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
@ -70,6 +74,8 @@ import com.raytheon.viz.grid.rsc.GridResourceData;
*/
public class GridProductBrowserDataDefinition extends
AbstractRequestableProductBrowserDataDefinition<GridResourceData> {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GridProductBrowserDataDefinition.class);
private static final String SHOW_UNKNOWN_MODELS = "Show Unknown Models";
@ -166,27 +172,32 @@ public class GridProductBrowserDataDefinition extends
e.printStackTrace();
}
LevelFactory lf = LevelFactory.getInstance();
if (selection.length > 3) {
List<String> availLevels = new ArrayList<String>();
for (String levelid : returnQueue) {
Level level = lf.getLevel(levelid);
if (level.getMasterLevel().getName().equals(selection[3])) {
availLevels.add(levelid);
try {
if (selection.length > 3) {
List<String> availLevels = new ArrayList<String>();
for (String levelid : returnQueue) {
Level level = lf.getLevel(levelid);
if (level.getMasterLevel().getName().equals(selection[3])) {
availLevels.add(levelid);
}
}
return formatData(GridInventory.LEVEL_ID_QUERY,
availLevels.toArray(new String[availLevels.size()]));
} else {
Set<String> masterLevels = new HashSet<String>();
for (String levelid : returnQueue) {
Level level = lf.getLevel(levelid);
masterLevels.add(level.getMasterLevel().getName());
}
List<ProductBrowserLabel> results = formatData(
GridInventory.MASTER_LEVEL_QUERY,
masterLevels.toArray(new String[masterLevels.size()]));
Collections.sort(results);
return results;
}
return formatData(GridInventory.LEVEL_ID_QUERY,
availLevels.toArray(new String[availLevels.size()]));
} else {
Set<String> masterLevels = new HashSet<String>();
for (String levelid : returnQueue) {
Level level = lf.getLevel(levelid);
masterLevels.add(level.getMasterLevel().getName());
}
List<ProductBrowserLabel> results = formatData(
GridInventory.MASTER_LEVEL_QUERY,
masterLevels.toArray(new String[masterLevels.size()]));
Collections.sort(results);
return results;
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
return super.populateData(selection);
}
}
@ -249,8 +260,13 @@ public class GridProductBrowserDataDefinition extends
} else if (GridInventory.LEVEL_ID_QUERY.equals(param)) {
Level[] levels = new Level[parameters.length];
LevelFactory lf = LevelFactory.getInstance();
for (int i = 0; i < levels.length; i++) {
levels[i] = lf.getLevel(parameters[i]);
try {
for (int i = 0; i < levels.length; i++) {
levels[i] = lf.getLevel(parameters[i]);
}
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
Arrays.sort(levels, levelComparator);
for (int i = 0; i < parameters.length; i++) {
@ -264,10 +280,15 @@ public class GridProductBrowserDataDefinition extends
return labels;
} else if (GridInventory.MASTER_LEVEL_QUERY.equals(param)) {
LevelFactory lf = LevelFactory.getInstance();
for (int i = 0; i < parameters.length; i++) {
MasterLevel masterLevel = lf.getMasterLevel(parameters[i]);
labels.add(new ProductBrowserLabel(
masterLevel.getDescription(), masterLevel.getName()));
try {
for (int i = 0; i < parameters.length; i++) {
MasterLevel masterLevel = lf.getMasterLevel(parameters[i]);
labels.add(new ProductBrowserLabel(masterLevel
.getDescription(), masterLevel.getName()));
}
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
return super.formatData(param, parameters);
@ -281,14 +302,18 @@ public class GridProductBrowserDataDefinition extends
}
HashMap<String, RequestConstraint> queryList = super
.getProductParameters(selection, order);
try {
// Convert Level id to level one and level two values.
Level level = LevelFactory.getInstance().getLevel(selection[4]);
queryList.put(GridInventory.LEVEL_ONE_QUERY, new RequestConstraint(
level.getLevelOneValueAsString()));
queryList.put(GridInventory.LEVEL_TWO_QUERY, new RequestConstraint(
level.getLevelTwoValueAsString()));
queryList.remove(order[4]);
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
queryList.remove(order[4]);
// Convert Level id to level one and level two values.
Level level = LevelFactory.getInstance().getLevel(selection[4]);
queryList.put(GridInventory.LEVEL_ONE_QUERY, new RequestConstraint(
level.getLevelOneValueAsString()));
queryList.put(GridInventory.LEVEL_TWO_QUERY, new RequestConstraint(
level.getLevelTwoValueAsString()));
}
return queryList;
}

View file

@ -25,6 +25,7 @@ import java.lang.ref.WeakReference;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.Unit;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
@ -37,6 +38,9 @@ import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.HDF5Util;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.exception.VizException;
@ -61,6 +65,8 @@ import com.raytheon.viz.radar.util.DataUtilities;
*/
public class RadarRequestableData extends GribRequestableData {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(RadarRequestableData.class);
private RadarRecord radarSource;
@ -80,8 +86,13 @@ public class RadarRequestableData extends GribRequestableData {
RadarAdapter.getGridSpacing());
this.source = "radar";
this.dataTime = source.getDataTime();
this.level = LevelFactory.getInstance().getLevel("TILT",
source.getPrimaryElevationAngle());
try {
this.level = LevelFactory.getInstance().getLevel("TILT",
source.getPrimaryElevationAngle());
} catch (CommunicationException e1) {
statusHandler
.handle(Priority.PROBLEM, e1.getLocalizedMessage(), e1);
}
this.parameter = parameterAbbrev;
this.parameterName = "";
this.unit = unit;
@ -146,14 +157,12 @@ public class RadarRequestableData extends GribRequestableData {
fdr.setDimension(2);
cache = new WeakReference<FloatDataRecord>(fdr);
}
if (arg == null) {
return new IDataRecord[] { fdr };
} else if (arg instanceof Request) {
if (arg instanceof Request) {
fdr = SliceUtil.slice(fdr, (Request) arg);
return new IDataRecord[] { fdr };
} else {
return new IDataRecord[] { fdr };
}
throw new VizException(this.getClass().getSimpleName()
+ " cannot process request of type: "
+ arg.getClass().getSimpleName());
}
}

View file

@ -21,6 +21,7 @@ package com.raytheon.viz.grid.data;
import javax.measure.unit.SI;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.grib.util.GribModelLookup;
import com.raytheon.uf.common.dataplugin.grib.util.GridModel;
@ -29,6 +30,9 @@ import com.raytheon.uf.common.dataplugin.grib.util.StaticGridDataType;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData;
import com.raytheon.viz.grid.util.CoverageUtils;
@ -51,6 +55,9 @@ import com.raytheon.viz.grid.util.SliceUtil;
*/
public class StaticGridRequestableData extends AbstractRequestableData {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(StaticGridRequestableData.class);
private StaticGridDataType dataType;
public StaticGridRequestableData(StaticGridDataType dataType, String source) {
@ -63,7 +70,11 @@ public class StaticGridRequestableData extends AbstractRequestableData {
} else {
this.unit = SI.METER;
}
this.level = LevelFactory.getInstance().getLevel("SFC", 0.0);
try {
this.level = LevelFactory.getInstance().getLevel("SFC", 0.0);
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
/*
@ -107,13 +118,11 @@ public class StaticGridRequestableData extends AbstractRequestableData {
break;
}
}
if (arg == null) {
return rval;
} else if (arg instanceof Request) {
if (arg instanceof Request) {
return SliceUtil.slice(rval, (Request) arg);
} else {
return rval;
}
throw new VizException(this.getClass().getSimpleName()
+ " cannot process request of type: "
+ arg.getClass().getSimpleName());
}
}

View file

@ -26,10 +26,14 @@ import javax.measure.unit.SI;
import org.geotools.coverage.grid.GridGeometry2D;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.grib.spatial.projections.GridCoverage;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.topo.TopoQuery;
import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData;
@ -53,6 +57,9 @@ import com.raytheon.viz.grid.util.SliceUtil;
*/
public class TopoRequestableData extends AbstractRequestableData {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(TopoRequestableData.class);
// need to move to a static timed cache
private static Map<GridCoverage, FloatDataRecord> topoCache = new HashMap<GridCoverage, FloatDataRecord>();
@ -61,7 +68,11 @@ public class TopoRequestableData extends AbstractRequestableData {
this.parameter = "staticTopo";
this.parameterName = "Topography";
this.unit = SI.METER;
this.level = LevelFactory.getInstance().getLevel("SFC", 0.0);
try {
this.level = LevelFactory.getInstance().getLevel("SFC", 0.0);
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
/*
@ -85,13 +96,10 @@ public class TopoRequestableData extends AbstractRequestableData {
topoCache.put(coverage, rval);
}
}
if (arg == null) {
return rval;
} else if (arg instanceof Request) {
if (arg instanceof Request) {
return SliceUtil.slice(rval, (Request) arg);
} else {
return rval;
}
throw new VizException(this.getClass().getSimpleName()
+ " cannot process request of type: "
+ arg.getClass().getSimpleName());
}
}

View file

@ -131,7 +131,8 @@ public class GridInventory extends AbstractInventory implements
private List<Map<String, RequestConstraint>> failedRequests = new ArrayList<Map<String, RequestConstraint>>();
@Override
public void initTree(Map<String, DerivParamDesc> derParLibrary) {
public void initTree(Map<String, DerivParamDesc> derParLibrary)
throws VizException {
super.initTree(derParLibrary);
if (updater == null) {
updater = new GridUpdater(this);
@ -144,32 +145,28 @@ public class GridInventory extends AbstractInventory implements
}
public void reinitTree() {
initTree(derParLibrary);
// reprocess all failed requests to see if data has become available.
List<Map<String, RequestConstraint>> constraintsToTry = this.failedRequests;
this.failedRequests = new ArrayList<Map<String, RequestConstraint>>(
failedRequests.size());
for (Map<String, RequestConstraint> constraints : constraintsToTry) {
evaluateRequestConstraints(constraints);
try {
initTree(derParLibrary);
// reprocess all failed requests to see if data has become
// available.
List<Map<String, RequestConstraint>> constraintsToTry = this.failedRequests;
this.failedRequests = new ArrayList<Map<String, RequestConstraint>>(
failedRequests.size());
for (Map<String, RequestConstraint> constraints : constraintsToTry) {
evaluateRequestConstraints(constraints);
}
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
private DataTree getTreeFromEdex() {
private DataTree getTreeFromEdex() throws VizException {
String request = "from com.raytheon.edex.uengine.tasks.grib import GridCatalog\n"
+ "from com.raytheon.uf.common.message.response import ResponseMessageGeneric\n"
+ "test = GridCatalog()\n"
+ "return ResponseMessageGeneric(test.execute())";
Object[] tree = null;
try {
tree = Connector.getInstance().connect(request, null, 60000);
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM,
"Error communicating with server.", e);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred while retrieving grid tree.", e);
}
tree = Connector.getInstance().connect(request, null, 60000);
if (tree != null) {
return (DataTree) tree[0];
}
@ -266,7 +263,7 @@ public class GridInventory extends AbstractInventory implements
return null;
}
protected DataTree createBaseTree() {
protected DataTree createBaseTree() throws VizException {
DataTree newTree = getTreeFromEdex();
if (newTree == null) {
return newTree;
@ -639,7 +636,8 @@ public class GridInventory extends AbstractInventory implements
@Override
protected LevelNode getCubeNode(SourceNode sNode, DerivParamField field,
Deque<StackEntry> stack, Set<StackEntry> nodata) {
Deque<StackEntry> stack, Set<StackEntry> nodata)
throws VizCommunicationException {
StackEntry se = new StackEntry(sNode.getValue(), field.getParam(),
Long.MIN_VALUE);
if (stack.contains(se)) {
@ -654,8 +652,14 @@ public class GridInventory extends AbstractInventory implements
String masterLevelName = get3DMasterLevel(sNode.getValue());
boolean isRadar = sNode.getValue().equals(RadarAdapter.RADAR_SOURCE);
NavigableSet<Level> levels = LevelUtilities
.getOrderedSetOfStandardLevels(masterLevelName);
NavigableSet<Level> levels = null;
try {
levels = LevelUtilities
.getOrderedSetOfStandardLevels(masterLevelName);
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
return null;
}
List<CubeLevel<AbstractRequestableLevelNode, AbstractRequestableLevelNode>> cubeLevels = new ArrayList<CubeLevel<AbstractRequestableLevelNode, AbstractRequestableLevelNode>>(
levels.size());

View file

@ -28,6 +28,7 @@ import java.util.Map;
import java.util.Set;
import com.raytheon.edex.util.Util;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
@ -215,11 +216,18 @@ public class GridUpdater implements IAlertObserver {
}
GribMapKey updateKey = new GribMapKey(alert.decodedAlert);
GribTimeCache.getInstance().clearTimes(updateKey);
Level level = LevelFactory.getInstance().getLevel(
updateKey.masterLevel, updateKey.levelone,
updateKey.leveltwo);
LevelNode lNode = inventory.getNode(updateKey.modelName,
updateKey.parameter, level);
LevelNode lNode = null;
try {
Level level = LevelFactory.getInstance().getLevel(
updateKey.masterLevel, updateKey.levelone,
updateKey.leveltwo);
lNode = inventory.getNode(updateKey.modelName,
updateKey.parameter, level);
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
if (lNode == null) {
inventory.reinitTree();
// System.out.println(alert.dataURI);

View file

@ -7,6 +7,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
@ -157,8 +158,14 @@ public class RadarUpdater implements IAlertObserver {
}
Double elevationAngle = (Double) obj;
cache.remove(new CacheKey(productCode, elevationAngle));
Level level = LevelFactory.getInstance().getLevel(
RadarAdapter.CUBE_MASTER_LEVEL_NAME, elevationAngle);
Level level = null;
try {
level = LevelFactory.getInstance().getLevel(
RadarAdapter.CUBE_MASTER_LEVEL_NAME, elevationAngle);
} catch (CommunicationException e1) {
statusHandler.handle(Priority.PROBLEM,
e1.getLocalizedMessage(), e1);
}
GribRecord fakeRec = new GribRecord();
fakeRec.setPluginName("grib");
fakeRec.setDataTime(time);

View file

@ -22,6 +22,7 @@ package com.raytheon.viz.grid.rsc;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.level.LevelMapping;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.rsc.AbstractNameGenerator;
@ -118,12 +119,17 @@ public class GridNameGenerator extends AbstractNameGenerator {
}
private String lookupPlane(Level level) {
LevelMapping mapping = LevelMappingFactory.getInstance()
.getLevelMappingForLevel(level);
if (mapping == null) {
try {
LevelMapping mapping = LevelMappingFactory.getInstance()
.getLevelMappingForLevel(level);
if (mapping == null) {
return level.getMasterLevel().getName();
}
return mapping.getDisplayName();
} catch (VizCommunicationException e) {
return level.getMasterLevel().getName();
}
return mapping.getDisplayName();
}
public void setPlaneLabelString(String planeLabelString) {

View file

@ -56,6 +56,9 @@ import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.geospatial.ISpatialEnabled;
import com.raytheon.uf.common.geospatial.ISpatialObject;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.HDF5Util;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
@ -65,7 +68,6 @@ import com.raytheon.uf.viz.core.datastructure.VizDataCubeException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData;
import com.raytheon.uf.viz.derivparam.library.DerivParamDesc;
import com.raytheon.uf.viz.derivparam.library.DerivedParameterGenerator;
import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableLevelNode;
import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableLevelNode.Dependency;
@ -89,13 +91,13 @@ import com.raytheon.viz.grid.record.RequestableDataRecord;
* @version 1.0
*/
public class GribDataCubeAdapter implements IDataCubeAdapter {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GribDataCubeAdapter.class);
private static final String DERIVED = "DERIVED";
private GridInventory gridInventory;
private Map<String, DerivParamDesc> derParLibrary;
protected void getTimeQuery(
AbstractRequestableLevelNode req,
boolean latestOnly,
@ -293,17 +295,33 @@ public class GribDataCubeAdapter implements IDataCubeAdapter {
@Override
public void initInventory() {
derParLibrary = DerivedParameterGenerator.getDerParLibrary();
if (gridInventory == null) {
GridInventory gridInventory = new GridInventory();
gridInventory.initTree(derParLibrary);
this.gridInventory = gridInventory;
try {
gridInventory.initTree(DerivedParameterGenerator
.getDerParLibrary());
this.gridInventory = gridInventory;
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
}
@Override
public Object getInventory() {
if (gridInventory == null) {
GridInventory gridInventory = new GridInventory();
try {
gridInventory.initTree(DerivedParameterGenerator
.getDerParLibrary());
this.gridInventory = gridInventory;
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
return gridInventory;
}

View file

@ -34,6 +34,7 @@ import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.crs.ProjectedCRS;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
@ -309,7 +310,12 @@ public class RadarAdapter {
* @param level
*/
private void initTopoParam(SourceNode modelNameNode) {
Level sfc = LevelFactory.getInstance().getLevel("SFC", 0.0);
Level sfc = null;
try {
sfc = LevelFactory.getInstance().getLevel("SFC", 0.0);
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
DerivParamDesc topo = new DerivParamDesc();
topo.setAbbreviation("Topo");
topo.setName("Topography");

View file

@ -26,6 +26,7 @@ Export-Package: com.raytheon.viz.pointdata,
com.raytheon.viz.pointdata.rsc.retrieve,
com.raytheon.viz.pointdata.util
Import-Package: com.raytheon.edex.meteoLib,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.derivparam.tree,
com.raytheon.uf.common.message.response,

View file

@ -15,6 +15,7 @@ import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
@ -23,8 +24,12 @@ import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.BinOffset;
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.map.MapDescriptor;
@ -39,6 +44,8 @@ import com.raytheon.viz.pointdata.util.PointDataInventory;
public class PlotModelDataDefinition extends
AbstractRequestableProductBrowserDataDefinition<PlotResourceData> {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(PlotModelDataDefinition.class);
private static final String PLOTLOCATION = "plotModels";
@ -271,10 +278,18 @@ public class PlotModelDataDefinition extends
}
List<String> validLevels = new ArrayList<String>();
for (String levelid : possibleLevels) {
Level level = LevelFactory.getInstance().getLevel(
Long.parseLong(levelid));
validLevels.add(LevelMappingFactory.getInstance()
.getLevelMappingForLevel(level).getDisplayName());
try {
Level level = LevelFactory.getInstance().getLevel(
Long.parseLong(levelid));
validLevels.add(LevelMappingFactory.getInstance()
.getLevelMappingForLevel(level).getDisplayName());
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
return validLevels.toArray(new String[0]);
}

View file

@ -40,6 +40,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.RecordFactory;
import com.raytheon.uf.viz.core.catalog.CatalogQuery;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData;
@ -71,9 +72,6 @@ public abstract class AbstractPointDataInventory extends AbstractInventory {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(AbstractPointDataInventory.class);
public static final Level STATION = LevelMappingFactory.getInstance()
.getLevelMappingForKey("Station").getLevels().get(0);
public static String PLUGIN_NAME = "pluginName";
protected List<String> plugins;
@ -135,7 +133,7 @@ public abstract class AbstractPointDataInventory extends AbstractInventory {
protected DataTree getInitialTree() {
DataTree tree = new DataTree();
String stationId = Long.toString(STATION.getId());
String stationId = Long.toString(getStationLevel().getId());
for (String pluginName : plugins) {
try {
String[] types = getAvailableTypes(pluginName);
@ -276,4 +274,14 @@ public abstract class AbstractPointDataInventory extends AbstractInventory {
return plugins;
}
public static Level getStationLevel() {
try {
return LevelMappingFactory.getInstance()
.getLevelMappingForKey("Station").getLevels().get(0);
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
return null;
}
}
}

View file

@ -65,7 +65,7 @@ public class PointAccumLevelNode extends AbstractDerivedLevelNode {
public PointAccumLevelNode(DerivParamDesc desc, DerivParamMethod method,
List<AbstractRequestableLevelNode> idNodes,
AbstractRequestableLevelNode timeNode) {
super(PointDataInventory.STATION, desc, method, null);
super(PointDataInventory.getStationLevel(), desc, method, null);
this.idNodes = idNodes;
this.timeNode = timeNode;
}

View file

@ -37,6 +37,9 @@ import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.RecordFactory;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
@ -49,7 +52,6 @@ import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData;
import com.raytheon.uf.viz.derivparam.library.DerivParamDesc;
import com.raytheon.uf.viz.derivparam.library.DerivedParameterGenerator;
import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableLevelNode;
import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableLevelNode.Dependency;
@ -76,6 +78,8 @@ import com.raytheon.viz.pointdata.PointDataRequest;
*/
public class PointDataCubeAdapter implements IDataCubeAdapter {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(PointDataCubeAdapter.class);
public static String PLUGIN_NAME = PointDataInventory.PLUGIN_NAME;
@ -88,8 +92,6 @@ public class PointDataCubeAdapter implements IDataCubeAdapter {
protected AbstractPointDataInventory inventory;
protected Map<String, DerivParamDesc> derParLibrary;
/*
* (non-Javadoc)
*
@ -112,6 +114,9 @@ public class PointDataCubeAdapter implements IDataCubeAdapter {
*/
@Override
public Object getInventory() {
if (inventory == null) {
initInventory();
}
return this.inventory;
}
@ -301,12 +306,17 @@ public class PointDataCubeAdapter implements IDataCubeAdapter {
*/
@Override
public void initInventory() {
derParLibrary = DerivedParameterGenerator.getDerParLibrary();
if (inventory == null) {
PointDataInventory pointInventory = new PointDataInventory(
Arrays.asList(supportedPlugins));
pointInventory.initTree(derParLibrary);
this.inventory = pointInventory;
try {
pointInventory.initTree(DerivedParameterGenerator
.getDerParLibrary());
this.inventory = pointInventory;
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
}

View file

@ -112,7 +112,12 @@ public class PointDataInventory extends AbstractPointDataInventory implements
}
if (getAllSources() != null && !getAllSources().contains(source)) {
initTree(derParLibrary);
try {
initTree(derParLibrary);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
}
}

View file

@ -48,7 +48,7 @@ public class PointRequestableData extends AbstractRequestableData {
public PointRequestableData(IDataRecord rec, Unit<?> unit) {
this.unit = unit;
this.rec = rec;
this.level = PointDataInventory.STATION;
this.level = PointDataInventory.getStationLevel();
this.parameter = rec.getName();
}

View file

@ -35,6 +35,9 @@ import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponseSet;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.BinOffset;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.exception.VizException;
@ -61,6 +64,9 @@ import com.raytheon.viz.pointdata.util.PointDataCubeAdapter;
* @version 1.0
*/
public class RadarDataCubeAdapter extends PointDataCubeAdapter {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(RadarDataCubeAdapter.class);
private static final String DATA_TIME_FIELD = "dataTime";
private static final String LATEST_DATA_TIME_FIELD = "dataTime.refTime";
@ -74,11 +80,16 @@ public class RadarDataCubeAdapter extends PointDataCubeAdapter {
@Override
public void initInventory() {
derParLibrary = DerivedParameterGenerator.getDerParLibrary();
if (inventory == null) {
AbstractPointDataInventory pointInventory = new VwpInventory();
pointInventory.initTree(derParLibrary);
this.inventory = pointInventory;
try {
pointInventory.initTree(DerivedParameterGenerator
.getDerParLibrary());
this.inventory = pointInventory;
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
}

View file

@ -38,7 +38,8 @@ Export-Package: com.raytheon.viz.volumebrowser,
com.raytheon.viz.volumebrowser.datacatalog,
com.raytheon.viz.volumebrowser.vbui,
com.raytheon.viz.volumebrowser.xml
Import-Package: com.raytheon.uf.common.dataplugin.grib,
Import-Package: com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.grib.util,
com.raytheon.uf.common.dataplugin.level,

View file

@ -40,6 +40,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Label;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.grib.util.GribModelLookup;
import com.raytheon.uf.common.dataplugin.grib.util.GridModel;
import com.raytheon.uf.common.dataplugin.level.Level;
@ -58,15 +59,15 @@ import com.raytheon.viz.grid.rsc.GridResourceData;
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 11/29/2006 #7 brockwoo Initial creation
* 12/05/2006 #98 brockwoo Fix for the grid parameter list not
* updating when only the model time
* changes
* Aug 27, 2008 1502 dglazesk Updated to use JAXB marshalling
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 11/29/2006 #7 brockwoo Initial creation
* 12/05/2006 #98 brockwoo Fix for the grid parameter list not
* updating when only the model time
* changes
* Aug 27, 2008 1502 dglazesk Updated to use JAXB marshalling
* Switched to GridModel from plugin-grib
*
* </pre>
@ -267,10 +268,14 @@ public class GridDataCatalog implements IDataCatalog {
LevelFactory lf = LevelFactory.getInstance();
for (int i = 0; i < levelIds.length; i++) {
Level level = lf.getLevel(levelIds[i]);
levelNames[i] = level.getMasterLevel().getName()
+ level.getLevelInfo();
this.levelList.put(levelNames[i], level);
try {
Level level = lf.getLevel(levelIds[i]);
levelNames[i] = level.getMasterLevel().getName()
+ level.getLevelInfo();
this.levelList.put(levelNames[i], level);
} catch (CommunicationException e) {
e.printStackTrace();
}
}
Arrays.sort(levelNames);

View file

@ -33,6 +33,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.level.LevelMapping;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.level.LevelUtilities;
@ -344,15 +345,25 @@ public abstract class AbstractDataCatalog implements IDataCatalog {
String planesKey = catalogEntry.getSelectedData().getPlanesKey();
LevelMappingFactory lmf = LevelMappingFactory.getInstance();
Collection<Level> levels = Collections.emptyList();
if (planesKey.startsWith("spatial-")) {
levels = LevelUtilities.getOrderedSetOfStandardLevels(planesKey
.replace("spatial-", ""));
try {
levels = LevelUtilities.getOrderedSetOfStandardLevels(planesKey
.replace("spatial-", ""));
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
} else {
LevelMapping lm = lmf.getLevelMappingForKey(planesKey);
if (lm != null) {
levels = lm.getLevels();
try {
LevelMappingFactory lmf = LevelMappingFactory.getInstance();
LevelMapping lm = lmf.getLevelMappingForKey(planesKey);
if (lm != null) {
levels = lm.getLevels();
}
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
ParamLevelMatchCriteria match = new ParamLevelMatchCriteria();

View file

@ -35,12 +35,14 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.level.LevelMapping;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.level.LevelUtilities;
@ -172,22 +174,31 @@ public abstract class AbstractInventoryDataCatalog extends AbstractDataCatalog {
String levelStr = levelQueue.poll();
while (levelStr != null) {
// Convert levels into planes.
Level level = LevelFactory.getInstance().getLevel(levelStr);
try {
Level level = LevelFactory.getInstance().getLevel(levelStr);
if (levels3D.contains(level)) {
for (String plane : get3DPlanes(sourcesToProcess)) {
request.addAvailablePlane(plane);
if (levels3D.contains(level)) {
for (String plane : get3DPlanes(sourcesToProcess)) {
request.addAvailablePlane(plane);
}
}
}
request.addAvailablePlane("spatial-"
+ level.getMasterLevel().getName());
LevelMapping lm = LevelMappingFactory.getInstance()
.getLevelMappingForLevel(level);
request.addAvailablePlane("spatial-"
+ level.getMasterLevel().getName());
try {
LevelMapping lm = LevelMappingFactory.getInstance()
.getLevelMappingForLevel(level);
if (lm != null) {
request.addAvailablePlane(lm.getKey());
if (lm != null) {
request.addAvailablePlane(lm.getKey());
}
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
levelStr = levelQueue.poll();
}
@ -273,13 +284,23 @@ public abstract class AbstractInventoryDataCatalog extends AbstractDataCatalog {
for (String plane : selectedPlanes) {
Collection<Level> levels = Collections.emptyList();
if (plane.startsWith("spatial-")) {
levels = LevelUtilities.getOrderedSetOfStandardLevels(plane
.replace("spatial-", ""));
try {
levels = LevelUtilities
.getOrderedSetOfStandardLevels(plane.replace(
"spatial-", ""));
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
} else {
LevelMapping lm = lmf.getLevelMappingForKey(plane);
if (lm != null) {
levels = lm.getLevels();
try {
levels = lm.getLevels();
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
}
for (Level l : levels) {

View file

@ -21,6 +21,7 @@ package com.raytheon.viz.volumebrowser.datacatalog;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -43,6 +44,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.level.LevelUtilities;
@ -177,11 +179,16 @@ public class GribDataCatalog extends AbstractInventoryDataCatalog {
.getInvalidLevelValueAsString()));
} else {
// Get all possible levels for the selected levels
LevelMappingFactory lmf = LevelMappingFactory.getInstance();
List<Level> selectedLevels = new ArrayList<Level>(lmf
.getLevelMappingForKey(catalogEntry.selectedPlanesKey)
.getLevels());
List<Level> selectedLevels = Collections.emptyList();
try {
LevelMappingFactory lmf = LevelMappingFactory.getInstance();
selectedLevels = new ArrayList<Level>(lmf
.getLevelMappingForKey(
catalogEntry.selectedPlanesKey).getLevels());
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
RequestConstraint masterRC = new RequestConstraint(null,
ConstraintType.IN);
RequestConstraint oneRC = new RequestConstraint(null,
@ -355,21 +362,34 @@ public class GribDataCatalog extends AbstractInventoryDataCatalog {
@Override
protected Collection<? extends Level> get3DLevels() {
ArrayList<Level> all = new ArrayList<Level>();
NavigableSet<Level> tilts = LevelUtilities
.getOrderedSetOfStandardLevels("TILT");
if (tilts != null) {
all.addAll(tilts);
try {
NavigableSet<Level> tilts = LevelUtilities
.getOrderedSetOfStandardLevels("TILT");
if (tilts != null) {
all.addAll(tilts);
}
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
NavigableSet<Level> pres = LevelUtilities
.getOrderedSetOfStandardLevels("MB");
if (pres != null) {
all.addAll(pres);
try {
NavigableSet<Level> pres = LevelUtilities
.getOrderedSetOfStandardLevels("MB");
if (pres != null) {
all.addAll(pres);
}
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
NavigableSet<Level> theta = LevelUtilities
.getOrderedSetOfStandardLevels("K");
if (theta != null) {
all.addAll(theta);
try {
NavigableSet<Level> theta = LevelUtilities
.getOrderedSetOfStandardLevels("K");
if (theta != null) {
all.addAll(theta);
}
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
return all;
}

View file

@ -41,6 +41,7 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.BinOffset;
import com.raytheon.uf.viz.core.catalog.DbQuery;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
@ -386,8 +387,13 @@ public class PointDataCatalog extends AbstractInventoryDataCatalog {
*/
@Override
protected Collection<? extends Level> get3DLevels() {
return LevelMappingFactory.getInstance()
.getLevelMappingForKey("Station").getLevels();
try {
return LevelMappingFactory.getInstance()
.getLevelMappingForKey("Station").getLevels();
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
return Collections.emptyList();
}
}
@Override

View file

@ -58,6 +58,7 @@ Import-Package: com.raytheon.edex.db.dao,
com.raytheon.edex.util,
com.raytheon.edex.util.grib,
com.raytheon.uf.common.activetable,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.annotations,
com.raytheon.uf.common.dataplugin.grib,

View file

@ -57,6 +57,7 @@ import com.raytheon.edex.plugin.gfe.server.GridParmManager;
import com.raytheon.edex.plugin.gfe.server.database.GridDatabase;
import com.raytheon.edex.plugin.gfe.util.GridTranslator;
import com.raytheon.edex.plugin.gfe.util.SendNotifications;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory;
@ -651,16 +652,19 @@ public class GFEDao extends DefaultPluginDao {
Level level = null;
// to have a level 2, must have a level one
if (levelOnePresent && levelTwoPresent) {
level = LevelFactory.getInstance().getLevel(levelName,
levelValues[0], levelValues[1]);
} else if (levelOnePresent) {
level = LevelFactory.getInstance().getLevel(levelName,
levelValues[0]);
} else {
level = LevelFactory.getInstance().getLevel(levelName, 0.0);
try {
if (levelOnePresent && levelTwoPresent) {
level = LevelFactory.getInstance().getLevel(levelName,
levelValues[0], levelValues[1]);
} else if (levelOnePresent) {
level = LevelFactory.getInstance().getLevel(levelName,
levelValues[0]);
} else {
level = LevelFactory.getInstance().getLevel(levelName, 0.0);
}
} catch (CommunicationException e) {
logger.error(e.getLocalizedMessage(), e);
}
if (level == null) {
logger.warn("Unable to query D2D parms, ParmID " + id
+ " does not map to a level");
@ -1013,7 +1017,7 @@ public class GFEDao extends DefaultPluginDao {
throws DataAccessLayerException {
QueryResult result = (QueryResult) this
.executeNativeSql("select max(dbid) as maxdbid from awips.gfe where dbid like '"
+ siteId + "!_GRID!_!_" + modelName + "!_%' escape '!'");
+ siteId + "!_GRID!_!_" + modelName + "!_%' escape '!'");
if (result.getResultCount() == 0) {
return null;
} else {

View file

@ -24,6 +24,7 @@ Require-Bundle: javax.measure,
com.raytheon.uf.common.awipstools;bundle-version="1.12.1174",
ucar.nc2;bundle-version="1.0.0"
Import-Package: com.raytheon.edex.exception,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.grib,
com.raytheon.uf.common.dataplugin.grib.exception,
com.raytheon.uf.common.dataplugin.grib.request,

View file

@ -53,6 +53,7 @@ import com.raytheon.edex.util.Util;
import com.raytheon.edex.util.grib.Grib1TableMap;
import com.raytheon.edex.util.grib.GribParamTranslator;
import com.raytheon.edex.util.grib.GribTableLookup;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
@ -1225,10 +1226,12 @@ public class Grib1Decoder extends AbstractDecoder {
* The level two scale factor
* @param value2
* The level two value
* @throws GribException
*/
private void getLevelInfo(GribModel model, int centerID, int subcenterID,
float levelOneNumber, float scaleFactor1, float value1,
float levelTwoNumber, float scaleFactor2, float value2) {
float levelTwoNumber, float scaleFactor2, float value2)
throws GribException {
String levelName = null;
String levelUnit = null;
double levelOneValue = Level.getInvalidLevelValue();
@ -1281,9 +1284,13 @@ public class Grib1Decoder extends AbstractDecoder {
levelOneValue = 0.0;
levelTwoValue = Level.getInvalidLevelValue();
}
Level level = LevelFactory.getInstance().getLevel(levelName,
levelOneValue, levelTwoValue, levelUnit);
model.setLevel(level);
try {
Level level = LevelFactory.getInstance().getLevel(levelName,
levelOneValue, levelTwoValue, levelUnit);
model.setLevel(level);
} catch (CommunicationException e) {
throw new GribException("Error requesting levels", e);
}
}
/**

View file

@ -21,6 +21,7 @@
package com.raytheon.edex.plugin.grib.decoderpostprocessors;
import com.raytheon.edex.plugin.grib.util.GribModelCache;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.grib.GribModel;
import com.raytheon.uf.common.dataplugin.grib.GribRecord;
import com.raytheon.uf.common.dataplugin.grib.exception.GribException;
@ -62,9 +63,13 @@ public class LapsPostProcessor implements IDecoderPostProcessor {
GribModel gribModel = record.getModelInfo();
boolean modelInfoModified = false;
if (levelName.equals(FHAG)) {
Level sfcLevel = LevelFactory.getInstance().getLevel(SFC, 0);
gribModel.setLevel(sfcLevel);
modelInfoModified = true;
try {
Level sfcLevel = LevelFactory.getInstance().getLevel(SFC, 0);
gribModel.setLevel(sfcLevel);
modelInfoModified = true;
} catch (CommunicationException e) {
throw new GribException("Error modifying LAPS records.", e);
}
}
if (gribModel.getParameterAbbreviation().equals(PMSL)) {

View file

@ -21,7 +21,8 @@ Export-Package: com.raytheon.edex.plugin.radar,
com.raytheon.edex.plugin.radar.level2,
com.raytheon.edex.uengine.tasks.radar
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.raytheon.uf.common.menus,
Import-Package: com.raytheon.uf.common.comm,
com.raytheon.uf.common.menus,
com.raytheon.uf.common.menus.xml,
com.raytheon.uf.common.site.ingest,
org.apache.commons.logging,

View file

@ -19,4 +19,5 @@ Export-Package: com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.level.request,
com.raytheon.uf.common.dataplugin.level.xml
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.hibernate.annotations
Import-Package: com.raytheon.uf.common.comm,
org.hibernate.annotations

View file

@ -38,8 +38,8 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.dataplugin.level.util.Constants;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
@ -71,7 +71,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
@XmlRootElement
@XmlType(namespace = "dataplugin-level")
public class Level extends PersistableDataObject implements ISerializableObject {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(Level.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(Level.class);
public static final double INVALID_VALUE = -999999;
@ -216,7 +217,7 @@ public class Level extends PersistableDataObject implements ISerializableObject
dirtyFlag = false;
}
public Level getUpperLevel() {
public Level getUpperLevel() throws CommunicationException {
Level rval = null;
if (isRangeLevel()) {
@ -278,7 +279,7 @@ public class Level extends PersistableDataObject implements ISerializableObject
return bestLevel;
}
public Level getLowerLevel() {
public Level getLowerLevel() throws CommunicationException {
Level rval = null;
if (isRangeLevel()) {

View file

@ -37,6 +37,7 @@ import javax.xml.bind.JAXB;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.request.GetLevelByIdRequest;
import com.raytheon.uf.common.dataplugin.level.request.GetLevelRequest;
import com.raytheon.uf.common.dataplugin.level.request.GetMasterLevelRequest;
@ -98,6 +99,10 @@ public class LevelFactory {
private ILevelRetrievalAdapter retrievalAdapter = null;
private boolean hasRequestedAllLevels = false;
private boolean hasRequestedAllMasterLevels = false;
private static final double INVALID_LEVEL = Level.getInvalidLevelValue();
public static LevelFactory getInstance() {
@ -119,43 +124,58 @@ public class LevelFactory {
}
loadLevelAliases();
LoadAllMasterLevels();
loadMasterLevelFiles();
loadAllLevels();
try {
loadAllMasterLevels();
} catch (CommunicationException e) {
; // This is non-fatal, master levels should still be retrieved
// individually
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
try {
loadAllLevels();
} catch (CommunicationException e) {
; // This is non-fatal, master levels should still be retrieved
// individually
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
public void checkMasterLevel(MasterLevel level) {
public void checkMasterLevel(MasterLevel level)
throws CommunicationException {
loadMasterLevel(level, true);
}
public MasterLevel getMasterLevel(String name) {
public MasterLevel getMasterLevel(String name)
throws CommunicationException {
MasterLevel request = new MasterLevel(name);
return loadMasterLevel(request, false);
}
public Level getLevel(long id) {
public Level getLevel(long id) throws CommunicationException {
return loadLevel(id);
}
public Level getLevel(String name) {
public Level getLevel(String name) throws CommunicationException {
return loadLevel(name);
}
public Level getLevel(String name, double levelOneValue) {
public Level getLevel(String name, double levelOneValue)
throws CommunicationException {
return getLevel(name, levelOneValue, INVALID_LEVEL, null);
}
public Level getLevel(String name, double levelOneValue, String unit) {
public Level getLevel(String name, double levelOneValue, String unit)
throws CommunicationException {
return getLevel(name, levelOneValue, INVALID_LEVEL, unit);
}
public Level getLevel(String name, double levelOneValue,
double levelTwoValue) {
double levelTwoValue) throws CommunicationException {
return getLevel(name, levelOneValue, levelTwoValue, null);
}
public Level getLevel(String name, double levelOneValue,
double levelTwoValue, String unit) {
double levelTwoValue, String unit) throws CommunicationException {
Level rval = null;
// lookup master level
@ -204,7 +224,8 @@ public class LevelFactory {
return rval;
}
private MasterLevel loadMasterLevel(MasterLevel level, boolean createFlag) {
private MasterLevel loadMasterLevel(MasterLevel level, boolean createFlag)
throws CommunicationException {
MasterLevel rval = null;
String levelName = level.getName();
@ -213,6 +234,9 @@ public class LevelFactory {
levelName = levelAliasMap.get(levelName);
}
if (!hasRequestedAllMasterLevels) {
loadAllMasterLevels();
}
if (masterLevelCache.containsKey(levelName)) {
rval = masterLevelCache.get(levelName);
} else if (retrievalAdapter != null) {
@ -243,7 +267,7 @@ public class LevelFactory {
return rval;
}
private Level loadLevel(Level level) {
private Level loadLevel(Level level) throws CommunicationException {
// limit precision to 3 places past the decimal
double levelone = ((int) (level.getLevelonevalue() * 1000)) / 1000.0;
double leveltwo = ((int) (level.getLeveltwovalue() * 1000)) / 1000.0;
@ -259,6 +283,9 @@ public class LevelFactory {
}
level.setLevelonevalue(levelone);
level.setLeveltwovalue(leveltwo);
if (!hasRequestedAllLevels) {
loadAllLevels();
}
// check if we have already loaded level
Level rval = levelCache.get(level);
@ -280,7 +307,10 @@ public class LevelFactory {
return rval;
}
private Level loadLevel(long id) {
private Level loadLevel(long id) throws CommunicationException {
if (!hasRequestedAllLevels) {
loadAllLevels();
}
// check if we have already loaded level
Level rval = levelCacheById.get(id);
@ -298,7 +328,10 @@ public class LevelFactory {
return rval;
}
private Level loadLevel(String id) {
private Level loadLevel(String id) throws CommunicationException {
if (!hasRequestedAllLevels) {
loadAllLevels();
}
// check if we have already loaded level
Level rval = levelCacheByIdAsString.get(id);
@ -386,7 +419,7 @@ public class LevelFactory {
}
}
private void loadAllLevels() {
private void loadAllLevels() throws CommunicationException {
if (retrievalAdapter != null) {
LevelContainer container = retrievalAdapter.getAllLevels();
if (container != null) {
@ -408,10 +441,11 @@ public class LevelFactory {
}
}
}
hasRequestedAllLevels = true;
}
}
private void LoadAllMasterLevels() {
private void loadAllMasterLevels() throws CommunicationException {
if (retrievalAdapter != null) {
MasterLevelContainer container = retrievalAdapter
.getAllMasterLevels();
@ -426,6 +460,8 @@ public class LevelFactory {
}
}
}
hasRequestedAllMasterLevels = true;
loadMasterLevelFiles();
}
}
@ -450,7 +486,7 @@ public class LevelFactory {
}
private void loadMasterLevelFile(File file) {
private void loadMasterLevelFile(File file) throws CommunicationException {
if (file == null || !file.exists()) {
return;
}

View file

@ -34,11 +34,15 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.apache.commons.lang.builder.ToStringBuilder;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.annotations.DataURI;
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
/**
* MasterLevel - once a field is set it cannot be changed.
@ -61,6 +65,9 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
@XmlRootElement
public class MasterLevel extends PersistableDataObject implements
ISerializableObject {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(MasterLevel.class);
private static final long serialVersionUID = 1L;
@Id
@ -151,7 +158,12 @@ public class MasterLevel extends PersistableDataObject implements
public Progression getProgression() {
if (processType) {
processTypeField();
try {
processTypeField();
} catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
return progression;
@ -216,7 +228,7 @@ public class MasterLevel extends PersistableDataObject implements
return rval;
}
private void processTypeField() {
private void processTypeField() throws CommunicationException {
if (type != null && type.trim().length() > 0) {
try {
setProgression(Progression.valueOf(type));

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.uf.common.dataplugin.level.request;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelContainer;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
@ -39,16 +40,21 @@ import com.raytheon.uf.common.dataplugin.level.MasterLevelContainer;
* @version 1.0
*/
public interface ILevelRetrievalAdapter {
public abstract Level getLevel(GetLevelRequest request);
public abstract Level getLevel(GetLevelRequest request)
throws CommunicationException;
public abstract Level getLevel(GetLevelByIdRequest request);
public abstract Level getLevel(GetLevelByIdRequest request)
throws CommunicationException;
public abstract MasterLevel getMasterLevel(GetMasterLevelRequest request);
public abstract MasterLevel getMasterLevel(GetMasterLevelRequest request)
throws CommunicationException;
public abstract LevelContainer getAllLevelsForMasterLevel(
GetAllLevelsForMasterLevelRequest request);
GetAllLevelsForMasterLevelRequest request)
throws CommunicationException;
public abstract LevelContainer getAllLevels();
public abstract LevelContainer getAllLevels() throws CommunicationException;
public abstract MasterLevelContainer getAllMasterLevels();
public abstract MasterLevelContainer getAllMasterLevels()
throws CommunicationException;
}

View file

@ -9,6 +9,7 @@ Bundle-ActivationPolicy: lazy
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
Eclipse-BuddyPolicy: registered, ext, global
Import-Package: com.raytheon.edex.scriptfactory,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.serialization.annotations,

View file

@ -21,6 +21,7 @@ package com.raytheon.uf.common.derivparam.tree;
import javax.persistence.Transient;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
@ -67,7 +68,11 @@ public class LevelNode extends AbstractNode<LevelNode> {
*/
public Level getLevel() {
if (value != null && level == null) {
level = LevelFactory.getInstance().getLevel(value);
try {
level = LevelFactory.getInstance().getLevel(value);
} catch (CommunicationException e) {
e.printStackTrace();
}
}
return level;
}

View file

@ -9,6 +9,7 @@ Require-Bundle: com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.edex.plugin.level
Import-Package: com.raytheon.edex.db.dao,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.edex.database.plugin,
org.apache.commons.logging,

View file

@ -18,3 +18,4 @@ Require-Bundle: com.raytheon.edex.common,
Export-Package: com.raytheon.uf.edex.plugin.level.adapter,
com.raytheon.uf.edex.plugin.level.dao
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.raytheon.uf.common.comm

View file

@ -10,6 +10,7 @@ Import-Package: com.raytheon.edex.db.dao,
com.raytheon.edex.exception,
com.raytheon.edex.plugin,
com.raytheon.edex.uengine.tasks.query,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.persist,

View file

@ -26,7 +26,6 @@ import java.util.Map.Entry;
import com.raytheon.edex.uengine.tasks.query.CatalogQuery;
import com.raytheon.edex.uengine.tasks.query.MetadataCatalogQuery;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.derivparam.tree.DataTree;
import com.raytheon.uf.common.pointdata.GetPointDataTreeRequest;
@ -52,16 +51,14 @@ import com.raytheon.uf.common.serialization.comm.IRequestHandler;
public class GetPointDataTreeHandler implements
IRequestHandler<GetPointDataTreeRequest> {
public static final Level STATION = LevelFactory.getInstance().getLevel(
LevelFactory.UNKNOWN_LEVEL, 0.0);
public static final String PLUGIN_NAME = "pluginName";
@Override
public DataTree handleRequest(GetPointDataTreeRequest request)
throws Exception {
DataTree tree = new DataTree();
String stationId = Long.toString(STATION.getId());
String stationId = Long.toString(LevelFactory.getInstance()
.getLevel(LevelFactory.UNKNOWN_LEVEL, 0.0).getId());
for (Entry<String, String> entry : request.getPluginTypeKeyMap()
.entrySet()) {
String[] types = getAvailableTypes(entry.getKey(), entry.getValue());

View file

@ -19,8 +19,9 @@ Require-Bundle: javax.measure,
com.raytheon.uf.common.serialization.comm,
com.raytheon.uf.edex.python.decoder;bundle-version="1.11.26",
gov.noaa.nws.ncep.common.dataplugin.ncgrib;bundle-version="1.0.0",
ucar.nc2;bundle-version="1.0.0"
Import-Package: com.raytheon.uf.common.dataplugin.level,
ucar.nc2
Import-Package: com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.derivparam.tree,
com.raytheon.uf.common.status,
gov.noaa.nws.ncep.common.dataplugin.ncgrib,

View file

@ -20,6 +20,29 @@
package gov.noaa.nws.ncep.edex.plugin.ncgrib;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribLevel;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribParameter;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LambertConformalNcgridCoverage;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LatLonNcgridCoverage;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.MercatorNcgridCoverage;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.PolarStereoNcgridCoverage;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel;
import gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcgribDao;
import gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial.NcgribSpatialCache;
import gov.noaa.nws.ncep.edex.plugin.ncgrib.util.NcgribModelCache;
import gov.noaa.nws.ncep.edex.util.grib2vars.Grib2VarsTableLookup;
import gov.noaa.nws.ncep.edex.util.grib2vcrd.Grib2Vcrd;
import gov.noaa.nws.ncep.edex.util.grib2vcrd.Grib2VcrdTableLookup;
import gov.noaa.nws.ncep.edex.util.ncgrib.Ncgrib1TableMap;
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribModelLookup;
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribParamTranslator;
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribTableLookup;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@ -27,6 +50,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import ucar.grib.GribNumbers;
@ -42,35 +66,20 @@ import ucar.grib.grib1.GribPDSParamTable;
import ucar.grid.GridParameter;
import ucar.unidata.io.RandomAccessFile;
import gov.noaa.nws.ncep.edex.plugin.ncgrib.dao.NcgribDao;
import gov.noaa.nws.ncep.edex.plugin.ncgrib.spatial.NcgribSpatialCache;
import gov.noaa.nws.ncep.edex.plugin.ncgrib.util.NcgribModelCache;
import gov.noaa.nws.ncep.edex.util.ncgrib.Ncgrib1TableMap;
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribModelLookup;
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribParamTranslator;
import gov.noaa.nws.ncep.edex.util.ncgrib.NcgribTableLookup;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribLevel;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribModel;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribParameter;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.NcgribRecord;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.exception.GribException;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.NcgridCoverage;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LambertConformalNcgridCoverage;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.LatLonNcgridCoverage;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.MercatorNcgridCoverage;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.spatial.projections.PolarStereoNcgridCoverage;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
import gov.noaa.nws.ncep.common.dataplugin.ncgrib.util.NcgridModel;
import gov.noaa.nws.ncep.edex.util.grib2vcrd.Grib2VcrdTableLookup;
import gov.noaa.nws.ncep.edex.util.grib2vars.Grib2VarsTableLookup;
import gov.noaa.nws.ncep.edex.util.grib2vcrd.Grib2Vcrd;
import com.raytheon.edex.util.Util;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.edex.plugin.AbstractDecoder;
import com.raytheon.edex.util.Util;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataquery.db.QueryResult;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.edex.database.DataAccessLayerException;
@ -86,6 +95,8 @@ import com.raytheon.uf.edex.database.plugin.PluginFactory;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 3/11/10 4758 bphillip Initial Creation
* 9/08/10 X. Guo Add new column
* 11/02/11 X. Guo Check octet size for isEnsmble()
*
* </pre>
*
@ -93,6 +104,8 @@ import com.raytheon.uf.edex.database.plugin.PluginFactory;
* @version 1
*/
public class Ncgrib1Decoder extends AbstractDecoder {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(Ncgrib1Decoder.class);
/** Missing value string */
private static final String MISSING = "Missing";
@ -101,15 +114,41 @@ public class Ncgrib1Decoder extends AbstractDecoder {
private static final Set<Integer> AVG_ACCUM_LIST = new HashSet<Integer>();
private String traceId = "";
private NcgribDao dao;
private String fileName="";
private NcgribDao dao;
private String fileName = "";
private boolean addCol = false;
private static final int[] fourtyOne = new int[] { 1, 1, 2, 3, 2, 3, 2, 3,
2, 3, 2, 3 };
private static final int[] fourtyTwo = new int[] { 1, 2, 1, 1, 2, 2, 3, 3,
4, 4, 5, 5 };
private static final int[] perturbation = new int[] { 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12 };
static {
AVG_ACCUM_LIST.add(3);
AVG_ACCUM_LIST.add(4);
AVG_ACCUM_LIST.add(6);
AVG_ACCUM_LIST.add(7);
IPathManager pm = PathManagerFactory.getPathManager();
String ucarUserFile = pm.getFile(
pm.getContext(LocalizationType.EDEX_STATIC,
LocalizationLevel.BASE), "/ncgrib/ucar/userTables.lst")
.getPath();
try {
GribPDSParamTable.addParameterUserLookup(ucarUserFile);
} catch (IOException e) {
statusHandler
.handle(Priority.PROBLEM,
"Error reading user parameter tables for ucar grib decoder",
e);
}
}
/**
@ -120,13 +159,13 @@ public class Ncgrib1Decoder extends AbstractDecoder {
}
public NcgribDao getDao() {
return dao;
}
return dao;
}
public void setDao(NcgribDao dao) {
this.dao = dao;
}
public void setDao(NcgribDao dao) {
this.dao = dao;
}
/**
* Decodes the grib file provided.
*
@ -140,8 +179,8 @@ public class Ncgrib1Decoder extends AbstractDecoder {
File gribFile = new File(gribFileName);
fileName = gribFileName;
RandomAccessFile raf = null;
//System.out.println (" grib file name =" + gribFileName);
// System.out.println (" grib file name =" + gribFileName);
try {
try {
@ -160,11 +199,16 @@ public class Ncgrib1Decoder extends AbstractDecoder {
+ gribFile + "]");
}
ArrayList<Grib1Record> records = g1i.getRecords();
NcgribRecord[] gribRecords = new NcgribRecord[records.size()];
// NcgribRecord[] gribRecords = new NcgribRecord[records.size()];
List<NcgribRecord> gribRecords = new ArrayList<NcgribRecord>();
for (int i = 0; i < records.size(); i++) {
gribRecords[i] = decodeRecord((Grib1Record) records.get(i), raf);
NcgribRecord rec = decodeRecord((Grib1Record) records.get(i),
raf);
if (rec != null) {
gribRecords.add(rec);
}
}
return gribRecords;
return gribRecords.toArray(new NcgribRecord[] {});
} finally {
if (raf != null) {
try {
@ -192,7 +236,7 @@ public class Ncgrib1Decoder extends AbstractDecoder {
private NcgribRecord decodeRecord(Grib1Record rec, RandomAccessFile raf)
throws GribException {
int discipline=255,category=255,pid=255;
int discipline = 255, category = 255, pid = 255;
NcgribRecord retVal = new NcgribRecord();
// Extract the sections from the grib record
@ -210,20 +254,23 @@ public class Ncgrib1Decoder extends AbstractDecoder {
// Some centers use other center's parameter tables so we need to check
// for that
int[] tableValue = Ncgrib1TableMap.getInstance().getTableAlias(centerid,
subcenterid, pdsVars.getParameterTableVersion());
// System.out.println ("==centerid:" + centerid + " subcenterid:" +
// subcenterid + " pdsVars.getTableVersion():" +
// pdsVars.getTableVersion());
int[] tableValue = Ncgrib1TableMap.getInstance().getTableAlias(
centerid, subcenterid, pdsVars.getParameterTableVersion());
int centerAlias = tableValue[0];
int subcenterAlias = tableValue[1];
int tableAlias = tableValue[2];
int vcrdid = pdsVars.getLevelType1();
/*
* Decodes the parameter information from the record. An attempt is
* first made to map the gribimport gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid;
1 parameter to the equivalent grib 2
* parameter. If this cannot be successfully executed, the grib 1
* parameter will be used from the parameter tables contained in the
* unidata decoder.
* first made to map the gribimport
* gov.noaa.nws.ncep.common.dataplugin.ncgrib.subgrid.SubNcgrid; 1
* parameter to the equivalent grib 2 parameter. If this cannot be
* successfully executed, the grib 1 parameter will be used from the
* parameter tables contained in the unidata decoder.
*/
NcgribParameter parameter = NcgribTableLookup.getInstance()
.getNcgrib2Parameter(centerAlias, subcenterAlias, tableAlias,
@ -231,19 +278,19 @@ public class Ncgrib1Decoder extends AbstractDecoder {
if (parameter == null || parameter.getName().equals(MISSING)) {
try {
logger
.warn("Unable to map Grib 1 parameter to equivalent Grib 2 parameter for center ["
+ centerid
+ "] subcenter ["
+ subcenterid
+ "] table number ["
+ pdsVars.getParameterTableVersion()
+ "] parameter number ["
+ pdsVars.getParameterNumber()
+ "] Using grib 1 parameter mapping");
logger.warn("Unable to map Grib 1 parameter to equivalent Grib 2 parameter for center ["
+ centerid
+ "] subcenter ["
+ subcenterid
+ "] table number ["
+ pdsVars.getParameterTableVersion()
+ "] parameter number ["
+ pdsVars.getParameterNumber()
+ "] Using grib 1 parameter mapping");
GridParameter param = GribPDSParamTable.getParameterTable(
centerid, subcenterid, pdsVars.getParameterTableVersion())
.getParameter(pdsVars.getParameterNumber());
centerid, subcenterid,
pdsVars.getParameterTableVersion()).getParameter(
pdsVars.getParameterNumber());
parameterName = param.getDescription();
parameterAbbreviation = param.getName();
parameterUnit = param.getUnit();
@ -277,10 +324,24 @@ public class Ncgrib1Decoder extends AbstractDecoder {
model.setParameterName(parameterName);
model.setParameterAbbreviation(parameterAbbreviation);
model.setParameterUnit(parameterUnit);
if (pdsVars.isEnsemble()) {
// unidata does not handle isEnsemble call when
// octet size is less than 40.
if (pdsVars.getLength() > 40 && pdsVars.isEnsemble()) {
model.setNumForecasts(pdsVars.getNumberForecasts());
model.setTypeEnsemble(pdsVars.getType());
model.setPerturbationNumber(pdsVars.getPerturbationNumber());
// rcg: added code to get perturbation
int pos41 = pdsVars.getOctet(42);
int pos42 = pdsVars.getOctet(43);
int pert = pdsVars.getID();
for (int i = 0; i < perturbation.length; i++) {
if (pos41 == fourtyOne[i] && pos42 == fourtyTwo[i]) {
pert = perturbation[i];
break;
}
}
model.setPerturbationNumber(pert);
// model.setPerturbationNumber(pdsVars.getPerturbation());
} else {
model.setNumForecasts(null);
model.setTypeEnsemble(null);
@ -291,11 +352,9 @@ public class Ncgrib1Decoder extends AbstractDecoder {
createModelName(model);
// Get the level information
float[] levelMetadata = this.convertGrib1LevelInfo(pdsVars
.getLevelType1(), (float) pdsVars
.getLevelValue1(), pdsVars
.getLevelType2(), (float) pdsVars
.getLevelValue2());
float[] levelMetadata = this.convertGrib1LevelInfo(
pdsVars.getLevelType1(), (float) pdsVars.getLevelValue1(),
pdsVars.getLevelType2(), (float) pdsVars.getLevelValue2());
getLevelInfo(model, centerid, subcenterid, levelMetadata[0],
levelMetadata[1], levelMetadata[2], levelMetadata[3],
levelMetadata[4], levelMetadata[5]);
@ -303,11 +362,13 @@ public class Ncgrib1Decoder extends AbstractDecoder {
// Construct the DataTime
GregorianCalendar refTime = new GregorianCalendar();
refTime.setTimeInMillis(pdsVars.getReferenceTime());
int forecastTime = convertToSeconds(pdsVars.getForecastTime(), pdsVars
.getTimeUnit());
DataTime dataTime = constructDataTime(refTime, forecastTime,
getTimeInformation(refTime, pdsVars.getTimeRangeIndicator(), pdsVars
.getP1(), pdsVars.getP2()), model);
int forecastTime = convertToSeconds(pdsVars.getForecastTime(),
pdsVars.getTimeUnit());
DataTime dataTime = constructDataTime(
refTime,
forecastTime,
getTimeInformation(refTime, pdsVars.getTimeRangeIndicator(),
pdsVars.getP1(), pdsVars.getP2()), model);
/*
* Extract the data values from the file. The AVG_ACCUM_LIST is checked
@ -316,6 +377,7 @@ public class Ncgrib1Decoder extends AbstractDecoder {
*/
Grib1Data gd = new Grib1Data(raf);
float[] data = null;
try {
boolean bmsPresent = pdsVars.bmsExists();
int scanMode = gdsVars.getScanMode();
@ -327,12 +389,17 @@ public class Ncgrib1Decoder extends AbstractDecoder {
data = new float[gdsVars.getNx() * gdsVars.getNy()];
} else {
data = gd.getData(rec.getDataOffset() - gdsVars.getLength(),
rec.getDataOffset(), pdsVars.getDecimalScale(), pdsVars
.bmsExists());
rec.getDataOffset(), pdsVars.getDecimalScale(),
pdsVars.bmsExists());
}
correctForScanMode(data, gdsVars.getNx(), gdsVars.getNy(),
bmsPresent, scanMode);
retVal.setMessageData(data);
if (getAddCol()) {
float[] dataArry = this.addOneColumnDataTo1D(data,
gdsVars.getNx(), gdsVars.getNy());
retVal.setMessageData(dataArry);
} else
retVal.setMessageData(data);
} catch (IOException e) {
throw new GribException("Error getting data from grib file", e);
}
@ -345,19 +412,29 @@ public class Ncgrib1Decoder extends AbstractDecoder {
if (subCoverage != null) {
SubNcgrid subGrid = NcgribSpatialCache.getInstance().getSubGrid(
modelName);
int nx = gridCoverage.getNx();
if (getAddCol()) {
nx = nx - 1;
}
// resize the data array
float[][] dataArray = this.resizeDataTo2D(data, gridCoverage
.getNx(), gridCoverage.getNy());
dataArray = this.subGrid(dataArray, subGrid.getStartX(), subGrid
.getStartY(), subGrid.getNX(), subGrid.getNY());
data = this.resizeDataTo1D(dataArray, subGrid.getNY(), subGrid
.getNX());
retVal.setMessageData(data);
float[][] dataArray = this.resizeDataTo2D(data, nx,
gridCoverage.getNy());
dataArray = this.subGrid(dataArray, subGrid.getStartX(),
subGrid.getStartY(), subGrid.getNX(), subGrid.getNY());
data = this.resizeDataTo1D(dataArray, subGrid.getNY(),
subGrid.getNX());
if (getAddCol()) {
float[] dataArray1 = this.addOneColumnDataTo1D(data,
subGrid.getNX(), subGrid.getNY());
retVal.setMessageData(dataArray1);
} else
retVal.setMessageData(data);
model.setLocation(subCoverage);
}
setAddCol(false);
String newAbbr = NcgribParamTranslator.getInstance().translateParameter(
1, model, dataTime);
String newAbbr = NcgribParamTranslator.getInstance()
.translateParameter(1, model, dataTime);
if (newAbbr == null) {
if (!model.getParameterName().equals(MISSING)
@ -371,6 +448,9 @@ public class Ncgrib1Decoder extends AbstractDecoder {
}
if (!model.getParameterName().equals(MISSING)) {
if (modelName.toUpperCase().equals("GFS")) {
model.generateId(fileName);
}
try {
model = NcgribModelCache.getInstance().getModel(model);
} catch (DataAccessLayerException e) {
@ -385,41 +465,43 @@ public class Ncgrib1Decoder extends AbstractDecoder {
retVal.setDataTime(dataTime);
retVal.setResCompFlags(gdsVars.getResolution());
retVal.setModelName(model.getModelName());
String []fileTokens = fileName.split("/");
String flName="";
if ( fileTokens.length > 0 ) {
flName = fileTokens[fileTokens.length-1];
String[] fileTokens = fileName.split("/");
String flName = "";
if (fileTokens.length > 0) {
flName = fileTokens[fileTokens.length - 1];
}
retVal.setFileName(flName);
String eventName=flName;
String eventName = flName;
int index = flName.indexOf(".");
if ( index > 0) {
eventName = flName.substring(0, index);
if (index > 0) {
eventName = flName.substring(0, index);
}
retVal.setEventName(eventName);
retVal.setDiscipline(discipline);
retVal.setCategory(category);
retVal.setParameterId(pid);
retVal.setProcessedDataType(pdsVars.getGenProcessId());
retVal.setGlevel1((int)model.getLevel().getLevelonevalue());
retVal.setGlevel2((int)model.getLevel().getLeveltwovalue());
retVal.setGlevel1((int) model.getLevel().getLevelonevalue());
retVal.setGlevel2((int) model.getLevel().getLeveltwovalue());
retVal.setVcrdId1(vcrdid);
retVal.setVcrdId2(vcrdid);
retVal.setGridVersion(1);
String vcord = "NONE";
String scale = "";
Grib2Vcrd grib2Vcrd = Grib2VcrdTableLookup.getGrib2VcrdByGrib1VcrdId (vcrdid);
if ( grib2Vcrd != null ) {
vcord = grib2Vcrd.getGnam();
scale = grib2Vcrd.getScale();
Grib2Vcrd grib2Vcrd = Grib2VcrdTableLookup
.getGrib2VcrdByGrib1VcrdId(vcrdid);
if (grib2Vcrd != null) {
vcord = grib2Vcrd.getGnam();
scale = grib2Vcrd.getScale();
}
retVal.setVcord(vcord);
retVal.setScale(scale);
String parm = Grib2VarsTableLookup.getVarGnam4Grib1 (discipline,category,pid);
retVal.setScale(scale);
String parm = Grib2VarsTableLookup.getVarGnam4Grib1(discipline,
category, pid);
retVal.setParm(parm);
// Special case handling for ffg grids
try {
if (model.getCenterid() == 9) {
@ -474,6 +556,32 @@ public class Ncgrib1Decoder extends AbstractDecoder {
return newGrid;
}
/**
* Resizes a 1-D data array into a 2-D array based on the provided row and
* column count and add one column for each row, then convert to 1-D array.
*
* @param data
* The 1-D array of data
* @param columnCount
* The number of columns to map the data to
* @param rowCount
* The number of rows to map the data to
* @return The 1-D array of data
*/
private float[] addOneColumnDataTo1D(float[] data, int columnCount,
int rowCount) {
float[][] newGrid = new float[rowCount][columnCount + 1];
for (int row = 0; row < rowCount; row++) {
for (int column = 0; column < columnCount; column++) {
newGrid[row][column] = data[row * columnCount + column];
}
newGrid[row][columnCount] = newGrid[row][0];
}
return resizeDataTo1D(newGrid, rowCount, columnCount + 1);
}
/**
* Resizes a 2-D array of data to a 1-D array
*
@ -620,15 +728,26 @@ public class Ncgrib1Decoder extends AbstractDecoder {
NcgridCoverage coverage = null;
int gridType = gdsVars.getGdtn();
int nx;
float Lon1, Lon2, lo2;
switch (gridType) {
case 0:
LatLonNcgridCoverage latLonCoverage = new LatLonNcgridCoverage();
latLonCoverage.setNx(gdsVars.getNx());
nx = gdsVars.getNx();
lo2 = gdsVars.getLo2() + 360.0F;
Lon1 = gdsVars.getLo1() + lo2;
Lon2 = lo2 + gdsVars.getDx();
if (Lon1 == 360.0 || Lon2 == 360.0) {
nx = nx + 1;
lo2 = Lon2;
setAddCol(true);
}
latLonCoverage.setNx(nx);
latLonCoverage.setNy(gdsVars.getNy());
latLonCoverage.setLa1(gdsVars.getLa1());
latLonCoverage.setLo1(gdsVars.getLo1());
latLonCoverage.setLa2(gdsVars.getLa2());
latLonCoverage.setLo2(gdsVars.getLo2());
latLonCoverage.setLo2(lo2);
if (gdsVars.getGridUnits().equals("degrees")) {
latLonCoverage.setSpacingUnit("degree");
latLonCoverage.setDx(gdsVars.getDx());
@ -648,12 +767,23 @@ public class Ncgrib1Decoder extends AbstractDecoder {
MercatorNcgridCoverage mercator = new MercatorNcgridCoverage();
mercator.setMajorAxis(gdsVars.getMajorAxis() * 1000);
mercator.setMinorAxis(gdsVars.getMinorAxis() * 1000);
mercator.setNx(gdsVars.getNx());
nx = gdsVars.getNx();
lo2 = gdsVars.getLo2() + 360.0F;
Lon1 = gdsVars.getLo1() + lo2;
Lon2 = lo2 + gdsVars.getDx();
if (Lon1 == 360.0 || Lon2 == 360.0) {
nx = nx + 1;
lo2 = Lon2;
setAddCol(true);
} else {
lo2 = correctLon(lo2);
}
mercator.setNx(nx);
mercator.setNy(gdsVars.getNy());
mercator.setLa1(correctLat(gdsVars.getLa1()));
mercator.setLo1(correctLon(gdsVars.getLo1()));
mercator.setLa2(correctLat(gdsVars.getLa2()));
mercator.setLo2(correctLon(gdsVars.getLo2()));
mercator.setLo2(lo2);
mercator.setLatin(correctLat(gdsVars.getLatin1()));
if (gdsVars.getGridUnits().equals("degrees")) {
mercator.setSpacingUnit("degree");
@ -732,7 +862,8 @@ public class Ncgrib1Decoder extends AbstractDecoder {
private NcgridCoverage getGridFromCache(NcgridCoverage coverage)
throws GribException {
NcgridCoverage grid = NcgribSpatialCache.getInstance().getGrid(coverage);
NcgridCoverage grid = NcgribSpatialCache.getInstance()
.getGrid(coverage);
if (grid == null) {
NcgribSpatialCache.getInstance().putGrid(coverage, true);
@ -753,8 +884,8 @@ public class Ncgrib1Decoder extends AbstractDecoder {
String gridid = model.getGridid();
int process = model.getGenprocess();
NcgridModel gridModel = NcgribModelLookup.getInstance().getModel(center,
subcenter, gridid, process);
NcgridModel gridModel = NcgribModelLookup.getInstance().getModel(
center, subcenter, gridid, process);
String name = null;
if (gridModel == null) {
name = "UnknownModel:" + String.valueOf(center) + ":"
@ -789,7 +920,8 @@ public class Ncgrib1Decoder extends AbstractDecoder {
if (endTime == null) {
dataTime = new DataTime(refTime, forecastTime);
} else {
TimeRange timeRange = new TimeRange(startTime.getTimeInMillis(),endTime.getTimeInMillis());
TimeRange timeRange = new TimeRange(startTime.getTimeInMillis(),
endTime.getTimeInMillis());
dataTime = new DataTime(refTime, forecastTime, timeRange);
}
return dataTime;
@ -1093,8 +1225,16 @@ public class Ncgrib1Decoder extends AbstractDecoder {
* -1));
}
}
Level level = LevelFactory.getInstance().getLevel(levelName,
levelOneValue, levelTwoValue, levelUnit);
Level level = null;
try {
level = LevelFactory.getInstance().getLevel(levelName,
levelOneValue, levelTwoValue, levelUnit);
} catch (CommunicationException e) {
// TODO njensen: didn't know how to merge, needs to be handled
// better
// TODO Auto-generated catch block. Please revise as appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
model.setLevel(level);
}
@ -1144,5 +1284,12 @@ public class Ncgrib1Decoder extends AbstractDecoder {
}
return lat;
}
private void setAddCol(boolean addCol) {
this.addCol = addCol;
}
private boolean getAddCol() {
return this.addCol;
}
}