[rules-users] Getting Error while using Drools 5.3.0

Wolfgang Laun wolfgang.laun at gmail.com
Thu Apr 26 15:58:26 EDT 2012


This rule (and note the correct spelling of modelYear with a capital
'Y', in contrast to your first post) compiles and executes correctly
using 5.3.0.

rule qr
when
    info: CarRulesInfo( quoteRequest.VIN == null,
                        quoteRequest.modelYear > 1982 )
then
    System.out.println( "got new car" );
end

-W



On 25/04/2012, mkhan_rt54fde <maliullah at gmail.com> wrote:
> Hi,
>
> Thanks for the reply.
>
> In my application,one of the input parameters is Year.In my java class,I am
> getting the modelyear from year and converting it an integer.But even then,
> I am getting the error posted earlier.Here is my rule file:
>
> rule "Set Time To Live"
> 	when
> 		there is a restoration request
> 	then
> 		set quote process time to live to: 15
> 		add additional action "check state regulation for vintage car
> restoration"
> end
>
>
> #validation
> rule "Year is required"
> no-loop true
> 	when
> 		request does not contain model year
> 	then
> 		set reason of rejection to "year is required"
> 		reject request
> end
>
>
> #additional action
> rule "VIN required for newer vehicles"
> no-loop true
> 	when
> 		request contains no VIN and the car was built after year 1982
> 	then
> 		ask the customer to provide VIN
> end
>
> and here is my java class:
>
> public class QuoteRequest {
>
> 	private Contact contact;
> 	private Address address;
>
> 	private String make;
> 	private String model;
> 	private String style;
> 	private String year;
>
> 	private String VIN;
> 	private String condition;
> 	private String description;
> 	private String zip;
>
> 	private List<Link> links = new ArrayList<Link>();
>
> 	public static void printForMe() {
> 		System.out.println("printing for you");
> 	}
>
> 	public Contact getContact() {
> 		return contact;
> 	}
>
> 	public void setContact(Contact contact) {
> 		this.contact = contact;
> 	}
>
> 	public Address getAddress() {
> 		return address;
> 	}
>
> 	public void setAddress(Address address) {
> 		this.address = address;
> 	}
>
> 	public String getMake() {
> 		return make;
> 	}
>
> 	public void setMake(String make) {
> 		this.make = make;
> 	}
>
> 	public String getModel() {
> 		return model;
> 	}
>
> 	public void setModel(String model) {
> 		this.model = model;
> 	}
>
> 	public String getStyle() {
> 		return style;
> 	}
>
> 	public void setStyle(String style) {
> 		this.style = style;
> 	}
>
> 	public String getYear() {
> 		return returnString(year);
> 	}
> 	
> 	public Integer getModelYear() {
> 		Integer modelYear = (getYear() == null) ? null : Integer.parseInt(year);
> 	return modelYear;
> 	}
>
> 	public void setYear(String year) {
> 		this.year = year;
> 	}
>
> 	public String getVIN() {
> 		return returnString(VIN);
> 	}
>
> 	public void setVIN(String vin) {
> 		VIN = vin;
> 	}
>
> 	public String getCondition() {
> 		return condition;
> 	}
>
> 	public void setCondition(String condition) {
> 		this.condition = condition;
> 	}
>
> 	public String getDescription() {
> 		return description;
> 	}
>
> 	public void setDescription(String description) {
> 		this.description = description;
> 	}
>
> 	public String getZip() {
> 		return zip;
> 	}
>
> 	public void setZip(String zip) {
> 		this.zip = zip;
> 	}
>
> 	public List<Link> getLinks() {
> 		return links;
> 	}
>
> 	public void setLinks(List<Link> links) {
> 		this.links = links;
> 	}
> 	
> 	private String returnString(String s) {
> 	 return (s == null || s.isEmpty()) ? null : s;	
> 	}
> }
>
> Are there any changes I need to make any changes to the java class to fix
> the error I am seeing?
>
> Thanks.
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Getting-Error-while-using-Drools-5-3-0-tp3936714p3939076.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list