Package com.storedobject.iot
Class AbstractUnit
java.lang.Object
com.storedobject.core.StoredObject
com.storedobject.core.Name
com.storedobject.iot.AbstractUnit
- All Implemented Interfaces:
Displayable
,HasName
,StringFiller
,HasId
Represents an abstract unit within a system.
This class serves as a base for specific unit implementations, providing common functionality
and requiring extensions to supply specific attributes or behaviors.
- Author:
- Syam
-
Field Summary
Fields inherited from class com.storedobject.core.StoredObject
logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Configures column definitions for the given `Columns` object by adding metadata about the "Active" column.protected Double
computeConsumption
(int resource, long from, long to) Computes the resource consumption for a specific unit within a given time interval.boolean
consumes
(int resource) Determines whether the unit consumes a specified resource.boolean
Determines whether the unit consumes a specified resource.boolean
Retrieves the active status of the unit.abstract Id
Retrieves the unique identifier of the block associated with this unit.protected ConsumptionCalculator
getConsumptionCalculator
(int resource) Retrieves the specific consumption calculator for a given resource.final DailyConsumption
getDailyConsumption
(Resource resource) Retrieves the daily consumption record for a specific resource.final DailyConsumption
getDailyConsumption
(Resource resource, int year, int day) Retrieves daily consumption data for a specific resource on a given day of a year.final <D extends Date>
DailyConsumptiongetDailyConsumption
(Resource resource, D date) Retrieves the daily consumption for a specific resource and date.final HourlyConsumption
getHourlyConsumption
(Resource resource) Retrieves the hourly consumption for the specified resource.final HourlyConsumption
getHourlyConsumption
(Resource resource, int year, int hour) Retrieves the hourly consumption for a specific resource, year, and hour.final <D extends Date>
HourlyConsumptiongetHourlyConsumption
(Resource resource, D date) Retrieves the hourly consumption for the specified resource and date.final MonthlyConsumption
getMonthlyConsumption
(Resource resource) Retrieves the monthly consumption data for the specified resource.final MonthlyConsumption
getMonthlyConsumption
(Resource resource, int year, int month) Retrieves the monthly consumption for a specific resource in a given year and month.final <D extends Date>
MonthlyConsumptiongetMonthlyConsumption
(Resource resource, D date) Retrieves the monthly consumption for a given resource and date.abstract Site
getSite()
Retrieves the associated site of the current unit.final WeeklyConsumption
getWeeklyConsumption
(Resource resource) Retrieves the weekly consumption for a given resource.final WeeklyConsumption
getWeeklyConsumption
(Resource resource, int year, int week) Retrieves the weekly consumption for a specified resource, year, and week.final <D extends Date>
WeeklyConsumptiongetWeeklyConsumption
(Resource resource, D date) Retrieves the weekly consumption data for a given resource based on a specific date.final YearlyConsumption
getYearlyConsumption
(Resource resource) Retrieves the yearly consumption details for a specific resource.final YearlyConsumption
getYearlyConsumption
(Resource resource, int year) Retrieves the yearly consumption for a specified resource and year.final <D extends Date>
YearlyConsumptiongetYearlyConsumption
(Resource resource, D date) Retrieves the yearly consumption for a specific resource based on the provided date.final List
<DailyConsumption> listDailyConsumption
(Resource resource, int year, int dayFrom, int dayTo) Retrieves a list of daily consumption records for a specific resource within a given time range.final List
<DailyConsumption> listDailyConsumption
(Resource resource, int yearFrom, int dayFrom, int yearTo, int dayTo) Retrieves a list of daily consumption data for a specified resource over a range of dates.final List
<DailyConsumption> listDailyConsumption
(Resource resource, Site site, int periodCount) Retrieves a list of daily consumption records for a given resource within a specific time period.final List
<HourlyConsumption> listHourlyConsumption
(Resource resource, int year, int hourFrom, int hourTo) Retrieves a list of hourly consumption data for the specified resource within a given year and time interval.final List
<HourlyConsumption> listHourlyConsumption
(Resource resource, int yearFrom, int hourFrom, int yearTo, int hourTo) Retrieves a list of hourly consumption records for a specified resource between given years and hours.final List
<HourlyConsumption> listHourlyConsumption
(Resource resource, Site site, int periodCount) Retrieves a list of hourly consumption data for a specified resource at a given site over a defined period.final List
<MonthlyConsumption> listMonthlyConsumption
(Resource resource, int year, int monthFrom, int monthTo) Retrieves a list of monthly consumption records for a specified resource and time range.final List
<MonthlyConsumption> listMonthlyConsumption
(Resource resource, int yearFrom, int monthFrom, int yearTo, int monthTo) Retrieves a list of monthly consumption data for the specified resource within the given date range.final List
<MonthlyConsumption> listMonthlyConsumption
(Resource resource, Site site, int periodCount) Retrieves a list of monthly consumption data for a specified resource and site over a given number of periods (months).final List
<WeeklyConsumption> listWeeklyConsumption
(Resource resource, int year, int weekFrom, int weekTo) Retrieves a list of weekly consumption data for a given resource and specified time range.final List
<WeeklyConsumption> listWeeklyConsumption
(Resource resource, int yearFrom, int weekFrom, int yearTo, int weekTo) Retrieves the weekly consumption data for a given resource over a specified time period.final List
<WeeklyConsumption> listWeeklyConsumption
(Resource resource, Site site, int periodCount) Retrieves a list of weekly consumption data for the specified resource and site over a given number of weeks.final List
<YearlyConsumption> listYearlyConsumption
(Resource resource, int yearFrom, int yearTo) Retrieves a list of yearly consumption data for the specified resource over a range of years.final List
<YearlyConsumption> listYearlyConsumption
(Resource resource, Site site, int periodCount) Retrieves a list of yearly consumption data for a given resource and site over a specified number of years.void
setActive
(boolean active) Sets the active status of the unit.Methods inherited from class com.storedobject.core.Name
getName, getUniqueCondition, indices, setName, toString, validateData
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, saved, saving, setMaster, setRawValue, setTransaction, stringify, tableName, timestamp, toCode, toDisplay, transacting, undelete, undelete, undeleted, updated, user, userId, validate, validateChildAttach, validateChildDetach, validateChildUpdate, validateDelete, validateInsert, validateParentAttach, validateParentDetach, validateParentUpdate, validateUndelete, validateUpdate, valueEquals
-
Constructor Details
-
AbstractUnit
public AbstractUnit()Default constructor for the AbstractUnit class. This constructor initializes an instance of the AbstractUnit class or its subclasses. The class acts as a base class providing foundational functionality for concrete unit implementations.
-
-
Method Details
-
columns
Configures column definitions for the given `Columns` object by adding metadata about the "Active" column.- Parameters:
columns
- the object where column definitions are added. This should support methods to add metadata, such as name and type, for database or data export structures.
-
setActive
public void setActive(boolean active) Sets the active status of the unit.- Parameters:
active
- a boolean value indicating whether the unit should be active (true) or inactive (false)
-
getActive
-
computeConsumption
Computes the resource consumption for a specific unit within a given time interval.- Parameters:
resource
- the resource identifier to calculate consumption forfrom
- the start time (in milliseconds since epoch) of the period for which consumption is to be computedto
- the end time (in milliseconds since epoch) of the period for which consumption is to be computed- Returns:
- the calculated consumption as a Double, or null if no ConsumptionCalculator is available for the resource
-
getSite
Retrieves the associated site of the current unit. This method is abstract and must be implemented by subclasses.- Returns:
- The site object associated with the current unit.
-
getBlockId
Retrieves the unique identifier of the block associated with this unit.- Returns:
- an
Id
object representing the block's unique identifier.
-
getConsumptionCalculator
Retrieves the specific consumption calculator for a given resource. The consumption calculator is responsible for calculating resource usage over a specific time period based on the provided resource identifier.- Parameters:
resource
- the identifier of the resource for which the consumption calculator is requested- Returns:
- the
ConsumptionCalculator
for the specified resource, ornull
if no relevant calculator is available
-
consumes
public boolean consumes(int resource) Determines whether the unit consumes a specified resource.- Parameters:
resource
- The resource identifier to check for consumption.- Returns:
true
if the unit consumes the specified resource;false
otherwise.
-
consumes
Determines whether the unit consumes a specified resource.- Parameters:
resource
- The resource to check for consumption.- Returns:
true
if the unit consumes the specified resource;false
otherwise.
-
listYearlyConsumption
public final List<YearlyConsumption> listYearlyConsumption(Resource resource, int yearFrom, int yearTo) Retrieves a list of yearly consumption data for the specified resource over a range of years.- Parameters:
resource
- the resource for which the yearly consumption data is requestedyearFrom
- the starting year of the range (inclusive)yearTo
- the ending year of the range (inclusive)- Returns:
- a list of
YearlyConsumption
objects representing the yearly consumption data for the specified resource
-
listYearlyConsumption
public final List<YearlyConsumption> listYearlyConsumption(Resource resource, Site site, int periodCount) Retrieves a list of yearly consumption data for a given resource and site over a specified number of years.- Parameters:
resource
- the resource for which the yearly consumption data is to be retrievedsite
- the site associated with the resource and its consumption dataperiodCount
- the number of years for which the yearly consumption data will be listed- Returns:
- a list of YearlyConsumption objects representing the yearly consumption data over the specified period
-
getYearlyConsumption
Retrieves the yearly consumption for a specified resource and year. This method calculates the resource consumption aggregated over the specified year.- Parameters:
resource
- the resource for which the yearly consumption is to be retrievedyear
- the year for which the consumption is to be calculated- Returns:
- the
YearlyConsumption
object representing the aggregated consumption for the specified resource and year
-
getYearlyConsumption
Retrieves the yearly consumption for a specific resource based on the provided date.- Type Parameters:
D
- A type that extendsDate
, representing the specific date used for determining the year.- Parameters:
resource
- The resource for which the yearly consumption is being retrieved.date
- The date used to determine the year for retrieving the yearly consumption.- Returns:
- A
YearlyConsumption
object representing the resource's consumption for the determined year.
-
listMonthlyConsumption
public final List<MonthlyConsumption> listMonthlyConsumption(Resource resource, int year, int monthFrom, int monthTo) Retrieves a list of monthly consumption records for a specified resource and time range.- Parameters:
resource
- the resource for which monthly consumption data is requestedyear
- the year for the time rangemonthFrom
- the starting month of the time range (inclusive)monthTo
- the ending month of the time range (inclusive)- Returns:
- a list of
MonthlyConsumption
objects corresponding to the specified resource and time range
-
listMonthlyConsumption
public final List<MonthlyConsumption> listMonthlyConsumption(Resource resource, int yearFrom, int monthFrom, int yearTo, int monthTo) Retrieves a list of monthly consumption data for the specified resource within the given date range.- Parameters:
resource
- The resource for which the monthly consumption data is being retrieved.yearFrom
- The starting year of the date range.monthFrom
- The starting month of the date range.yearTo
- The ending year of the date range.monthTo
- The ending month of the date range.- Returns:
- A List of MonthlyConsumption objects representing the monthly consumption data for the specified resource within the provided date range. Returns an empty list if the date range is invalid.
-
listMonthlyConsumption
public final List<MonthlyConsumption> listMonthlyConsumption(Resource resource, Site site, int periodCount) Retrieves a list of monthly consumption data for a specified resource and site over a given number of periods (months).- Parameters:
resource
- the resource for which the consumption data is being retrievedsite
- the site associated with the resourceperiodCount
- the number of months for which the consumption data is required- Returns:
- a list of MonthlyConsumption objects representing the consumption data for the specified resource and site over the given period
-
getMonthlyConsumption
Retrieves the monthly consumption for a specific resource in a given year and month.- Parameters:
resource
- the resource for which the monthly consumption is being requestedyear
- the year for which the consumption data is requiredmonth
- the month for which the consumption data is required (1 for January, 12 for December)- Returns:
- a
MonthlyConsumption
object representing the consumption for the specified resource, year, and month, ornull
if no data is available
-
getMonthlyConsumption
Retrieves the monthly consumption for a given resource and date.- Type Parameters:
D
- a type that extendsDate
, representing the date parameter- Parameters:
resource
- the resource for which the monthly consumption is to be retrieveddate
- the date used to determine the year and month for the monthly consumption calculation- Returns:
- the
MonthlyConsumption
object for the specified resource and date
-
listWeeklyConsumption
public final List<WeeklyConsumption> listWeeklyConsumption(Resource resource, int year, int weekFrom, int weekTo) Retrieves a list of weekly consumption data for a given resource and specified time range.- Parameters:
resource
- the resource for which weekly consumption data is to be fetchedyear
- the specific year corresponding to the time rangeweekFrom
- the starting week number in the specified yearweekTo
- the ending week number in the specified year- Returns:
- a list of WeeklyConsumption objects representing the consumption data for the given resource within the specified year and week range
-
listWeeklyConsumption
public final List<WeeklyConsumption> listWeeklyConsumption(Resource resource, int yearFrom, int weekFrom, int yearTo, int weekTo) Retrieves the weekly consumption data for a given resource over a specified time period.- Parameters:
resource
- the resource for which the weekly consumption needs to be calculatedyearFrom
- the starting year of the time rangeweekFrom
- the starting week of the starting yearyearTo
- the ending year of the time rangeweekTo
- the ending week of the ending year- Returns:
- a list of WeeklyConsumption objects representing the consumption data for the given time range
-
listWeeklyConsumption
public final List<WeeklyConsumption> listWeeklyConsumption(Resource resource, Site site, int periodCount) Retrieves a list of weekly consumption data for the specified resource and site over a given number of weeks.- Parameters:
resource
- The resource for which the consumption data is being requested.site
- The site associated with the resource.periodCount
- The number of weeks for which data should be retrieved, counting back from the current week.- Returns:
- A list of WeeklyConsumption objects representing the consumption data for the specified period.
-
getWeeklyConsumption
Retrieves the weekly consumption for a specified resource, year, and week.- Parameters:
resource
- the resource for which the weekly consumption is requestedyear
- the year for which the weekly consumption is calculatedweek
- the week of the specified year for which the consumption is calculated- Returns:
- the
WeeklyConsumption
object containing the data for the specified resource, year, and week
-
getWeeklyConsumption
Retrieves the weekly consumption data for a given resource based on a specific date. Internally, this method calculates the year and week of the provided date and fetches the corresponding weekly consumption information.- Type Parameters:
D
- a generic type extendingDate
, representing the date parameter type- Parameters:
resource
- the resource for which the weekly consumption data is to be retrieveddate
- the date used to determine the year and week for weekly consumption retrieval; must be a subclass ofDate
- Returns:
- the
WeeklyConsumption
object containing the resource's weekly consumption data
-
listHourlyConsumption
public final List<HourlyConsumption> listHourlyConsumption(Resource resource, int year, int hourFrom, int hourTo) Retrieves a list of hourly consumption data for the specified resource within a given year and time interval.- Parameters:
resource
- the resource for which hourly consumption data is requestedyear
- the year during which the hourly consumption data should be retrievedhourFrom
- the starting hour (inclusive) of the time interval within the yearhourTo
- the ending hour (inclusive) of the time interval within the year- Returns:
- a list of
HourlyConsumption
objects representing the consumption data for the specified resource and time range
-
listHourlyConsumption
public final List<HourlyConsumption> listHourlyConsumption(Resource resource, int yearFrom, int hourFrom, int yearTo, int hourTo) Retrieves a list of hourly consumption records for a specified resource between given years and hours.- Parameters:
resource
- the resource for which hourly consumption data is to be retrievedyearFrom
- the starting year of the rangehourFrom
- the starting hour of the range within the starting yearyearTo
- the ending year of the rangehourTo
- the ending hour of the range within the ending year- Returns:
- a list of hourly consumption records for the specified resource and range
-
listHourlyConsumption
public final List<HourlyConsumption> listHourlyConsumption(Resource resource, Site site, int periodCount) Retrieves a list of hourly consumption data for a specified resource at a given site over a defined period.- Parameters:
resource
- the resource for which hourly consumption data is to be retrievedsite
- the site associated with the resourceperiodCount
- the number of hours to include in the consumption data, counting backwards from the current time- Returns:
- a list of HourlyConsumption objects representing consumption data over the specified period
-
getHourlyConsumption
Retrieves the hourly consumption for a specific resource, year, and hour.- Parameters:
resource
- the resource for which the hourly consumption is retrievedyear
- the year for which the hourly consumption is calculatedhour
- the specific hour within the year for which the consumption is retrieved- Returns:
- the
HourlyConsumption
object containing the consumption data for the specified parameters
-
getHourlyConsumption
Retrieves the hourly consumption for the specified resource and date. The method calculates the corresponding year and hour for the given date and fetches the associated hourly consumption.- Type Parameters:
D
- a subclass ofDate
representing the date type- Parameters:
resource
- theResource
for which the hourly consumption is to be fetcheddate
- the date, of typeD
, which is used to determine the year and hour- Returns:
- an instance of
HourlyConsumption
representing the hourly consumption for the specified resource and date
-
listDailyConsumption
public final List<DailyConsumption> listDailyConsumption(Resource resource, int year, int dayFrom, int dayTo) Retrieves a list of daily consumption records for a specific resource within a given time range.- Parameters:
resource
- the resource for which daily consumption records are being queriedyear
- the year in which the daily consumption records residedayFrom
- the starting day (inclusive) of the time range, as a day-of-year valuedayTo
- the ending day (inclusive) of the time range, as a day-of-year value- Returns:
- a list of
DailyConsumption
objects representing the daily consumption for the specified resource and time range
-
listDailyConsumption
public final List<DailyConsumption> listDailyConsumption(Resource resource, int yearFrom, int dayFrom, int yearTo, int dayTo) Retrieves a list of daily consumption data for a specified resource over a range of dates.- Parameters:
resource
- the resource for which the daily consumption is to be listedyearFrom
- the starting year of the date rangedayFrom
- the starting day of the year in the date rangeyearTo
- the ending year of the date rangedayTo
- the ending day of the year in the date range- Returns:
- a list of
DailyConsumption
objects representing the daily consumption data for the specified resource within the given date range
-
listDailyConsumption
public final List<DailyConsumption> listDailyConsumption(Resource resource, Site site, int periodCount) Retrieves a list of daily consumption records for a given resource within a specific time period.- Parameters:
resource
- the resource for which the daily consumption data is to be retrievedsite
- the site where the resource is being consumedperiodCount
- the number of days for which daily consumption data should be fetched- Returns:
- a list of daily consumption records spanning the specified period
-
getDailyConsumption
Retrieves daily consumption data for a specific resource on a given day of a year.- Parameters:
resource
- the resource for which the daily consumption is being retrievedyear
- the year during which the daily consumption is to be retrievedday
- the day of the year (1-365 or 1-366 for leap years) for which the daily consumption is to be retrieved- Returns:
- a
DailyConsumption
object representing the consumption data for the specified resource on the given day, ornull
if no data is available
-
getDailyConsumption
Retrieves the daily consumption for a specific resource and date. The method calculates the corresponding year and day of the year from the provided date and fetches the daily consumption data accordingly.- Type Parameters:
D
- the date type, which must be a subclass ofDate
- Parameters:
resource
- the resource for which the daily consumption is being retrieveddate
- the date for which the daily consumption is being retrieved; must extendDate
- Returns:
- the
DailyConsumption
object representing the consumption data for the given resource and date
-
getHourlyConsumption
Retrieves the hourly consumption for the specified resource. If the hourly consumption for the resource does not exist, it either fetches it based on the current timestamp adjusted for the site's timezone or creates a new record for the resource.- Parameters:
resource
- the resource for which the hourly consumption is being retrieved- Returns:
- the
HourlyConsumption
object representing the resource's consumption for the hour, either fetched or newly created
-
getDailyConsumption
Retrieves the daily consumption record for a specific resource. If no record exists for the current date, it attempts to retrieve or create a new record associated with the resource and the current timestamp.- Parameters:
resource
- the resource for which the daily consumption information is to be retrieved.- Returns:
- the
DailyConsumption
instance associated with the specified resource.
-
getWeeklyConsumption
Retrieves the weekly consumption for a given resource. If the weekly consumption data does not exist, it will compute or create a new instance of the weekly consumption for the resource based on the current site date. The method ensures data is updated and cached for future retrievals.- Parameters:
resource
- the resource object for which the weekly consumption is to be retrieved- Returns:
- the
WeeklyConsumption
instance representing the weekly consumption for the specified resource
-
getMonthlyConsumption
Retrieves the monthly consumption data for the specified resource. If no existing data is available, it attempts to generate new data for the current or the previous month based on the site's time configuration and stores it for future use.- Parameters:
resource
- the resource for which monthly consumption data is to be retrieved.- Returns:
- a
MonthlyConsumption
object representing the consumption details of the resource.
-
getYearlyConsumption
Retrieves the yearly consumption details for a specific resource. If the yearly consumption is not already calculated or available, it attempts to initialize and cache a new instance for the specified resource.- Parameters:
resource
- the resource for which to retrieve the yearly consumption data- Returns:
- the
YearlyConsumption
object representing the consumption details of the resource for the relevant year
-