Issue #2725 deriv param to common stage 1

* Removing viz dependencys from derivparam
** Move LevelUtilities to common
** Use spring instead of eclipse plugin extentions
   to configure derived parameter function types
** Use RequestRouter instead of ThriftClient so
   we can use IServerRequest objects in both CAVE
   and EDEX

The next stage will be to clean up exceptions in
derived parameters to stop using VizException and
VizCommunicationException.


Former-commit-id: bd50a38d87 [formerly 604ae156f8b235e2e1736863b419547289403240]
Former-commit-id: 80ad25754b
This commit is contained in:
Everett Kladstrup 2014-01-21 13:59:05 -06:00
parent b651ada4b3
commit 415ccd78fb
17 changed files with 205 additions and 166 deletions

View file

@ -39,6 +39,7 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping;
import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory;
import com.raytheon.uf.common.dataplugin.level.util.LevelUtilities;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
import com.raytheon.uf.common.geospatial.MapUtil; import com.raytheon.uf.common.geospatial.MapUtil;
@ -52,7 +53,6 @@ import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer; import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelUtilities;
import com.raytheon.uf.viz.core.rsc.DisplayType; import com.raytheon.uf.viz.core.rsc.DisplayType;
import com.raytheon.uf.viz.objectiveanalysis.rsc.OAGridTransformer; import com.raytheon.uf.viz.objectiveanalysis.rsc.OAGridTransformer;
import com.raytheon.uf.viz.xy.timeseries.adapter.AbstractTimeSeriesAdapter; import com.raytheon.uf.viz.xy.timeseries.adapter.AbstractTimeSeriesAdapter;

View file

@ -3,4 +3,4 @@ output.. = bin/
bin.includes = META-INF/,\ bin.includes = META-INF/,\
.,\ .,\
localization/,\ localization/,\
plugin.xml res/

View file

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This_software_was_developed_and_/_or_modified_by_Raytheon_Company,
pursuant_to_Contract_DG133W-05-CQ-1067_with_the_US_Government.
U.S._EXPORT_CONTROLLED_TECHNICAL_DATA
This_software_product_contains_export-restricted_data_whose
export/transfer/disclosure_is_restricted_by_U.S._law._Dissemination
to_non-U.S._persons_whether_in_the_United_States_or_abroad_requires
an_export_license_or_other_authorization.
Contractor_Name:________Raytheon_Company
Contractor_Address:_____6825_Pine_Street,_Suite_340
________________________Mail_Stop_B8
________________________Omaha,_NE_68106
________________________402.291.0100
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information.
-->
<?eclipse version="3.2"?>
<plugin>
<extension
point="com.raytheon.uf.viz.derivparam.functionType">
<functionType
adapter="com.raytheon.uf.viz.derivparam.python.DerivParamPythonFunctionAdapter"
extension="py"
name="Python">
</functionType>
</extension>
</plugin>

View file

@ -0,0 +1,14 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="pythonDerParFunctionAdapter"
class="com.raytheon.uf.viz.derivparam.python.DerivParamPythonFunctionAdapter" />
<bean id="registeredPythonDerParFunctionAdapter"
class="com.raytheon.uf.viz.derivparam.library.DerivedParameterGenerator"
factory-method="addFunctionAdapter">
<constructor-arg ref="pythonDerParFunctionAdapter" />
</bean>
</beans>

View file

@ -49,6 +49,8 @@ import com.raytheon.uf.viz.derivparam.library.DerivedParameterGenerator;
* Dec 16, 2010 mschenke Initial creation * Dec 16, 2010 mschenke Initial creation
* Jun 04, 2013 2041 bsteffen Switch derived parameters to use * Jun 04, 2013 2041 bsteffen Switch derived parameters to use
* concurrent python for threading. * concurrent python for threading.
* Jan 30, 2014 #2725 ekladstrup Add name and extention get methods
* after removing RCP extention point
* *
* </pre> * </pre>
* *
@ -158,4 +160,25 @@ public class DerivParamPythonFunctionAdapter implements
} }
} }
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.derivparam.IDerivParamFunctionAdapter#getName()
*/
@Override
public String getName() {
return "Python";
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.derivparam.IDerivParamFunctionAdapter#getExtension()
*/
@Override
public String getExtension() {
return "py";
}
} }

View file

@ -37,7 +37,8 @@ import com.raytheon.uf.viz.derivparam.DerivParamFunctionType.FunctionArgument;
* Dec 16, 2010 mschenke Initial creation * Dec 16, 2010 mschenke Initial creation
* Jun 04, 2013 2041 bsteffen Switch derived parameters to use * Jun 04, 2013 2041 bsteffen Switch derived parameters to use
* concurrent python for threading. * concurrent python for threading.
* * Jan 30, 2014 #2725 ekladstrup Add name and extention get methods
* after removing RCP extention point
* </pre> * </pre>
* *
* @author mschenke * @author mschenke
@ -86,4 +87,18 @@ public interface IDerivParamFunctionAdapter {
* Stop the adapter and any child threads. * Stop the adapter and any child threads.
*/ */
public void shutdown(); public void shutdown();
/**
* Return the name of the function type
*
* @return
*/
public String getName();
/**
* Return the file extension of the function type
*
* @return
*/
public String getExtension();
} }

View file

@ -37,11 +37,11 @@ import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponseSet; import com.raytheon.uf.common.dataquery.responses.DbQueryResponseSet;
import com.raytheon.uf.common.datastorage.Request; import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.datastructure.DefaultDataCubeAdapter; import com.raytheon.uf.viz.core.datastructure.DefaultDataCubeAdapter;
import com.raytheon.uf.viz.core.datastructure.VizDataCubeException; import com.raytheon.uf.viz.core.datastructure.VizDataCubeException;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.uf.viz.derivparam.inv.AvailabilityContainer; import com.raytheon.uf.viz.derivparam.inv.AvailabilityContainer;
import com.raytheon.uf.viz.derivparam.inv.MetadataContainer; import com.raytheon.uf.viz.derivparam.inv.MetadataContainer;
import com.raytheon.uf.viz.derivparam.inv.TimeAndSpace; import com.raytheon.uf.viz.derivparam.inv.TimeAndSpace;
@ -60,6 +60,7 @@ import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableNode;
* Jan 30, 2012 mschenke Initial creation * Jan 30, 2012 mschenke Initial creation
* Feb 25, 2013 1659 bsteffen Stop derived parameters from sending * Feb 25, 2013 1659 bsteffen Stop derived parameters from sending
* empty requests for cached times * empty requests for cached times
* Jan 30, 2014 #2725 ekladstrup Remove usage of ThriftClient
* *
* </pre> * </pre>
* *
@ -125,8 +126,13 @@ public abstract class AbstractDataCubeAdapter extends DefaultDataCubeAdapter {
if (!fullList.isEmpty()) { if (!fullList.isEmpty()) {
DbQueryRequestSet requestSet = new DbQueryRequestSet(); DbQueryRequestSet requestSet = new DbQueryRequestSet();
requestSet.setQueries(fullList.toArray(new DbQueryRequest[0])); requestSet.setQueries(fullList.toArray(new DbQueryRequest[0]));
DbQueryResponseSet responseSet = (DbQueryResponseSet) ThriftClient DbQueryResponseSet responseSet;
.sendRequest(requestSet); try {
responseSet = (DbQueryResponseSet) RequestRouter
.route(requestSet);
} catch (Exception e) {
throw new VizException(e);
}
responses = responseSet.getResults(); responses = responseSet.getResults();
} }
int responseIndex = 0; int responseIndex = 0;

View file

@ -36,6 +36,7 @@ import java.util.concurrent.BlockingQueue;
import com.raytheon.uf.common.comm.CommunicationException; import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory; import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.level.util.LevelUtilities;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.derivparam.tree.AbstractNode; import com.raytheon.uf.common.derivparam.tree.AbstractNode;
import com.raytheon.uf.common.derivparam.tree.DataTree; import com.raytheon.uf.common.derivparam.tree.DataTree;
@ -48,7 +49,6 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.exception.VizCommunicationException; import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelUtilities;
import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData; import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData;
import com.raytheon.uf.viz.derivparam.data.FloatRequestableData; import com.raytheon.uf.viz.derivparam.data.FloatRequestableData;
import com.raytheon.uf.viz.derivparam.library.DerivParamConstantField; import com.raytheon.uf.viz.derivparam.library.DerivParamConstantField;
@ -84,6 +84,8 @@ import com.raytheon.uf.viz.derivparam.tree.UnionLevelNode;
* ------------- -------- ----------- -------------------------- * ------------- -------- ----------- --------------------------
* Mar 17, 2010 bsteffen Initial creation * Mar 17, 2010 bsteffen Initial creation
* Jan 23, 2014 2711 bsteffen Get all levels from LevelFactory. * Jan 23, 2014 2711 bsteffen Get all levels from LevelFactory.
* Jan 30, 2014 #2725 ekladstrup handle different exceptions for moving
* derived parameters to common
* *
* </pre> * </pre>
* *
@ -933,10 +935,14 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
endCount += 1; endCount += 1;
nodes.add(target); nodes.add(target);
} }
SortedSet<Level> levels = LevelUtilities SortedSet<Level> levels = null;
.getOrderedSetOfStandardLevels( try {
level.getMasterLevel().getName()).subSet( levels = LevelUtilities.getOrderedSetOfStandardLevels(
lowerLevel, false, upperLevel, false); level.getMasterLevel().getName()).subSet(
lowerLevel, false, upperLevel, false);
} catch ( CommunicationException e ) {
throw new VizCommunicationException(e);
}
for (Level fieldLevel : levels) { for (Level fieldLevel : levels) {
target = resolveNode(sourceNode, param, fieldLevel, stack, target = resolveNode(sourceNode, param, fieldLevel, stack,
nodata); nodata);
@ -1070,15 +1076,19 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
} }
} else { } else {
SortedSet<Level> levels = null; SortedSet<Level> levels = null;
if (type == LevelType.Upper) { try {
levels = LevelUtilities.getOrderedSetOfStandardLevels( if (type == LevelType.Upper) {
level.getMasterLevel().getName()).tailSet(level, levels = LevelUtilities.getOrderedSetOfStandardLevels(
false); level.getMasterLevel().getName()).tailSet(
} else { level, false);
levels = LevelUtilities } else {
.getOrderedSetOfStandardLevels( levels = LevelUtilities
level.getMasterLevel().getName()) .getOrderedSetOfStandardLevels(
.headSet(level, false).descendingSet(); level.getMasterLevel().getName())
.headSet(level, false).descendingSet();
}
} catch ( CommunicationException e ) {
throw new VizCommunicationException(e);
} }
for (Level l : levels) { for (Level l : levels) {
target = resolveNode(fieldSourceNode, fieldParamAbbrev, l, target = resolveNode(fieldSourceNode, fieldParamAbbrev, l,

View file

@ -34,8 +34,8 @@ import com.raytheon.uf.common.dataquery.requests.DbQueryRequestSet;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse; import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponseSet; import com.raytheon.uf.common.dataquery.responses.DbQueryResponseSet;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.uf.viz.derivparam.tree.AbstractBaseDataNode; import com.raytheon.uf.viz.derivparam.tree.AbstractBaseDataNode;
import com.raytheon.uf.viz.derivparam.tree.AbstractDerivedDataNode; import com.raytheon.uf.viz.derivparam.tree.AbstractDerivedDataNode;
import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableNode; import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableNode;
@ -56,6 +56,7 @@ import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableNode.Dependency;
* Apr 11, 2012 bsteffen Initial creation * Apr 11, 2012 bsteffen Initial creation
* Feb 25, 2013 1659 bsteffen Stop derived parameters from sending * Feb 25, 2013 1659 bsteffen Stop derived parameters from sending
* empty requests for cached times * empty requests for cached times
* Jan 30, 2014 #2725 ekladstrup remove usage of ThriftClient
* *
* </pre> * </pre>
* *
@ -178,8 +179,13 @@ public class AvailabilityContainer {
if (!requests.isEmpty()) { if (!requests.isEmpty()) {
DbQueryRequestSet requestSet = new DbQueryRequestSet(); DbQueryRequestSet requestSet = new DbQueryRequestSet();
requestSet.setQueries(requests.toArray(new DbQueryRequest[0])); requestSet.setQueries(requests.toArray(new DbQueryRequest[0]));
DbQueryResponseSet responseSet = (DbQueryResponseSet) ThriftClient DbQueryResponseSet responseSet;
.sendRequest(requestSet); try {
responseSet = (DbQueryResponseSet) RequestRouter
.route(requestSet);
} catch (Exception e) {
throw new VizException(e);
}
DbQueryResponse[] responses = responseSet.getResults(); DbQueryResponse[] responses = responseSet.getResults();
for (int i = 0; i < responses.length; i++) { for (int i = 0; i < responses.length; i++) {

View file

@ -32,8 +32,8 @@ import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
import com.raytheon.uf.common.dataquery.requests.DbQueryRequestSet; import com.raytheon.uf.common.dataquery.requests.DbQueryRequestSet;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponseSet; import com.raytheon.uf.common.dataquery.responses.DbQueryResponseSet;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.viz.core.exception.VizException; 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.data.AbstractRequestableData;
import com.raytheon.uf.viz.derivparam.tree.AbstractBaseDataNode; import com.raytheon.uf.viz.derivparam.tree.AbstractBaseDataNode;
import com.raytheon.uf.viz.derivparam.tree.AbstractDerivedDataNode; import com.raytheon.uf.viz.derivparam.tree.AbstractDerivedDataNode;
@ -52,6 +52,7 @@ import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableNode.Dependency;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Apr 11, 2012 bsteffen Initial creation * Apr 11, 2012 bsteffen Initial creation
* Jan 30, 2014 #2725 ekladstrup remove usage of ThriftClient
* *
* </pre> * </pre>
* *
@ -223,8 +224,12 @@ public class MetadataContainer {
} }
DbQueryRequestSet requestSet = new DbQueryRequestSet(); DbQueryRequestSet requestSet = new DbQueryRequestSet();
requestSet.setQueries(requests.toArray(new DbQueryRequest[0])); requestSet.setQueries(requests.toArray(new DbQueryRequest[0]));
DbQueryResponseSet responseSet = (DbQueryResponseSet) ThriftClient DbQueryResponseSet responseSet;
.sendRequest(requestSet); try {
responseSet = (DbQueryResponseSet) RequestRouter.route(requestSet);
} catch (Exception e) {
throw new VizException(e);
}
for (int i = 0; i < nodes.size(); i++) { for (int i = 0; i < nodes.size(); i++) {
AbstractBaseDataNode node = nodes.get(i); AbstractBaseDataNode node = nodes.get(i);
dataCache.put(node, node.getData(originalConstraints, dataCache.put(node, node.getData(originalConstraints,

View file

@ -29,21 +29,12 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.measure.unit.Unit; import javax.measure.unit.Unit;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.services.IDisposable;
import com.raytheon.uf.common.datastorage.records.IDataRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.localization.FileUpdatedMessage; import com.raytheon.uf.common.localization.FileUpdatedMessage;
import com.raytheon.uf.common.localization.ILocalizationFileObserver; import com.raytheon.uf.common.localization.ILocalizationFileObserver;
@ -56,7 +47,6 @@ import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.Activator;
import com.raytheon.uf.viz.derivparam.DerivParamFunctionType; import com.raytheon.uf.viz.derivparam.DerivParamFunctionType;
import com.raytheon.uf.viz.derivparam.IDerivParamFunctionAdapter; import com.raytheon.uf.viz.derivparam.IDerivParamFunctionAdapter;
import com.raytheon.uf.viz.derivparam.library.DerivParamMethod.MethodType; import com.raytheon.uf.viz.derivparam.library.DerivParamMethod.MethodType;
@ -80,6 +70,9 @@ import com.raytheon.uf.viz.derivparam.library.DerivParamMethod.MethodType;
* concurrent python for threading. * concurrent python for threading.
* Nov 19, 2013 2361 njensen Only shutdown if initialized * Nov 19, 2013 2361 njensen Only shutdown if initialized
* Jan 14, 2014 2661 bsteffen Shutdown using uf.viz.core.Activator * Jan 14, 2014 2661 bsteffen Shutdown using uf.viz.core.Activator
* Jan 30, 2014 #2725 ekladstrup Refactor to remove dependencies on
* eclipse runtime and support some configuration
* through spring
* *
* </pre> * </pre>
* *
@ -102,8 +95,6 @@ public class DerivedParameterGenerator implements ILocalizationFileObserver {
public static final String XML_DIR = DERIV_PARAM_DIR + File.separator public static final String XML_DIR = DERIV_PARAM_DIR + File.separator
+ DEFINITIONS; + DEFINITIONS;
private static final String EXTENSION = "com.raytheon.uf.viz.derivparam.functionType";
public static interface DerivParamUpdateListener { public static interface DerivParamUpdateListener {
public void updateDerParLibrary( public void updateDerParLibrary(
Map<String, DerivParamDesc> derParLibrary); Map<String, DerivParamDesc> derParLibrary);
@ -123,21 +114,10 @@ public class DerivedParameterGenerator implements ILocalizationFileObserver {
private String extension = null; private String extension = null;
private Job notifyJob = new Job("Notify Derived Parameter Listeners") { protected static List<DerivParamFunctionType> functionTypes = new ArrayList<DerivParamFunctionType>(
1);
@Override protected ExecutorService execService = null;
protected IStatus run(IProgressMonitor arg0) {
Collection<DerivParamUpdateListener> l = null;
synchronized (listeners) {
l = new ArrayList<DerivParamUpdateListener>(listeners);
}
for (DerivParamUpdateListener listener : l) {
listener.updateDerParLibrary(derParLibrary);
}
return Status.OK_STATUS;
}
};
public static synchronized DerivedParameterGenerator getInstance() { public static synchronized DerivedParameterGenerator getInstance() {
if (instance == null) { if (instance == null) {
@ -146,34 +126,24 @@ public class DerivedParameterGenerator implements ILocalizationFileObserver {
return instance; return instance;
} }
/**
* Create a function type from the adapter and add it to the function type
* list
*
* @param adapter
* @return the adapter
*/
public static IDerivParamFunctionAdapter addFunctionAdapter(
IDerivParamFunctionAdapter adapter) {
DerivParamFunctionType functionType = new DerivParamFunctionType();
functionType.setName(adapter.getName());
functionType.setExtension(adapter.getExtension());
functionType.setAdapter(adapter);
functionTypes.add(functionType);
return adapter;
}
public static DerivParamFunctionType[] getFunctionTypes() { public static DerivParamFunctionType[] getFunctionTypes() {
List<DerivParamFunctionType> functionTypes = new ArrayList<DerivParamFunctionType>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
if (registry != null) {
IExtensionPoint point = registry.getExtensionPoint(EXTENSION);
IExtension[] extensions = point.getExtensions();
for (IExtension ext : extensions) {
IConfigurationElement[] config = ext.getConfigurationElements();
for (IConfigurationElement cfg : config) {
try {
DerivParamFunctionType functionType = new DerivParamFunctionType();
functionType.setName(cfg.getAttribute("name"));
functionType
.setExtension(cfg.getAttribute("extension"));
functionType
.setAdapter((IDerivParamFunctionAdapter) cfg
.createExecutableExtension("adapter"));
functionTypes.add(functionType);
} catch (Throwable t) {
statusHandler.handle(Priority.DEBUG,
t.getLocalizedMessage(), t);
}
}
}
}
return functionTypes.toArray(new DerivParamFunctionType[0]); return functionTypes.toArray(new DerivParamFunctionType[0]);
} }
@ -189,6 +159,10 @@ public class DerivedParameterGenerator implements ILocalizationFileObserver {
} }
private DerivedParameterGenerator() { private DerivedParameterGenerator() {
// We shouldn't every be running more than one job at a time anyway, but
// use an executor service just in case we want to tweak things later.
execService = Executors.newSingleThreadExecutor();
DerivParamFunctionType[] functionTypes = getFunctionTypes(); DerivParamFunctionType[] functionTypes = getFunctionTypes();
if (functionTypes == null || functionTypes.length == 0) { if (functionTypes == null || functionTypes.length == 0) {
@ -196,16 +170,9 @@ public class DerivedParameterGenerator implements ILocalizationFileObserver {
"Error creating derived parameter function type," "Error creating derived parameter function type,"
+ " derived paramters will not be available"); + " derived paramters will not be available");
} }
Activator.getDefault().registerDisposable(new IDisposable() {
@Override
public void dispose() {
shutdown();
}
});
this.adapter = functionTypes[0].getAdapter(); this.adapter = functionTypes[0].getAdapter();
this.extension = functionTypes[0].getExtension(); this.extension = functionTypes[0].getExtension();
notifyJob.setSystem(true);
LocalizationFile dir = PathManagerFactory.getPathManager() LocalizationFile dir = PathManagerFactory.getPathManager()
.getStaticLocalizationFile(DERIV_PARAM_DIR); .getStaticLocalizationFile(DERIV_PARAM_DIR);
if (dir != null) { if (dir != null) {
@ -306,7 +273,7 @@ public class DerivedParameterGenerator implements ILocalizationFileObserver {
this.derParLibrary = derParLibrary; this.derParLibrary = derParLibrary;
adapter.init(); adapter.init();
notifyJob.schedule(); scheduleNotifyJob(listeners, derParLibrary);
System.out.println("time to init derived parameters: " System.out.println("time to init derived parameters: "
+ (System.currentTimeMillis() - start) + "ms"); + (System.currentTimeMillis() - start) + "ms");
@ -314,6 +281,33 @@ public class DerivedParameterGenerator implements ILocalizationFileObserver {
} }
} }
/**
* Run the notification thread in the executor service.
*
* @param theListeners
* @param theDerParLibrary
*/
protected void scheduleNotifyJob(
final Set<DerivParamUpdateListener> theListeners,
final Map<String, DerivParamDesc> theDerParLibrary) {
Thread notifyJob = new Thread() {
@Override
public void run() {
Collection<DerivParamUpdateListener> l = null;
synchronized (listeners) {
l = new ArrayList<DerivParamUpdateListener>(listeners);
}
for (DerivParamUpdateListener listener : l) {
listener.updateDerParLibrary(derParLibrary);
}
}
};
execService.submit(notifyJob);
}
public Map<String, DerivParamDesc> getLibrary() { public Map<String, DerivParamDesc> getLibrary() {
initLibrary(); initLibrary();
return derParLibrary; return derParLibrary;

View file

@ -33,6 +33,7 @@ import java.util.Map.Entry;
import java.util.NavigableSet; import java.util.NavigableSet;
import java.util.Set; import java.util.Set;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.grid.GridConstants; import com.raytheon.uf.common.dataplugin.grid.GridConstants;
import com.raytheon.uf.common.dataplugin.grid.GridInfoConstants; import com.raytheon.uf.common.dataplugin.grid.GridInfoConstants;
import com.raytheon.uf.common.dataplugin.grid.GridInfoRecord; import com.raytheon.uf.common.dataplugin.grid.GridInfoRecord;
@ -41,6 +42,7 @@ import com.raytheon.uf.common.dataplugin.grid.dataset.DatasetInfoLookup;
import com.raytheon.uf.common.dataplugin.grid.request.GetGridTreeRequest; import com.raytheon.uf.common.dataplugin.grid.request.GetGridTreeRequest;
import com.raytheon.uf.common.dataplugin.grid.util.StaticGridDataType; import com.raytheon.uf.common.dataplugin.grid.util.StaticGridDataType;
import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.util.LevelUtilities;
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest; import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
@ -58,7 +60,6 @@ import com.raytheon.uf.viz.core.catalog.CatalogQuery;
import com.raytheon.uf.viz.core.catalog.DbQuery; import com.raytheon.uf.viz.core.catalog.DbQuery;
import com.raytheon.uf.viz.core.exception.VizCommunicationException; import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelUtilities;
import com.raytheon.uf.viz.core.requests.ThriftClient; import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData; import com.raytheon.uf.viz.derivparam.data.AbstractRequestableData;
import com.raytheon.uf.viz.derivparam.inv.AbstractInventory; import com.raytheon.uf.viz.derivparam.inv.AbstractInventory;
@ -91,6 +92,8 @@ import com.raytheon.viz.grid.util.RadarAdapter;
* Nov 21, 2009 #3576 rjpeter Refactored use of DerivParamDesc. * Nov 21, 2009 #3576 rjpeter Refactored use of DerivParamDesc.
* Feb 26, 2013 1659 bsteffen Add time agnostic caching to grid derived * Feb 26, 2013 1659 bsteffen Add time agnostic caching to grid derived
* parameters. * parameters.
* Jan 30, 2014 #2725 ekladstrup updated exception handling during move of derived
* parameters to common
* *
* </pre> * </pre>
* *
@ -697,8 +700,13 @@ public class GridInventory extends AbstractInventory implements
String masterLevelName = get3DMasterLevel(sNode.getValue()); String masterLevelName = get3DMasterLevel(sNode.getValue());
boolean isRadar = sNode.getValue().equals(RadarAdapter.RADAR_SOURCE); boolean isRadar = sNode.getValue().equals(RadarAdapter.RADAR_SOURCE);
NavigableSet<Level> levels = LevelUtilities NavigableSet<Level> levels;
.getOrderedSetOfStandardLevels(masterLevelName); try {
levels = LevelUtilities
.getOrderedSetOfStandardLevels(masterLevelName);
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
List<CubeLevel<AbstractRequestableNode, AbstractRequestableNode>> cubeLevels = new ArrayList<CubeLevel<AbstractRequestableNode, AbstractRequestableNode>>( List<CubeLevel<AbstractRequestableNode, AbstractRequestableNode>> cubeLevels = new ArrayList<CubeLevel<AbstractRequestableNode, AbstractRequestableNode>>(
levels.size()); levels.size());

View file

@ -34,6 +34,7 @@ import com.raytheon.uf.common.dataplugin.grid.util.GridLevelTranslator;
import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping;
import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory;
import com.raytheon.uf.common.dataplugin.level.util.LevelUtilities;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
@ -44,8 +45,6 @@ import com.raytheon.uf.common.style.StyleException;
import com.raytheon.uf.common.style.StyleManager; import com.raytheon.uf.common.style.StyleManager;
import com.raytheon.uf.common.style.StyleRule; import com.raytheon.uf.common.style.StyleRule;
import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.level.LevelUtilities;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.DisplayType; import com.raytheon.uf.viz.core.rsc.DisplayType;
import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.LoadProperties;
@ -83,6 +82,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Aug 20, 2013 2259 bsteffen Delete old skewt plugin. * Aug 20, 2013 2259 bsteffen Delete old skewt plugin.
* Sep 06, 2013 2251 mnash Move graph prefs style type to * Sep 06, 2013 2251 mnash Move graph prefs style type to
* graph plugin * graph plugin
* Jan 30, 2014 #2725 ekladstrup updated exception handling during move of derived
* parameters to common
* *
* </pre> * </pre>
* *
@ -361,7 +362,7 @@ public abstract class AbstractDataCatalog implements IDataCatalog {
try { try {
levels = LevelUtilities.getOrderedSetOfStandardLevels(planesKey levels = LevelUtilities.getOrderedSetOfStandardLevels(planesKey
.replace("spatial-", "")); .replace("spatial-", ""));
} catch (VizCommunicationException e) { } catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e); e);
} }

View file

@ -40,12 +40,11 @@ import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory; import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping; import com.raytheon.uf.common.dataplugin.level.mapping.LevelMapping;
import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory;
import com.raytheon.uf.common.dataplugin.level.util.LevelUtilities;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer; import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.level.LevelUtilities;
import com.raytheon.uf.viz.derivparam.inv.AbstractInventory; import com.raytheon.uf.viz.derivparam.inv.AbstractInventory;
import com.raytheon.viz.volumebrowser.vbui.DataListsProdTableComp.DataSelection; import com.raytheon.viz.volumebrowser.vbui.DataListsProdTableComp.DataSelection;
import com.raytheon.viz.volumebrowser.vbui.MenuItemManager; import com.raytheon.viz.volumebrowser.vbui.MenuItemManager;
@ -63,6 +62,8 @@ import com.raytheon.viz.volumebrowser.vbui.VolumeBrowserAction;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Apr 14, 2010 bsteffen Initial creation * Apr 14, 2010 bsteffen Initial creation
* Jul 25, 2013 2112 bsteffen Fix volume browser sounding errors. * Jul 25, 2013 2112 bsteffen Fix volume browser sounding errors.
* Jan 30, 2014 #2725 ekladstrup updated exception handling during move of derived
* parameters to common
* *
* </pre> * </pre>
* *
@ -291,7 +292,7 @@ public abstract class AbstractInventoryDataCatalog extends AbstractDataCatalog {
levels = LevelUtilities levels = LevelUtilities
.getOrderedSetOfStandardLevels(plane.replace( .getOrderedSetOfStandardLevels(plane.replace(
"spatial-", "")); "spatial-", ""));
} catch (VizCommunicationException e) { } catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e); e.getLocalizedMessage(), e);
} }

View file

@ -39,6 +39,7 @@ import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.grid.GridConstants; import com.raytheon.uf.common.dataplugin.grid.GridConstants;
import com.raytheon.uf.common.dataplugin.level.Level; import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory;
import com.raytheon.uf.common.dataplugin.level.util.LevelUtilities;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint; import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType; import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
import com.raytheon.uf.common.geospatial.MapUtil; import com.raytheon.uf.common.geospatial.MapUtil;
@ -47,9 +48,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.drawables.ResourcePair; 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.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelUtilities;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.DisplayType; import com.raytheon.uf.viz.core.rsc.DisplayType;
import com.raytheon.uf.viz.core.rsc.ResourceType; import com.raytheon.uf.viz.core.rsc.ResourceType;
@ -85,6 +84,8 @@ import com.vividsolutions.jts.geom.LineString;
* Jul 31, 2012 875 rferrel Now uses points. * Jul 31, 2012 875 rferrel Now uses points.
* May 30, 2013 2055 bsteffen Remove modelName from sounding pointName. * May 30, 2013 2055 bsteffen Remove modelName from sounding pointName.
* Dec 06, 2013 2271 mpduff Added check for null coordinate. * Dec 06, 2013 2271 mpduff Added check for null coordinate.
* Jan 30, 2014 #2725 ekladstrup updated exception handling during move of derived
* parameters to common
* *
* </pre> * </pre>
* *
@ -349,7 +350,7 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog {
if (tilts != null) { if (tilts != null) {
all.addAll(tilts); all.addAll(tilts);
} }
} catch (VizCommunicationException e) { } catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
} }
try { try {
@ -358,7 +359,7 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog {
if (pres != null) { if (pres != null) {
all.addAll(pres); all.addAll(pres);
} }
} catch (VizCommunicationException e) { } catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
} }
try { try {
@ -367,7 +368,7 @@ public class GridDataCatalog extends AbstractInventoryDataCatalog {
if (theta != null) { if (theta != null) {
all.addAll(theta); all.addAll(theta);
} }
} catch (VizCommunicationException e) { } catch (CommunicationException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
} }

View file

@ -19,4 +19,6 @@ Require-Bundle: com.raytheon.uf.common.dataplugin,
javax.measure javax.measure
Export-Package: com.raytheon.uf.common.dataplugin.level, Export-Package: com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.level.mapping, com.raytheon.uf.common.dataplugin.level.mapping,
com.raytheon.uf.common.dataplugin.level.request com.raytheon.uf.common.dataplugin.level.request,
com.raytheon.uf.common.dataplugin.level.util
Import-Package: com.raytheon.uf.common.comm

View file

@ -17,7 +17,7 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information. * further licensing information.
**/ **/
package com.raytheon.uf.viz.core.level; package com.raytheon.uf.common.dataplugin.level.util;
import java.text.ParsePosition; import java.text.ParsePosition;
import java.util.Comparator; import java.util.Comparator;
@ -36,7 +36,6 @@ import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory; import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.level.MasterLevel; import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory; import com.raytheon.uf.common.dataplugin.level.mapping.LevelMappingFactory;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
/** /**
* Level utilities * Level utilities
@ -49,6 +48,8 @@ import com.raytheon.uf.viz.core.exception.VizCommunicationException;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* 11/21/2009 #3576 rjpeter Initial version * 11/21/2009 #3576 rjpeter Initial version
* 01/30/2014 #2725 ekladstrup Moved to common and removed
* usage of VizCommunicationException
* </pre> * </pre>
* *
* @author rjpeter * @author rjpeter
@ -67,23 +68,15 @@ public class LevelUtilities {
} }
public static boolean isPressureLevel(long levelId) public static boolean isPressureLevel(long levelId)
throws VizCommunicationException { throws CommunicationException {
try { return isPressureLevel(LevelFactory.getInstance().getLevel(levelId)
return isPressureLevel(LevelFactory.getInstance().getLevel(levelId) .getMasterLevel());
.getMasterLevel());
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
} }
public static boolean isPressureLevel(String masterLevelName) public static boolean isPressureLevel(String masterLevelName)
throws VizCommunicationException { throws CommunicationException {
try { return isPressureLevel(LevelFactory.getInstance().getMasterLevel(
return isPressureLevel(LevelFactory.getInstance().getMasterLevel( masterLevelName));
masterLevelName));
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
} }
public static boolean isPressureLevel(Level level) { public static boolean isPressureLevel(Level level) {
@ -106,7 +99,7 @@ public class LevelUtilities {
* @throws CommunicationException * @throws CommunicationException
*/ */
public synchronized static NavigableSet<Level> getOrderedSetOfStandardLevels( public synchronized static NavigableSet<Level> getOrderedSetOfStandardLevels(
String masterLevelName) throws VizCommunicationException { String masterLevelName) throws CommunicationException {
if (masterLevelToOrderedSet == null) { if (masterLevelToOrderedSet == null) {
Comparator<Level> levelComparator = new Comparator<Level>() { Comparator<Level> levelComparator = new Comparator<Level>() {
@ -125,13 +118,9 @@ public class LevelUtilities {
}; };
Map<String, NavigableSet<Level>> masterLevelToOrderedSet = new HashMap<String, NavigableSet<Level>>(); Map<String, NavigableSet<Level>> masterLevelToOrderedSet = new HashMap<String, NavigableSet<Level>>();
Set<Level> allLevels; Set<Level> allLevels;
try { allLevels = LevelMappingFactory.getInstance(
allLevels = LevelMappingFactory.getInstance( LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE)
LevelMappingFactory.VOLUMEBROWSER_LEVEL_MAPPING_FILE) .getAllLevels();
.getAllLevels();
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
for (Level level : allLevels) { for (Level level : allLevels) {
NavigableSet<Level> levels = masterLevelToOrderedSet.get(level NavigableSet<Level> levels = masterLevelToOrderedSet.get(level
.getMasterLevel().getName()); .getMasterLevel().getName());
@ -142,12 +131,8 @@ public class LevelUtilities {
} }
if (level.isRangeLevel()) { if (level.isRangeLevel()) {
try { levels.add(level.getUpperLevel());
levels.add(level.getUpperLevel()); levels.add(level.getLowerLevel());
levels.add(level.getLowerLevel());
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
} else { } else {
levels.add(level); levels.add(level);
} }