Problems with condition Rules
by javier hector
I'm using JBoos Drools 3.0.
I'm using Java 5
I have the following classes
package org.unlp.model;
import java.util.ArrayList;
import java.util.List;
/**
* @author Jvelilla
*
*/
public class Curso {
...
// describe el numero total de cuotas del curso
protected Integer cuotas;
// Un curso de postgrado tiene una lista de materias
protected List<Materia> materias;
// ~ Constructors ================================================
...
// ~ Methods ================================================
public void setCuotas(Integer cuotas) {
this.cuotas = cuotas;
}
...
public Integer getCuotas() {
return cuotas;
}
...
}
package org.unlp.model;
/**
* @author Jvelilla
*
*/
public class Estudiante extends Persona {
// restriccion un estudiante solo se puede
// inscribir en un curso.
// ejemplo: Mg. en Ingenieria de Sotware
protected Curso inscripcion;
protected int cuotasPagas;
//~ Methods ================================================
public void setInscripcion(Curso inscripcion) {
this.inscripcion = inscripcion;
}
public void setNumero(int numero) {
this.numero = numero;
}
public void setCuotasPagas(int cuotas_pagas) {
this.cuotasPagas = cuotas_pagas;
}
public Curso getInscripcion() {
return inscripcion;
}
public int getCuotasPagas() {
return cuotasPagas;
}
}
My Rule is
#created on: 13/08/2006
package org.unlp.model
#list any import classes here.
import org.unlp.model.Estudiante;
#declare any global variables here
rule "Descuento por pago al contado"
when
alumno : Estudiante (cuota : cuotasPagas, x: inscripcion -> (
x.getCuotas().intValue() > cuota.intValue() ) )
then
System.out.println( "El alumno: [" + alumno.getNombre()+ "]
recibira un descuento por pago al contado del 25%");
System.out.println( "La cantindad de cuotas es [" +
alumno.getCuotasPagas()+ "] ");
end
But I obtain the followin error
org.drools.RuntimeDroolsException: java.lang.NullPointerException
at org.drools.rule.PredicateConstraint.isAllowed(Unknown Source)
at org.drools.common.BetaNodeBinder.isAllowed(Unknown Source)
at org.drools.reteoo.LeftInputAdapterNode.assertObject(Unknown Source)
at org.drools.reteoo.ObjectSource.propagateAssertObject(Unknown Source)
at org.drools.reteoo.ObjectTypeNode.assertObject(Unknown Source)
at org.drools.reteoo.Rete.assertObject(Unknown Source)
at org.drools.reteoo.ReteooRuleBase.assertObject(Unknown Source)
at org.drools.reteoo.ReteooWorkingMemory.doAssertObject(Unknown Source)
at org.drools.common.AbstractWorkingMemory.assertObject(Unknown Source)
at org.drools.common.AbstractWorkingMemory.assertObject(Unknown Source)
at org.unlp.model.BusinessRulesTest.main(BusinessRulesTest.java:45)
Caused by: java.lang.NullPointerException
at
org.unlp.model.Rule_Descuento_por_pago_al_contado_0Predicate0Invoker.evaluate
(Rule_Descuento_por_pago_al_contado_0Predicate0Invoker.java:13)
... 11 more
What do you suggest I do ?
--
"Component design should be the Formula-1 racing of software engineering."
Bertrand Meyer
18 years, 4 months