[rules-users] All the values from one list must be present in other

Suvek suvek.shah at gmail.com
Mon Aug 20 09:33:05 EDT 2012


Thanks laune!!!
I think I did not explain properly and duplicate name "FOREIGN_BUSINESS"
added more to the confusion...  still you understood my problem , I will try
putting more flesh on the bones in terms of classes to explain further
details...

public class TaxPayer {
...
 ArrayList<Address> addersses;
 TaxpayerType taxpayerType;
...
}

public class Address {
	...
   AddressType addressType;
	...
}

public enum AddressType{
UNKNOWN,
BUSINESS,
FOREIGN_BUSINESS_ADDRESS,
RENTED,
OWNED,
....
}

public enum TaxpayerType{
BUSINESS,
FOREIGN_BUSINESS,
INDIVIDUAL,
FAMILY,
PROPRITER
....
}

Now based on the taxpayerType say FOREIGN_BUSINESS, the taxpayer must have
atleast 2 Addresses (BUSINESS and FOREIGN_BUSINESS_ADDRESS). 

I will have seperate rule for each type of tax payer, I am not passing in
the AddressTypes (BUSINESS and FOREIGN_BUSINESS_ADDRESS) to be verified
against as the facts, I want to set these values in the rule. So ideally I
want something like 

rule "Validate Foreign Business"
when 	
    $tpType: List() from [ AddressType.BUSINESS,
AddressType.FOREIGN_BUSINESS_ADDRESS ] //This line is incorrect
    Taxpayer( $name: name, taxpayerType == $tpType, $addrs: addresses ) 
    accumulate( Address( $addrType: addressType ) from $addrs, 
                $addrTypeSet: collectSet( $addrType ) ) 
    eval( ! $addrTypeSet.containsAll( $addressTypes ) ) 
then 
    System.out.println( $name + " is not OK" ); 
end 

Also is it possible to show which address type is missing? say
AddressType.BUSINESS is not present in the list

thanks in advance for your help











the rule is always resolving to success irrespective of weather the
addresses are present or not. 




the only change that I have done is 
replaced
$tpType: TaxpayerType( $addressTypes: addressTypes ) 
with 
$tpType: 



--
View this message in context: http://drools.46999.n3.nabble.com/All-the-values-from-one-list-must-be-present-in-other-tp4019276p4019280.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list