BEAST
eu.baltrad.beast.rules.util.IRuleUtilities Interface Reference

Utility functions when accessing the database and querying for various things. More...

Inheritance diagram for eu.baltrad.beast.rules.util.IRuleUtilities:
eu.baltrad.beast.rules.util.RuleUtilities

Public Member Functions

Map< String, Double > fetchLowestSourceElevationAngle (DateTime startDT, DateTime stopDT, List< String > sources)
 Fetch the lowest scan for all provided sources.
 
Map< String, Double > fetchLowestSourceElevationAngle (DateTime startDT, DateTime stopDT, List< String > sources, String quantity)
 Fetch the lowest scan for all provided sources.
 
CatalogEntry findFirstStoredEntry (List< CatalogEntry > entries)
 Returns the catalog entry that was stored first among the provided entries.
 
CatalogEntry findLastStoredEntry (List< CatalogEntry > entries)
 Returns the catalog entry that was stored last among the provided entries.
 
List< CatalogEntryremoveEntriesWithStorageTimeOlderThan (List< CatalogEntry > entries, DateTime limit)
 Removes all entries that have a storage time older than limit.
 
CatalogEntry getEntryBySource (String source, List< CatalogEntry > entries)
 Returns an entry with the specified name.
 
List< CatalogEntrygetEntriesByClosestTime (DateTime nominalDT, List< CatalogEntry > entries)
 Filter entries by time closest to a nominal time.
 
List< CatalogEntrygetEntriesBySources (List< String > sources, List< CatalogEntry > entries)
 Filter entries by source.
 
List< String > getFilesFromEntries (List< CatalogEntry > entries)
 Creates a list of files from the entries.
 
List< String > getUuidStringsFromEntries (List< CatalogEntry > entries)
 Creates a list of uuids.
 
List< Double > getElanglesFromEntries (List< CatalogEntry > entries)
 Creates a list of elevation angles.
 
List< String > getSourcesFromEntries (List< CatalogEntry > entries)
 Returns a list of sources from the provided entries.
 
DateTime createStorageDateTime (CatalogEntry ce)
 Creates the storage DateTime from a catalog entry.
 
Calendar createCalendar (DateTime dt)
 Creates a gregorian calendar with the specified date/time.
 
Calendar now ()
 
DateTime nowDT ()
 
DateTime createDateTime (Calendar c)
 Creates an date time instance from a calendar.
 
DateTime createDateTime (int year, int month, int dayOfMonth, int hourOfDay, int minute, int second)
 Creates a date time instance.
 
DateTime createDateTime (java.util.Date date)
 Creates a date time instance from a util date.
 
DateTime createNominalTime (DateTime now, int interval)
 Creates the nominal time from current time and an interval.
 
DateTime createNominalTime (Date d, Time t, int interval)
 Same as createNominalTime(DateTime, int) but takes date and time separately instead.
 
DateTime createNextNominalTime (DateTime now, int interval)
 Almost same as createNominalTime(DateTime, int) but returns the end time in the interval instead.
 
DateTime createPrevNominalTime (DateTime now, int interval)
 Almost same as createNominalTime(DateTime, int) but returns the previous nominal time instead.
 
long getTimeoutTime (DateTime nominalTime, boolean nominalTimeout, long timeout)
 Calculates the timeout in ms that should be used.
 
void trigger (int ruleid, DateTime now)
 This is a way of indicating if a rule has been triggered or not for a specific time period.
 
boolean isTriggered (int ruleid, DateTime now)
 Returns if the rule has been triggered for the specified date time.
 
List< String > getRadarSources ()
 Returns a list of all available radar source names, like searl,...
 
Map< String, Integer > diff (List< String > expected, List< String > actual)
 Creates a diff between expected and actual list of strings.
 
void reportRadarSourceUsage (List< String > expected, List< String > actual)
 Useful for reporting to the system that there might be a deviation between expected and actual sources.
 

Detailed Description

Utility functions when accessing the database and querying for various things.

Author
Anders Henja

Member Function Documentation

◆ createCalendar()

Calendar eu.baltrad.beast.rules.util.IRuleUtilities.createCalendar ( DateTime dt)

Creates a gregorian calendar with the specified date/time.

Parameters
dtthe date time
Returns
a gregorian calendar

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ createDateTime() [1/3]

DateTime eu.baltrad.beast.rules.util.IRuleUtilities.createDateTime ( Calendar c)

Creates an date time instance from a calendar.

Parameters
cthe calendar
Returns
the date time instance

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ createDateTime() [2/3]

DateTime eu.baltrad.beast.rules.util.IRuleUtilities.createDateTime ( int year,
int month,
int dayOfMonth,
int hourOfDay,
int minute,
int second )

Creates a date time instance.

Parameters
yearthe year
monththe month between 1 - 12
dayOfMonththe day between 1 - 31
hourOfDaythe hour of the day between 0 - 23
minutethe minute of the hour between 0 - 59
secondthe second of the minute between 0 - 59
Returns
the date time instance

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ createDateTime() [3/3]

DateTime eu.baltrad.beast.rules.util.IRuleUtilities.createDateTime ( java.util.Date date)

Creates a date time instance from a util date.

Parameters
datethe date
Returns
the date time

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ createNextNominalTime()

DateTime eu.baltrad.beast.rules.util.IRuleUtilities.createNextNominalTime ( DateTime now,
int interval )

Almost same as createNominalTime(DateTime, int) but returns the end time in the interval instead.

I.e. if interval is 10 and minutes is 9, then the minutes returned will be 10.

Parameters
nowcurrent time
intervalthe interval
Returns
end nominal time

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ createNominalTime() [1/2]

DateTime eu.baltrad.beast.rules.util.IRuleUtilities.createNominalTime ( Date d,
Time t,
int interval )

Same as createNominalTime(DateTime, int) but takes date and time separately instead.

Parameters
dthe date
tthe time
intervalthe interval
Returns
a nominal time

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ createNominalTime() [2/2]

DateTime eu.baltrad.beast.rules.util.IRuleUtilities.createNominalTime ( DateTime now,
int interval )

Creates the nominal time from current time and an interval.

The interval must be evenly dividable by 60. E.g. 1,2,3,4,...,15,..30,60. The nominal time will be adjusted so that it is within the nearest lowest time interval. I.e. If interval is 10 and minutes is 9, then the minutes will be set to 0.

Parameters
nowcurrent time
intervalthe interval
Returns
the nominal time.
Exceptions
InvalidArgumentExceptionif interval not valid

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ createPrevNominalTime()

DateTime eu.baltrad.beast.rules.util.IRuleUtilities.createPrevNominalTime ( DateTime now,
int interval )

Almost same as createNominalTime(DateTime, int) but returns the previous nominal time instead.

I.e. if interval is 10 and minutes is 9, then the minutes returned will be 0.

Parameters
nowcurrent time
intervalthe interval
Returns
previous nominal time

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ createStorageDateTime()

DateTime eu.baltrad.beast.rules.util.IRuleUtilities.createStorageDateTime ( CatalogEntry ce)

Creates the storage DateTime from a catalog entry.

Parameters
cethe catalog entry
Returns
the date time

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ diff()

Map< String, Integer > eu.baltrad.beast.rules.util.IRuleUtilities.diff ( List< String > expected,
List< String > actual )

Creates a diff between expected and actual list of strings.

The returned mapping contains the joined strings in expected and actual and the Integer value has the following meaning. 0 = means that the string exists in both expected and actual -1 = means that the string exists in expected but not in actual +1 = means that the string exists in actual but not in expected

Parameters
expectedthe list of expected strings
actualthe list of actual strings
Returns
a mapping to identify the difference between the two lits

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ fetchLowestSourceElevationAngle() [1/2]

Map< String, Double > eu.baltrad.beast.rules.util.IRuleUtilities.fetchLowestSourceElevationAngle ( DateTime startDT,
DateTime stopDT,
List< String > sources )

Fetch the lowest scan for all provided sources.

The elevation angle is accessible from the eu.baltrad.beast.db.CatalogEntry#getAttribute(String).

Parameters
startDTthe start time of the interval to search in
stopDTthe stop time of the interval to search in
sourcesthe node id of the sources
Returns
a map of source : elevation angle

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ fetchLowestSourceElevationAngle() [2/2]

Map< String, Double > eu.baltrad.beast.rules.util.IRuleUtilities.fetchLowestSourceElevationAngle ( DateTime startDT,
DateTime stopDT,
List< String > sources,
String quantity )

Fetch the lowest scan for all provided sources.

The elevation angle is accessible from the eu.baltrad.beast.db.CatalogEntry#getAttribute(String).

Parameters
startDTthe start time of the interval to search in
stopDTthe stop time of the interval to search in
sourcesthe node id of the sources
quantitythe quantity to look for in the files
Returns
a map of source : elevation angle

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ findFirstStoredEntry()

CatalogEntry eu.baltrad.beast.rules.util.IRuleUtilities.findFirstStoredEntry ( List< CatalogEntry > entries)

Returns the catalog entry that was stored first among the provided entries.

Parameters
entriesthe entries
Returns
the first stored entry

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ findLastStoredEntry()

CatalogEntry eu.baltrad.beast.rules.util.IRuleUtilities.findLastStoredEntry ( List< CatalogEntry > entries)

Returns the catalog entry that was stored last among the provided entries.

Parameters
entriesthe entries
Returns
the first stored entry

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ getElanglesFromEntries()

List< Double > eu.baltrad.beast.rules.util.IRuleUtilities.getElanglesFromEntries ( List< CatalogEntry > entries)

Creates a list of elevation angles.

It is assumed that each entry contains an elangle at /dataset1/where/elangle, otherwise unexpected behaviour

Parameters
entriesa list of entries
Returns
a list of doubles.

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ getEntriesByClosestTime()

List< CatalogEntry > eu.baltrad.beast.rules.util.IRuleUtilities.getEntriesByClosestTime ( DateTime nominalDT,
List< CatalogEntry > entries )

Filter entries by time closest to a nominal time.

If the list contains more than one entry from the same source, the one nearest in time to the nominal time will be used.

Parameters
nominalDTthe nominal time
entriesa list of entries
Returns
a list of entries

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ getEntriesBySources()

List< CatalogEntry > eu.baltrad.beast.rules.util.IRuleUtilities.getEntriesBySources ( List< String > sources,
List< CatalogEntry > entries )

Filter entries by source.

Pick entries that have a source present in sources.

Parameters
sourceslist of sources to match against
entriesa list of entries to filter
Returns
a list of entries

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ getEntryBySource()

CatalogEntry eu.baltrad.beast.rules.util.IRuleUtilities.getEntryBySource ( String source,
List< CatalogEntry > entries )

Returns an entry with the specified name.

Note, it will always be the first match so if there are more than one entry with the specified source name you will not be aware of that if using this method.

Parameters
sourcethe source name
entriesthe list of entries to traverse
Returns
a catalog entry

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ getFilesFromEntries()

List< String > eu.baltrad.beast.rules.util.IRuleUtilities.getFilesFromEntries ( List< CatalogEntry > entries)

Creates a list of files from the entries.

Parameters
entriesa list of entries
Returns
a list of files

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ getRadarSources()

List< String > eu.baltrad.beast.rules.util.IRuleUtilities.getRadarSources ( )

Returns a list of all available radar source names, like searl,...

Returns
the list of radar names

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ getSourcesFromEntries()

List< String > eu.baltrad.beast.rules.util.IRuleUtilities.getSourcesFromEntries ( List< CatalogEntry > entries)

Returns a list of sources from the provided entries.

Parameters
entriesthe entries
Returns
a list of sources

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ getTimeoutTime()

long eu.baltrad.beast.rules.util.IRuleUtilities.getTimeoutTime ( DateTime nominalTime,
boolean nominalTimeout,
long timeout )

Calculates the timeout in ms that should be used.

If nominalTimeout = false, then the returned value will be timeout regardless of nominal time. However, if nominalTimeout is specified then the difference between now and nominal time will be used and the difference will either be substracted or added to the timeout value

Parameters
nominalTimethe nominal time that we are aiming for
nominalTimeoutif timeout should be based on nominal time or not
timeoutthe timeout in milliseconds
Returns
the timeout in ms

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ getUuidStringsFromEntries()

List< String > eu.baltrad.beast.rules.util.IRuleUtilities.getUuidStringsFromEntries ( List< CatalogEntry > entries)

Creates a list of uuids.

Parameters
entriesa list of entries
Returns
a list of uuids

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ isTriggered()

boolean eu.baltrad.beast.rules.util.IRuleUtilities.isTriggered ( int ruleid,
DateTime now )

Returns if the rule has been triggered for the specified date time.

Parameters
ruleidthe rule id
nowthe time period to check
Returns
true if the rule has been triggered, false otherwise

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ now()

Calendar eu.baltrad.beast.rules.util.IRuleUtilities.now ( )
Returns
the current calendar. Same as calling GregorianCalendar.getInstance().

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ nowDT()

DateTime eu.baltrad.beast.rules.util.IRuleUtilities.nowDT ( )
Returns
the current date time.

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ removeEntriesWithStorageTimeOlderThan()

List< CatalogEntry > eu.baltrad.beast.rules.util.IRuleUtilities.removeEntriesWithStorageTimeOlderThan ( List< CatalogEntry > entries,
DateTime limit )

Removes all entries that have a storage time older than limit.

Parameters
entriesThe entries to filter
limitthe date time limit
Returns
the filtered list

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ reportRadarSourceUsage()

void eu.baltrad.beast.rules.util.IRuleUtilities.reportRadarSourceUsage ( List< String > expected,
List< String > actual )

Useful for reporting to the system that there might be a deviation between expected and actual sources.

This is probably quite handy when reporting alarms to an alarm handler.

Parameters
expectedthe expected sources
actualthe actual sources

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.

◆ trigger()

void eu.baltrad.beast.rules.util.IRuleUtilities.trigger ( int ruleid,
DateTime now )

This is a way of indicating if a rule has been triggered or not for a specific time period.

This can be quite useful if you know that a rule will be triggered more than once and only want to generate it more than once. Note, that old entries will automatically be removed.

Parameters
ruleidthe rule id
nowthe time period for this rule

Implemented in eu.baltrad.beast.rules.util.RuleUtilities.


The documentation for this interface was generated from the following file: