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<String,Map<LocalDateTime,List<DiagnosisKey>>>
distributableDiagnosisKeys
A map containing diagnosis keys, grouped by country and mapped by the LocalDateTime on which they may be distributed.protected LocalDateTime
distributionTime
The hour at which the distribution runs.protected long
expiryPolicyMinutes
protected Map<String,List<DiagnosisKey>>
groupedDiagnosisKeys
A map containing diagnosis keys, grouped by country code.protected int
minNumberOfKeysPerBundle
static long
ONE_HOUR_INTERVAL_SECONDS
The submission timestamp is counted in 1 hour intervals since epoch.protected List<String>
supportedCountries
static long
TEN_MINUTES_INTERVAL_SECONDS
The rolling start interval number is counted in 10 minute intervals since epoch.
-
Constructor Summary
Constructors Modifier Constructor Description protected
DiagnosisKeyBundler(DistributionServiceConfig distributionServiceConfig)
Constructs a DiagnosisKeyBundler based on the specified service configuration.
-
Method Summary
All 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(String country)
Returns allDiagnosisKeys
contained by thisDiagnosisKeyBundler
.Set<LocalDate>
getDatesWithDistributableDiagnosisKeys(String country)
Returns a set of alldates
on whichdiagnosis keys
shall be distributed based on country.List<DiagnosisKey>
getDiagnosisKeysForDate(LocalDate date, String country)
Returns all diagnosis keys that should be distributed on a specific date for a specific country.List<DiagnosisKey>
getDiagnosisKeysForHour(LocalDateTime hour, String country)
Returns all diagnosis keys that should be distributed in a specific hour for a specific country.LocalDateTime
getDistributionTime()
Returns theLocalDateTime
at which the distribution runs.Set<LocalDateTime>
getHoursWithDistributableDiagnosisKeys(LocalDate currentDate, String country)
Returns a map of allhours
of a specifieddate
and country during whichdiagnosis keys
shall be distributed.protected LocalDateTime
getSubmissionDateTime(DiagnosisKey diagnosisKey)
Returns the submission timestamp of aDiagnosisKey
as aLocalDateTime
.protected Map<String,List<DiagnosisKey>>
mapDiagnosisKeysPerVisitedCountries(Collection<DiagnosisKey> diagnosisKeys)
boolean
numberOfKeysForDateBelowMaximum(LocalDate date, String country)
protected void
populateEuPackageWithDistributableDiagnosisKeys()
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
The hour at which the distribution runs. This field is needed to prevent the run from distributing any keys that have already been submitted but may only be distributed in the future (e.g. because they are not expired yet).
-
distributableDiagnosisKeys
protected final Map<String,Map<LocalDateTime,List<DiagnosisKey>>> distributableDiagnosisKeys
A map containing diagnosis keys, grouped by country and mapped by the LocalDateTime on which they may be distributed.
-
groupedDiagnosisKeys
protected Map<String,List<DiagnosisKey>> groupedDiagnosisKeys
A map containing diagnosis keys, grouped by country code.
-
-
Constructor Detail
-
DiagnosisKeyBundler
protected DiagnosisKeyBundler(DistributionServiceConfig distributionServiceConfig)
Constructs a DiagnosisKeyBundler based on the specified service configuration.
-
-
Method Detail
-
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.
-
getDistributionTime
public LocalDateTime getDistributionTime()
Returns theLocalDateTime
at which the distribution runs.
-
getAllDiagnosisKeys
public List<DiagnosisKey> getAllDiagnosisKeys(String country)
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(String country)
Returns a set of alldates
on whichdiagnosis keys
shall be distributed based on country.
-
numberOfKeysForDateBelowMaximum
public boolean numberOfKeysForDateBelowMaximum(LocalDate date, String country)
-
getHoursWithDistributableDiagnosisKeys
public Set<LocalDateTime> getHoursWithDistributableDiagnosisKeys(LocalDate currentDate, String country)
Returns a map of allhours
of a specifieddate
and country during whichdiagnosis keys
shall be distributed.
-
getSubmissionDateTime
protected LocalDateTime getSubmissionDateTime(DiagnosisKey diagnosisKey)
Returns the submission timestamp of aDiagnosisKey
as aLocalDateTime
.
-
getDiagnosisKeysForDate
public List<DiagnosisKey> getDiagnosisKeysForDate(LocalDate date, String country)
Returns all diagnosis keys that should be distributed on a specific date for a specific country.
-
getDiagnosisKeysForHour
public List<DiagnosisKey> getDiagnosisKeysForHour(LocalDateTime hour, String country)
Returns all diagnosis keys that should be distributed in a specific hour for a specific country.
-
mapDiagnosisKeysPerVisitedCountries
protected Map<String,List<DiagnosisKey>> mapDiagnosisKeysPerVisitedCountries(Collection<DiagnosisKey> diagnosisKeys)
-
populateEuPackageWithDistributableDiagnosisKeys
protected void populateEuPackageWithDistributableDiagnosisKeys()
-
-