diff --git a/cave/com.raytheon.uf.viz.common.core.feature/feature.xml b/cave/com.raytheon.uf.viz.common.core.feature/feature.xml index bbb9fd5394..ff2dcb2510 100644 --- a/cave/com.raytheon.uf.viz.common.core.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.common.core.feature/feature.xml @@ -21,13 +21,6 @@ - - - - - - - - - * - * SOFTWARE HISTORY - * - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * 7/1/06 chammack Initial Creation. - * 8/8/07 chammack Refactored: moved loading logic to core.comm.Loader - * - * - * - * @author chammack - * @version 1 - */ -public class RequestJob extends Job { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(RequestJob.class); - - /** - * Resource that is being added via a request job - */ - private class Resource { - public AbstractVizResource vizResource; - - public IDescriptor descriptor; - } - - public static class Request { - public AbstractRequestableResourceData resourceData; - - public LoadProperties loadProperties; - } - - private final List requests; - - private boolean blendable; - - private boolean difference; - - private IDisplayPane[] displayPanes; - - /** - * Constructor - * - * @param property - * the layer property to build data from - * @param timeOut - * time out in seconds - * @param requests2 - * @param displayPanes - * @param loadProperties - * the load properties (null will construct a default load - * properties) - */ - public RequestJob(int timeOut, AbstractEditor editor, Request... requests) { - super("Requesting EDEX Product(s)"); - this.requests = new ArrayList(); - for (Request r : requests) { - this.requests.add(r); - } - this.displayPanes = editor.getDisplayPanes(); - - IDisplayPane selected = getSelectedDisplayPane(editor); - if (selected != null) { - this.displayPanes = new IDisplayPane[] { selected }; - } - - this.blendable = false; - this.setDifference(false); - } - - /** - * @param editor - * @return the selectedDisplayPane, null if nothing is selected - */ - private IDisplayPane getSelectedDisplayPane(AbstractEditor editor) { - - IDisplayPane selected = null; - if (editor instanceof IMultiPaneEditor) { - selected = ((IMultiPaneEditor) editor) - .getSelectedPane(IMultiPaneEditor.LOAD_ACTION); - } - return selected; - } - - /** - * - * @param flag - * the requests to be loaded as blendable resources. by default - * resource blending is disabled. - */ - public void setBlendable(boolean flag) { - this.blendable = flag; - } - - /** - * - * @return true if there are exactly two resources and the resources to be - * loaded by this RequestJob are set to be blendable. - */ - public boolean isBlendable() { - return (requests.size() == 2) && blendable; - } - - /* - * (non-Javadoc) - * - * @seeorg.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime. - * IProgressMonitor) - */ - @Override - protected IStatus run(IProgressMonitor monitor) { - - List resources = null; - - try { - resources = new ArrayList(); - - for (Request request : this.requests) { - for (IDisplayPane displayPane : displayPanes) { - - Resource resource = new Resource(); - try { - resource.vizResource = request.resourceData.construct( - request.loadProperties, - displayPane.getDescriptor()); - if (resource.vizResource != null) { - resource.descriptor = displayPane.getDescriptor(); - resources.add(resource); - } - } catch (NoDataAvailableException e) { - statusHandler - .handle(Priority.PROBLEM, - "No Data Available for " - + getMetaDataValueString(request.resourceData - .getMetadataMap()), e); - } - } - } - requests.clear(); - } catch (VizException e1) { - final Status s = new Status(IStatus.ERROR, UiPlugin.PLUGIN_ID, - IStatus.ERROR, "Error: " + e1.getMessage(), e1); - - return s; - } - - if (resources.size() == 2) { - - if (isBlendable()) { - BlendedResourceData resourceData = new BlendedResourceData(); - BlendedResource resource = new BlendedResource(resourceData, - new LoadProperties()); - - resource.addResource(resources.get(0).vizResource); - resource.addResource(resources.get(1).vizResource); - - Resource blendedResource = new Resource(); - blendedResource.vizResource = resource; - blendedResource.descriptor = resources.get(0).descriptor; - - resources.clear(); - resources.add(blendedResource); - - } - - } - - try { - - for (Resource resource : resources) { - if (resource.vizResource - .hasCapability(ColorableCapability.class) == false) { - resource.vizResource.getCapability( - ColorableCapability.class).setColor( - ColorUtil.getNewColor(displayPanes)); - } - resource.descriptor.getResourceList().add(resource.vizResource); - } - - HistoryList.getInstance().refreshLatestBundle(); - - } catch (VizException e) { - - final Status s = new Status(IStatus.ERROR, UiPlugin.PLUGIN_ID, - IStatus.ERROR, "Error: " + e.getMessage(), e); - - return s; - } - - return Status.OK_STATUS; - } - - /** - * @param metadataMap - * @return - */ - private String getMetaDataValueString( - HashMap metadataMap) { - StringBuilder valueString = new StringBuilder(); - for (RequestConstraint constraint : metadataMap.values()) { - if (valueString.length() != 0) { - valueString.append("::"); - } - valueString.append(constraint.getConstraintValue()); - } - return valueString.toString(); - } - - public void setDifference(boolean difference) { - this.difference = difference; - } - - public boolean isDifference() { - return difference; - } -} diff --git a/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml b/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml index 2a4d7989f7..00d166b5ca 100644 --- a/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.common.base.feature/feature.xml @@ -368,4 +368,30 @@ version="0.0.0" unpack="false"/> + + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.common.dataquery/src/com/raytheon/uf/common/dataquery/responses/DbQueryResponse.java b/edexOsgi/com.raytheon.uf.common.dataquery/src/com/raytheon/uf/common/dataquery/responses/DbQueryResponse.java index 62fcae6ef6..8ccf58cdd5 100644 --- a/edexOsgi/com.raytheon.uf.common.dataquery/src/com/raytheon/uf/common/dataquery/responses/DbQueryResponse.java +++ b/edexOsgi/com.raytheon.uf.common.dataquery/src/com/raytheon/uf/common/dataquery/responses/DbQueryResponse.java @@ -66,13 +66,17 @@ public class DbQueryResponse implements ISerializableObject { return getResults().size(); } - @SuppressWarnings("unchecked") public T[] getEntityObjects(Class entityType) { + return getFieldObjects(ENTITY_RESULT_KEY, entityType); + } + + @SuppressWarnings("unchecked") + public T[] getFieldObjects(String fieldKey, Class fieldType) { List> results = getResults(); - T[] entities = (T[]) Array.newInstance(entityType, results.size()); + T[] entities = (T[]) Array.newInstance(fieldType, results.size()); int i = 0; for (Map result : results) { - entities[i++] = entityType.cast(result.get(ENTITY_RESULT_KEY)); + entities[i++] = fieldType.cast(result.get(fieldKey)); } return entities; } diff --git a/edexOsgi/com.raytheon.uf.common.pointdata/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.pointdata/META-INF/MANIFEST.MF index b5f6e2e2bf..4343015c1a 100644 --- a/edexOsgi/com.raytheon.uf.common.pointdata/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.common.pointdata/META-INF/MANIFEST.MF @@ -3,6 +3,8 @@ Bundle-ManifestVersion: 2 Bundle-Name: PointData Bundle-SymbolicName: com.raytheon.uf.common.pointdata Bundle-Version: 1.12.1174.qualifier +Bundle-Vendor: RAYTHEON +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization Export-Package: com.raytheon.uf.common.pointdata, com.raytheon.uf.common.pointdata.accumulate, diff --git a/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml index 07bf2c4716..86abdf2f3c 100644 --- a/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml +++ b/edexOsgi/com.raytheon.uf.edex.base.feature/feature.xml @@ -125,6 +125,13 @@ version="0.0.0" unpack="false"/> + + - - - - - - - - - - queryParameters; + /** List of query parameters for "querying" the netCDF file */ + private final List queryParameters; - /** - * Constructs a new QCDataQuery - * - * @throws DataAccessLayerException - * If errors occur while retrieving the data access object - * @throws PluginException - * If the data access object is of the wrong type - */ - public QCDataQuery() throws DataAccessLayerException, PluginException { - super("qc"); - queryParameters = new ArrayList(); - } + /** + * Constructs a new QCDataQuery + * + * @throws DataAccessLayerException + * If errors occur while retrieving the data access object + * @throws PluginException + * If the data access object is of the wrong type + */ + public QCDataQuery() throws DataAccessLayerException, PluginException { + super("qc"); + queryParameters = new ArrayList(); + } - @Override + @Override public void addParameter(String name, String value, String operand) { - queryParameters.add(name + " " + value + " " + operand); - } + queryParameters.add(name + " " + value + " " + operand); + } - /** - * Executes the query and returns the data in a PointDataContainer - * - * @return The data in a PointDataContainer - * @throws Exception - * if errors occur while retrieving the data - */ - @Override + /** + * Executes the query and returns the data in a PointDataContainer + * + * @return The data in a PointDataContainer + * @throws Exception + * if errors occur while retrieving the data + */ + @Override public PointDataContainer execute() throws Exception { - List containers = new ArrayList(); + List containers = new ArrayList(); - // Gets the available files for querying - Map pathMap = QCPaths.getPaths(); - for (File dir : pathMap.values()) { + // Gets the available files for querying + Map pathMap = QCPaths.getPaths(); + for (File dir : pathMap.values()) { List files = FileUtil.listFiles(dir, null, false); - if (!files.isEmpty()) { - String[] fileParams = ((QCDao) dao).getParameters(files.get(0)); - Set attribSet = new HashSet( - Arrays.asList(attribs)); - attribSet.retainAll(Arrays.asList(fileParams)); - List attributes = new ArrayList(); - attributes.addAll(attribSet); - for (File file : files) { - PointDataContainer pdc = ((QCDao) dao).getPointData(file, - attributes, queryParameters); - if (pdc == null) { - return null; - } - if (pdc.getAllocatedSz() != 0) { - containers.add(pdc); - } - } - } - } + if (!files.isEmpty()) { + String[] fileParams = ((QCDao) dao).getParameters(files.get(0)); + Set attribSet = new HashSet( + Arrays.asList(attribs)); + attribSet.retainAll(Arrays.asList(fileParams)); + List attributes = new ArrayList(); + attributes.addAll(attribSet); + for (File file : files) { + PointDataContainer pdc = ((QCDao) dao).getPointData(file, + attributes, queryParameters); + if (pdc == null) { + return null; + } + if (pdc.getAllocatedSz() != 0) { + containers.add(pdc); + } + } + } + } - if (containers.size() == 0) - return null; + if (containers.size() == 0) + return null; - PointDataContainer c0 = containers.get(0); + PointDataContainer c0 = containers.get(0); - for (int i = 1; i < containers.size(); i++) { - c0.combine(containers.get(i)); - } - return c0; - } + for (int i = 1; i < containers.size(); i++) { + c0.combine(containers.get(i)); + } + return c0; + } - @Override - public ResponseMessageCatalog getAvailableParameters() throws Exception { - String[] p = new String[0]; - Map> fnameMap = getRetrievalMap(1); + @Override + public ResponseMessageCatalog getAvailableParameters() throws Exception { + String[] p = new String[0]; + Map> fnameMap = getRetrievalMap(1); - if (fnameMap.size() > 0) { + if (fnameMap.size() > 0) { - Iterator str = fnameMap.keySet().iterator(); - p = ((QCDao) dao).getParameters(new File(str.next())); - } - ResponseMessageCatalog cat = new ResponseMessageCatalog(); - cat.setValues(p); + Iterator str = fnameMap.keySet().iterator(); + p = ((QCDao) dao).getParameters(new File(str.next())); + } + ResponseMessageCatalog cat = new ResponseMessageCatalog(); + cat.setValues(p); - return cat; - } + return cat; + } - @SuppressWarnings("unchecked") - private Map> getRetrievalMap(int limit) - throws Exception { + private Map> getRetrievalMap(int limit) + throws Exception { - String[] fnameKeys = dao.getKeysRequiredForFileName(); - tq.addReturnedField("pointDataView.curIdx", null); - tq.addReturnedField("id", null); - tq.setCount(limit); - for (String fnameKey : fnameKeys) { - tq.addReturnedField(fnameKey, null); - } - List results = tq.execute(); + String[] fnameKeys = dao.getKeysRequiredForFileName(); + query.addReturnedField("pointDataView.curIdx"); + query.addReturnedField("id"); + query.setMaxResults(limit); + for (String fnameKey : fnameKeys) { + query.addReturnedField(fnameKey); + } + List results = dao.queryByCriteria(query); - Map> fnameMap = new HashMap>(); + Map> fnameMap = new HashMap>(); - Map workingMap = new HashMap(); - for (Object o : results) { - Object[] oArr = (Object[]) o; - workingMap.clear(); - for (int i = 0; i < fnameKeys.length; i++) { - workingMap.put(fnameKeys[i], oArr[i + 2]); - } + Map workingMap = new HashMap(); + for (Object o : results) { + Object[] oArr = (Object[]) o; + workingMap.clear(); + for (int i = 0; i < fnameKeys.length; i++) { + workingMap.put(fnameKeys[i], oArr[i + 2]); + } - String fileName = dao.getPointDataFileName(workingMap); - List ints = fnameMap.get(fileName); - if (ints == null) { - ints = new ArrayList(500); - fnameMap.put(fileName, ints); - } - ints.add(new Integer[] { (Integer) oArr[0], (Integer) oArr[1] }); - } + String fileName = dao.getPointDataFileName(workingMap); + List ints = fnameMap.get(fileName); + if (ints == null) { + ints = new ArrayList(500); + fnameMap.put(fileName, ints); + } + ints.add(new Integer[] { (Integer) oArr[0], (Integer) oArr[1] }); + } - return fnameMap; - } + return fnameMap; + } } diff --git a/edexOsgi/com.raytheon.uf.edex.pointdata/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.pointdata/META-INF/MANIFEST.MF index 1b35e4795b..d701383659 100644 --- a/edexOsgi/com.raytheon.uf.edex.pointdata/META-INF/MANIFEST.MF +++ b/edexOsgi/com.raytheon.uf.edex.pointdata/META-INF/MANIFEST.MF @@ -16,7 +16,6 @@ Require-Bundle: com.raytheon.uf.common.pointdata;bundle-version="1.12.1174";visi com.raytheon.uf.common.derivparam;bundle-version="1.12.1174", com.raytheon.uf.common.dataplugin.level;bundle-version="1.12.1174", com.raytheon.edex.common;bundle-version="1.12.1174", - com.raytheon.edex.uengine;bundle-version="1.12.1174", org.geotools;bundle-version="2.6.4", javax.measure;bundle-version="1.0.0" Export-Package: com.raytheon.uf.edex.pointdata, diff --git a/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/GetPointDataTreeHandler.java b/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/GetPointDataTreeHandler.java index 5f148cde32..50153843ad 100644 --- a/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/GetPointDataTreeHandler.java +++ b/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/GetPointDataTreeHandler.java @@ -24,12 +24,14 @@ import java.util.Collections; import java.util.List; 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.LevelFactory; +import com.raytheon.uf.common.dataquery.requests.DbQueryRequest; +import com.raytheon.uf.common.dataquery.requests.RequestConstraint; +import com.raytheon.uf.common.dataquery.responses.DbQueryResponse; import com.raytheon.uf.common.derivparam.tree.DataTree; import com.raytheon.uf.common.pointdata.GetPointDataTreeRequest; import com.raytheon.uf.common.serialization.comm.IRequestHandler; +import com.raytheon.uf.common.serialization.comm.RequestRouter; /** * @@ -79,9 +81,15 @@ public class GetPointDataTreeHandler implements private String[] getAvailableTypes(String pluginName, String typeKey) { if (!typeKey.equals(PLUGIN_NAME)) { try { - CatalogQuery query = new MetadataCatalogQuery(pluginName); - query.setDistinctField(typeKey); - String[] result = query.execute().getValues(); + DbQueryRequest request = new DbQueryRequest(); + request.addConstraint(PLUGIN_NAME, new RequestConstraint( + pluginName)); + request.addRequestField(typeKey); + request.setDistinct(true); + DbQueryResponse response = (DbQueryResponse) RequestRouter + .route(request); + String[] result = response.getFieldObjects(typeKey, + String.class); return result; } catch (Exception e) { e.printStackTrace(); diff --git a/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/PointDataQuery.java b/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/PointDataQuery.java index 1646a6ed2a..ff1fa811b6 100644 --- a/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/PointDataQuery.java +++ b/edexOsgi/com.raytheon.uf.edex.pointdata/src/com/raytheon/uf/edex/pointdata/PointDataQuery.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import com.raytheon.edex.uengine.tasks.query.TableQuery; import com.raytheon.uf.common.dataplugin.PluginException; import com.raytheon.uf.common.datastorage.records.FloatDataRecord; import com.raytheon.uf.common.datastorage.records.IDataRecord; @@ -43,6 +42,7 @@ import com.raytheon.uf.common.pointdata.PointDataView; import com.raytheon.uf.edex.database.DataAccessLayerException; import com.raytheon.uf.edex.database.plugin.PluginDao; import com.raytheon.uf.edex.database.plugin.PluginFactory; +import com.raytheon.uf.edex.database.query.DatabaseQuery; import com.raytheon.uf.edex.pointdata.PointDataPluginDao.LevelRequest; /** @@ -63,9 +63,9 @@ import com.raytheon.uf.edex.pointdata.PointDataPluginDao.LevelRequest; public class PointDataQuery { - protected PointDataPluginDao dao; + protected DatabaseQuery query; - protected TableQuery tq; + protected PointDataPluginDao dao; protected String[] attribs; @@ -73,9 +73,6 @@ public class PointDataQuery { public PointDataQuery(final String plugin) throws DataAccessLayerException, PluginException { - this.tq = new TableQuery(PluginFactory.getInstance() - .getDatabase(plugin), PluginFactory.getInstance() - .getPluginRecordClass(plugin).getName()); try { PluginDao pd = PluginFactory.getInstance().getPluginDao(plugin); if (!(pd instanceof PointDataPluginDao)) { @@ -83,6 +80,7 @@ public class PointDataQuery { + " DAO is not a point data DAO"); } this.dao = (PointDataPluginDao) pd; + this.query = new DatabaseQuery(pd.getDaoClass()); } catch (Exception e) { e.printStackTrace(); throw new DataAccessLayerException( @@ -105,8 +103,7 @@ public class PointDataQuery { operand = "="; } - tq.addParameter(name, value, operand); - + query.addQueryParam(name, value, operand); } public void requestAllLevels() { @@ -171,10 +168,10 @@ public class PointDataQuery { final int limit) throws Exception { for (String field : fields) { - tq.addReturnedField(field, null); + query.addReturnedField(field); } - tq.setCount(limit); - List queryResults = tq.execute(); + query.setMaxResults(limit); + List queryResults = dao.queryByCriteria(query); List> results = new ArrayList>(); @@ -365,4 +362,3 @@ public class PointDataQuery { return masterPDC; } } - diff --git a/ncep/gov.noaa.nws.ncep.ui.nctextui/META-INF/MANIFEST.MF b/ncep/gov.noaa.nws.ncep.ui.nctextui/META-INF/MANIFEST.MF index 3d0ebdb88d..5c6c09cd42 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nctextui/META-INF/MANIFEST.MF +++ b/ncep/gov.noaa.nws.ncep.ui.nctextui/META-INF/MANIFEST.MF @@ -27,7 +27,6 @@ Import-Package: com.raytheon.uf.common.dataplugin, com.raytheon.uf.viz.core.map, com.raytheon.uf.viz.core.rsc, com.raytheon.viz.pointdata, - com.raytheon.viz.ui.jobs, com.vividsolutions.jts.geom, gov.noaa.nws.ncep.viz.common.ui, gov.noaa.nws.ncep.viz.localization,