[rules-users] Template rules & eval

Bertrand Grottier b_grottier at hotmail.com
Wed Mar 10 06:57:01 EST 2010


You are right, that was the problem !
Thank you very much for your help.
Regards,
Benoît

Date: Wed, 10 Mar 2010 11:49:05 +0000
From: ejdiggins at gmail.com
To: rules-users at lists.jboss.org
Subject: Re: [rules-users] Template rules & eval


You're getting a NullPointer in the predicate... is dDeb null?

Enda

2010/3/10 Wolfgang Laun <wolfgang.laun at gmail.com>

All I can see is that the date string is the same in Periode1 and Periode2, so you must have the same date in lines 1 and 2, which won't work well, but is perhaps due to simplification? 

-W




2010/3/10 Bertrand Grottier <b_grottier at hotmail.com>







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
 		 	   		  
Envie de naviguer sur Internet sans laisser de trace? La solution avec Internet Explorer 8



_______________________________________________

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




-- 
Enda J Diggins
 		 	   		  
_________________________________________________________________
Hotmail et MSN dans la poche? HOTMAIL et MSN sont dispo gratuitement sur votre téléphone!
http://www.messengersurvotremobile.com/?d=Hotmail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100310/7749d062/attachment.html 


More information about the rules-users mailing list