Update constraint checking

This commit is contained in:
Lars Westermann 2019-06-08 22:55:03 +02:00
parent f417764695
commit 3187f472fc
Signed by: lars.westermann
GPG key ID: 9D417FA5BB9D5E1D

View file

@ -40,6 +40,21 @@ fun checkConstraints(
errors += ConstraintError("Work group requires accessible, but room does not have one!") errors += ConstraintError("Work group requires accessible, but room does not have one!")
} }
val start = schedule.getAbsoluteStartTime()
val end = schedule.getAbsoluteEndTime()
for (leader in schedule.workGroup.leader) {
for (s in against) {
if (
leader in s.workGroup.leader &&
start <= s.getAbsoluteEndTime() &&
s.getAbsoluteStartTime() <= end
) {
errors += ConstraintError("Work group with leader $leader cannot be at same time with ${s.workGroup.name}!")
}
}
}
for ((type, constraints) in schedule.workGroup.constraints.groupBy { it.type }) { for ((type, constraints) in schedule.workGroup.constraints.groupBy { it.type }) {
when (type) { when (type) {
ConstraintType.OnlyOnDay -> { ConstraintType.OnlyOnDay -> {
@ -89,8 +104,6 @@ fun checkConstraints(
} }
ConstraintType.NotAtSameTime -> { ConstraintType.NotAtSameTime -> {
val start = schedule.getAbsoluteStartTime()
val end = schedule.getAbsoluteEndTime()
for (constraint in constraints) { for (constraint in constraints) {
for (s in against) { for (s in against) {
if ( if (
@ -105,7 +118,6 @@ fun checkConstraints(
} }
ConstraintType.OnlyAfterWorkGroup -> { ConstraintType.OnlyAfterWorkGroup -> {
val start = schedule.getAbsoluteStartTime()
for (constraint in constraints) { for (constraint in constraints) {
for (s in against) { for (s in against) {
if ( if (