Reputation: 985
I am listing my problem here.
These are my events:
These are my rules.
Now I want 1 and 3 combined together.
like:
4. Alert the Teacher if a student who has attribute status complete enters the room.
Now as I told earlier both events come separately. So handling it in 2 different rules was easier. But when I want to create a rule which is a combination of 1 and 3 as in rule 4 then I have to verify if a person enters a room is a student and if he has attribute "complete".
But, loading the status attribute even before validating if he is a student, sounds bad to me. So, I want to call a method for loading the attribute only if
"a person is a student and there is a rule trying to load the attribute status".
I am planning to do it by a method call in LHS, which is not straightforward.
Is there any other way, I could handle this?
Upvotes: 0
Views: 246
Reputation: 6322
Having small rules identifying specific situation in most of the times is better than having complex rules trying to identify mixed situations. What is not clear to me is whether your want to replace rule 3 with rule 4 or not. I would leave rule 3 and create rule 4 as follow:
when
PersonEnteringRoom($p: person, $r: room, person.type == "Student", person.status == "Complete") // status was set by rule 3.
Room(this == $r, $t: currentTeacher != null) //the relation could be stablished by rule 1
then
Notifier.notify($t, "The student has completed the course", $p);
end
Of course, whether this rule works for you or not depends in other factors like your execution cycle.
Hope it helps,
Upvotes: 2