Class DiagnosisKeyBundler
- java.lang.Object
-
- app.coronawarn.server.services.distribution.assembly.diagnosiskeys.DiagnosisKeyBundler
-
- Direct Known Subclasses:
DemoDiagnosisKeyBundler
,ProdDiagnosisKeyBundler
public abstract class DiagnosisKeyBundler extends Object
An instance of this class contains a collection ofDiagnosisKeys
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<LocalDateTime,List<DiagnosisKey>>
distributableDiagnosisKeys
protected LocalDateTime
distributionTime
protected long
expiryPolicyMinutes
protected int
minNumberOfKeysPerBundle
static long
ONE_HOUR_INTERVAL_SECONDS
The submission timestamp is counted in 1 hour intervals since epoch.static long
TEN_MINUTES_INTERVAL_SECONDS
The rolling start interval number is counted in 10 minute intervals since epoch.
-
Constructor Summary
Constructors Constructor Description DiagnosisKeyBundler(DistributionServiceConfig distributionServiceConfig)
Constructs a DiagnosisKeyBundler based on the specified service configuration.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
createDiagnosisKeyDistributionMap(Collection<DiagnosisKey> diagnosisKeys)
Initializes the internaldistributableDiagnosisKeys
map, which should contain all diagnosis keys, grouped by the LocalDateTime on which they may be distributed.List<DiagnosisKey>
getAllDiagnosisKeys()
Returns allDiagnosisKeys
contained by thisDiagnosisKeyBundler
.Set<LocalDate>
getDatesWithDistributableDiagnosisKeys()
Returns a set of alldates
on whichdiagnosis keys
shall be distributed.List<DiagnosisKey>
getDiagnosisKeysForDate(LocalDate date)
Returns all diagnosis keys that should be distributed on a specific date.List<DiagnosisKey>
getDiagnosisKeysForHour(LocalDateTime hour)
Returns all diagnosis keys that should be distributed in a specific hour.Set<LocalDateTime>
getHoursWithDistributableDiagnosisKeys(LocalDate currentDate)
static LocalDateTime
getLocalDateTimeFromHoursSinceEpoch(long timestamp)
Creates aLocalDateTime
based on the specified epoch timestamp.protected LocalDateTime
getSubmissionDateTime(DiagnosisKey diagnosisKey)
Returns the submission timestamp of aDiagnosisKey
as aLocalDateTime
.boolean
numberOfKeysForDateBelowMaximum(LocalDate date)
void
setDiagnosisKeys(Collection<DiagnosisKey> diagnosisKeys, LocalDateTime distributionTime)
Sets theDiagnosisKeys
contained by thisDiagnosisKeyBundler
and the time at which the distribution runs and callscreateDiagnosisKeyDistributionMap(java.util.Collection<app.coronawarn.server.common.persistence.domain.DiagnosisKey>)
.
-
-
-
Field Detail
-
ONE_HOUR_INTERVAL_SECONDS
public static final long ONE_HOUR_INTERVAL_SECONDS
The submission timestamp is counted in 1 hour intervals since epoch.
-
TEN_MINUTES_INTERVAL_SECONDS
public static final long TEN_MINUTES_INTERVAL_SECONDS
The rolling start interval number is counted in 10 minute intervals since epoch.
-
expiryPolicyMinutes
protected final long expiryPolicyMinutes
-
minNumberOfKeysPerBundle
protected final int minNumberOfKeysPerBundle
-
distributionTime
protected LocalDateTime distributionTime
-
distributableDiagnosisKeys
protected final Map<LocalDateTime,List<DiagnosisKey>> distributableDiagnosisKeys
-
-
Constructor Detail
-
DiagnosisKeyBundler
public DiagnosisKeyBundler(DistributionServiceConfig distributionServiceConfig)
Constructs a DiagnosisKeyBundler based on the specified service configuration.
-
-
Method Detail
-
getLocalDateTimeFromHoursSinceEpoch
public static LocalDateTime getLocalDateTimeFromHoursSinceEpoch(long timestamp)
Creates aLocalDateTime
based on the specified epoch timestamp.
-
setDiagnosisKeys
public void setDiagnosisKeys(Collection<DiagnosisKey> diagnosisKeys, LocalDateTime distributionTime)
Sets theDiagnosisKeys
contained by thisDiagnosisKeyBundler
and the time at which the distribution runs and callscreateDiagnosisKeyDistributionMap(java.util.Collection<app.coronawarn.server.common.persistence.domain.DiagnosisKey>)
.- Parameters:
diagnosisKeys
- TheDiagnosisKeys
contained by thisDiagnosisKeyBundler
.distributionTime
- TheLocalDateTime
at which the distribution runs.
-
getAllDiagnosisKeys
public List<DiagnosisKey> getAllDiagnosisKeys()
Returns allDiagnosisKeys
contained by thisDiagnosisKeyBundler
.
-
createDiagnosisKeyDistributionMap
protected abstract void createDiagnosisKeyDistributionMap(Collection<DiagnosisKey> diagnosisKeys)
Initializes the internaldistributableDiagnosisKeys
map, which should contain all diagnosis keys, grouped by the LocalDateTime on which they may be distributed.
-
getDatesWithDistributableDiagnosisKeys
public Set<LocalDate> getDatesWithDistributableDiagnosisKeys()
Returns a set of alldates
on whichdiagnosis keys
shall be distributed.
-
numberOfKeysForDateBelowMaximum
public boolean numberOfKeysForDateBelowMaximum(LocalDate date)
-
getHoursWithDistributableDiagnosisKeys
public Set<LocalDateTime> getHoursWithDistributableDiagnosisKeys(LocalDate currentDate)
-
getSubmissionDateTime
protected LocalDateTime getSubmissionDateTime(DiagnosisKey diagnosisKey)
Returns the submission timestamp of aDiagnosisKey
as aLocalDateTime
.
-
getDiagnosisKeysForDate
public List<DiagnosisKey> getDiagnosisKeysForDate(LocalDate date)
Returns all diagnosis keys that should be distributed on a specific date.
-
getDiagnosisKeysForHour
public List<DiagnosisKey> getDiagnosisKeysForHour(LocalDateTime hour)
Returns all diagnosis keys that should be distributed in a specific hour.
-
-