The idea of the rule given below is to collect a List&lt;AcquiredCertification&gt; from a certain User that&#39;s contained in the Position object&#39;s list of requiredCertifications, and then to compare the sizes. Equality means that User meets all requirements.<br>
<br>rule &quot;meets requirements&quot;<br>dialect &quot;mvel&quot;<br>when<br>    Position( $certifications: requiredCertifications )<br>    User( $name: name, $profile: profile )<br>    $got: List() from collect (  AcquiredCertification( certification memberOf $certifications ) from $profile.userCertifications )<br>
    eval($certifications.size == $got.size  )<br>then<br>    System.out.println( &quot;Hire &quot; + $name );<br>end<br><br>-W<br><br><div class="gmail_quote">On 19 September 2010 01:26, lnguyen <span dir="ltr">&lt;<a href="mailto:mzspdrcr@gmail.com">mzspdrcr@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi,<br>
<br>
I&#39;m trying to determine if a user has the required certifications for a<br>
position. So I&#39;m comparing the list of required certifications to the list<br>
of User Certifications but I&#39;m throwing a nullPointerException even though I<br>
check to make sure the list are not null on their respective objects. How do<br>
I iterate between both list?<br>
<br>
rule &quot;Determine if the user has the required certifications&quot;<br>
dialect &#39;mvel&#39;<br>
    no-loop true<br>
    salience 80<br>
when<br>
    $user : User()<br>
    $profile : UserProfile($userCertifications : userCertifications,<br>
eval(userCertifications != null)) from $user.userProfile<br>
    $position : Position($certifications : requiredCertifications,<br>
eval(requiredCertifications != null))<br>
    exists ($certification: Certification() from $certifications and<br>
UserCertification(certification == $certification) from $userCertifications)<br>
then<br>
    System.out.println(&quot;The user has the required certifications&quot;);<br>
<br>
end<br>
<br>
public UserProfile<br>
{<br>
<br>
    List&lt;UserCertification&gt; userCertifications;<br>
    //more fields<br>
}<br>
<br>
public Position<br>
{<br>
    List&lt;Certification&gt; requiredCertifications;<br>
   //more fields<br>
}<br>
<br>
public Certification<br>
{<br>
    Long id;<br>
<br>
    String name;<br>
    //more fields<br>
}<br>
<br>
public UserCertification<br>
{<br>
<br>
    Long id;<br>
<br>
    Date certificationDate;<br>
<br>
    Certification certification;<br>
    //more fields<br>
}<br>
<font color="#888888">--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/LHS-compare-two-lists-tp1521979p1521979.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/LHS-compare-two-lists-tp1521979p1521979.html</a><br>

Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>