Okay, I've written a fairly simple rule set for this project. It's
compiling and running fine, it's just not behaving in the way I expect.
Basically, my code has two rules; one checks each schedule object given to
it, and adds up how much time an employee spends working. That one is
working fine. The second rule checks that the employee has not worked too
many hours. The rule should fire when the employee has worked more hours
than his maximum, but should not if the employee has worked less, or if the
employee does not have a maximum. In my testing, though, the rule fires
with both of the first two conditions. It doesn't fire under the third.
<rule name="Max Hours" salience="100">
<parameter identifier="user">
<class>User</class>
</parameter>
<!-- If the user has a maximum -->
<java:condition>
user.getMaxHours() != null
</java:condition>
<java:condition>
user.getMaxHours().intValue() >
getTotalHours(user).intValue()
</java:condition>
<java:consequence>
System.out.println("User " + user.getName() + " has worked " +
(getTotalHours(user).intValue() - user.getMaxHours().intValue()) + " more
hours than is allowed.");
</java:consequence>
</rule>
The > seems backward to me, but the rule doesn't fire even under the
correct condition if I change it around. Does anyone know what I'm doing
wrong?
--
- Angus