BEAST
|
Utility functions when accessing the database and querying for various things. More...
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< CatalogEntry > | removeEntriesWithStorageTimeOlderThan (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< CatalogEntry > | getEntriesByClosestTime (DateTime nominalDT, List< CatalogEntry > entries) |
Filter entries by time closest to a nominal time. | |
List< CatalogEntry > | getEntriesBySources (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. | |
Utility functions when accessing the database and querying for various things.
Calendar eu.baltrad.beast.rules.util.IRuleUtilities.createCalendar | ( | DateTime | dt | ) |
Creates a gregorian calendar with the specified date/time.
dt | the date time |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
DateTime eu.baltrad.beast.rules.util.IRuleUtilities.createDateTime | ( | Calendar | c | ) |
Creates an date time instance from a calendar.
c | the calendar |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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.
year | the year |
month | the month between 1 - 12 |
dayOfMonth | the day between 1 - 31 |
hourOfDay | the hour of the day between 0 - 23 |
minute | the minute of the hour between 0 - 59 |
second | the second of the minute between 0 - 59 |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
DateTime eu.baltrad.beast.rules.util.IRuleUtilities.createDateTime | ( | java.util.Date | date | ) |
Creates a date time instance from a util date.
date | the date |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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.
now | current time |
interval | the interval |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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.
d | the date |
t | the time |
interval | the interval |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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.
now | current time |
interval | the interval |
InvalidArgumentException | if interval not valid |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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.
now | current time |
interval | the interval |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
DateTime eu.baltrad.beast.rules.util.IRuleUtilities.createStorageDateTime | ( | CatalogEntry | ce | ) |
Creates the storage DateTime from a catalog entry.
ce | the catalog entry |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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
expected | the list of expected strings |
actual | the list of actual strings |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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)
.
startDT | the start time of the interval to search in |
stopDT | the stop time of the interval to search in |
sources | the node id of the sources |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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)
.
startDT | the start time of the interval to search in |
stopDT | the stop time of the interval to search in |
sources | the node id of the sources |
quantity | the quantity to look for in the files |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
CatalogEntry eu.baltrad.beast.rules.util.IRuleUtilities.findFirstStoredEntry | ( | List< CatalogEntry > | entries | ) |
Returns the catalog entry that was stored first among the provided entries.
entries | the entries |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
CatalogEntry eu.baltrad.beast.rules.util.IRuleUtilities.findLastStoredEntry | ( | List< CatalogEntry > | entries | ) |
Returns the catalog entry that was stored last among the provided entries.
entries | the entries |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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
entries | a list of entries |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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.
nominalDT | the nominal time |
entries | a list of entries |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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.
sources | list of sources to match against |
entries | a list of entries to filter |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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.
source | the source name |
entries | the list of entries to traverse |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
List< String > eu.baltrad.beast.rules.util.IRuleUtilities.getFilesFromEntries | ( | List< CatalogEntry > | entries | ) |
Creates a list of files from the entries.
entries | a list of entries |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
List< String > eu.baltrad.beast.rules.util.IRuleUtilities.getRadarSources | ( | ) |
Returns a list of all available radar source names, like searl,...
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
List< String > eu.baltrad.beast.rules.util.IRuleUtilities.getSourcesFromEntries | ( | List< CatalogEntry > | entries | ) |
Returns a list of sources from the provided entries.
entries | the entries |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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
nominalTime | the nominal time that we are aiming for |
nominalTimeout | if timeout should be based on nominal time or not |
timeout | the timeout in milliseconds |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
List< String > eu.baltrad.beast.rules.util.IRuleUtilities.getUuidStringsFromEntries | ( | List< CatalogEntry > | entries | ) |
Creates a list of uuids.
entries | a list of entries |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
boolean eu.baltrad.beast.rules.util.IRuleUtilities.isTriggered | ( | int | ruleid, |
DateTime | now ) |
Returns if the rule has been triggered for the specified date time.
ruleid | the rule id |
now | the time period to check |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
Calendar eu.baltrad.beast.rules.util.IRuleUtilities.now | ( | ) |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
DateTime eu.baltrad.beast.rules.util.IRuleUtilities.nowDT | ( | ) |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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.
entries | The entries to filter |
limit | the date time limit |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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.
expected | the expected sources |
actual | the actual sources |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.
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.
ruleid | the rule id |
now | the time period for this rule |
Implemented in eu.baltrad.beast.rules.util.RuleUtilities.