[rules-users] Template rules & eval

Wolfgang Laun wolfgang.laun at gmail.com
Wed Mar 10 05:41:36 EST 2010


Can you post the "drl generated string" you are referring to?
-W

2010/3/10 Bertrand Grottier <b_grottier at hotmail.com>:
> 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@{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 at 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
>
>
> ________________________________
> Commander un cadeau en ligne discrètement? Voir la solution offerte par
> Internet Explorer8
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>




More information about the rules-users mailing list