stella.sensor
Class WeatherDatabase

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by mysql.GenericSql
                  extended by stella.sensor.WeatherDatabase
All Implemented Interfaces:
Cloneable, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying

public class WeatherDatabase
extends GenericSql

A simple class that reads weather data from the database and generates WeatherSurveying.BlockData out of it.


Nested Class Summary
static class WeatherDatabase.Dump
          Retrieves a list of weather data and dumpe it to stdout.
 
Nested classes/interfaces inherited from class mysql.GenericSql
GenericSql.Extract
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static String DEFDATEFIELD
          The default binding name of the weather trigger.
private static long DEFEXTRATIME
          The default extra time.
private static String DEFGOODFLAG
          The default setting of the non-valid-reading indicator.
private static String DEFPRINCIPAL
          The default mapping of STELLA sensor names to sql fields.
private static String DEFWEATHERFIELD
          The default binding name of the weather trigger.
static String KEY_DATEFIELD
          The key to the sql date-field name.
static String KEY_EXTRATIME
          A time which is added to date queries to enlarge the time-space.
static String KEY_GOODFLAG
          The key to the good-weather string.
static String KEY_PRINCIPAL
          The mapping of STELLA sensor names to sql data fields.
static String KEY_WEATHERFIELD
          The key to the sql weather-field name.
private  Map<String,String> principal
          The mapping of STELLA sensors names to sql field names.
 
Fields inherited from class mysql.GenericSql
DEFDATEFORMAT, KEY_BRIDGE, KEY_CONNECT, KEY_DATEFORMAT, KEY_FAILFILE, KEY_PASSWORD, KEY_TABLE, KEY_TRUEREAD, KEY_TRUEWRITE, KEY_USER
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
WeatherDatabase(Map<String,String> prop)
          Constructs a new database collector.
 
Method Summary
 List<WeatherSurveying.DataBlock> getWeatherData(Date fromsharp, Date tosharp)
          Returns a list of mappings of sensor names to sensor values.
 void init()
          Initializes the database current object as well as the database acess object.
 
Methods inherited from class mysql.GenericSql
allColumns, canRead, canWrite, close, delete, exit, getConnection, getStatement, insert, isOpen, isReady, join, open, replace, retrieve, retrieve
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

KEY_PRINCIPAL

public static final String KEY_PRINCIPAL
The mapping of STELLA sensor names to sql data fields.

See Also:
Constant Field Values

KEY_DATEFIELD

public static final String KEY_DATEFIELD
The key to the sql date-field name.

See Also:
Constant Field Values

KEY_WEATHERFIELD

public static final String KEY_WEATHERFIELD
The key to the sql weather-field name.

See Also:
Constant Field Values

KEY_GOODFLAG

public static final String KEY_GOODFLAG
The key to the good-weather string.

See Also:
Constant Field Values

KEY_EXTRATIME

public static final String KEY_EXTRATIME
A time which is added to date queries to enlarge the time-space.

See Also:
Constant Field Values

DEFPRINCIPAL

private static final String DEFPRINCIPAL
The default mapping of STELLA sensor names to sql fields.

See Also:
Constant Field Values

DEFDATEFIELD

private static final String DEFDATEFIELD
The default binding name of the weather trigger.

See Also:
Constant Field Values

DEFWEATHERFIELD

private static final String DEFWEATHERFIELD
The default binding name of the weather trigger.

See Also:
Constant Field Values

DEFGOODFLAG

private static final String DEFGOODFLAG
The default setting of the non-valid-reading indicator.

See Also:
Constant Field Values

DEFEXTRATIME

private static final long DEFEXTRATIME
The default extra time.

See Also:
Constant Field Values

principal

private Map<String,String> principal
The mapping of STELLA sensors names to sql field names.

Constructor Detail

WeatherDatabase

public WeatherDatabase(Map<String,String> prop)
Constructs a new database collector. The properties of this collector are also used to generate the databank access object, this means that the properties defined in the GenericSql class must also be present here if non-default values are wanted. Additionally, the weather trigger stub is constructed here with the generic properties of the collector.

Method Detail

init

public void init()
Initializes the database current object as well as the database acess object. For the sql connsction, this means calling it GenericSql.init() method and opening the connection.
For the current database collector, its essential mappes (principal, #minima, and #maxima) are assigned. Additionally, the format look-up table is constructed using the class names pointed to in the #KEY_FORMAT property to java classes. Only classes found that also support a single-string constructor are used.

Specified by:
init in interface Initializable
Overrides:
init in class GenericSql

getWeatherData

public List<WeatherSurveying.DataBlock> getWeatherData(Date fromsharp,
                                                       Date tosharp)
Returns a list of mappings of sensor names to sensor values. As no sigma/min/max value is stored in the database, this info is lost.

Returns:
A list of WeatherSurveying.BlockData objects.