Thanks, it helps.
But there are some more questions.
1. What is an official name of rule language, if it is not MVEL? Why "MVEL
dialect" in split constraints allow using code like:
$p: Person ( age > 21 )
DRL - presumably standing for Drools Rule
Language
2. Why it is not possible to use rules in actions in MVEL mode? I
suppose it
would be useful.
What do you actually mean by using a rule in an action..
The answer is likely to be it is due to the way that rules are declarative and not
procedural and how the Rete algorithm works.
3. How can I create new object in the constraint? For example, I have
a
constraint:
$p : Person( age < 21 )
- in this branch I need to create the new object "PersonFault" and insert it
to the working memory, but the code :
$p : Person( age < 21 )
$fault = new PersonFault($p, "WRONG AGE");
kcontext.getKnowledgeRuntime().insert($fault);
- is not working. Nor in the constraint, nor in the action...
It won't work in the constraint as it doesn't make sense to create objects in the
constraint.
The standard way to do it is as follows - also note the knowledge runtime methods are
exposed directly (see
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/ht...)
Rule "foo"
when
$p : Person(age < 21)
then
insert(new PersonFault($p, "WRONG AGE"));
end
Thomas
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes. To protect the environment please
do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United
Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603
8808 40-00
**************************************************************************************