Package com.storedobject.iot
Class Unit
java.lang.Object
com.storedobject.core.StoredObject
com.storedobject.core.Name
com.storedobject.iot.AbstractUnit
com.storedobject.iot.Unit
- All Implemented Interfaces:
Displayable
,HasName
,StringFiller
,HasId
- Direct Known Subclasses:
SuperUnit
Represents a unit with various attributes and methods for handling its statistics,
ordinality, block association, and other operations. A unit is a fundamental entity
that is associated with a site, block, and statistical data used for resource
consumption analysis and monitoring over different time periods.
This class extends
This class extends
AbstractUnit
and provides specific implementations and
utilities for managing unit-related tasks in a structured and efficient manner.-
Field Summary
Fields inherited from class com.storedobject.core.StoredObject
logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Configures the specifiedColumns
instance by adding predefined column definitions.void
Computes and updates statistics for the given transaction manager based on the unit type and data classes associated with the unit.static Unit
Retrieves a Unit instance that matches the given name.getBlock()
Retrieves the associatedBlock
for the current Unit.Retrieves the block ID associated with this unit.int
getCode()
Retrieves the unique unit code associated with the unit.final DailyStatistics
getDailyStatistics
(String name) Retrieves the DailyStatistics for a given name.final DailyStatistics
getDailyStatistics
(String name, int year, int day) Retrieves daily statistics for a given name, year, and day.final <D extends Date>
DailyStatisticsgetDailyStatistics
(String name, D date) Retrieves the daily statistics for a given name and date.final HourlyStatistics
getHourlyStatistics
(String name) Retrieves the hourly statistics for a given name.final HourlyStatistics
getHourlyStatistics
(String name, int year, int hour) Retrieves the hourly statistics for a specific name, year, and hour.final <D extends Date>
HourlyStatisticsgetHourlyStatistics
(String name, D date) Retrieves the hourly statistics for the specified name and date.int
Retrieves the layout style identifier for this unit's associated block.final MonthlyStatistics
getMonthlyStatistics
(String name) Retrieves the monthly statistics for the given name.final MonthlyStatistics
getMonthlyStatistics
(String name, int year, int month) Retrieves the monthly statistics for the specified name, year, and month.final <D extends Date>
MonthlyStatisticsgetMonthlyStatistics
(String name, D date) Retrieves the monthly statistics for the specified name and date.int
Gets the ordinality of this unit, which represents its order or sequence in some context.Retrieves the descriptive string corresponding to the current object's ordinality value.static String
getOrdinalityValue
(int ordinality) Retrieves the ordinality value corresponding to the specified ordinality index.static String[]
Retrieves an array of ordinality values associated with the Unit class.final Site
getSite()
Retrieves the associatedSite
for this unit.final Id
Retrieves the identifier of the associated site.final UnitType
getType()
Retrieves the type of this unit as an instance of UnitType.final WeeklyStatistics
getWeeklyStatistics
(String name) Retrieves the weekly statistics for the given name.final WeeklyStatistics
getWeeklyStatistics
(String name, int year, int week) Retrieves weekly statistics for a specific name, year, and week.final <D extends Date>
WeeklyStatisticsgetWeeklyStatistics
(String name, D date) Retrieves weekly statistics for the specified name and date.final YearlyStatistics
getYearlyStatistics
(String name) Retrieves the yearly statistics for a given name.final YearlyStatistics
getYearlyStatistics
(String name, int year) Retrieves the yearly statistics for a given name and year.final <D extends Date>
YearlyStatisticsgetYearlyStatistics
(String name, D date) Retrieves the yearly statistics for the given name and date.static int
hints()
Provides a hint about the type of object or structure used within this context.static void
Configures indices for the Unit instance.static String[]
links()
Provides a list of links to related classes or resources in the system.static ObjectIterator
<? extends Unit> Lists theUnit
objects based on the given name.final List
<DailyStatistics> listDailyStatistics
(String name, int year, int dayFrom, int dayTo) Retrieves a list of daily statistics filtered by the specified name, year, and day range.final List
<DailyStatistics> listDailyStatistics
(String name, int yearFrom, int dayFrom, int yearTo, int dayTo) Retrieves a list of daily statistics within a specified date range.final List
<DailyStatistics> listDailyStatistics
(String name, Site site, int periodCount) Retrieves a list of daily statistics for the specified parameters.final List
<HourlyStatistics> listHourlyStatistics
(String name, int year, int hourFrom, int hourTo) Retrieves a list of hourly statistics for a given name and year within the specified hour range.final List
<HourlyStatistics> listHourlyStatistics
(String name, int yearFrom, int hourFrom, int yearTo, int hourTo) Retrieves hourly statistics for a given name across a specified time range.final List
<HourlyStatistics> listHourlyStatistics
(String name, Site site, int periodCount) Retrieves a list of HourlyStatistics for a specified name, site, and period count.final List
<MonthlyStatistics> listMonthlyStatistics
(String name, int year, int monthFrom, int monthTo) Retrieves a list of monthly statistics based on the specified parameters.final List
<MonthlyStatistics> listMonthlyStatistics
(String name, int yearFrom, int monthFrom, int yearTo, int monthTo) Retrieves a list of monthly statistics for a given name within a specified date range.final List
<MonthlyStatistics> listMonthlyStatistics
(String name, Site site, int periodCount) Retrieves a list of monthly statistics for a given site and time period.final List
<WeeklyStatistics> listWeeklyStatistics
(String name, int year, int weekFrom, int weekTo) Retrieves a list of weekly statistics for the specified name and year within the given week range.final List
<WeeklyStatistics> listWeeklyStatistics
(String name, int yearFrom, int weekFrom, int yearTo, int weekTo) Retrieves a list of weekly statistics for a given name, over a specified range of years and weeks.final List
<WeeklyStatistics> listWeeklyStatistics
(String name, Site site, int periodCount) Retrieves a list of weekly statistics based on the specified parameters.final List
<YearlyStatistics> listYearlyStatistics
(String name, int yearFrom, int yearTo) Retrieves a list of yearly statistics for a given name and within a specified year range.final List
<YearlyStatistics> listYearlyStatistics
(String name, Site site, int periodCount) Retrieves a list of yearly statistics for a specified entity within a given time period.void
Recomputes all statistics for the current unit by first deleting the existing statistics and then regenerating them.void
saved()
Overridden method that is invoked when the object's state has been saved successfully.void
Sets the block identifier for this Unit.void
Sets the block associated with this unit.void
setBlock
(BigDecimal idValue) Sets the block for the unit using the specified block identifier value.void
setCode
(int code) Sets the unique code for the Unit.void
setOrdinality
(int ordinality) Sets the ordinality value for the unit.Converts the object to a displayable string format, combining the super class's display string with this instance's code value in parentheses.void
Validates the Unit's data by ensuring theblockId
is associated with an instance of theBlock
class and invoking additional data validation logic from the superclass.Methods inherited from class com.storedobject.iot.AbstractUnit
computeConsumption, consumes, consumes, getActive, getConsumptionCalculator, getDailyConsumption, getDailyConsumption, getDailyConsumption, getHourlyConsumption, getHourlyConsumption, getHourlyConsumption, getMonthlyConsumption, getMonthlyConsumption, getMonthlyConsumption, getWeeklyConsumption, getWeeklyConsumption, getWeeklyConsumption, getYearlyConsumption, getYearlyConsumption, getYearlyConsumption, listDailyConsumption, listDailyConsumption, listDailyConsumption, listHourlyConsumption, listHourlyConsumption, listHourlyConsumption, listMonthlyConsumption, listMonthlyConsumption, listMonthlyConsumption, listWeeklyConsumption, listWeeklyConsumption, listWeeklyConsumption, listYearlyConsumption, listYearlyConsumption, setActive
Methods inherited from class com.storedobject.core.Name
getName, getUniqueCondition, setName, toString
Methods inherited from class com.storedobject.core.StoredObject
addLink, addLink, addLink, addLink, addLink, addLink, addLink, addLink, checkCurrency, checkCurrency, checkForDuplicate, checkForDuplicate, checkTimeZone, checkTransaction, clearObjectLinks, contemporary, copy, copy, count, count, count, count, count, count, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, create, created, delete, delete, delete, deleted, directUpdate, equals, exists, exists, exists, exists, exists, existsFileData, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsMaster, existsMaster, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, family, family, family, fill, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, getAttachment, getAttachmentId, getChildren, getDeleted, getDeleted, getExistsCondition, getExistsCondition, getFileData, getFileData, getHistorical, getId, getKeyIndex, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getNotExistsCondition, getNotExistsCondition, getParent, getParent, getParent, getParentId, getParentId, getParentId, getRelated, getRelated, getTransaction, getTransactionId, getTransactionIP, getUnique, hashCode, inserted, isModified, isVirtual, list, list, list, list, list, list, list, list, list, list, list, list, list, listFileData, listFileData, listHistory, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listTree, listTree, listTree, listTree, listViaQuery, listViaQuery, load, load, load, load, loaded, loading, makeNew, makeVirtual, migrate, moduleName, nextVersion, objectLink, objectLink, objectLink, objectLinks, objectLinks, old, person, previousVersion, previousVersion, query, query, query, query, query, query, query, query, query, query, query, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, reload, reload, reloaded, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeReverseLinks, removeReverseLinks, save, save, save, save, save, save, save, save, save, save, save, save, save, save, saving, setMaster, setRawValue, setTransaction, stringify, tableName, timestamp, toCode, transacting, undelete, undelete, undeleted, updated, user, userId, validate, validateChildAttach, validateChildDetach, validateChildUpdate, validateDelete, validateInsert, validateParentAttach, validateParentDetach, validateParentUpdate, validateUndelete, validateUpdate, valueEquals
-
Constructor Details
-
Unit
public Unit()Default constructor for the Unit class. Initializes a new instance of the Unit class.
-
-
Method Details
-
columns
Configures the specifiedColumns
instance by adding predefined column definitions.- Parameters:
columns
- theColumns
object to be configured; it will have additional column definitions added, specifically "Block" with data type "id", "Code" with data type "int", and "Ordinality" with data type "int".
-
indices
Configures indices for the Unit instance.- Parameters:
indices
- The Indices object to which index definitions are added.
-
links
Provides a list of links to related classes or resources in the system.- Returns:
- An array of strings where each string represents a link with the format "Description|ClassPath".
-
saved
Overridden method that is invoked when the object's state has been saved successfully. This method calls the parent class's `saved()` method to ensure that any additional saving logic from the superclass is executed. After the superclass logic is executed, it triggers a refresh operation for the `DataSet` to ensure any associated data is updated and synchronized if applicable.- Overrides:
saved
in classStoredObject
- Throws:
Exception
- if an error occurs during the save or refresh process
-
get
-
list
Lists theUnit
objects based on the given name.- Parameters:
name
- The name of the unit to list.- Returns:
- An iterator providing access to the list of
Unit
objects matching the given name.
-
hints
public static int hints()Provides a hint about the type of object or structure used within this context.- Returns:
- A constant value representing a hint, such as ObjectHint.SMALL_LIST.
-
setBlock
Sets the block identifier for this Unit.- Parameters:
blockId
- the identifier of the block to associate with this Unit
-
setBlock
Sets the block for the unit using the specified block identifier value.- Parameters:
idValue
- The identifier value of the block as a BigDecimal.
-
setBlock
Sets the block associated with this unit.- Parameters:
block
- The block to be set. If null, the block ID will be set to null; otherwise, the block's ID will be used to set the block.
-
getBlockId
Retrieves the block ID associated with this unit.- Specified by:
getBlockId
in classAbstractUnit
- Returns:
- The block ID of the unit as an instance of
Id
.
-
getBlock
Retrieves the associatedBlock
for the current Unit. If the block is not already loaded, it is fetched and initialized using thegetRelated()
method with the block ID.- Returns:
- The associated Block instance. If the block is not set, it will attempt to retrieve it using the related block ID.
-
setCode
public void setCode(int code) Sets the unique code for the Unit.- Parameters:
code
- the unique integer code that identifies the Unit
-
getCode
-
setOrdinality
public void setOrdinality(int ordinality) Sets the ordinality value for the unit.- Parameters:
ordinality
- The ordinality value to set.
-
getOrdinality
-
getOrdinalityValue
Retrieves the descriptive string corresponding to the current object's ordinality value.- Returns:
- The string representation of the ordinality value for this instance.
-
getOrdinalityValue
Retrieves the ordinality value corresponding to the specified ordinality index.- Parameters:
ordinality
- The ordinality index to determine the ordinality value.- Returns:
- A string representation of the ordinality value based on the provided index.
-
getOrdinalityValues
Retrieves an array of ordinality values associated with the Unit class.- Returns:
- A string array containing the ordinality values.
-
getLayoutStyle
public int getLayoutStyle()Retrieves the layout style identifier for this unit's associated block.- Returns:
- An integer representing the layout style of the associated block.
-
validateData
Validates the Unit's data by ensuring theblockId
is associated with an instance of theBlock
class and invoking additional data validation logic from the superclass.- Overrides:
validateData
in className
- Parameters:
tm
- TheTransactionManager
used to perform validation operations.- Throws:
Exception
- If validation fails or an error occurs during the validation process.
-
getSite
Retrieves the associatedSite
for this unit. If the site is not already set, it initializes thesite
field by fetching the site from the associated block.- Specified by:
getSite
in classAbstractUnit
- Returns:
- The
Site
object associated with this unit. If the site is not set, it retrieves the site from the block and returns it.
-
getSiteId
Retrieves the identifier of the associated site. If the site is defined for the current instance, its identifier is returned. Otherwise, the site identifier is retrieved from the associated block.- Returns:
- The identifier of the site as an
Id
object.
-
getType
Retrieves the type of this unit as an instance of UnitType. This method attempts to create and return a UnitType object based on the class of this unit. If an exception occurs during the creation process, it returns null.- Returns:
- The UnitType instance representing the type of this unit, or null if the type cannot be determined.
-
recomputeStatistics
Recomputes all statistics for the current unit by first deleting the existing statistics and then regenerating them.- Parameters:
tm
- TheTransactionManager
instance used for performing the necessary database transactions.- Throws:
Exception
- If an error occurs during the recomputation process, including database transaction failures or operations on statistics.
-
computeStatistics
Computes and updates statistics for the given transaction manager based on the unit type and data classes associated with the unit.- Parameters:
tm
- The transaction manager instance responsible for managing database transactions during the computation of statistics.- Throws:
Exception
- If any exception occurs during the computation or interaction with the data methods.
-
listYearlyStatistics
Retrieves a list of yearly statistics for a given name and within a specified year range.- Parameters:
name
- the name for which statistics are being retrievedyearFrom
- the starting year of the rangeyearTo
- the ending year of the range- Returns:
- a list of YearlyStatistics objects within the specified year range for the given name
-
listYearlyStatistics
Retrieves a list of yearly statistics for a specified entity within a given time period.- Parameters:
name
- the name of the entity for which yearly statistics are to be retrievedsite
- the site associated with the entityperiodCount
- the number of years for which statistics should be retrieved, counting backwards from the current year- Returns:
- a list of YearlyStatistics representing the yearly data for the specified entity and period
-
getYearlyStatistics
Retrieves the yearly statistics for a given name and year.- Parameters:
name
- the name identifier for which the statistics are to be retrievedyear
- the year for which the statistics are requested- Returns:
- an instance of YearlyStatistics containing the data for the specified name and year
-
getYearlyStatistics
Retrieves the yearly statistics for the given name and date.- Parameters:
name
- the name for which the yearly statistics are to be retrieveddate
- the date used to determine the year for the statistics- Returns:
- the yearly statistics corresponding to the given name and year derived from the date
-
listMonthlyStatistics
public final List<MonthlyStatistics> listMonthlyStatistics(String name, int year, int monthFrom, int monthTo) Retrieves a list of monthly statistics based on the specified parameters.- Parameters:
name
- the name of the entity for which statistics are retrievedyear
- the year for the data to be retrievedmonthFrom
- the starting month (inclusive) for the data rangemonthTo
- the ending month (inclusive) for the data range- Returns:
- a list of MonthlyStatistics objects representing the retrieved data
-
listMonthlyStatistics
public final List<MonthlyStatistics> listMonthlyStatistics(String name, int yearFrom, int monthFrom, int yearTo, int monthTo) Retrieves a list of monthly statistics for a given name within a specified date range.- Parameters:
name
- the name for which statistics need to be retrievedyearFrom
- the starting year of the desired date rangemonthFrom
- the starting month of the desired date rangeyearTo
- the ending year of the desired date rangemonthTo
- the ending month of the desired date range- Returns:
- a list of MonthlyStatistics objects within the specified range; an empty list if the range is invalid or no statistics are available
-
listMonthlyStatistics
Retrieves a list of monthly statistics for a given site and time period.- Parameters:
name
- the name or identifier for the entity whose statistics are being retrievedsite
- the site for which the statistics are to be generatedperiodCount
- the number of months for which the statistics should be retrieved- Returns:
- a list of MonthlyStatistics objects containing the requested data
-
getMonthlyStatistics
Retrieves the monthly statistics for the specified name, year, and month.- Parameters:
name
- the identifier for which the statistics are retrievedyear
- the year for which the statistics are retrievedmonth
- the month for which the statistics are retrieved- Returns:
- an instance of MonthlyStatistics containing the relevant data for the specified parameters
-
getMonthlyStatistics
Retrieves the monthly statistics for the specified name and date.- Parameters:
name
- the identifier for which the monthly statistics are to be retrieveddate
- the date object used to extract the month and year for the statistics- Returns:
- the monthly statistics based on the provided name and date
-
listWeeklyStatistics
public final List<WeeklyStatistics> listWeeklyStatistics(String name, int year, int weekFrom, int weekTo) Retrieves a list of weekly statistics for the specified name and year within the given week range. The method supports querying statistics for a single week, a range of weeks within the same year, or for weeks spanning across two consecutive years.- Parameters:
name
- the name associated with the statistics being queriedyear
- the starting year for the week rangeweekFrom
- the starting week number (inclusive)weekTo
- the ending week number (inclusive)- Returns:
- a list of weekly statistics for the specified parameters
-
listWeeklyStatistics
public final List<WeeklyStatistics> listWeeklyStatistics(String name, int yearFrom, int weekFrom, int yearTo, int weekTo) Retrieves a list of weekly statistics for a given name, over a specified range of years and weeks.- Parameters:
name
- the name for which the weekly statistics are to be retrievedyearFrom
- the starting year of the rangeweekFrom
- the starting week of the range within the starting yearyearTo
- the ending year of the rangeweekTo
- the ending week of the range within the ending year- Returns:
- a list of WeeklyStatistics for the specified range, or an empty list if the range is invalid
-
listWeeklyStatistics
Retrieves a list of weekly statistics based on the specified parameters.- Parameters:
name
- the name associated with the statistics to be retrievedsite
- the site for which the statistics are to be generatedperiodCount
- the number of periods (weeks) to include in the statistics- Returns:
- a list of WeeklyStatistics that match the specified criteria
-
getWeeklyStatistics
Retrieves weekly statistics for a specific name, year, and week.- Parameters:
name
- the identifier for which the weekly statistics are to be retrievedyear
- the year for the desired weekly statisticsweek
- the week in the specified year for the desired statistics- Returns:
- an instance of WeeklyStatistics representing the data for the specified name, year, and week
-
getWeeklyStatistics
Retrieves weekly statistics for the specified name and date.- Type Parameters:
D
- a type that extends java.util.Date- Parameters:
name
- the name associated with the statistics to retrievedate
- the date used to determine the year and week for the statistics- Returns:
- a WeeklyStatistics object containing the statistics for the specified name and date
-
listHourlyStatistics
public final List<HourlyStatistics> listHourlyStatistics(String name, int year, int hourFrom, int hourTo) Retrieves a list of hourly statistics for a given name and year within the specified hour range.- Parameters:
name
- the name for which hourly statistics are to be retrievedyear
- the year for which hourly statistics are to be retrievedhourFrom
- the starting hour of the rangehourTo
- the ending hour of the range- Returns:
- a list of HourlyStatistics objects containing data for the specified range
-
listHourlyStatistics
public final List<HourlyStatistics> listHourlyStatistics(String name, int yearFrom, int hourFrom, int yearTo, int hourTo) Retrieves hourly statistics for a given name across a specified time range.- Parameters:
name
- the name for which hourly statistics are being retrievedyearFrom
- the starting year of the rangehourFrom
- the starting hour of the range in the starting yearyearTo
- the ending year of the rangehourTo
- the ending hour of the range in the ending year- Returns:
- a list of hourly statistics for the specified name and time range, or an empty list if the range is invalid
-
listHourlyStatistics
Retrieves a list of HourlyStatistics for a specified name, site, and period count.- Parameters:
name
- the identifier for which hourly statistics are requestedsite
- the site associated with the hourly statisticsperiodCount
- the number of periods to retrieve statistics for- Returns:
- a list of HourlyStatistics objects representing the data for the specified parameters
-
getHourlyStatistics
Retrieves the hourly statistics for a specific name, year, and hour.- Parameters:
name
- the name identifier for which the statistics are to be retrievedyear
- the year for which the statistics are to be retrievedhour
- the specific hour of the day (0-23) for which the statistics are to be retrieved- Returns:
- an instance of HourlyStatistics containing the relevant data for the specified parameters
-
getHourlyStatistics
Retrieves the hourly statistics for the specified name and date.- Type Parameters:
D
- the type of the date parameter, which must extend java.util.Date- Parameters:
name
- the name for which the hourly statistics are to be retrieveddate
- the date object specifying the year and hour of the statistics- Returns:
- an HourlyStatistics object containing the statistics for the given name and date
-
listDailyStatistics
public final List<DailyStatistics> listDailyStatistics(String name, int year, int dayFrom, int dayTo) Retrieves a list of daily statistics filtered by the specified name, year, and day range.- Parameters:
name
- the name identifier for the daily statisticsyear
- the year to filter the statisticsdayFrom
- the starting day of the range (inclusive)dayTo
- the ending day of the range (inclusive)- Returns:
- a list of DailyStatistics objects within the specified range
-
listDailyStatistics
public final List<DailyStatistics> listDailyStatistics(String name, int yearFrom, int dayFrom, int yearTo, int dayTo) Retrieves a list of daily statistics within a specified date range.- Parameters:
name
- the name of the entity for which the statistics are being retrievedyearFrom
- the starting year of the rangedayFrom
- the starting day of the year in the rangeyearTo
- the ending year of the rangedayTo
- the ending day of the year in the range- Returns:
- a list of DailyStatistics objects representing the statistics for each day within the specified date range; returns an empty list if the range is invalid
-
listDailyStatistics
Retrieves a list of daily statistics for the specified parameters.- Parameters:
name
- the name associated with the daily statisticssite
- the site for which the daily statistics are being retrievedperiodCount
- the number of daily periods to be considered- Returns:
- a list of DailyStatistics objects for the specified parameters
-
getDailyStatistics
Retrieves daily statistics for a given name, year, and day.- Parameters:
name
- the name associated with the statistics to retrieveyear
- the year for which the statistics are being retrievedday
- the day (within the specified year) for which the statistics are being retrieved- Returns:
- the daily statistics corresponding to the specified parameters
-
getDailyStatistics
Retrieves the daily statistics for a given name and date.- Type Parameters:
D
- the type of the date, which extends java.util.Date- Parameters:
name
- the name associated with the daily statisticsdate
- the date for which the daily statistics are requested- Returns:
- the daily statistics corresponding to the provided name and date
-
getHourlyStatistics
Retrieves the hourly statistics for a given name. If the statistics are not yet available, they are fetched or created for the corresponding time period and stored for future use.- Parameters:
name
- the name for which the hourly statistics are to be retrieved- Returns:
- the HourlyStatistics object associated with the given name
-
getDailyStatistics
Retrieves the DailyStatistics for a given name. If the statistics are not already available, it initializes and stores a new DailyStatistics instance for the specified name and date.- Parameters:
name
- the name for which the DailyStatistics are retrieved or created- Returns:
- the DailyStatistics instance corresponding to the given name
-
getWeeklyStatistics
Retrieves the weekly statistics for the given name. If the statistics are not already cached, they are either fetched or created for the specified name and date.- Parameters:
name
- the identifier for the statistics to be retrieved- Returns:
- the WeeklyStatistics object corresponding to the specified name
-
getMonthlyStatistics
Retrieves the monthly statistics for the given name. If no statistics are found, it attempts to generate or retrieve statistics for the previous month.- Parameters:
name
- the name for which the monthly statistics are required- Returns:
- the MonthlyStatistics object corresponding to the given name
-
getYearlyStatistics
Retrieves the yearly statistics for a given name. If the statistics do not exist, it will attempt to create and cache the statistics for the specified name.- Parameters:
name
- the name for which the yearly statistics are retrieved- Returns:
- the YearlyStatistics object associated with the given name
-
toDisplay
Converts the object to a displayable string format, combining the super class's display string with this instance's code value in parentheses.- Specified by:
toDisplay
in interfaceDisplayable
- Overrides:
toDisplay
in classStoredObject
- Returns:
- a formatted string combining the super class display string and the code value.
-