net.agmodel.metBroker
Class MetSourceImpl

java.lang.Object
  extended bynet.agmodel.brokerImpl.GenericSourceImpl
      extended bynet.agmodel.metBroker.MetSourceImpl
All Implemented Interfaces:
GenericSourceForDrivers, MetSourceForDrivers

public class MetSourceImpl
extends GenericSourceImpl
implements MetSourceForDrivers

An implementation of MetDataSource Responsible for knowing how to get weather element(s) for a period from a station. Relies on a collection of ServerStationImpl objects to record details of which elements are held on the database for each station. Note that MetSourceImpl is not persistent, though it uses persistent station and region details.


Nested Class Summary
 class MetSourceImpl.MetSourceContext
          The MetSourceContext class is used by UserManagerImpl to maintain client-specific context.
 
Constructor Summary
MetSourceImpl(String ID, MetBrokerImpl broker, MultilingualString sourceName, GeographicalArea coverage, int loginRequirements, String systemUsercode, String systemPassword, String driverName, String suggestedTimeZone, float suggestedDailyOffset, Duration shortestResolution, Duration longestResolution, Duration timeliness, boolean rebuildRequired, String fromStation, GeographicalArea defaultDisplayArea, BrokerConfigDataSource source)
          Creates an object responsible for managing the metadata associated with a database, and spawning driver instances.
 
Method Summary
 void addRegion(String regionID, MultilingualString regionName)
          Adds a region to the list associated with a MetDataSource.
If the region is already in the list, updates its associated details.
 void addStation(String stationID, MultilingualString placeName, Location location, Period stationOperational, String regionID)
          Adds a station to the list associated with a MetDataSource.
If the station is already in the list, updates the data associated with the station.
 boolean catalogCardExists(String clientSessionName, String stationID, MetElement element, MetDuration resolution)
           
 boolean checkCatalog(String clientSessionName, String stationID, MetElement element, Duration resolution, Period period)
           
 boolean checkElementCatalog(String stationID, MetElement element, Duration resolution, Period period)
           
 MetSourceImpl.MetSourceContext createMetSourceContextForUser(String clientSessionName, String language)
           
 void disposeMetSourceContext(String clientSessionName)
          Deletes the session for this client.
 void fillSpatialMetSet(SpatialMetRequest request, MetBrokerImpl broker, String language, SpatialMetSetImpl result, String clientSessionName)
           
 DataSourceDetail getDetails(String language)
          Returns the details of the MetSource in a transient form
 Period getOperatingPeriod()
          Get the period over which the database has data available
 String getParameterValue(String name)
           
 Date getRecent()
          Gets a data for which currently operating stations of this database should have data
 Region getRegion(String clientSessionName, String language, String regionID)
           
 String getStationReport(String clientSessionName, String stationID, String language)
           
 float getSuggestedDailyOffset()
          Provide client applications with a sensible default offset for building requests for daily data for displaying the resulting data.
 String getSuggestedTimezone()
          Provide a sensible default timezone for building requests to the database and for displaying the resulting data.
 WeatherStation getWeatherStation(String stationID, String language)
           
 WeatherStation[] listMatchingStations(String clientSessionName, SpatialMetRequest request, String language)
          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.
 Region[] listRegions(String clientSessionName, String language)
           
 WeatherStation[] listStations(String clientSessionName, String regionID, String language)
           
 void processSequence(MetElement element, MetSequence sequence, MetRequest request, Duration queryResolution, StationDataSetImpl result)
          Adds the supplied sequence into the supplied result set, summarising it if necessary.
If the sequence is null the source metadata is updated to reflect the absence of any data.
 void recordElementStatus(String stationID, MetElement element, Duration resolution, Period period, boolean status)
          Record that a station measured or didn't measure an element at a particular resolution over a period.
 void recordMultipleElementStatus(String stationID, MetElement[] elements, Duration[] resolutions, Period period, boolean status)
          Record that a station measured or didn't measure a set of elements at a particular resolution over a period.
 void updateStationListIfRequired(String fromStation)
           
 
Methods inherited from class net.agmodel.brokerImpl.GenericSourceImpl
enter, exit, getDefaultDisplayArea, getDriverInstance, getGeographicalArea, getID, getLog4jCategory, getLoginRequirements, getName, getSystemPassword, getSystemUsercode, putName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.agmodel.brokerImpl.GenericSourceForDrivers
getID, getLog4jCategory, getName, getSystemPassword, getSystemUsercode
 

Constructor Detail

MetSourceImpl

public MetSourceImpl(String ID,
                     MetBrokerImpl broker,
                     MultilingualString sourceName,
                     GeographicalArea coverage,
                     int loginRequirements,
                     String systemUsercode,
                     String systemPassword,
                     String driverName,
                     String suggestedTimeZone,
                     float suggestedDailyOffset,
                     Duration shortestResolution,
                     Duration longestResolution,
                     Duration timeliness,
                     boolean rebuildRequired,
                     String fromStation,
                     GeographicalArea defaultDisplayArea,
                     BrokerConfigDataSource source)
              throws GeneralException
Creates an object responsible for managing the metadata associated with a database, and spawning driver instances.

Parameters:
ID - the identifier MetBroker uses to refer to this data source
broker - a link back to MetBroker
sourceName - the source name, maybe in several languages.
coverage - the area of the globe covered by this data source
loginRequirements - whether the database requires that users log in (use one of the three constants in the MetBroker interface)
systemUsercode - the usercode that MetBroker uses to get metadata
systemPassword - the password that MetBroker uses to get metadata
driverName - the name of the database driver class (assumed to be in net.agmodel.metDriver package)
suggestedTimeZone - the default timeZone for queries to the database and responses (not necessarily the timezone of the data)
suggestedDailyOffset - the default offset to use for daily data (usually 9 for 9am or 0 for midnight)
shortestResolution - the shortest resolution data stored in the database (eg hourly)
longestResolution - the longest resolution data stored in the database (eg daily)
timeliness - the maximum time it takes for newly recorded data to get into the database (usually between a month and an hour)
rebuildRequired - force rebuilding of the list of stations
fromStation - building the station list from this station onward
Throws:
GeneralException
Method Detail

getRecent

public Date getRecent()
Description copied from interface: MetSourceForDrivers
Gets a data for which currently operating stations of this database should have data

Specified by:
getRecent in interface MetSourceForDrivers

updateStationListIfRequired

public void updateStationListIfRequired(String fromStation)
                                 throws GeneralException
Throws:
GeneralException

getWeatherStation

public WeatherStation getWeatherStation(String stationID,
                                        String language)
Specified by:
getWeatherStation in interface MetSourceForDrivers

getStationReport

public String getStationReport(String clientSessionName,
                               String stationID,
                               String language)

addStation

public void addStation(String stationID,
                       MultilingualString placeName,
                       Location location,
                       Period stationOperational,
                       String regionID)
Adds a station to the list associated with a MetDataSource.
If the station is already in the list, updates the data associated with the station.

Specified by:
addStation in interface MetSourceForDrivers
Parameters:
stationID - the ID that the host database uses to refer to the station
placeName - the name of the place where the station is located, in one or more languages
location - the location of the station
stationOperational - the date when the station began operating, and, if it has closed, the date when it closed.
regionID - the region which the station belongs to, or null if there are no regions in the database.
Returns:
a driver-side interface to the station

addRegion

public void addRegion(String regionID,
                      MultilingualString regionName)
Adds a region to the list associated with a MetDataSource.
If the region is already in the list, updates its associated details.

Specified by:
addRegion in interface MetSourceForDrivers
Parameters:
regionID - a string used to identify the region on the host database.
regionName - the name of the region in one or more languages.

recordElementStatus

public void recordElementStatus(String stationID,
                                MetElement element,
                                Duration resolution,
                                Period period,
                                boolean status)
Description copied from interface: MetSourceForDrivers
Record that a station measured or didn't measure an element at a particular resolution over a period. Used to initially specify the data holding of a station, and update it based on the results of queries.

Specified by:
recordElementStatus in interface MetSourceForDrivers
Parameters:
stationID - the station in question
element - the meteorological element
period - the period of time (which might not have an end specified)
resolution - the temporal resolution. There are useful constants in weatherData.MetDuration
status - true if the element was recorded over the period, false if it wasn't

recordMultipleElementStatus

public void recordMultipleElementStatus(String stationID,
                                        MetElement[] elements,
                                        Duration[] resolutions,
                                        Period period,
                                        boolean status)
Description copied from interface: MetSourceForDrivers
Record that a station measured or didn't measure a set of elements at a particular resolution over a period. Used to initially specify the data holding of a station, and update it based on the results of queries. This method calls recordElementStatus(String, MetElement...) multiple times within a single transaction, improving performance considerably

Specified by:
recordMultipleElementStatus in interface MetSourceForDrivers
Parameters:
stationID - the station in question
elements - the meteorological elements
period - the period of time (which might not have an end specified)
status - true if the element was recorded over the period, false if it wasn't

checkElementCatalog

public boolean checkElementCatalog(String stationID,
                                   MetElement element,
                                   Duration resolution,
                                   Period period)
Specified by:
checkElementCatalog in interface MetSourceForDrivers

checkCatalog

public boolean checkCatalog(String clientSessionName,
                            String stationID,
                            MetElement element,
                            Duration resolution,
                            Period period)

catalogCardExists

public boolean catalogCardExists(String clientSessionName,
                                 String stationID,
                                 MetElement element,
                                 MetDuration resolution)

getSuggestedTimezone

public String getSuggestedTimezone()
Description copied from interface: MetSourceForDrivers
Provide 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:
getSuggestedTimezone in interface MetSourceForDrivers
Returns:
the timezone that users of this database are likely to be in.

getSuggestedDailyOffset

public float getSuggestedDailyOffset()
Description copied from interface: MetSourceForDrivers
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:
getSuggestedDailyOffset in interface MetSourceForDrivers
Returns:
the number of hours from midnight that the data is recorded,eg if at midnight return 0, if at 9am return 9

getOperatingPeriod

public Period getOperatingPeriod()
Get the period over which the database has data available

Returns:
a Period from the earliest date that data is available to the latest.

getDetails

public DataSourceDetail getDetails(String language)
Returns the details of the MetSource in a transient form

Specified by:
getDetails in class GenericSourceImpl
Parameters:
language - the language to use for any text;
Returns:
the details

listMatchingStations

public WeatherStation[] listMatchingStations(String clientSessionName,
                                             SpatialMetRequest request,
                                             String language)
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. If the parameter is null, then all the MetSource's stations are returned.

Parameters:
request - specifies the data required
Returns:
an array of client-side interfaces for the stations which can contribute useful data

listStations

public WeatherStation[] listStations(String clientSessionName,
                                     String regionID,
                                     String language)

listRegions

public Region[] listRegions(String clientSessionName,
                            String language)

getRegion

public Region getRegion(String clientSessionName,
                        String language,
                        String regionID)

fillSpatialMetSet

public void fillSpatialMetSet(SpatialMetRequest request,
                              MetBrokerImpl broker,
                              String language,
                              SpatialMetSetImpl result,
                              String clientSessionName)
                       throws ConnectionException
Throws:
ConnectionException

getParameterValue

public String getParameterValue(String name)
Specified by:
getParameterValue in interface GenericSourceForDrivers

processSequence

public void processSequence(MetElement element,
                            MetSequence sequence,
                            MetRequest request,
                            Duration queryResolution,
                            StationDataSetImpl result)
Description copied from interface: MetSourceForDrivers
Adds the supplied sequence into the supplied result set, summarising it if necessary.
If the sequence is null the source metadata is updated to reflect the absence of any data.

Specified by:
processSequence in interface MetSourceForDrivers
Parameters:
element - the element that the sequence represents
queryResolution - the resolution of the original database query
sequence - a set of data or null if there is no data
result - the result set that the sequence will be added into

createMetSourceContextForUser

public MetSourceImpl.MetSourceContext createMetSourceContextForUser(String clientSessionName,
                                                                    String language)

disposeMetSourceContext

public void disposeMetSourceContext(String clientSessionName)
Deletes the session for this client.



Copyright (C) NARC 2001 All Rights Reserved.