net.agmodel.metBroker
Class MetBrokerImpl

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended byjava.rmi.server.UnicastRemoteObject
              extended bynet.agmodel.brokerImpl.GenericBrokerImpl
                  extended bynet.agmodel.metBroker.MetBrokerImpl
All Implemented Interfaces:
GenericBrokerRMI, MetBroker, Remote, Serializable, ServerRMI

public class MetBrokerImpl
extends GenericBrokerImpl
implements MetBroker

An implementation of MetBroker which maintains a list of the user's active connections

Author:
Matthew Laurenson
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class net.agmodel.brokerImpl.GenericBrokerImpl
GenericBrokerImpl.DBCheckAndUpdate
 
Field Summary
 
Fields inherited from interface net.agmodel.weatherData.MetBroker
AMEDAS, CLIDB, FAWN, GAEMN, HRI, PAWS, PREFMETDB, RMIHOSTPARAM, RMINAME, SASA
 
Fields inherited from interface net.agmodel.genericBroker.GenericBrokerRMI
EMAIL, HOSTPARAMEXTENSION, NOLOGIN, PASSWORD
 
Fields inherited from interface net.agmodel.genericBroker.ServerRMI
EXISTINGUSER, NEWUSER, SUPERUSER
 
Constructor Summary
MetBrokerImpl()
           
 
Method Summary
 String getConnection(String clientInfo, String language, String metBrokerUserName, String metBrokerPassword, int userType)
          Establishes a session for the client application.
 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.
 float getSourceSuggestedDailyOffset(String sessionID, String metSourceID)
          Provide client applications with a sensible default offset for building requests for daily data for displaying the resulting data.
 String getSourceSuggestedTimezone(String sessionID, String metSourceID)
          Provide client applications with a sensible default timezone for building requests to the database and for displaying the resulting data.
 Location getStationLocation(String sessionID, String metSourceID, String stationID)
          Get the weather station's position on the globe.
 String getStationName(String sessionID, String metSourceID, String stationID)
          Get the weather station's location's name.
 Period getStationOperational(String sessionID, String metSourceID, String stationID)
          Get the period of operation of the weather station
 String getStationRegionID(String sessionID, String metSourceID, String stationID)
          Get the weather station's current region ID.
 String getStationReport(String sessionID, String metSourceID, String stationID)
          Provide a description of the station and the data it holds
 WeatherStation getWeatherStation(String sessionID, String metSourceID, String stationID)
          Get the details of the weather station
 String[] listMatchingStationIDs(String sessionID, String metSourceID, SpatialMetRequest request)
           
 WeatherStation[] listMatchingStations(String sessionID, SpatialMetRequest request)
          Get an array of all the stations that can potentially contribute to 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.
 String[] listMetSources(String sessionID)
          Get the IDs for all the MetSources in MetBroker.
 String[] listMetSources(String sessionID, GeographicalArea ofInterest)
          Get the IDs 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 Typically used by a client application to get a subset of the entire list of stations for a large database.
 WeatherStation[] listStations(String sessionID, String metSourceID, String regionID)
          Get an array of all the stations that can potentially contribute to the request Typically used by a client application to get a subset of the entire list of stations for a large database.
 boolean loginToMetDataSource(String sessionID, String sourceID)
          Establish a connection to the specified database without identifying the user in any way
 boolean loginToMetDataSource(String sessionID, String sourceID, String emailAddress)
          Establish a connection to the specified database using the e-mail address supplied as identification.
 boolean loginToMetDataSource(String sessionID, String sourceID, String usercode, String password)
          Establish a connection to the specified database using the usercode and password supplied
static void main(String[] args)
           
 boolean metCatalogCardExists(String sessionID, String metSourceID, String stationID, MetElement element, MetDuration resolution)
          Check whether a station has ever recorded an element at a particular resolution.
 void registerSource(String sessionID, MetSourceImpl source)
           
 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.brokerImpl.GenericBrokerImpl
alreadyLoggedIn, cleanup, DBMonitor, disconnect, enter, exit, getAccess, getConnection, getLanguage, getSourceDetail, getSourceGeographicalArea, getSourceID, getSourceImplAndRecordUse, getSourceLoginRequirements, getSourceName, listDataSources, listDataSources, listSourceDetails, listSourceDetails, loginToDataSource, loginToDataSource, loginToDataSource, logMessage, logOutOfAllSources, logOutOfSource, setDBNames, shutdown, start, stop, wait10
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.agmodel.weatherData.MetBroker
getSourceGeographicalArea, getSourceLoginRequirements, getSourceName
 
Methods inherited from interface net.agmodel.genericBroker.GenericBrokerRMI
alreadyLoggedIn, getSourceDetail, getSourceID, listSourceDetails, listSourceDetails, loginToDataSource, loginToDataSource, loginToDataSource, logOutOfAllSources, logOutOfSource
 
Methods inherited from interface net.agmodel.genericBroker.ServerRMI
disconnect, getConnection
 

Constructor Detail

MetBrokerImpl

public MetBrokerImpl()
              throws RemoteException
Method Detail

main

public static void main(String[] args)

listMetSources

public String[] listMetSources(String sessionID)
                        throws RemoteException,
                               GeneralException
Description copied from interface: MetBroker
Get the IDs for all the MetSources in MetBroker.

Specified by:
listMetSources in interface MetBroker
Parameters:
sessionID - the ID returned by getConnection
Returns:
a list of sources
Throws:
RemoteException
GeneralException

listMetSources

public String[] listMetSources(String sessionID,
                               GeographicalArea ofInterest)
                        throws RemoteException,
                               GeneralException
Description copied from interface: MetBroker
Get the IDs of the MetSources in MetBroker that coincide with the area specified.

Specified by:
listMetSources in interface MetBroker
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
Throws:
RemoteException
GeneralException

listMetSourceDetails

public MetSourceDetail[] listMetSourceDetails(String sessionID)
                                       throws RemoteException,
                                              GeneralException
Description copied from interface: MetBroker
Get the details for all the MetSources in MetBroker.

Specified by:
listMetSourceDetails in interface MetBroker
Parameters:
sessionID - the ID returned by getConnection
Returns:
a list of sources
Throws:
RemoteException
GeneralException
See Also:
for a generic version

listMetSourceDetails

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

Specified by:
listMetSourceDetails in interface MetBroker
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
Throws:
RemoteException
GeneralException
See Also:
for a generic version

loginToMetDataSource

public boolean loginToMetDataSource(String sessionID,
                                    String sourceID,
                                    String usercode,
                                    String password)
                             throws RemoteException,
                                    GeneralException
Description copied from interface: MetBroker
Establish a connection to the specified database using the usercode and password supplied

Specified by:
loginToMetDataSource in interface MetBroker
Parameters:
sessionID - the ID returned by getConnection
sourceID - the identifier assigned to the source by MetBroker - see listMetSources
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
Throws:
RemoteException
GeneralException
See Also:
MetBroker.getSourceLoginRequirements(String,String)

loginToMetDataSource

public boolean loginToMetDataSource(String sessionID,
                                    String sourceID,
                                    String emailAddress)
                             throws RemoteException,
                                    GeneralException
Description copied from interface: MetBroker
Establish a connection to the specified database using the e-mail address supplied as identification.

Specified by:
loginToMetDataSource in interface MetBroker
Parameters:
sessionID - the ID returned by getConnection
sourceID - the identifier assigned to the source by MetBroker - see listMetSources
emailAddress - the user's e-mail address
Returns:
true if the MetBroker was able to log in to the source, false otherwise
Throws:
RemoteException
GeneralException
See Also:
MetBroker.getSourceLoginRequirements(String,String)

loginToMetDataSource

public boolean loginToMetDataSource(String sessionID,
                                    String sourceID)
                             throws RemoteException,
                                    GeneralException
Description copied from interface: MetBroker
Establish a connection to the specified database without identifying the user in any way

Specified by:
loginToMetDataSource in interface MetBroker
Parameters:
sessionID - the ID returned by getConnection
sourceID - the identifier assigned to the source by MetBroker - see listMetSources
Returns:
true if the MetBroker was able to log in to the source, false otherwise
Throws:
RemoteException
GeneralException
See Also:
MetBroker.getSourceLoginRequirements(String,String)

supplyMetData

public SpatialMetSet supplyMetData(String sessionID,
                                   SpatialMetRequest request)
                            throws RemoteException,
                                   ConnectionException
Description copied from interface: MetBroker
Get the relevant data from multiple stations. If a station "should" have data, based on the metadata MetBroker holds, then a StationDataSet will be returned for that station. "Should" means that the station operated during the period of the query and recorded elements of interest at an appropriate resolution. The StationDataSet returned may, however, be empty (as in the single station example).

Specified by:
supplyMetData in interface MetBroker
Parameters:
sessionID - the ID returned by getConnection
request - specifies which area to get data for, and what data to get
Returns:
the requested data
Throws:
RemoteException
ConnectionException

supplyMetData

public StationDataSet supplyMetData(String sessionID,
                                    StationMetRequest request)
                             throws RemoteException,
                                    ConnectionException,
                                    InvalidRequestException
Description copied from interface: MetBroker
Get the relevant data from a single station. If no matching data is found for the query, a StationDataSet is returned rather than null. However, the station data set will not contain any data sequences.

Specified by:
supplyMetData in interface MetBroker
Parameters:
sessionID - the ID returned by getConnection
request - specifies which station get data for, and what data to get
Returns:
the requested data, or an "empty" StationDataSet if no matching data is found.
Throws:
RemoteException
ConnectionException
InvalidRequestException

getMetSourceDetail

public MetSourceDetail getMetSourceDetail(String sessionID,
                                          String metSourceID)
                                   throws RemoteException
Description copied from interface: MetBroker
Gets details about the MetSource in one object.

Specified by:
getMetSourceDetail in interface MetBroker
Parameters:
sessionID - the ID returned by getConnection
Returns:
the database details
Throws:
RemoteException
See Also:
for a generic version

getSourceSuggestedTimezone

public String getSourceSuggestedTimezone(String sessionID,
                                         String metSourceID)
                                  throws RemoteException
Description copied from interface: MetBroker
Provide client applications with a sensible default timezone for building requests to the database and for displaying the resulting data. The String ID of the timezone is used rather than a TimeZone object for speed of transmission and portability to other languages.

Specified by:
getSourceSuggestedTimezone in interface MetBroker
Parameters:
sessionID - the ID returned by getConnection
metSourceID - the identifier assigned to the source by MetBroker
Returns:
the timezone that users of this database are likely to be in.
Throws:
RemoteException

getSourceSuggestedDailyOffset

public float getSourceSuggestedDailyOffset(String sessionID,
                                           String metSourceID)
                                    throws RemoteException
Description copied from interface: MetBroker
Provide client applications with a sensible default offset for building requests for daily data for displaying the resulting data. Daily weather data is usually recorded either at midnight or in the morning at around 9am local time.

Specified by:
getSourceSuggestedDailyOffset in interface MetBroker
Parameters:
sessionID - the ID returned by getConnection
metSourceID - the identifier assigned to the source by MetBroker
Returns:
the number of hours from midnight that the data is recorded,eg if at midnight return 0, if at 9am return 9
Throws:
RemoteException

listRegions

public Region[] listRegions(String sessionID,
                            String metSourceID)
                     throws RemoteException
Description copied from interface: MetBroker
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.

Specified by:
listRegions in interface MetBroker
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.
Throws:
RemoteException

getRegion

public Region getRegion(String sessionID,
                        String metSourceID,
                        String regionID)
                 throws RemoteException
Description copied from interface: MetBroker
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.

Specified by:
getRegion in interface MetBroker
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.
Throws:
RemoteException

listStations

public WeatherStation[] listStations(String sessionID,
                                     String metSourceID)
                              throws RemoteException
Description copied from interface: MetBroker
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.

Specified by:
listStations in interface MetBroker
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
Throws:
RemoteException

listStations

public WeatherStation[] listStations(String sessionID,
                                     String metSourceID,
                                     String regionID)
                              throws RemoteException
Description copied from interface: MetBroker
Get an array of all the stations that can potentially contribute to the request 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.

Specified by:
listStations in interface MetBroker
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
Throws:
RemoteException

listMatchingStations

public WeatherStation[] listMatchingStations(String sessionID,
                                             SpatialMetRequest request)
                                      throws RemoteException
Description copied from interface: MetBroker
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 to display stations spatially

Specified by:
listMatchingStations in interface MetBroker
Parameters:
sessionID - the ID returned by getConnection
request - specifies the data required
Returns:
an array of WeatherStations which can contribute useful data
Throws:
RemoteException

getWeatherStation

public WeatherStation getWeatherStation(String sessionID,
                                        String metSourceID,
                                        String stationID)
                                 throws RemoteException
Description copied from interface: MetBroker
Get the details of the weather station

Specified by:
getWeatherStation in interface MetBroker
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.
Throws:
RemoteException

listMatchingStationIDs

public String[] listMatchingStationIDs(String sessionID,
                                       String metSourceID,
                                       SpatialMetRequest request)

getStationReport

public String getStationReport(String sessionID,
                               String metSourceID,
                               String stationID)
                        throws RemoteException
Description copied from interface: MetBroker
Provide a description of the station and the data it holds

Specified by:
getStationReport in interface MetBroker
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:
a summary of the station's metadata
Throws:
RemoteException

getStationName

public String getStationName(String sessionID,
                             String metSourceID,
                             String stationID)
                      throws RemoteException
Description copied from interface: MetBroker
Get the weather station's location's name.

Specified by:
getStationName in interface MetBroker
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 name of the place where the station is located, in the language specified at initialization
Throws:
RemoteException

getStationLocation

public Location getStationLocation(String sessionID,
                                   String metSourceID,
                                   String stationID)
                            throws RemoteException
Description copied from interface: MetBroker
Get the weather station's position on the globe.

Specified by:
getStationLocation in interface MetBroker
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 location of the station (latitude, longitude and altitude)
Throws:
RemoteException

getStationRegionID

public String getStationRegionID(String sessionID,
                                 String metSourceID,
                                 String stationID)
                          throws RemoteException
Description copied from interface: MetBroker
Get the weather station's current region ID.

Specified by:
getStationRegionID in interface MetBroker
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
Throws:
RemoteException

getStationOperational

public Period getStationOperational(String sessionID,
                                    String metSourceID,
                                    String stationID)
                             throws RemoteException
Description copied from interface: MetBroker
Get the period of operation of the weather station

Specified by:
getStationOperational in interface MetBroker
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 date when the station began operating, and, if it has closed, the date when it closed.
Throws:
RemoteException

metCatalogCardExists

public boolean metCatalogCardExists(String sessionID,
                                    String metSourceID,
                                    String stationID,
                                    MetElement element,
                                    MetDuration resolution)
                             throws RemoteException
Description copied from interface: MetBroker
Check whether a station has ever recorded an element at a particular resolution.

Specified by:
metCatalogCardExists in interface MetBroker
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.
element - the weather element of interest
resolution - the temporal resolution (eg hourly or daily)
Returns:
true if it has recorded the element, false if it hasn't.
Throws:
RemoteException

getMetCatalog

public boolean[][] getMetCatalog(String sessionID,
                                 String metSourceID,
                                 String stationID)
                          throws RemoteException
Description copied from interface: MetBroker
Check whether a station has ever recorded an element at a particular resolution.

Specified by:
getMetCatalog in interface MetBroker
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.
Throws:
RemoteException

registerSource

public void registerSource(String sessionID,
                           MetSourceImpl source)

getConnection

public String getConnection(String clientInfo,
                            String language,
                            String metBrokerUserName,
                            String metBrokerPassword,
                            int userType)
                     throws RemoteException
Description copied from interface: ServerRMI
Establishes a session for the client application.

Specified by:
getConnection in interface ServerRMI
Overrides:
getConnection in class GenericBrokerImpl
Throws:
RemoteException


Copyright (C) NARC 2001 All Rights Reserved.