Hello,
I want to use template rules. Here is my .drt file:
template header
ddeb
dfin
prix
package com.tarification
import java.util.Date ;
import tarification.Produit ;
import java.text.SimpleDateFormat;
function Date getDate(String pStrDate)
{
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
return sdf.parse(pStrDate) ;
}
template "tarification_produit"
rule "Periode(a){row.rowNumber}"
when
$p : Produit(id == 1, eval( dDeb.before( getDate("@{ddeb}") ) ) )
then
$p.setId(2) ;
$p.setPrix(@{prix}) ;
update( $p );
end
end template
I modified an example provided with Drools but encounter the following exception:
Exception in thread "main" org.drools.RuntimeDroolsException: Exception
executing predicate com.tarification.Rule_Periode2_0Predicate0Invoker@2110b61d
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:279)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:143)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:147)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
at tarification.TestTemplate.executeExample(TestTemplate.java:49)
at tarification.TestTemplate.main(TestTemplate.java:26)
Caused by: java.lang.NullPointerException
at com.tarification.Rule_Periode2_0.predicate0(Rule_Periode2_0.java:9)
at
com.tarification.Rule_Periode2_0Predicate0Invoker.evaluate(Rule_Periode2_0Predicate0Invoker.java:23)
at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:272)
... 11 more
I am puzzle because when I copy the drl generated string in a drl file, everything works
fine.
Any idea ? Thank you in advance.
Regards,
Benoît
_________________________________________________________________
Hotmail et MSN dans la poche? HOTMAIL et MSN sont dispo gratuitement sur votre téléphone!
http://www.messengersurvotremobile.com/?d=Hotmail