[rules-users] LHS compare two lists

lnguyen mzspdrcr at gmail.com
Sat Sep 18 19:26:43 EDT 2010


Hi,

I'm trying to determine if a user has the required certifications for a
position. So I'm comparing the list of required certifications to the list
of User Certifications but I'm throwing a nullPointerException even though I
check to make sure the list are not null on their respective objects. How do
I iterate between both list?

rule "Determine if the user has the required certifications"
dialect 'mvel'
    no-loop true
    salience 80
when
    $user : User()
    $profile : UserProfile($userCertifications : userCertifications,
eval(userCertifications != null)) from $user.userProfile
    $position : Position($certifications : requiredCertifications,
eval(requiredCertifications != null))
    exists ($certification: Certification() from $certifications and
UserCertification(certification == $certification) from $userCertifications)
then
    System.out.println("The user has the required certifications");

end

public UserProfile
{

    List<UserCertification> userCertifications;
    //more fields
}

public Position
{
    List<Certification> requiredCertifications;
   //more fields
}

public Certification
{
    Long id;

    String name;
    //more fields
}

public UserCertification
{

    Long id;

    Date certificationDate;

    Certification certification;
    //more fields
}
-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/LHS-compare-two-lists-tp1521979p1521979.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list