diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/.classpath b/edexOsgi/com.raytheon.uf.common.dataaccess/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/.project b/edexOsgi/com.raytheon.uf.common.dataaccess/.project new file mode 100644 index 0000000000..07d8ab1b31 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.common.dataaccess + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.common.dataaccess/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..e23a1c7d0c --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Tue Sep 18 14:46:02 CDT 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.dataaccess/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..7982f9fe8f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Dataaccess +Bundle-SymbolicName: com.raytheon.uf.common.dataaccess +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: RAYTHEON +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: com.raytheon.uf.common.time;visibility:=reexport, + com.raytheon.uf.common.datastorage, + com.raytheon.uf.common.geospatial;visibility:=reexport, + javax.measure;bundle-version="1.0.0", + com.raytheon.uf.common.dataplugin.level;visibility:=reexport +Export-Package: com.raytheon.uf.common.dataaccess, + com.raytheon.uf.common.dataaccess.exception, + com.raytheon.uf.common.dataaccess.geom, + com.raytheon.uf.common.dataaccess.grid, + com.raytheon.uf.common.dataaccess.impl diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/build.properties b/edexOsgi/com.raytheon.uf.common.dataaccess/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/res/spring/dataaccess-common.xml b/edexOsgi/com.raytheon.uf.common.dataaccess/res/spring/dataaccess-common.xml new file mode 100644 index 0000000000..1a7c87f3e0 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/res/spring/dataaccess-common.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/DataAccessLayer.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/DataAccessLayer.java new file mode 100644 index 0000000000..bb52712bfc --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/DataAccessLayer.java @@ -0,0 +1,165 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess; + +import org.geotools.coverage.grid.GridGeometry2D; + +import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException; +import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException; +import com.raytheon.uf.common.dataaccess.geom.IGeometryDataFactory; +import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest; +import com.raytheon.uf.common.dataaccess.grid.IGridDataFactory; +import com.raytheon.uf.common.dataaccess.grid.IGridRequest; +import com.raytheon.uf.common.time.BinOffset; +import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.common.time.TimeRange; + +/** + * The Data Access Layer is the published API for getting data through the Data + * Access Framework. Code from other components should go through these methods + * to retrieve the data. All methods may potentially throw + * UnsupportedOperationException or IllegalArgumentException dependent on how + * much support has been provided per datatype. + * + * The implementation of this class is a retrieval of the corresponding factory + * and then delegating the processing to that factory. All the generics that + * exist in this implementation are to save the caller from the hassle of + * casting what is returned. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 24, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class DataAccessLayer { + + /** + * Gets the times of available data to the request + * + * @param request + * the request to find available times for + * @return the available times that match the request + * @throws TimeAgnosticDataException + */ + public static , D extends IData> DataTime[] getAvailableTimes( + R request) { + IDataFactory factory = getFactory(request); + return factory.getAvailableTimes(request); + } + + /** + * Gets the times of available data to the request with a BinOffset applied + * + * @param request + * the request to find available times for + * @param binOffset + * the BinOffset to apply + * @return the available times with the bin offset applied that match the + * request + * @throws TimeAgnosticDataException + */ + public static , D extends IData> DataTime[] getAvailableTimes( + R request, BinOffset binOffset) { + IDataFactory factory = getFactory(request); + return factory.getAvailableTimes(request, binOffset); + } + + /** + * Gets the data that matches the request at the specified times. If data is + * time agnostic then simply don't pass in any DataTimes, for example + * DataAccessLayer.getData(R) + * + * @param request + * the request to get data for + * @param times + * the times to get data for + * @return the data that matches the request and times + */ + public static , D extends IData> D[] getData( + R request, DataTime... times) { + IDataFactory factory = getFactory(request); + return factory.getData(request, times); + } + + /** + * Gets the data that matches the request within the time range + * + * @param request + * the request to get data for + * @param timeRange + * the time range to get data for + * @return the data that matches the request and time range + */ + public static , D extends IData> D[] getData( + R request, TimeRange timeRange) { + IDataFactory factory = getFactory(request); + return factory.getData(request, timeRange); + } + + /** + * Gets the grid geometry of the data matching the request without actually + * requesting the data. Useful for then making slab/subgrid/line requests by + * setting the storage request parameter on an IGridRequest. + * + * @param request + * the request to get the grid geometry of the data for + * @return the geometry of the data if the data was requested + */ + public static GridGeometry2D getGridGeometry(IGridRequest request) { + IGridDataFactory factory = (IGridDataFactory) getFactory(request); + return factory.getGeometry(request); + } + + /** + * Gets the available location names that match the request without actually + * requesting the data. + * + * @param request + * @return the available location names if the data was requested + */ + public static String[] getAvailableLocationNames(IGeometryRequest request) { + IGeometryDataFactory factory = (IGeometryDataFactory) getFactory(request); + return factory.getAvailableLocationNames(request); + } + + /** + * TODO: contemplate making this public to allow for special case handling + * Returns the factory that should process the request. Will never return + * null, will instead throw exceptions. + * + * @param request + * @return the factory that matches the request + * @throws DataFactoryNotFoundException + */ + private static , D extends IData> IDataFactory getFactory( + R request) { + return DataFactoryRegistry.getInstance().getFactory(request); + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/DataFactoryRegistry.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/DataFactoryRegistry.java new file mode 100644 index 0000000000..98448f8e1c --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/DataFactoryRegistry.java @@ -0,0 +1,143 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import com.raytheon.uf.common.dataaccess.exception.DataFactoryNotFoundException; + +/** + * Registry containing the support for different datatypes in the Data Access + * Framework. The registry maps a datatype name/key to a request type + * (IGridRequest vs IGeometryRequest) and the corresponding factory to support + * that request type. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 10, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class DataFactoryRegistry { + + private Map>, IDataFactory>> datatypeMap; + + private static DataFactoryRegistry instance; + + /** + * Constructor + */ + private DataFactoryRegistry() { + datatypeMap = new HashMap>, IDataFactory>>(); + } + + /** + * Returns the instance of the DataFactoryRegistry + * + * @return + */ + public static DataFactoryRegistry getInstance() { + if (instance == null) { + instance = new DataFactoryRegistry(); + } + return instance; + } + + /** + * Registers a datatype name with a request type and the supporting factory. + * Should only be called from spring. + * + * @param datatype + * the datatype name that will become the key for requests' + * datatypes + * @param requestType + * IGridRequest vs IGeometryRequest + * @param factory + * the factory that will support requests of this datatype and + * type + */ + public void register(String datatype, Class> requestType, + IDataFactory factory) { + Map>, IDataFactory> requestTypeMap = datatypeMap + .get(datatype); + if (requestTypeMap == null) { + requestTypeMap = new HashMap>, IDataFactory>(); + datatypeMap.put(datatype, requestTypeMap); + } + requestTypeMap.put(requestType, factory); + } + + /** + * Returns the factory that should process the request. Will never return + * null and will instead throw an exception if no registered factories + * match. + * + * @param request + * the request to find a matching factory for + * @return the factory that is registered to process the request + * @throws DataFactoryNotFoundException + * @throws IllegalArgumentException + */ + @SuppressWarnings("unchecked") + public , D extends IData> IDataFactory getFactory( + R request) { + String datatype = request.getDatatype(); + if (datatype != null) { + Map>, IDataFactory> requestTypeMap = datatypeMap + .get(datatype); + if (requestTypeMap != null) { + IDataFactory factory = null; + for (Entry>, IDataFactory> entry : requestTypeMap + .entrySet()) { + if (entry.getKey().isInstance(request)) { + factory = entry.getValue(); + break; + } + } + if (factory != null) { + return (IDataFactory) factory; + } else { + throw new DataFactoryNotFoundException( + "No data access support for requests of datatype " + + datatype + " and type " + + request.getClass()); + } + } else { + throw new DataFactoryNotFoundException( + "No data access support registered to datatype key: " + + datatype); + } + } else { + throw new IllegalArgumentException( + "Request must have a datatype set"); + } + + } +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/IData.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/IData.java new file mode 100644 index 0000000000..65279f2bab --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/IData.java @@ -0,0 +1,67 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess; + +import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.time.DataTime; + +/** + * An IData represents the bare minimum of any piece of data, namely that it can + * have attributes, a time, and a level. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 10, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public interface IData { + + /** + * Gets an attribute of the data based on the key. + * + * @param key + * @return the attribute + */ + public Object getAttribute(String key); + + /** + * Gets the DataTime of the data. May be null if the data is time agnostic. + * + * @return the time of the data, possibly null for some data types + */ + public DataTime getDataTime(); + + /** + * Gets the level of the data. May be null depending on the datatype. + * + * @return the level of the data, possibly null for some data types + */ + public Level getLevel(); + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/IDataFactory.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/IDataFactory.java new file mode 100644 index 0000000000..7e77767f7a --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/IDataFactory.java @@ -0,0 +1,116 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess; + +import com.raytheon.uf.common.dataaccess.exception.TimeAgnosticDataException; +import com.raytheon.uf.common.time.BinOffset; +import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.common.time.TimeRange; + +/** + * Factory interface for producing data objects that implement IData, hiding the + * details of the underlying data implementation object and how it was + * retrieved. + * + * Implementations of IDataFactory should strive to handle all their processing + * based on the request interface that was received. If at all possible, they + * should not cast the request to a specific request implementation, ensuring + * that they will work with multiple request implementations. + * + * The return types of the getData() methods should be geared towards returning + * what a caller of the API would expect. For example, a request for county + * polygons may not explicitly request that it wants the US state name as an + * attribute on the returned object. However, a caller could reasonably expect + * when requesting counties that the returned object includes state name. This + * must be balanced carefully since a caller of the API does not see the factory + * implementation but has expectations about what will be returned. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 10, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + * @param + */ + +public interface IDataFactory, D extends IData> { + + /** + * Gets the available times that match the request. Implementations should + * throw TimeAgnosticDataException if the datatype is time agnostic. + * + * @param request + * the request to find matching times for + * @return the times that have data available for this request + * @throws TimeAgnosticDataException + */ + public DataTime[] getAvailableTimes(R request) + throws TimeAgnosticDataException; + + /** + * Gets the available times that match the request within the BinOffset. + * Implementations should throw TimeAgnosticDataException if the datatype is + * time agnostic. + * + * @param request + * the request to find matching times for + * @param binOffset + * the bin offset to limit the returned times + * @return the times with the bin offset applied that have data available + * for this request + * @throws TimeAgnosticDataException + */ + public DataTime[] getAvailableTimes(R request, BinOffset binOffset) + throws TimeAgnosticDataException; + + /** + * Gets the available data that matches the request at the specified times. + * If data is time agnostic, use getData(R). + * + * @param request + * the request to get matching data for + * @param times + * the times to get data for. If data is time agnostic, use + * getData(R) + * @return the data that matches the request at the specified times + */ + public D[] getData(R request, DataTime... times); + + /** + * Gets the available data that matches the request and is within the time + * range. If data is time agnostic, use getData(R). + * + * @param request + * the request to get matching data for + * @param timeRange + * the time range to return data for. If data is time agnostic, + * use getData(R). + * @return the data that matches the request within the time range + */ + public D[] getData(R request, TimeRange timeRange); + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/IDataRequest.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/IDataRequest.java new file mode 100644 index 0000000000..99eaee65a8 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/IDataRequest.java @@ -0,0 +1,113 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess; + +import java.util.Map; + +import com.raytheon.uf.common.dataplugin.level.Level; + +/** + * A generic request for geospatial data to the Data Access Framework. All + * requests must have a datatype set. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 10, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public interface IDataRequest { + + /** + * The datatype of the data, usually the pluginName. This value will be used + * as a key to determine the corresponding IDataFactory that should process + * the request. This is required to be non-null. + * + * @param datatype + * the datatype of the data to request + */ + public void setDatatype(String datatype); + + /** + * Adds an identifier the factory can use to determine exactly what data is + * desired. Note that sub-interfaces may add methods for specific + * identifying characteristics. + * + * @param key + * the name of the identifier + * @param value + * the value desired on all the return data + */ + public void addIdentifier(String key, Object value); + + /** + * Sets the parameters to request of the data. + * + * @param params + * the parameters to request + */ + public void setParameters(String... params); + + /** + * Sets the levels to request of the data. Some factories may ignore this or + * throw an exception if all data is at one level. + * + * @param levels + * the levels to request + */ + public void setLevels(Level... levels); + + /** + * Returns the datatype set on the request. + * + * @return the datatype of the request + */ + public String getDatatype(); + + /** + * Returns the identifiers added to the request. + * + * @return the identifiers of the request + */ + public Map getIdentifiers(); + + /** + * Returns the parameters set on the request. + * + * @return the parameters of the request + */ + public String[] getParameters(); + + /** + * Returns the levels set on the request. + * + * @return the levels of the request + */ + public Level[] getLevels(); + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/DataAccessException.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/DataAccessException.java new file mode 100644 index 0000000000..6cc3a1ae6e --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/DataAccessException.java @@ -0,0 +1,82 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.exception; + +/** + * An exception that comes out of the Data Access Framework. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 12, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public abstract class DataAccessException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + /** + * Constructor + */ + public DataAccessException() { + + } + + /** + * Constructor + * + * @param message + * the error message + */ + public DataAccessException(String message) { + super(message); + } + + /** + * Constructor + * + * @param message + * the error message + * @param cause + * the cause of the error + */ + public DataAccessException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructor + * + * @param cause + * the cause of the error + */ + public DataAccessException(Throwable cause) { + super(cause); + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/DataFactoryNotFoundException.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/DataFactoryNotFoundException.java new file mode 100644 index 0000000000..a2d1a70f8e --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/DataFactoryNotFoundException.java @@ -0,0 +1,82 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.exception; + +/** + * An exception for when a data factory is not found to fulfill a request. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 12, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class DataFactoryNotFoundException extends DataAccessException { + + private static final long serialVersionUID = 1L; + + /** + * Constructor + */ + public DataFactoryNotFoundException() { + + } + + /** + * Constructor + * + * @param message + * the error message + */ + public DataFactoryNotFoundException(String message) { + super(message); + } + + /** + * Constructor + * + * @param message + * the error message + * @param cause + * the cause of the error + */ + public DataFactoryNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructor + * + * @param cause + * the cause of the error + */ + public DataFactoryNotFoundException(Throwable cause) { + super(cause); + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/EnvelopeUnsupportedException.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/EnvelopeUnsupportedException.java new file mode 100644 index 0000000000..5f36f67de0 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/EnvelopeUnsupportedException.java @@ -0,0 +1,82 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.exception; + +/** + * An exception for when the data does not support bounding envelopes. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 12, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class EnvelopeUnsupportedException extends DataAccessException { + + private static final long serialVersionUID = 1L; + + /** + * Constructor + */ + public EnvelopeUnsupportedException() { + + } + + /** + * Constructor + * + * @param message + * the error message + */ + public EnvelopeUnsupportedException(String message) { + super(message); + } + + /** + * Constructor + * + * @param message + * the error message + * @param cause + * the cause of the error + */ + public EnvelopeUnsupportedException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructor + * + * @param cause + * the cause of the error + */ + public EnvelopeUnsupportedException(Throwable cause) { + super(cause); + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/LocationNameUnsupportedException.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/LocationNameUnsupportedException.java new file mode 100644 index 0000000000..aa01959653 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/LocationNameUnsupportedException.java @@ -0,0 +1,82 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.exception; + +/** + * An exception for when the data does not support location names. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 12, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class LocationNameUnsupportedException extends DataAccessException { + + private static final long serialVersionUID = 1L; + + /** + * Constructor + */ + public LocationNameUnsupportedException() { + + } + + /** + * Constructor + * + * @param message + * the error message + */ + public LocationNameUnsupportedException(String message) { + super(message); + } + + /** + * Constructor + * + * @param message + * the error message + * @param cause + * the cause of the error + */ + public LocationNameUnsupportedException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructor + * + * @param cause + * the cause of the error + */ + public LocationNameUnsupportedException(Throwable cause) { + super(cause); + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/TimeAgnosticDataException.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/TimeAgnosticDataException.java new file mode 100644 index 0000000000..da658a2443 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/exception/TimeAgnosticDataException.java @@ -0,0 +1,83 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.exception; + +/** + * An exception for when the data is time agnostic and time requests are not + * supported. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 12, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class TimeAgnosticDataException extends DataAccessException { + + private static final long serialVersionUID = 1L; + + /** + * Constructor + */ + public TimeAgnosticDataException() { + + } + + /** + * Constructor + * + * @param message + * the error message + */ + public TimeAgnosticDataException(String message) { + super(message); + } + + /** + * Constructor + * + * @param message + * the error message + * @param cause + * the cause of the error + */ + public TimeAgnosticDataException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructor + * + * @param cause + * the cause of the error + */ + public TimeAgnosticDataException(Throwable cause) { + super(cause); + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/geom/IGeometryData.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/geom/IGeometryData.java new file mode 100644 index 0000000000..440813bd54 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/geom/IGeometryData.java @@ -0,0 +1,129 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.geom; + +import java.util.Set; + +import javax.measure.converter.ConversionException; +import javax.measure.unit.Unit; + +import com.raytheon.uf.common.dataaccess.IData; +import com.vividsolutions.jts.geom.Geometry; + +/** + * An IGeometryData represents data of potentially multiple parameters + * associated with a single geometry, typically a point or polygon, at a single + * level. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 10, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public interface IGeometryData extends IData { + + public static enum Type { + STRING, INT, LONG, FLOAT, DOUBLE; + }; + + /** + * Gets the geometry associated with this instance of data. The geometry + * coordinates are in Lat/Lon space. + * + * @return the geometry of the data + */ + public Geometry getGeometry(); + + /** + * Gets the list of parameters associated with this instance of data + * + * @return the parameters on this instance of data + */ + public Set getParameters(); + + /** + * Gets the string value of a particular parameter. + * + * @param param + * the parameter to get the value of + * @return the string value of the parameter + */ + public String getString(String param); + + /** + * Gets the number value of a particular parameter + * + * @param param + * the parameter to get the value of + * @return the number value of the parameter + */ + public Number getNumber(String param); + + /** + * Gets the number value of a particular parameter converted to the + * specified unit. Will throw ConversionException if the units are + * incompatible or the data has no unit. + * + * @param param + * the parameter to get the value of + * @param unit + * the unit to get the value as + * @return the number value of a parameter, converted to the specified unit + * @throws ConversionException + */ + public Number getNumber(String param, Unit unit) + throws ConversionException; + + /** + * Gets the unit associated with a particular parameter. May be null. + * + * @param param + * the parameter to get the unit of + * @return the unit of the parameter + */ + public Unit getUnit(String param); + + /** + * Gets the type of a particular parameter. + * + * @param param + * the parameter to get the type of + * @return the type as specified in IGeometryData.type + */ + public Type getType(String param); + + /** + * Gets the location name associated with this instance of IData. May be + * null. + * + * @return the location name or null + */ + public String getLocationName(); + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/geom/IGeometryDataFactory.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/geom/IGeometryDataFactory.java new file mode 100644 index 0000000000..ed50d996a8 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/geom/IGeometryDataFactory.java @@ -0,0 +1,58 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.geom; + +import com.raytheon.uf.common.dataaccess.IDataFactory; +import com.raytheon.uf.common.dataaccess.exception.LocationNameUnsupportedException; + +/** + * IDataFactory for any data that is non-gridded, for example points or + * polygons. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 10, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public interface IGeometryDataFactory extends + IDataFactory { + + /** + * Gets the available location names that match the request. Implementations + * should throw LocationNameUnsupportedException if location names do not + * apply to their datatype. + * + * @param request + * the request to find matching location names for + * @return the available location names that match the request + */ + public String[] getAvailableLocationNames(IGeometryRequest request) + throws LocationNameUnsupportedException; + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/geom/IGeometryRequest.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/geom/IGeometryRequest.java new file mode 100644 index 0000000000..aaf9331001 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/geom/IGeometryRequest.java @@ -0,0 +1,83 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.geom; + +import com.raytheon.uf.common.dataaccess.IDataRequest; +import com.vividsolutions.jts.geom.Envelope; + +/** + * A request for any data type that is non-gridded and can be represented by a + * geometry. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 10, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public interface IGeometryRequest extends IDataRequest { + + /** + * Sets a bounding box on the request to limit the area of the request. The + * envelope coordinates should be in Lat/Lon space. Note that not all + * factories may support the envelope and instead may throw an + * EnvelopeUnsupportedException or ignore the envelope. + * + * @param env + * the envelope to constrain the request + */ + public void setEnvelope(Envelope env); + + /** + * Returns the envelope set on the request. + * + * @return the envelope set on the request + */ + public Envelope getEnvelope(); + + /** + * Sets a list of location names to limit what is returned. Each datatype + * may have its own mapping of what a location is (e.g. ICAO vs stationId vs + * radar name, etc). Possible location names can be retrieved by using the + * method getAvailableLocationNames(IGeometryRequest) on the DataAccessLayer + * or IGeometryDataFactory. Note that not all factories may support requests + * by location names and instead may throw a + * LocationNameUnsupportedException or ignore the location names. + * + * @param locationNames + */ + public void setLocationNames(String... locationNames); + + /** + * Returns the location names set on the request. + * + * @return + */ + public String[] getLocationNames(); + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/grid/IGridData.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/grid/IGridData.java new file mode 100644 index 0000000000..fe8d210094 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/grid/IGridData.java @@ -0,0 +1,93 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.grid; + +import javax.measure.unit.Unit; + +import org.geotools.coverage.grid.GridGeometry2D; + +import com.raytheon.uf.common.dataaccess.IData; +import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.geospatial.interpolation.data.DataDestination; +import com.raytheon.uf.common.geospatial.interpolation.data.UnitConvertingDataDestination; + +/** + * An IGridData represents data that is gridded, ie rectangular (when not + * projected) with a set x and y size. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 9, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public interface IGridData extends IData { + + /** + * Gets the parameter of the data + * + * @return the parameter of the data + */ + public String getParameter(); + + /** + * Gets the level of the data + * + * @return the level of the data + */ + public Level getLevel(); + + /** + * Gets the GridGeometry of the data + * + * @return the grid geometry of the data + */ + public GridGeometry2D getGridGeometry(); + + /** + * Gets the unit of the raw data. This may differ from the unit of a data + * destination. + * + * @return the unit of the data + */ + public Unit getUnit(); + + /** + * Populates the DataDestination argument with the raw data converted to the + * type to match the DataDestination. The destination must not be null. If + * unit conversions are desired, use the + * {@link UnitConvertingDataDestination} to specify what unit conversion + * should be applied to the data. + * + * @param destination + * the destination to fill with data + * @return the data destination that was passed in, with the data populated + */ + public
DD populateData(DD destination); + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/grid/IGridDataFactory.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/grid/IGridDataFactory.java new file mode 100644 index 0000000000..2dd85c13c8 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/grid/IGridDataFactory.java @@ -0,0 +1,60 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.grid; + +import org.geotools.coverage.grid.GridGeometry2D; + +import com.raytheon.uf.common.dataaccess.IDataFactory; + +/** + * IDataFactory interface for two dimensional gridded data. Note that IGridData + * has the populateData() methods, therefore the implementations of this + * interface can choose to either retrieve the raw data when factory.getData() + * is called, or have the implementation of IGridData retrieve the raw data when + * populateData() is called. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 9, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public interface IGridDataFactory extends IDataFactory { + + /** + * Gets the GridGeometry2D that matches the request. Useful for determining + * the area before requesting the data. + * + * @param request + * the request to get the geometry for + * @return the grid geometry of the data that would be returned from this + * request + */ + public GridGeometry2D getGeometry(IGridRequest request); + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/grid/IGridRequest.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/grid/IGridRequest.java new file mode 100644 index 0000000000..f52931ee47 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/grid/IGridRequest.java @@ -0,0 +1,61 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.grid; + +import com.raytheon.uf.common.dataaccess.IDataRequest; +import com.raytheon.uf.common.datastorage.Request; + +/** + * A request for gridded data. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Oct 9, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public interface IGridRequest extends IDataRequest { + + /** + * Sets a storage request as part of the request. If null, the entire + * dataset will be retrieved. Useful for slab requests to avoid retrieving + * the entire dataset and boost performance in some scenarios. + * + * @param request + * the {@link Request} to limit the data returned + */ + public void setStorageRequest(Request request); + + /** + * Gets the storage request set on the request. + * + * @return the {@link Request} set on the IGridRequest + */ + public Request getStorageRequest(); + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/AbstractDataRequest.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/AbstractDataRequest.java new file mode 100644 index 0000000000..e5cc5eacc0 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/AbstractDataRequest.java @@ -0,0 +1,90 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.impl; + +import java.util.HashMap; +import java.util.Map; + +import com.raytheon.uf.common.dataplugin.level.Level; + +/** + * + * An abstract request for requesting data through the Data Access Framework. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 6, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public abstract class AbstractDataRequest { + + protected String datatype; + + protected Map identifiers; + + protected String[] parameters; + + protected Level[] levels; + + public void setDatatype(String datatype) { + this.datatype = datatype; + } + + public void addIdentifier(String key, Object value) { + if (identifiers == null) { + identifiers = new HashMap(); + } + identifiers.put(key, value); + } + + public void setParameters(String... params) { + this.parameters = params; + } + + public void setLevels(Level... levels) { + this.levels = levels; + } + + public String getDatatype() { + return datatype; + } + + public Map getIdentifiers() { + return identifiers; + } + + public String[] getParameters() { + return parameters; + } + + public Level[] getLevels() { + return levels; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGeometryData.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGeometryData.java new file mode 100644 index 0000000000..a2c83afd68 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGeometryData.java @@ -0,0 +1,223 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.impl; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.measure.converter.ConversionException; +import javax.measure.unit.Unit; + +import com.raytheon.uf.common.dataaccess.geom.IGeometryData; +import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.time.DataTime; +import com.vividsolutions.jts.geom.Geometry; + +/** + * A default geometry data object if factory developers do not wish to create + * their own IGeometryData implementations. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 9, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class DefaultGeometryData implements IGeometryData { + + /** + * A simple object to hold a value, type, and unit of a parameter + */ + public class GeomData { + private Object value; + + private Type type; + + private Unit unit; + } + + protected Map dataMap = new HashMap(); + + protected DataTime time; + + protected Level level; + + protected Geometry geometry; + + protected String locationName; + + protected Map attributes; + + @Override + public Object getAttribute(String key) { + Object result = null; + if (attributes != null) { + result = attributes.get(key); + } + return result; + } + + @Override + public DataTime getDataTime() { + return time; + } + + @Override + public Level getLevel() { + return level; + } + + @Override + public Geometry getGeometry() { + return geometry; + } + + @Override + public Set getParameters() { + return dataMap.keySet(); + } + + @Override + public String getString(String param) { + String result = null; + GeomData data = dataMap.get(param); + if (data != null) { + result = data.value.toString(); + } + return result; + } + + @Override + public Number getNumber(String param) { + Number result = null; + GeomData data = dataMap.get(param); + if (data != null) { + switch (data.type) { + case STRING: + result = Double.valueOf((String) data.value); + break; + case INT: + result = (Integer) data.value; + break; + case LONG: + result = (Long) data.value; + break; + case FLOAT: + result = (Float) data.value; + break; + case DOUBLE: + result = (Double) data.value; + break; + default: + throw new UnsupportedOperationException( + "Unable to handle data of type " + + data.value.getClass()); + } + } + return result; + } + + @Override + public Number getNumber(String param, Unit unit) { + Number result = null; + if (unit == null) { + throw new IllegalArgumentException( + "Unable to convert data to null unit"); + } + GeomData data = dataMap.get(param); + if (data != null) { + if (data.unit != null) { + if (data.unit.isCompatible(unit)) { + Number orig = getNumber(param); + result = data.unit.getConverterTo(unit).convert( + orig.doubleValue()); + } else { + throw new ConversionException("Requested unit " + unit + + " is incompatible with " + param + + " data's unit " + data.unit); + } + } else { + throw new ConversionException( + "Unable to convert data due to no unit associated with " + + param); + } + } + return result; + } + + @Override + public Unit getUnit(String param) { + Unit result = null; + GeomData data = dataMap.get(param); + if (data != null) { + result = data.unit; + } + return result; + } + + @Override + public Type getType(String param) { + Type result = null; + GeomData data = dataMap.get(param); + if (data != null) { + result = data.type; + } + return result; + } + + @Override + public String getLocationName() { + return locationName; + } + + public void addData(String parameter, GeomData data) { + this.dataMap.put(parameter, data); + } + + public void setGeometry(Geometry geom) { + this.geometry = geom; + } + + public void setLevel(Level level) { + this.level = level; + } + + public void setDataTime(DataTime time) { + this.time = time; + } + + public void setLocationName(String locationName) { + this.locationName = locationName; + } + + public void setAttributes(Map attrs) { + this.attributes = attrs; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGeometryRequest.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGeometryRequest.java new file mode 100644 index 0000000000..b67d782180 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGeometryRequest.java @@ -0,0 +1,70 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.impl; + +import com.raytheon.uf.common.dataaccess.geom.IGeometryRequest; +import com.vividsolutions.jts.geom.Envelope; + +/** + * A default IGeometryRequest that can be used for most IGeometryRequests. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 5, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class DefaultGeometryRequest extends AbstractDataRequest implements + IGeometryRequest { + + protected Envelope envelope; + + protected String[] locationNames; + + @Override + public void setEnvelope(Envelope env) { + this.envelope = env; + } + + @Override + public Envelope getEnvelope() { + return envelope; + } + + @Override + public void setLocationNames(String... locationNames) { + this.locationNames = locationNames; + + } + + @Override + public String[] getLocationNames() { + return locationNames; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGridData.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGridData.java new file mode 100644 index 0000000000..654f1df779 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGridData.java @@ -0,0 +1,142 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.impl; + +import java.util.Map; + +import javax.measure.unit.Unit; + +import org.geotools.coverage.grid.GridGeometry2D; + +import com.raytheon.uf.common.dataaccess.grid.IGridData; +import com.raytheon.uf.common.dataplugin.level.Level; +import com.raytheon.uf.common.geospatial.interpolation.data.DataDestination; +import com.raytheon.uf.common.geospatial.interpolation.data.DataSource; +import com.raytheon.uf.common.time.DataTime; + +/** + * A default grid data object if factory developers do not wish to create their + * own IGridData implementations. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 5, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class DefaultGridData implements IGridData { + + protected DataSource data; + + protected DataTime time; + + protected String parameter; + + protected Level level; + + protected Unit unit; + + protected GridGeometry2D gridGeometry; + + protected Map attributes; + + public DefaultGridData(DataSource data, GridGeometry2D gridGeometry) { + this.data = data; + this.gridGeometry = gridGeometry; + } + + @Override + public Object getAttribute(String key) { + Object result = null; + if (attributes != null) { + result = attributes.get(key); + } + return result; + } + + @Override + public DataTime getDataTime() { + return time; + } + + @Override + public String getParameter() { + return parameter; + } + + @Override + public Level getLevel() { + return level; + } + + @Override + public GridGeometry2D getGridGeometry() { + return gridGeometry; + } + + @Override + public Unit getUnit() { + return unit; + } + + @Override + public DataDestination populateData(DataDestination destination) { + if (destination == null) { + throw new IllegalArgumentException( + "Data destination must not be null"); + } + + for (int x = 0; x < gridGeometry.axisDimensionX; x++) { + for (int y = 0; y < gridGeometry.axisDimensionY; y++) { + destination.setDataValue(data.getDataValue(x, y), x, y); + } + } + return destination; + } + + public void setDataTime(DataTime time) { + this.time = time; + } + + public void setParameter(String parameter) { + this.parameter = parameter; + } + + public void setLevel(Level level) { + this.level = level; + } + + public void setUnit(Unit unit) { + this.unit = unit; + } + + public void setAttributes(Map attrs) { + this.attributes = attrs; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGridRequest.java b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGridRequest.java new file mode 100644 index 0000000000..ef497d32c6 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.dataaccess/src/com/raytheon/uf/common/dataaccess/impl/DefaultGridRequest.java @@ -0,0 +1,57 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.dataaccess.impl; + +import com.raytheon.uf.common.dataaccess.grid.IGridRequest; +import com.raytheon.uf.common.datastorage.Request; + +/** + * A default IGridRequest that can be used for most IGridRequests. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 5, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class DefaultGridRequest extends AbstractDataRequest implements + IGridRequest { + + protected Request storageRequest; + + @Override + public void setStorageRequest(Request request) { + this.storageRequest = request; + } + + @Override + public Request getStorageRequest() { + return this.storageRequest; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/data/IntArrayWrapper.java b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/data/IntArrayWrapper.java new file mode 100644 index 0000000000..bcf8093239 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/data/IntArrayWrapper.java @@ -0,0 +1,80 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.geospatial.interpolation.data; + +import org.geotools.coverage.grid.GeneralGridGeometry; + +/** + * Wraps an int array as a {@link DataSource} and {@link DataDestination} + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 5, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class IntArrayWrapper extends DataWrapper1D { + + protected final int[] array; + + public IntArrayWrapper(int[] array, GeneralGridGeometry geometry) { + super(geometry); + this.array = array; + } + + public IntArrayWrapper(int[] array, int nx, int ny) { + super(nx, ny); + this.array = array; + } + + public IntArrayWrapper(int nx, int ny) { + this(new int[nx * ny], nx, ny); + } + + public IntArrayWrapper(GeneralGridGeometry geometry) { + // assume this is going to be a destination and avoid passing + // geometry to super to save time on checking for wrapping. + this(geometry.getGridRange().getSpan(0), geometry.getGridRange() + .getSpan(1)); + } + + public int[] getArray() { + return array; + } + + @Override + protected double getDataValueInternal(int index) { + return array[index]; + } + + @Override + protected void setDataValueInternal(double dataValue, int index) { + array[index] = (int) dataValue; + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/data/UnitConvertingDataDestination.java b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/data/UnitConvertingDataDestination.java new file mode 100644 index 0000000000..093669023e --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/data/UnitConvertingDataDestination.java @@ -0,0 +1,67 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.geospatial.interpolation.data; + +import javax.measure.converter.UnitConverter; + +/** + * A data destination that converts to a unit with the specified unit converter; + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 12, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class UnitConvertingDataDestination implements DataDestination { + + protected UnitConverter unitConverter; + + protected DataDestination wrappedDestination; + + /** + * Constructor + * + * @param converter + * the unit converter to apply when setting the values in the + * destination + * @param destination + * the destination to set values on + */ + public UnitConvertingDataDestination(UnitConverter converter, + DataDestination destination) { + this.unitConverter = converter; + this.wrappedDestination = destination; + } + + @Override + public void setDataValue(double dataValue, int x, int y) { + wrappedDestination.setDataValue(unitConverter.convert(dataValue), x, y); + } + +} diff --git a/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/data/UnitConvertingDataSource.java b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/data/UnitConvertingDataSource.java new file mode 100644 index 0000000000..587e4953ca --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.geospatial/src/com/raytheon/uf/common/geospatial/interpolation/data/UnitConvertingDataSource.java @@ -0,0 +1,67 @@ +/** + * 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. + **/ +package com.raytheon.uf.common.geospatial.interpolation.data; + +import javax.measure.converter.UnitConverter; + +/** + * A data source that converts requested values to a unit with the specified + * converter. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 12, 2012            njensen     Initial creation
+ * 
+ * 
+ * + * @author njensen + * @version 1.0 + */ + +public class UnitConvertingDataSource implements DataSource { + + protected UnitConverter unitConverter; + + protected DataSource wrappedSource; + + /** + * Constructor + * + * @param converter + * the unit converter to apply when getting the values in the + * data source + * @param source + * the source to get values from + */ + public UnitConvertingDataSource(UnitConverter converter, DataSource source) { + this.unitConverter = converter; + this.wrappedSource = source; + } + + @Override + public double getDataValue(int x, int y) { + return unitConverter.convert(wrappedSource.getDataValue(x, y)); + } + +}