You have something similar to what you want. If *resultState *is a global variable, there is nothing stopping you from writing any amount of java code you want in the consequence part. Create whatever you want and then do *resultState.add(SOMEOBJECT);

*You already perform a similar action with the code you have already:
frontAxleAttributes.put("Capacity" ,new Double(c.attributes.Capacity));

hth
Minh


On 10/18/2010 2:58 PM, Navdeep Kumar wrote:
Hi..

After execution of each rule, i want to create a new object of a particular class and want to add that to the list. i know how to set the global list but i am not sure whether i can create a new instance in the consequence of the rule.


here is the rule file and description that what i am trying to do.

import java.util.Map;
global java.util.HashMap availablity;
global java.util.HashMap frontAxleAttributes;
global java.util.HashMap frontSuspensionAttributes;
global java.util.ArrayList resultState;




rule "FrontAxle:Capacity|FrontSuspension:Capacity"
dialect "mvel"
when
b:Feature(featureClass.name=="FrontSuspension")
c:Feature(featureClass.name=="FrontAxle")
eval(b.attributes.Capacity>=c.attributes.Capacity)
then
System.out.println(b.attributes.Capacity);
frontAxleAttributes.put("Capacity" ,new Double(c.attributes.Capacity));
frontSuspensionAttributes.put("Capacity", new Double(b.attributes.Capacity));
frontAxleAttributes.put("Feature Code",b.getCode());
frontSuspensionAttributes.put("Feature Code",c.getCode());
availablity.put(b.featureClass.getName+"-"+c.getFeatureClass().getName(),new Double(b.attributes.Capacity)); * **// i want to create a new Object of a class named AvailabilityRuleState and want to add that in the list named resultState. *
* *
end

*//resultState is a list of AvailabilityRuleState Class. Please do check the global declaration if that is wrong.*

will appreciate your help.

Thanks.


_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to