[rules-users] how to check HashSet size in drool

yashwantkh yashwantkh at gmail.com
Thu Jul 18 06:20:39 EDT 2013


sorry but for explaining

I have a class
public class Creative {
	private Integer id;
	private Integer geo_type;
	private HashSet<GeoMap> geo_mapList=null;
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getGeo_type() {
		return geo_type;
	}
	public void setGeo_type(Integer geo_type) {
		this.geo_type = geo_type;
	}
	public HashSet<GeoMap> getGeo_mapList() {
		return geo_mapList;
	}
	public void setGeo_mapList(HashSet<GeoMap> geo_mapList) {
		this.geo_mapList = geo_mapList;
	}


and in knowledgebase 
i m inserting this class like this
Creative c2=new Creative();
			c2.setId(new Integer(3));
			c2.setGeo_type(1);
			HashSet<GeoMap> geo_mapList=new HashSet<GeoMap>();
			c2.setGeo_mapList(geo_mapList);
                       session.insert(c2);


and in drl file i have to check if creative have geoType ==1 and sized of
geo_mapList is zero then have to show the error message

i m doing like this
rule "geo_map2"
//dialect "java"
	when 
	$creative : Creative()
	not exists($geo_map : GeoMap() from $creative.geo_mapList)
		//$creative : Creative()
		//exists(
		//$geo_map : GeoMap()
		//$creative : Creative( id > 0 ,  geo_mapList not contains $geo_map)
		
	then
		System.out.println("geo_map2 fail for  CreativeId--"+$creative.id );
end

its not working how will i do that





--
View this message in context: http://drools.46999.n3.nabble.com/how-to-check-HashSet-size-in-drool-tp4025036p4025043.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list