1
|
|
|
from typing import List |
2
|
|
|
|
3
|
|
|
from kerapu.boom.attribuut_groep_koppeling import AttribuutGroepKoppeling |
4
|
1 |
|
from kerapu.lbz.Subtraject import Subtraject |
5
|
|
|
|
6
|
|
|
|
7
|
1 |
|
class AttribuutGroep: |
8
|
|
|
""" |
9
|
|
|
Klasse voor attribuutgroep. |
10
|
|
|
""" |
11
|
|
|
|
12
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
13
|
1 |
|
def __init__(self, |
14
|
|
|
attribute_groep_id: int, |
15
|
|
|
aantal_voorwaarden_voor_true: int, |
16
|
|
|
koppelingen: List[AttribuutGroepKoppeling]): |
17
|
|
|
""" |
18
|
|
|
Object constructor. |
19
|
|
|
|
20
|
|
|
:param int attribute_groep_id: Het ID van deze attribuutgroep. |
21
|
|
|
:param int aantal_voorwaarden_voor_true: Het minimale aantal voorwaarden waaraan moet worden voldaan. |
22
|
|
|
:param list[kerapu.boom.attribuut_groep_koppeling.AttribuutGroepKoppeling.AttribuutGroepKoppeling] koppelingen: |
23
|
|
|
De attribuutgroepkoppelingen. |
24
|
|
|
""" |
25
|
1 |
|
self._attribute_groep_id: int = attribute_groep_id |
26
|
|
|
""" |
27
|
|
|
Het ID van deze attribuutgroep. |
28
|
|
|
""" |
29
|
|
|
|
30
|
|
|
self._aantal_voorwaarden_voor_true: int = aantal_voorwaarden_voor_true |
31
|
|
|
""" |
32
|
1 |
|
Het minimale aantal voorwaarden waaraan moet worden voldaan om deze attribuutgroep te laten vuren. |
33
|
|
|
""" |
34
|
|
|
|
35
|
|
|
self._koppelingen: List[AttribuutGroepKoppeling] = koppelingen |
36
|
|
|
""" |
37
|
|
|
De attribuutgroepkoppelingen. |
38
|
|
|
""" |
39
|
1 |
|
|
40
|
1 |
|
# ------------------------------------------------------------------------------------------------------------------ |
41
|
|
|
def test(self, subtraject: Subtraject) -> bool: |
42
|
|
|
""" |
43
|
|
|
Test of een subtraject voldoet aan de voorwaarden van deze attribuutgroep. |
44
|
|
|
|
45
|
|
|
:param Subtraject subtraject: Het subtraject. |
46
|
|
|
|
47
|
1 |
|
:rtype: bool |
48
|
|
|
""" |
49
|
|
|
aantal = 0 |
50
|
|
|
for koppeling in self._koppelingen: |
51
|
|
|
if koppeling.test(subtraject): |
52
|
|
|
aantal += 1 |
53
|
|
|
|
54
|
|
|
return aantal >= self._aantal_voorwaarden_voor_true |
55
|
1 |
|
|
56
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
57
|
|
|
|