RE: [rules-users] compare string and int in LHS
Hi, the class TripleObject has a method getValue. This method convert the String value to an Ingeger. rule a Rule when $vb_refmax : TripleObject( name == vb_refmax ); $vb_reflow : TripleObject( name == vb_reflow); eval( $vb_reflow.getValue(TripleObject.VALUE_TYP_INTEGER) = $vb_refmax.getValue(TripleObject.VALUE_TYP_INTEGER) ); then end I hope this helps. blackone wrote: Hi! Could you provide the rule showing how you have used eval to solve the problem? I'm new to drools and have the same problem... brenner wrote: Thanks for your answer. Yes, with eval it works. I had oversight it. The question with the model I have aked myself. But I can't change it. There are to much factors involved. Storable by Hibernate. Based on configuration files with key-value, whereas the value could have various data types (c-types) and all without a rule. Very bad, I know. Anstis, Michael (M.) wrote: You could use an inline eval too. The problem possibly lies more with your model; why not have one subclass expose the String property and another the Integer property and code the rules using the subclasses? Much safer throughout the entire application than having to worry whether some field is meant to be a string or number (It's very easy to question problems though - there could be very good reason why you need the model as is). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of brenner Sent: 08 February 2008 12:33 To: rules-users@lists.jboss.org Subject: Re: [rules-users] compare string and int in LHS Hi, I have found a solution, but I don't know that it is the best: My solution: I have extend my Class with a method which returns the string as a integer. And my rule is like this: i : Integer( intValue = 1) from $test.getValue(Test.VALUE_TYP_INTEGER); Is that the only/best solution. Can't I convert Strings to Integer on the LHS of a rule? greeting Daniel brenner wrote: Hi, I have a class, wich contains a string value. This value is in some use cases an integer. For this use case I want to convert (parse) the string typ to an integer because I want that the following rule matches: rule when t : Test(value = 1) then System.out.println(t) end class Test { String value; getValue(); setValue(); } Have anyone a solution or some help for me? Is that possible what I want to do? Thanks Daniel -- View this message in context: http://www.nabble.com/compare-string-and-int-in-LHS-tp15337728p15354435.html Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://www.nabble.com/compare-string-and-int-in-LHS-tp15337728p16301146.html Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] compare string and int in LHS
Hi, I have found a solution, but I don't know that it is the best: My solution: I have extend my Class with a method which returns the string as a integer. And my rule is like this: i : Integer( intValue = 1) from $test.getValue(Test.VALUE_TYP_INTEGER); Is that the only/best solution. Can't I convert Strings to Integer on the LHS of a rule? greeting Daniel brenner wrote: Hi, I have a class, wich contains a string value. This value is in some use cases an integer. For this use case I want to convert (parse) the string typ to an integer because I want that the following rule matches: rule when t : Test(value = 1) then System.out.println(t) end class Test { String value; getValue(); setValue(); } Have anyone a solution or some help for me? Is that possible what I want to do? Thanks Daniel -- View this message in context: http://www.nabble.com/compare-string-and-int-in-LHS-tp15337728p15354435.html Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
RE: [rules-users] compare string and int in LHS
You could use an inline eval too. The problem possibly lies more with your model; why not have one subclass expose the String property and another the Integer property and code the rules using the subclasses? Much safer throughout the entire application than having to worry whether some field is meant to be a string or number (It's very easy to question problems though - there could be very good reason why you need the model as is). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of brenner Sent: 08 February 2008 12:33 To: rules-users@lists.jboss.org Subject: Re: [rules-users] compare string and int in LHS Hi, I have found a solution, but I don't know that it is the best: My solution: I have extend my Class with a method which returns the string as a integer. And my rule is like this: i : Integer( intValue = 1) from $test.getValue(Test.VALUE_TYP_INTEGER); Is that the only/best solution. Can't I convert Strings to Integer on the LHS of a rule? greeting Daniel brenner wrote: Hi, I have a class, wich contains a string value. This value is in some use cases an integer. For this use case I want to convert (parse) the string typ to an integer because I want that the following rule matches: rule when t : Test(value = 1) then System.out.println(t) end class Test { String value; getValue(); setValue(); } Have anyone a solution or some help for me? Is that possible what I want to do? Thanks Daniel -- View this message in context: http://www.nabble.com/compare-string-and-int-in-LHS-tp15337728p15354435.html Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users smime.p7s Description: S/MIME cryptographic signature ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
RE: [rules-users] compare string and int in LHS
Thanks for your answer. Yes, with eval it works. I had oversight it. The question with the model I have aked myself. But I can't change it. There are to much factors involved. Storable by Hibernate. Based on configuration files with key-value, whereas the value could have various data types (c-types) and all without a rule. Very bad, I know. Anstis, Michael (M.) wrote: You could use an inline eval too. The problem possibly lies more with your model; why not have one subclass expose the String property and another the Integer property and code the rules using the subclasses? Much safer throughout the entire application than having to worry whether some field is meant to be a string or number (It's very easy to question problems though - there could be very good reason why you need the model as is). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of brenner Sent: 08 February 2008 12:33 To: rules-users@lists.jboss.org Subject: Re: [rules-users] compare string and int in LHS Hi, I have found a solution, but I don't know that it is the best: My solution: I have extend my Class with a method which returns the string as a integer. And my rule is like this: i : Integer( intValue = 1) from $test.getValue(Test.VALUE_TYP_INTEGER); Is that the only/best solution. Can't I convert Strings to Integer on the LHS of a rule? greeting Daniel brenner wrote: Hi, I have a class, wich contains a string value. This value is in some use cases an integer. For this use case I want to convert (parse) the string typ to an integer because I want that the following rule matches: rule when t : Test(value = 1) then System.out.println(t) end class Test { String value; getValue(); setValue(); } Have anyone a solution or some help for me? Is that possible what I want to do? Thanks Daniel -- View this message in context: http://www.nabble.com/compare-string-and-int-in-LHS-tp15337728p15354435.html Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://www.nabble.com/compare-string-and-int-in-LHS-tp15337728p15357593.html Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users