Re: [rules-users] get new errors caused by KnowledgeBuilder.add()
yeah the internal impl is arraylist but the interface is a collectionKnowledgeBuilderErrors, so everytime I had to convert it to array and keep counter of last-error-index and fetch new KnowledgeBuilderErrors on the collection, or use iterator to iterate the last-error-index and continue till the end of the collection. the knowledge builder dosent return any package if it has atleast one failed package. But I want the successfully-compiled rules to be in the kBase and log the failed rules with the unique identifier of it. so the author of the rule is notified and rest all rules work without any issue. creating new kBuilder for every rule (drl string) in the db and adding its packages to the kBase is the only way? may be something like kBuilder.remove(failedResource) or getSuccessfulKnowledgePackages(); On Sun, Jun 10, 2012 at 10:58 AM, Wolfgang Laun wolfgang.l...@gmail.comwrote: If the list of errors is extended by errors detected during another kb.add(): why not just keep track of the last size() of the list? New errors are bound to appear at the end of the list. -W On 10 June 2012 01:44, Sandeep Bandela gibsos...@gmail.com wrote: Hi, I have rules (drl format strings) stored in a database column in a schema like MyRules(rule_id integer, name text, rule text, enabled boolean ... ) I query the db to get them and iterate over the rows and add using KnowledgeBuilder.add() using String.getBytes. (I dont want to move to guvnor as of now) some rules might have compilation errors, hence the KnowledgeBuilder.hasErrors() is set to true. those will not be added to the package by the PackageBuilder. My problem is to log the error causing rule_id and the error message. KnowledgeBuilderErrors dosent expose the internal errors list so that I could see if any new errors are in the arraylist from the last time error seen time and log them. But only solution i could think of is using the low level api of using DrlParser to pre-parse it to check for errors+log and add to the kBuilder if its not failed. is there any elegant way to do this? I am using drools-5.2.0.final -- Regards, Sandeep Bandela. ___ 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 -- Regards, Sandeep Bandela. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] get new errors caused by KnowledgeBuilder.add()
I'd just instanceof test the Collection against List and cast. Second, consider an issue requiring support for error checking with this additive kind of build. If all of your rules are in the same package, consider concatenating the rules strings in a string builder and feed the results to the KB instance. Mapping accumulated line counts to rules will enable you to associate error messages to rules. As you wrote, you can also build each rule separately and add individual packages to the knowledge base. What's wrong with this approach? You might also keep track of correct rules in your DB: once it has been compiled individually, mark it as OK. New/modified rules lose the mark. -W On 10 June 2012 12:50, Sandeep Bandela gibsos...@gmail.com wrote: yeah the internal impl is arraylist but the interface is a collectionKnowledgeBuilderErrors, so everytime I had to convert it to array and keep counter of last-error-index and fetch new KnowledgeBuilderErrors on the collection, or use iterator to iterate the last-error-index and continue till the end of the collection. the knowledge builder dosent return any package if it has atleast one failed package. But I want the successfully-compiled rules to be in the kBase and log the failed rules with the unique identifier of it. so the author of the rule is notified and rest all rules work without any issue. creating new kBuilder for every rule (drl string) in the db and adding its packages to the kBase is the only way? may be something like kBuilder.remove(failedResource) or getSuccessfulKnowledgePackages(); On Sun, Jun 10, 2012 at 10:58 AM, Wolfgang Laun wolfgang.l...@gmail.com wrote: If the list of errors is extended by errors detected during another kb.add(): why not just keep track of the last size() of the list? New errors are bound to appear at the end of the list. -W On 10 June 2012 01:44, Sandeep Bandela gibsos...@gmail.com wrote: Hi, I have rules (drl format strings) stored in a database column in a schema like MyRules(rule_id integer, name text, rule text, enabled boolean ... ) I query the db to get them and iterate over the rows and add using KnowledgeBuilder.add() using String.getBytes. (I dont want to move to guvnor as of now) some rules might have compilation errors, hence the KnowledgeBuilder.hasErrors() is set to true. those will not be added to the package by the PackageBuilder. My problem is to log the error causing rule_id and the error message. KnowledgeBuilderErrors dosent expose the internal errors list so that I could see if any new errors are in the arraylist from the last time error seen time and log them. But only solution i could think of is using the low level api of using DrlParser to pre-parse it to check for errors+log and add to the kBuilder if its not failed. is there any elegant way to do this? I am using drools-5.2.0.final -- Regards, Sandeep Bandela. ___ 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 -- Regards, Sandeep Bandela. ___ 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
[rules-users] BigDecimal comparison
Hi there, Please assist. I have an object MaxCap that has a single property capAmount of type BigDecimal. The BigDecimal is negative when the rule is MaxCap( capAmount.doubleValue 0.00 ) it doesnt fire, which I expect it should but when the rule is MaxCap( capAmount.doubleValue 0.00 ) then the rules fires, so the rule recognises my negative number as a positive one. Any help would be appreciated. Thanks Devan -- View this message in context: http://drools.46999.n3.nabble.com/BigDecimal-comparison-tp4017841.html Sent from the Drools: User forum 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] BigDecimal comparison
Done a little test using 3 approachs (with new BigDecimal(-12.321)), all are working: rule test big decimal 1 when Pojo(bigDecimal 0.0) then System.out.println(test big decimal 1); end rule test big decimal 2 when Pojo(bigDecimal.doubleValue 0.0) then System.out.println(test big decimal 2); end rule test big decimal 3 when Pojo(bigDecimalValue 0.0) // with then System.out.println(test big decimal 3); end with a wrapper method for the 3rd rule : public Double getBigDecimalValue() { if (bigDecimal == null) { return null; } else { return bigDecimal.doubleValue(); } } Your problem come from somewhere else (other conditions, wrong number in your object, missing import, too old version ...) - Mail original - De: devan vanreenen devan.vanree...@gmail.com À: rules-users@lists.jboss.org Envoyé: Dimanche 10 Juin 2012 19:38:42 Objet: [rules-users] BigDecimal comparison Hi there, Please assist. I have an object MaxCap that has a single property capAmount of type BigDecimal. The BigDecimal is negative when the rule is MaxCap( capAmount.doubleValue 0.00 ) it doesnt fire, which I expect it should but when the rule is MaxCap( capAmount.doubleValue 0.00 ) then the rules fires, so the rule recognises my negative number as a positive one. Any help would be appreciated. Thanks Devan -- View this message in context: http://drools.46999.n3.nabble.com/BigDecimal-comparison-tp4017841.html Sent from the Drools: User forum 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