[rules-users] Template rules & eval

Bertrand Grottier b_grottier at hotmail.com
Wed Mar 10 06:04:11 EST 2010


Here is the "drl generated string":

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) ;
}

rule "Periode2"
    when
        $p : Produit(id == 1, eval( dDeb.before( getDate("01/06/2010") ) ) )
    then
        $p.setId(2) ; 
        $p.setPrix(100) ;
        update( $p );        
end

rule "Periode1"
    when
        $p : Produit(id == 1, eval( dDeb.before( getDate("01/06/2010") ) ) )
    then
        $p.setId(2) ; 
        $p.setPrix(50) ;
        update( $p );        
end


> Date: Wed, 10 Mar 2010 11:41:36 +0100
> From: wolfgang.laun at gmail.com
> To: rules-users at lists.jboss.org
> Subject: Re: [rules-users] Template rules & eval
> 
> 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
> >
> >
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
 		 	   		  
_________________________________________________________________
Découvrez comment SURFER DISCRETEMENT sur un site de rencontres !
http://clk.atdmt.com/FRM/go/206608211/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100310/7d903296/attachment.html 


More information about the rules-users mailing list