CourseSchedule schedule, int dayListSize, int timeslotListSize) throws IOException {
int periodListSize = dayListSize * timeslotListSize;
Map<List<Integer>, Period> periodMap = new HashMap<List<Integer>, Period>(periodListSize);
List<Day> dayList = new ArrayList<Day>(dayListSize);
for (int i = 0; i < dayListSize; i++) {
Day day = new Day();
day.setId((long) i);
day.setDayIndex(i);
day.setPeriodList(new ArrayList<Period>(timeslotListSize));
dayList.add(day);
}
schedule.setDayList(dayList);
List<Timeslot> timeslotList = new ArrayList<Timeslot>(timeslotListSize);
for (int i = 0; i < timeslotListSize; i++) {
Timeslot timeslot = new Timeslot();
timeslot.setId((long) i);
timeslot.setTimeslotIndex(i);
timeslotList.add(timeslot);
}
schedule.setTimeslotList(timeslotList);
List<Period> periodList = new ArrayList<Period>(periodListSize);
for (int i = 0; i < dayListSize; i++) {
Day day = dayList.get(i);
for (int j = 0; j < timeslotListSize; j++) {
Period period = new Period();
period.setId((long) (i * timeslotListSize + j));
period.setDay(day);
period.setTimeslot(timeslotList.get(j));
periodList.add(period);
periodMap.put(Arrays.asList(i, j), period);
day.getPeriodList().add(period);
}
}
schedule.setPeriodList(periodList);
return periodMap;
}