[rules-users] Template salience
Enda J Diggins
ejdiggins at gmail.com
Wed Mar 10 09:34:57 EST 2010
Hi,
Yes it is possible but I think the function has to return an int. Also, it
should be called as follows:
rule "Periode@{row.rowNumber}"
salience ( getNbJours("@{ddeb}", "@{dfin}") );
Include the stack trace from the NPE if this doesn't work.
Cheers,
Enda
2010/3/10 Bertrand Grottier <b_grottier at hotmail.com>
> Hello,
>
> Is it possible to specify a template salience such as:
>
> function long getNbJours(String pStrDDeb, String pStrDFin)
> {
> SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
>
> Date dDeb = sdf.parse(pStrDDeb) ;
> Date dFin = sdf.parse(pStrDFin) ;
>
> long diff = dFin.getTime() - dDeb.getTime() ;
>
> return (diff / (24 * 60 * 60 * 1000)) ;
> }
>
> template "tarification_produit"
>
> rule "Periode@{row.rowNumber}"
> salience getNbJours("@{ddeb}", "@{dfin}")
> when
> $p : Produit(id == 1, eval( dDeb.before( getDate("@{ddeb}") ) ) )
> then
> $p.setId(2) ;
> $p.setPrix(@{prix}) ;
> update( $p );
> end
> end template
>
> I encounter a java.lang.NullPointerException.
>
> Thank you in advance for your help.
>
> Regards,
>
> Benoît
>
> ------------------------------
> Acheter en ligne en toute sécurité ? Internet Explorer 8 vous protège
> gratuitement ! <http://clk.atdmt.com/FRM/go/206608211/direct/01/>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
Enda J Diggins
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100310/80b1c4d4/attachment.html
More information about the rules-users
mailing list