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 static StringCOUNTRY_ERROR_MESSAGEprotected Map<String,Map<LocalDateTime,List<DiagnosisKey>>>distributableDiagnosisKeysA map containing diagnosis keys, grouped by country and mapped by the LocalDateTime on which they may be distributed.protected LocalDateTimedistributionTimeThe hour at which the distribution runs.protected longexpiryPolicyMinutesprotected Map<String,List<DiagnosisKey>>groupedDiagnosisKeysA map containing diagnosis keys, grouped by country code.protected intminNumberOfKeysPerBundlestatic longONE_HOUR_INTERVAL_SECONDSThe submission timestamp is counted in 1 hour intervals since epoch.protected List<String>supportedCountriesstatic longTEN_MINUTES_INTERVAL_SECONDSThe rolling start interval number is counted in 10 minute intervals since epoch.
-
Constructor Summary
Constructors Modifier Constructor Description protectedDiagnosisKeyBundler(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 voidcreateDiagnosisKeyDistributionMap(Collection<DiagnosisKey> diagnosisKeys)Initializes the internaldistributableDiagnosisKeysmap, which should contain all diagnosis keys, grouped by the LocalDateTime on which they may be distributed.List<DiagnosisKey>getAllDiagnosisKeys(String country)Returns allDiagnosisKeyscontained by thisDiagnosisKeyBundler.Set<LocalDate>getDatesWithDistributableDiagnosisKeys(String country)Returns a set of alldateson whichdiagnosis keysshall 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.LocalDateTimegetDistributionTime()Returns theLocalDateTimeat which the distribution runs.Set<LocalDateTime>getHoursWithDistributableDiagnosisKeys(LocalDate currentDate, String country)Returns a map of allhoursof a specifieddateand country during whichdiagnosis keysshall be distributed.protected LocalDateTimegetSubmissionDateTime(DiagnosisKey diagnosisKey)Returns the submission timestamp of aDiagnosisKeyas aLocalDateTime.protected Map<String,List<DiagnosisKey>>mapDiagnosisKeysPerVisitedCountries(Collection<DiagnosisKey> diagnosisKeys)booleannumberOfKeysForDateBelowMaximum(LocalDate date, String country)protected voidpopulateEuPackageWithDistributableDiagnosisKeys()voidsetDiagnosisKeys(Collection<DiagnosisKey> diagnosisKeys, LocalDateTime distributionTime)Sets theDiagnosisKeyscontained by thisDiagnosisKeyBundlerand the time at which the distribution runs and callscreateDiagnosisKeyDistributionMap(java.util.Collection<app.coronawarn.server.common.persistence.domain.DiagnosisKey>).
-
-
-
Field Detail
-
COUNTRY_ERROR_MESSAGE
public static final String COUNTRY_ERROR_MESSAGE
- See Also:
- Constant Field Values
-
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 theDiagnosisKeyscontained by thisDiagnosisKeyBundlerand the time at which the distribution runs and callscreateDiagnosisKeyDistributionMap(java.util.Collection<app.coronawarn.server.common.persistence.domain.DiagnosisKey>).- Parameters:
diagnosisKeys- TheDiagnosisKeyscontained by thisDiagnosisKeyBundler.distributionTime- TheLocalDateTimeat which the distribution runs.
-
getDistributionTime
public LocalDateTime getDistributionTime()
Returns theLocalDateTimeat which the distribution runs.
-
getAllDiagnosisKeys
public List<DiagnosisKey> getAllDiagnosisKeys(String country)
Returns allDiagnosisKeyscontained by thisDiagnosisKeyBundler.
-
createDiagnosisKeyDistributionMap
protected abstract void createDiagnosisKeyDistributionMap(Collection<DiagnosisKey> diagnosisKeys)
Initializes the internaldistributableDiagnosisKeysmap, 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 alldateson whichdiagnosis keysshall 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 allhoursof a specifieddateand country during whichdiagnosis keysshall be distributed.
-
getSubmissionDateTime
protected LocalDateTime getSubmissionDateTime(DiagnosisKey diagnosisKey)
Returns the submission timestamp of aDiagnosisKeyas 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()
-
-