List<Event> eventsForDiffDay = new ArrayList<Event>();
DifferentDayConstraint diffDayConstr = new DifferentDayConstraint(settings, eventsForDiffDay);
diffDayConstr.setWeight(1000.0f);
int appointmentCounter = 0;
for (Integer integ : course.getHours()) {
Event ev = newEvent();
ev.setStart(0);
ev.setDuration(integ);
ev.setName(course.getName() + " (" + cInstance.getName()
+ "/" + course.getInstances().size() + ")\n"
+ ++appointmentCounter + "/" + course.getHours().size());
eDao.put(eCounter++, ev);
eventsForDiffDay.add(ev);
cInstance.getTeacher().addEvent(ev, Role.TEACHER, true);
for (Person p : cInstance.getStudents()) {
p.addEvent(ev, Role.STUDENT, true);
}
}
for (Person p : cInstance.getStudents()) {
MinGapsConstraint minGapConstr = new MinGapsConstraint(settings, p.getEvents());
minGapConstr.setWeight(1.0f);
p.putConstraint(minGapConstr);
}
// bind the constraint only if it makes sense
if (eventsForDiffDay.size() > 1) {
for (Event ev : eventsForDiffDay) {
ev.putConstraint(diffDayConstr);
}
}
}
}
}