Class RecordServiceUtil
java.lang.Object
com.bluebell.greenhouse.radicle.services.RecordServiceUtil
Utility functions shared by record services.
- Version:
- 2.0.6
- Author:
- Stephen Prizio
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T> buildRecordLogEntries(List<Account> accounts, Function<Account, T> recordFactory, Predicate<T> recordFilter) Builds per-account record log entries for accounts with non-empty records.static LocalDateTimeconvertLocalDateBoundaryToUtc(LocalDate date, ZoneId zoneId) Converts a local calendar-day boundary to its UTC equivalent.static LocalDateconvertUtcToLocalDate(LocalDateTime utcDateTime, ZoneId zoneId) Converts a stored UTC timestamp into a local date for bucket calculations.static LocalDateTimeconvertUtcToLocalDateTime(LocalDateTime utcDateTime, ZoneId zoneId) Converts a stored UTC timestamp into a local date/time for bucket calculations.static <T> intcountDistinctAccounts(List<T> records, Function<T, String> accountNumber) Counts the distinct accounts represented by record log entries.static RecordIntervalresolveFirstInterval(LocalDate start, RecordTimeInterval interval) Resolves the first interval range for a start date.static LocalDateTimeresolveRecentEnd(LocalDateTime lastEventDateTime, RecordTimeInterval interval) Resolves the compare/end local date/time for recent records.static LocalDateTimeresolveRecentStart(LocalDateTime firstEventDateTime, RecordTimeInterval interval) Resolves the first local date/time for recent records.static <T extends Comparable<? super T>>
List<T> sortAndLimitRecords(List<T> records, int count) Applies standard record sorting and limiting.static voidvalidateRecordDateParameters(LocalDate start, LocalDate end, RecordTimeInterval interval, ZoneId zoneId) Validates standard date parameters for record services.static voidvalidateRecordLogParameters(User user, LocalDate start, LocalDate end, RecordTimeInterval interval, ZoneId zoneId) Validates standard parameters for portfolio-level record log services.static voidvalidateRecordParameters(LocalDate start, LocalDate end, Account account, RecordTimeInterval interval, ZoneId zoneId) Validates standard parameters for account record services.
-
Method Details
-
validateRecordParameters
public static void validateRecordParameters(LocalDate start, LocalDate end, Account account, RecordTimeInterval interval, ZoneId zoneId) Validates standard parameters for account record services.- Parameters:
start- start dateend- end dateaccount-Accountinterval-RecordTimeIntervalzoneId-ZoneId
-
validateRecordDateParameters
public static void validateRecordDateParameters(LocalDate start, LocalDate end, RecordTimeInterval interval, ZoneId zoneId) Validates standard date parameters for record services.- Parameters:
start- start dateend- end dateinterval-RecordTimeIntervalzoneId-ZoneId
-
validateRecordLogParameters
public static void validateRecordLogParameters(User user, LocalDate start, LocalDate end, RecordTimeInterval interval, ZoneId zoneId) Validates standard parameters for portfolio-level record log services.- Parameters:
user-Userstart- start dateend- end dateinterval-RecordTimeIntervalzoneId-ZoneId
-
buildRecordLogEntries
public static <T> List<T> buildRecordLogEntries(List<Account> accounts, Function<Account, T> recordFactory, Predicate<T> recordFilter) Builds per-account record log entries for accounts with non-empty records.- Type Parameters:
T- log entry record type- Parameters:
accounts- accountsrecordFactory- record factoryrecordFilter- record filter- Returns:
Listof records
-
countDistinctAccounts
-
convertLocalDateBoundaryToUtc
Converts a local calendar-day boundary to its UTC equivalent.- Parameters:
date- local datezoneId- source timezone- Returns:
- UTC boundary
-
convertUtcToLocalDateTime
Converts a stored UTC timestamp into a local date/time for bucket calculations.- Parameters:
utcDateTime- stored UTC timestampzoneId- target timezone- Returns:
- localized date/time
-
convertUtcToLocalDate
Converts a stored UTC timestamp into a local date for bucket calculations.- Parameters:
utcDateTime- stored UTC timestampzoneId- target timezone- Returns:
- localized date
-
resolveFirstInterval
Resolves the first interval range for a start date.- Parameters:
start- requested start dateinterval-RecordTimeInterval- Returns:
RecordInterval
-
resolveRecentStart
public static LocalDateTime resolveRecentStart(LocalDateTime firstEventDateTime, RecordTimeInterval interval) Resolves the first local date/time for recent records.- Parameters:
firstEventDateTime- first event date/timeinterval-RecordTimeInterval- Returns:
- start date/time
-
resolveRecentEnd
public static LocalDateTime resolveRecentEnd(LocalDateTime lastEventDateTime, RecordTimeInterval interval) Resolves the compare/end local date/time for recent records.- Parameters:
lastEventDateTime- last event date/timeinterval-RecordTimeInterval- Returns:
- compare date/time
-
sortAndLimitRecords
public static <T extends Comparable<? super T>> List<T> sortAndLimitRecords(List<T> records, int count) Applies standard record sorting and limiting.- Type Parameters:
T- comparable record type- Parameters:
records- recordscount- limit- Returns:
- sorted and limited records
-