net.agmodel.weatherData
Class MetBrokerHTTP

java.lang.Object
  |
  +--net.agmodel.genericBroker.ServiceHTTP
        |
        +--net.agmodel.genericBroker.ServerHTTP
              |
              +--net.agmodel.genericBroker.GenericBrokerHTTP
                    |
                    +--net.agmodel.weatherData.MetBrokerHTTP

public class MetBrokerHTTP
extends GenericBrokerHTTP

Handles:
database connections,
requests for details of databases and weather stations, and
requests for weather data.

Typically a client establishes a MetBroker session through a call to ServerHTTP.getConnection(String,String).
The session manages connections to data sources, and also provides lists of available MetDataSources. MetBroker decides how to deal with requests for met data either from single stations, or over geographical only exists for the duration of a user session, and doesn't serve any other clients.


Field Summary
static int GETMETCATALOG
           
static int GETREGION
           
static int GETSTATION
           
static int GETSTATIONREGION
           
static String HTTPHOSTPARAM
           
static String HTTPPORTPARAM
           
static int LISTALLSTATIONS
           
static int LISTREGIONSFORMETSOURCE
           
static int LISTSTATIONSFORQUERY
           
static int LISTSTATIONSFORREGION
           
static int SUPPLYSPATIALDATA
           
static int SUPPLYSTATIONDATA
           
 
Fields inherited from class net.agmodel.genericBroker.GenericBrokerHTTP
ALREADYLOGGEDIN, GETSOURCEDETAIL, LISTSOURCES, LISTSOURCESINREGION, LOGIN, LOGINWITHEMAIL, LOGINWITHPASSWORD, LOGOUTALLSOURCES, LOGOUTOFSOURCE
 
Fields inherited from class net.agmodel.genericBroker.ServerHTTP
CONNECT, CONNECTUSER, DISCONNECT
 
Fields inherited from class net.agmodel.genericBroker.ServiceHTTP
HOSTPARAMEXTENSION, PORTPARAMEXTENSION, servlet
 
Constructor Summary
MetBrokerHTTP(String host)
           
MetBrokerHTTP(String host, int port)
           
 
Method Summary
 boolean[][] getMetCatalog(String sessionID, String metSourceID, String stationID)
          Check whether a station has ever recorded an element at a particular resolution.
 MetSourceDetail getMetSourceDetail(String sessionID, String metSourceID)
          Gets details about the MetSource in one object.
 Region getRegion(String sessionID, String metSourceID, String regionID)
          Gets details of a region associated with a data source.
protected  String getServletPath()
           
 String getStationRegionID(String sessionID, String metSourceID, String stationID)
          Get the weather station's current region ID.
 WeatherStation getWeatherStation(String sessionID, String metSourceID, String stationID)
          Get the details of the weather station
 WeatherStation[] listMatchingStations(String sessionID, SpatialMetRequest request)
          Get an array of all the stations that can potentially contribute to the request To contribute, stations must fall within the area specified in the request, and record elements requested, and have operated at some point during the period of interest of the request.
 MetSourceDetail[] listMetSourceDetails(String sessionID)
          Get the details for all the MetSources in MetBroker.
 MetSourceDetail[] listMetSourceDetails(String sessionID, GeographicalArea ofInterest)
          Get the details of the MetSources in MetBroker that coincide with the area specified.
 Region[] listRegions(String sessionID, String metSourceID)
          Get a list of all regions for which the database holds data.
 WeatherStation[] listStations(String sessionID, String metSourceID)
          Get an array of all the stations in a source.
 WeatherStation[] listStations(String sessionID, String metSourceID, String regionID)
          Get an array of all the stations in a database region.
 boolean loginToMetDataSource(String sessionID, String sourceID, String usercode, String password)
          Establish a connection to the specified database using the usercode and password supplied.
 SpatialMetSet supplyMetData(String sessionID, SpatialMetRequest request)
          Get the relevant data from multiple stations.
 StationDataSet supplyMetData(String sessionID, StationMetRequest request)
          Get the relevant data from a single station.
 
Methods inherited from class net.agmodel.genericBroker.GenericBrokerHTTP
alreadyLoggedIn, getSourceDetail, listSourceDetails, listSourceDetails, loginToDataSource, loginToDataSource, loginToDataSource, logOutOfAllSources, logOutOfSource, supplyData
 
Methods inherited from class net.agmodel.genericBroker.ServerHTTP
disconnect, getConnection, getConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LISTREGIONSFORMETSOURCE

public static final int LISTREGIONSFORMETSOURCE
See Also:
Constant Field Values

LISTSTATIONSFORREGION

public static final int LISTSTATIONSFORREGION
See Also:
Constant Field Values

LISTALLSTATIONS

public static final int LISTALLSTATIONS
See Also:
Constant Field Values

GETMETCATALOG

public static final int GETMETCATALOG
See Also:
Constant Field Values

GETSTATIONREGION

public static final int GETSTATIONREGION
See Also:
Constant Field Values

SUPPLYSTATIONDATA

public static final int SUPPLYSTATIONDATA
See Also:
Constant Field Values

SUPPLYSPATIALDATA

public static final int SUPPLYSPATIALDATA
See Also:
Constant Field Values

LISTSTATIONSFORQUERY

public static final int LISTSTATIONSFORQUERY
See Also:
Constant Field Values

GETREGION

public static final int GETREGION
See Also:
Constant Field Values

GETSTATION

public static final int GETSTATION
See Also:
Constant Field Values

HTTPHOSTPARAM

public static final String HTTPHOSTPARAM
See Also:
Constant Field Values

HTTPPORTPARAM

public static final String HTTPPORTPARAM
See Also:
Constant Field Values
Constructor Detail

MetBrokerHTTP

public MetBrokerHTTP(String host,
                     int port)
              throws GeneralException

MetBrokerHTTP

public MetBrokerHTTP(String host)
              throws GeneralException
Method Detail

getServletPath

protected String getServletPath()
Specified by:
getServletPath in class ServiceHTTP

getStationRegionID

public String getStationRegionID(String sessionID,
                                 String metSourceID,
                                 String stationID)
                          throws GeneralException
Get the weather station's current region ID.

Parameters:
sessionID - the ID returned by getConnection
metSourceID - the identifier assigned to the source by MetBroker
stationID - the identifier for the station used by the host database.
Returns:
the ID of the region that the station is currently under, or null if no reqions are used
GeneralException

listMetSourceDetails

public MetSourceDetail[] listMetSourceDetails(String sessionID)
                                       throws GeneralException
Get the details for all the MetSources in MetBroker.

Parameters:
sessionID - the ID returned by getConnection
Returns:
a list of sources
GeneralException

listMetSourceDetails

public MetSourceDetail[] listMetSourceDetails(String sessionID,
                                              GeographicalArea ofInterest)
                                       throws GeneralException
Get the details of the MetSources in MetBroker that coincide with the area specified.

Parameters:
sessionID - the ID returned by getConnection
ofInterest - the area from which weather data is required
Returns:
a list of sources whose GeographicalAreas overlap with the area of Interest
GeneralException
See Also:
for a generic version

getMetSourceDetail

public MetSourceDetail getMetSourceDetail(String sessionID,
                                          String metSourceID)
                                   throws GeneralException
Gets details about the MetSource in one object.

Parameters:
sessionID - the ID returned by getConnection
Returns:
the database details
Throws:
IllegalArgumentException - if the language is not known
GeneralException
See Also:
for a generic version

loginToMetDataSource

public boolean loginToMetDataSource(String sessionID,
                                    String sourceID,
                                    String usercode,
                                    String password)
                             throws GeneralException
Establish a connection to the specified database using the usercode and password supplied.

Parameters:
sessionID - the ID returned by getConnection
sourceID - the identifier assigned to the source by MetBroker
usercode - a valid usercode on the source
password - the corresponding password (warning - may be transmitted without encryption)
Returns:
true if the MetBroker was able to log in to the source, false otherwise
GeneralException

supplyMetData

public StationDataSet supplyMetData(String sessionID,
                                    StationMetRequest request)
                             throws GeneralException
Get the relevant data from a single station.

Parameters:
sessionID - the ID returned by getConnection
request - specifies which station get data for, and what data to get
Returns:
the requested data
GeneralException

supplyMetData

public SpatialMetSet supplyMetData(String sessionID,
                                   SpatialMetRequest request)
                            throws GeneralException
Get the relevant data from multiple stations.

Parameters:
sessionID - the ID returned by getConnection
request - specifies which area to get data for, and what data to get
Returns:
the requested data
GeneralException

listRegions

public Region[] listRegions(String sessionID,
                            String metSourceID)
                     throws GeneralException
Get a list of all regions for which the database holds data.
"Region" is not precisely defined, but might be prefecture, state or county depending on the database.

Parameters:
sessionID - the ID returned by getConnection
metSourceID - the identifier for the metsource
Returns:
an array of regions, or null if the database has no "region" layer.
GeneralException

getRegion

public Region getRegion(String sessionID,
                        String metSourceID,
                        String regionID)
                 throws GeneralException
Gets details of a region associated with a data source. Note that it is more efficient to call listRegions(sessionID, metSourceID) rather than calling getRegion repeatedly.

Parameters:
sessionID - the ID returned by getConnection
metSourceID - the identifier for the metsource
regionID - the identifier for the region
Returns:
a region, or null if the database has no "region" layer or the regionID doesn't exist.
GeneralException

listStations

public WeatherStation[] listStations(String sessionID,
                                     String metSourceID)
                              throws GeneralException
Get an array of all the stations in a source.
Typically used by a client application to get a subset of the entire list of stations for a large database. If the region parameter is null, then all the MetSource's stations are returned.

Parameters:
sessionID - the ID returned by getConnection
metSourceID - the identifier for the metsource
Returns:
an array of ids for the stations which can contribute useful data
GeneralException

listStations

public WeatherStation[] listStations(String sessionID,
                                     String metSourceID,
                                     String regionID)
                              throws GeneralException
Get an array of all the stations in a database region.
Typically used by a client application to get a subset of the entire list of stations for a large database. If the region parameter is null, then all the MetSource's stations are returned.

Parameters:
sessionID - the ID returned by getConnection
metSourceID - the identifier for the metsource
regionID - specifies the region for which data is required
Returns:
an array of ids for the stations which can contribute useful data
GeneralException

getWeatherStation

public WeatherStation getWeatherStation(String sessionID,
                                        String metSourceID,
                                        String stationID)
                                 throws GeneralException
Get the details of the weather station

Parameters:
sessionID - the ID returned by getConnection
metSourceID - the identifier assigned to the source by MetBroker
stationID - the identifier for the station used by the host database.
Returns:
the details of the station such as name, location, period of operation.
GeneralException

listMatchingStations

public WeatherStation[] listMatchingStations(String sessionID,
                                             SpatialMetRequest request)
                                      throws GeneralException
Get an array of all the stations that can potentially contribute to the request To contribute, stations must fall within the area specified in the request, and record elements requested, and have operated at some point during the period of interest of the request. The resolution of the request, and whether data may be summarised or temporally interpolated are also taken into account. This method would typically be used by a client application either to display stations spatially or to get a subset of the entire list of stations for a large database.

Parameters:
sessionID - the ID returned by getConnection
request - specifies the data required
Returns:
an array of ids for the stations which can contribute useful data
GeneralException

getMetCatalog

public boolean[][] getMetCatalog(String sessionID,
                                 String metSourceID,
                                 String stationID)
                          throws GeneralException
Check whether a station has ever recorded an element at a particular resolution.

Parameters:
sessionID - the ID returned by getConnection
metSourceID - the identifier assigned to the source by MetBroker
stationID - the identifier for the station used by the host database.
Returns:
true if it has recorded the element, false if it hasn't.
GeneralException