By &quot;(Java)&quot; do you mean Java code between calls to fireAllRules() or Java code<br>in RHS? I think that what you describe in items 5, 6 and 7 can very well be<br>written as rules, based on a Validation object inserted at the time the actual<br>
operation is done in WM. It should contain:<br>   - links to the old, or new, or both, Fact objects<br>   - the validation status (OPEN, VALID, INVALID)<br><br>Need a more detailed outline?<br><br>-W<br><br><div class="gmail_quote">
On 12 August 2010 10:08, Stephen Mcgruer <span dir="ltr">&lt;<a href="mailto:s0840449@sms.ed.ac.uk">s0840449@sms.ed.ac.uk</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi there,<br>
<br>
My project uses Drools to (among other things) validate new<br>
facts/updates to old facts, according to a set of rules. (For example,<br>
we might have a rule that says &quot;No two people can be named the same<br>
thing&quot;.) Our method of validation and error reporting was originally<br>
chosen for a stateless session (before we had the requirement of doing<br>
checks like the above), and I feel I&#39;ve had to hack it a bit much to<br>
get it working with stateful sessions. The current methodology is:<br>
<br>
1. (Website) The user inserts/updates a fact.<br>
2. (Java) If the fact is new, an object is created for it. If it is an<br>
update, the pre-existing object is fetched from the object repository<br>
(the interface to the database) and a backup copy of the object is<br>
taken.<br>
3. (Java) This fact is either inserted into the KnowledgeBase (KB) or<br>
a pre-existing fact in the KB is updated depending.<br>
4. (Rules) If the new/updated object fails a validation rule, it will<br>
be retracted and a ValidationError object will be inserted into the KB.<br>
5. (Java) The code then searches for ValidationError objects that<br>
match the just inserted/updated object. If it finds any it records<br>
them and then retracts them from the KB.<br>
6. (Java) If there are no errors, then that&#39;s it - a success report is<br>
generated and passed back to the website.<br>
7. (Java) If there were errors, then if the user was updating a fact<br>
the backup of it (before the changes) is inserted back into the KB.<br>
The website is then passed a failure report.<br>
<br>
<br>
It just feels very hacky to do so much manual insertion/retracting<br>
from the Java side of the code.<br>
<br>
So, is there a &#39;correct&#39; way to do stateful validation? And does our<br>
current way even work, or are there hidden problems that we&#39;ve not<br>
spotted?<br>
<br>
Cheers,<br>
Stephen<br>
<br>
--<br>
The University of Edinburgh is a charitable body, registered in<br>
Scotland, with registration number SC005336.<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br>