[rules-users] Rule Templates

FrankVhh frank.vanhoenshoven at agserv.eu
Thu Apr 14 09:36:07 EDT 2011


Hi W.,

Thanks for the fast reply.

Meanwhile, I have been trying to play with the templates. Unfortunately, I
run into a nullpointerexception in the problems view of Eclipse. At first, I
hoped it was the same error as in
http://lists.jboss.org/pipermail/rules-users/2010-November/017229.html but
that does not seem to be the case.

Underneath, you can find my drl file. This is the only artifact that I am
having right now. There is no Java code yet, apart from the Price object.
This shouldn't be necessary to fix the problem either.

I tried to comment out some pieces of code to narrow down on the problem.
The nullpointerexception persists even if you comment everything from
"package" to the bottom of the file. This should indicate the problem has to
be in the template header, but I do not have a clue.

Could anyone help with this?

Thanks in advance.

======================================================================

template header
minimumValue
maximumValue
precision
startlevel
endlevel
roundingvalue

package rounding

import rounding.Price;

template "Determine evaluated decimals"
rule "Determine evaluated decimals @{row.rowNumber}"
	salience 25
	lock-on-active true
	when
		$price: Price(integerpart >= @{minimumValue} && integerpart <
@{maximumValue} && evaluateddecimals == 9999999)
	then
		$price.setRoundedPrecision(@{precision});
		$price.calculateNumberOfRoundedDecimals();
		$price.calculateEvaluatedDecimals();
		$price.calculateBasenumber();
		update($price);
end
end template

template "Determine rounding value"
rule "Determine rounding value @{row.rowNumber}"
	salience 0
	no-loop true
	when
		$price: Price(integerpart >= @{minimumValue} && integerpart <
@{maximumValue} && evaluateddecimals >= @{startlevel} && evaluateddecimals <
@{endlevel})
	then
		$price.setRoundedPrice($price.getBasenumber() + @{roundingvalue});
		System.out.println($price.getPrice() + " => " + (double)
$price.getRoundedPrice() / Math.pow(10,$price.getNumberofroundeddecimals())
);
end
end template

--
View this message in context: http://drools.46999.n3.nabble.com/Rule-Templates-tp2820139p2820343.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list