From 3187f472fce1f71955b2b105423c0b079c154f08 Mon Sep 17 00:00:00 2001 From: Lars Westermann Date: Sat, 8 Jun 2019 22:55:03 +0200 Subject: [PATCH] Update constraint checking --- .../kotlin/de/kif/common/ConstraintChecking.kt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/commonMain/kotlin/de/kif/common/ConstraintChecking.kt b/src/commonMain/kotlin/de/kif/common/ConstraintChecking.kt index a188dc7..d865d8c 100644 --- a/src/commonMain/kotlin/de/kif/common/ConstraintChecking.kt +++ b/src/commonMain/kotlin/de/kif/common/ConstraintChecking.kt @@ -40,6 +40,21 @@ fun checkConstraints( 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 }) { when (type) { ConstraintType.OnlyOnDay -> { @@ -89,8 +104,6 @@ fun checkConstraints( } ConstraintType.NotAtSameTime -> { - val start = schedule.getAbsoluteStartTime() - val end = schedule.getAbsoluteEndTime() for (constraint in constraints) { for (s in against) { if ( @@ -105,7 +118,6 @@ fun checkConstraints( } ConstraintType.OnlyAfterWorkGroup -> { - val start = schedule.getAbsoluteStartTime() for (constraint in constraints) { for (s in against) { if (