in use-cases/vaccination-scheduling/src/main/java/org/acme/vaccinationscheduler/bootstrap/DemoDataGenerator.java [135:167]
private List<Appointment> generateAppointmentList(Random random,
LocalDate windowStartDate, int windowDaysLength, LocalTime dayStartTime, int totalBoothCount, int injectionsPerBoothPerTimeslot, int timeslotsPerBoothPerDay, List<VaccineType> vaccineTypeList, List<VaccinationCenter> vaccinationCenterList) {
int vaccinationCenterCount = vaccinationCenterList.size();
int massCount = (int) Math.round(massVaccinationCenterRatio * vaccinationCenterCount);
int massExtraBoothCount = totalBoothCount - vaccinationCenterCount;
List<Appointment> appointmentList = new ArrayList<>(windowDaysLength * timeslotsPerBoothPerDay * totalBoothCount * injectionsPerBoothPerTimeslot);
for (int i = 0; i < vaccinationCenterCount; i++) {
VaccinationCenter vaccinationCenter = vaccinationCenterList.get(i);
int boothCount;
if (i < massCount) {
// The + i distributes the remainder, for example if massExtraBoothCount=8 and massCount=3
boothCount = 1 + (massExtraBoothCount + i) / massCount;
} else {
boothCount = 1;
}
for (long boothId = 0; boothId < boothCount; boothId++) {
for (int dayIndex = 0; dayIndex < windowDaysLength; dayIndex++) {
VaccineType vaccineType = pickVaccineType(random, null, vaccineTypeList);
LocalDate date = windowStartDate.plusDays(dayIndex);
for (int timeIndex = 0; timeIndex < timeslotsPerBoothPerDay; timeIndex++) {
LocalTime time = dayStartTime.plusHours(timeIndex);
for (int j = 0; j < injectionsPerBoothPerTimeslot; j++) {
LocalDateTime dateTime = LocalDateTime.of(date, time.plusMinutes(j * (60L / injectionsPerBoothPerTimeslot)));
Appointment appointment = new Appointment(
vaccinationCenter, Long.toString(boothId), dateTime, vaccineType);
appointmentList.add(appointment);
}
}
}
}
}
return appointmentList;
}