[rules-users] How to determine Drools runtime version?
Hi, I'd like to determine at runtime which version of Drools is in use/on the classpath. I cannot use reflection on the Drools classes itself, as this will not work in the intended runtime environment (Google App Engine). The following code works in a normal Java VM, but not in GAE: Package droolsCorePackage = KnowledgePackageImp.class.getPackage(); String implementationTitle = droolsCorePackage.getImplementationTitle(); String implementationVersion = droolsCorePackage.getImplementationVersion(); In GAE, the getImplementation{Title|Version} methods both return null. Is there another, maybe more official way of determining the Drools version? I'd like to support Drools 5.x.y starting at x = 3. Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] continuous integration of rule assets via jenkins to guvnor?
Hi, we use drools for mortgage risk assessment and use TeamCity for continuous integration of rules. Our source code is *.drl (no DSL or processes yet). Rules get unit tested (TestNG), compiled into binary packages and some integration tests run against each of these packages. If all is good, we perform an ordinary maven release of the rules. They get a version number just as any other maven artifact and get deployed to a maven repository manager (Nexus OSS) and our packaging/deployment tool pulls them from there just before it needs them. We don't use guvnor at all (we have a very developer-centric rules-authoring/rollout process) and perform rule compilation with a maven plugin ( http://passion.forco.de/node/34 ). It does not need any running guvnor instance, but uses drools' public rules compilation Java API. If you want to know more details, or have questions, please let me know. Best regards, Ansgar Am 03.10.2012 23:27 schrieb Cedric Hurst ced...@spantree.net: I'd like to get a quick sanity check on best practices... I'm working on a project where, by policy, all assets (including drl's, bpmn files, etc) must be built, tested and packaged by a Jenkins server. Rule assets are structured within a project that also includes non-rule assets. As is quite common, the primary system of record for these assets is an SCM like svn or git, and that's what our Jenkins box talks to. However, for the rule stuff specifically, we're also using Guvnor's drools-repository to package the assets into a knowledge base, which is referenced jBPM's process engine in the runtime. The plan is to have several Guvnor environments running with parity to development, QA, UAT and production setups. However, we're having a very hard time figuring out how best to sync our rule assets to these various repositories as part of an automated release. To the best of my understanding, rule assets are deployed to a Guvnor instance file-by-file via WebDAV. One can also upload JARs for POJOs, but DRLs, BPMN, DSL files need to be synced individually. Is this the case? And, if so, how do other groups handle continuous integration and deployment of assets coming from external SCMs? Btw, I came across aware of a Maven plugin which seems to do this sort of piece-by-piece deployment: https://github.com/awaterma/drools-guvnor-plugin So we could certainly port this sort of functionality to our own build toolchain, but it seems like a lot of work so I'm hoping for a better way. -- View this message in context: http://drools.46999.n3.nabble.com/continuous-integration-of-rule-assets-via-jenkins-to-guvnor-tp4020122.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
Re: [rules-users] Drools with rules from database
Question: for a single lookup like the one shown in the rule you reference, do you want to add another technology to your stack (or rather code that in Java)? Am 23.08.2012 17:09 schrieb Michael Anstis michael.ans...@gmail.com: You will need to insert both Employee and EmployeeTypeSalary objects into WM:- Employee( manager ) Employee( director ) EmployeeTypeSalary( manager, 100 ) EmployeeTypeSalary( director, 300 ) You won't need any more rules than the one shown. This rule will not need to be changed. Just insert your reference data (EmployeeTypeSalary) and employee data (Employee) into Working Memory. How you get both the reference data and employee data is up to you. I'm not about to embark on JDBC\JPA etc lessons. On 23 August 2012 15:16, debchamps majumdar.debarg...@gmail.com wrote: So the thing is I will have rules like when EmployeeTypeSalary( $et : emplyeeType, $s : salary ) $e : Employee( employeeType == $et ) then modify($e) { setSalary( $s ); } end But by taking the value from db the rules will look like if(employesalary.color == manager) employesalary.salary = 100 if(employesalary.color == director) employesalary.salary = 300 There is only one template But I want to take this rules from db i.e employee salary --- manager 100 director 300 For this I need some reference/example specially for connecting Drools with db and how the things work. Thanks, Deb -- View this message in context: http://drools.46999.n3.nabble.com/Drools-with-rules-from-database-tp4019357p4019361.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 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Logical insert and cyclic rules dependences
Am 02.07.2012 15:29, schrieb zephyr: zephyr wrote I want to use magick of logical insert to keep dynamically changing inferred facts up to date. The problem are cyclic dependences: a - b means when a than insertLogical( new b()) end a - b b - c c - b when i insert a b and c are correctly inferred (they check equals so it doesnt loop) but when i remove a they persist, as they make they're rules active because ot the cycle is there a good way to remove such logical facts not supported by inserted data? [...] Hmm maybe there is some kind of better way to deal with this. b - c c - b in other words: b and c are logically equivalent. You can remove one of your symbols b or c and just work with the remaining one. b and c will always have the same truth value (true/false). If this does not help, please let me know a bit more about your use case. Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] maven drools compiler (plugin)
Hi Sean, thanks for giving it a try. Release 0.2.4 is horribly old. Latest release is 0.2.11. Could you retry with 0.2.11 and let me know how that works out? Best regards, Ansgar Am 14.04.2012 00:04 schrieb Sean Su sean.x...@gmail.com: Ansgar, I am able to connect to the repository and start to download the dependencies. However it failed with this error. Any idea? Caused by: org.sonatype.aether.resolution.VersionRangeResolutionException: No versions available for org.easytesting:fest-assert:jar:[1.4, 2.0) within specified range at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:376) at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:544) at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:240) ... 26 more I am pointing to http://lightful.de/mvnrepo/public/releases/ with plugin version 0.2.4. Thanks Sean On Fri, Apr 6, 2012 at 9:35 AM, Sean Su sean.x...@gmail.com wrote: Ansgar, I tried the plugin yesterday before sending the email to the list but did not succeed. The problem, I believe, is the repository specification inside my pom. Could you send it over so that I can be sure? Thanks Sean On Fri, Apr 6, 2012 at 2:32 AM, Geoffrey De Smet ge0ffrey.s...@gmail.com wrote: ** Hey Ansgar, Your plugin is by far the best maven plugin for drools out there. Nice work. Would you be interested in moving the code into https://github.com/droolsjbpm/droolsjbpm-tools next to drools-ant? Advantages: - It would be released together with the rest of the drools, using the latest drools version - It would be automatically synced to maven central - It would get more exposure, as it will be documented in our documentation - Others (including us) will start improving it too Disadvantages: - At first, you 'd have to fork it and create pull requests to get your changes back into blessed (but I can guarantee I 'll merge any non-conflicting pull requests frequently and won't let them go stale) - We 'd need at least a few lines of documentation in: https://github.com/droolsjbpm/drools/tree/master/drools-docs/drools-expert-docs We can worry about the more advanced features (such as aether usage) later, just getting an official maven plugin for drools out there will help a lot of people. Op 05-04-12 23:01, Ansgar Konermann schreef: Am 05.04.2012 21:48 schrieb Sean Su sean.x...@gmail.com: Hello, guys, I did some search online and it seems we do not have any official plugin that allows us to compile Drools rules as part of the maven build. There is already a jira issue for it: https://issues.jboss.org/browse/JBRULES-1273 Result so far: http://passion.forco.de/content/maven-drools-plugin Feel free to try it and let me know if you miss anything. Best regards, Ansgar Is this the case or I have not found it yet? Thanks for the help. Sean -- But beware of the Dark Side. Anger, fear, aggression - the Dark Side of the Force are they. -Yoda ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users -- With kind regards, Geoffrey De Smet ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- But beware of the Dark Side. Anger, fear, aggression - the Dark Side of the Force are they. -Yoda -- But beware of the Dark Side. Anger, fear, aggression - the Dark Side of the Force are they. -Yoda ___ 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
Re: [rules-users] maven drools compiler (plugin)
) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.sonatype.aether.collection.DependencyCollectionException: Failed to collect dependencies for de.lightful.maven.plugins:maven-drools-plugin:jar:0.2.11 () at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:258) at org.sonatype.aether.impl.internal.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:308) at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:199) ... 24 more Caused by: org.sonatype.aether.resolution.VersionRangeResolutionException: No versions available for org.easytesting:fest-assert:jar:[1.4, 2.0) within specified range at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:376) at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:544) at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:240) ... 26 more On Fri, Apr 13, 2012 at 6:09 PM, Ansgar Konermann ansgar.konerm...@googlemail.com wrote: Hi Sean, thanks for giving it a try. Release 0.2.4 is horribly old. Latest release is 0.2.11. Could you retry with 0.2.11 and let me know how that works out? Best regards, Ansgar Am 14.04.2012 00:04 schrieb Sean Su sean.x...@gmail.com: Ansgar, I am able to connect to the repository and start to download the dependencies. However it failed with this error. Any idea? Caused by: org.sonatype.aether.resolution.VersionRangeResolutionException: No versions available for org.easytesting:fest-assert:jar:[1.4, 2.0) within specified range at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:376) at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:544) at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:240) ... 26 more I am pointing to http://lightful.de/mvnrepo/public/releases/ with plugin version 0.2.4. Thanks Sean On Fri, Apr 6, 2012 at 9:35 AM, Sean Su sean.x...@gmail.com wrote: Ansgar, I tried the plugin yesterday before sending the email to the list but did not succeed. The problem, I believe, is the repository specification inside my pom. Could you send it over so that I can be sure? Thanks Sean On Fri, Apr 6, 2012 at 2:32 AM, Geoffrey De Smet ge0ffrey.s...@gmail.com wrote: Hey Ansgar, Your plugin is by far the best maven plugin for drools out there. Nice work. Would you be interested in moving the code into https://github.com/droolsjbpm/droolsjbpm-tools next to drools-ant? Advantages: - It would be released together with the rest of the drools, using the latest drools version - It would be automatically synced to maven central - It would get more exposure, as it will be documented in our documentation - Others (including us) will start improving it too Disadvantages: - At first, you 'd have to fork it and create pull requests to get your changes back into blessed (but I can guarantee I 'll merge any non-conflicting pull requests frequently and won't let them go stale) - We 'd need at least a few lines of documentation in: https://github.com/droolsjbpm/drools/tree/master/drools-docs/drools-expert-docs We can worry about the more advanced features (such as aether usage) later, just getting an official maven plugin for drools out there will help a lot of people. Op 05-04-12 23:01, Ansgar Konermann schreef: Am 05.04.2012 21:48 schrieb Sean Su sean.x...@gmail.com: Hello, guys, I did some search online and it seems we do not have any official plugin that allows us to compile Drools rules as part of the maven build. There is already a jira issue for it: https://issues.jboss.org/browse/JBRULES-1273 Result so far: http://passion.forco.de/content/maven-drools-plugin Feel free to try it and let me know if you miss anything. Best regards, Ansgar Is this the case or I have not found it yet? Thanks for the help. Sean -- But beware of the Dark Side. Anger, fear, aggression - the Dark Side of the Force are they. -Yoda ___ 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 -- With kind regards, Geoffrey De Smet ___ rules-users mailing list rules-users
Re: [rules-users] maven drools compiler (plugin)
) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.sonatype.aether.collection.DependencyCollectionException: Failed to collect dependencies for de.lightful.maven.plugins:maven-drools-plugin:jar:0.2.11 () at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:258) at org.sonatype.aether.impl.internal.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:308) at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:199) ... 24 more Caused by: org.sonatype.aether.resolution.VersionRangeResolutionException: No versions available for org.easytesting:fest-assert:jar:[1.4, 2.0) within specified range at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:376) at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:544) at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:240) ... 26 more On Fri, Apr 13, 2012 at 6:09 PM, Ansgar Konermann ansgar.konerm...@googlemail.com wrote: Hi Sean, thanks for giving it a try. Release 0.2.4 is horribly old. Latest release is 0.2.11. Could you retry with 0.2.11 and let me know how that works out? Best regards, Ansgar Am 14.04.2012 00:04 schrieb Sean Su sean.x...@gmail.com: Ansgar, I am able to connect to the repository and start to download the dependencies. However it failed with this error. Any idea? Caused by: org.sonatype.aether.resolution.VersionRangeResolutionException: No versions available for org.easytesting:fest-assert:jar:[1.4, 2.0) within specified range at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:376) at org.sonatype.aether.impl.internal.DefaultDependencyCollector.process(DefaultDependencyCollector.java:544) at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:240) ... 26 more I am pointing to http://lightful.de/mvnrepo/public/releases/ with plugin version 0.2.4. Thanks Sean On Fri, Apr 6, 2012 at 9:35 AM, Sean Su sean.x...@gmail.com wrote: Ansgar, I tried the plugin yesterday before sending the email to the list but did not succeed. The problem, I believe, is the repository specification inside my pom. Could you send it over so that I can be sure? Thanks Sean On Fri, Apr 6, 2012 at 2:32 AM, Geoffrey De Smet ge0ffrey.s...@gmail.com wrote: Hey Ansgar, Your plugin is by far the best maven plugin for drools out there. Nice work. Would you be interested in moving the code into https://github.com/droolsjbpm/droolsjbpm-tools next to drools-ant? Advantages: - It would be released together with the rest of the drools, using the latest drools version - It would be automatically synced to maven central - It would get more exposure, as it will be documented in our documentation - Others (including us) will start improving it too Disadvantages: - At first, you 'd have to fork it and create pull requests to get your changes back into blessed (but I can guarantee I 'll merge any non-conflicting pull requests frequently and won't let them go stale) - We 'd need at least a few lines of documentation in: https://github.com/droolsjbpm/drools/tree/master/drools-docs/drools-expert-docs We can worry about the more advanced features (such as aether usage) later, just getting an official maven plugin for drools out there will help a lot of people. Op 05-04-12 23:01, Ansgar Konermann schreef: Am 05.04.2012 21:48 schrieb Sean Su sean.x...@gmail.com: Hello, guys, I did some search online and it seems we do not have any official plugin that allows us to compile Drools rules as part of the maven build. There is already a jira issue for it: https://issues.jboss.org/browse/JBRULES-1273 Result so far: http://passion.forco.de/content/maven-drools-plugin Feel free to try it and let me know if you miss anything. Best regards, Ansgar Is this the case or I have not found it yet? Thanks for the help. Sean -- But beware of the Dark Side. Anger, fear, aggression - the Dark Side of the Force are they. -Yoda ___ 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 -- With kind regards
Re: [rules-users] maven drools compiler (plugin)
Am 06.04.2012 15:35, schrieb Sean Su: Ansgar, I tried the plugin yesterday before sending the email to the list but did not succeed. The problem, I believe, is the repository specification inside my pom. Could you send it over so that I can be sure? Hi Sean, could you paste the respective repo specification you're currently using? You should be using this URL: http://lightful.de/mvnrepo/public/ inside a pluginRepository stanza in your settings.xml Best regards Ansgar Thanks Sean On Fri, Apr 6, 2012 at 2:32 AM, Geoffrey De Smet ge0ffrey.s...@gmail.com mailto:ge0ffrey.s...@gmail.com wrote: Hey Ansgar, Your plugin is by far the best maven plugin for drools out there. Nice work. Would you be interested in moving the code into https://github.com/droolsjbpm/droolsjbpm-tools next to drools-ant? Advantages: - It would be released together with the rest of the drools, using the latest drools version - It would be automatically synced to maven central - It would get more exposure, as it will be documented in our documentation - Others (including us) will start improving it too Disadvantages: - At first, you 'd have to fork it and create pull requests to get your changes back into blessed (but I can guarantee I 'll merge any non-conflicting pull requests frequently and won't let them go stale) - We 'd need at least a few lines of documentation in: https://github.com/droolsjbpm/drools/tree/master/drools-docs/drools-expert-docs We can worry about the more advanced features (such as aether usage) later, just getting an official maven plugin for drools out there will help a lot of people. Op 05-04-12 23:01, Ansgar Konermann schreef: Am 05.04.2012 21:48 schrieb Sean Su sean.x...@gmail.com mailto:sean.x...@gmail.com: Hello, guys, I did some search online and it seems we do not have any official plugin that allows us to compile Drools rules as part of the maven build. There is already a jira issue for it: https://issues.jboss.org/browse/JBRULES-1273 Result so far: http://passion.forco.de/content/maven-drools-plugin Feel free to try it and let me know if you miss anything. Best regards, Ansgar Is this the case or I have not found it yet? Thanks for the help. Sean -- But beware of the Dark Side. Anger, fear, aggression - the Dark Side of the Force are they. -Yoda ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- With kind regards, Geoffrey De Smet ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- But beware of the Dark Side. Anger, fear, aggression - the Dark Side of the Force are they. -Yoda ___ 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
Re: [rules-users] maven drools compiler (plugin)
Am 05.04.2012 21:48 schrieb Sean Su sean.x...@gmail.com: Hello, guys, I did some search online and it seems we do not have any official plugin that allows us to compile Drools rules as part of the maven build. There is already a jira issue for it: https://issues.jboss.org/browse/JBRULES-1273 Result so far: http://passion.forco.de/content/maven-drools-plugin Feel free to try it and let me know if you miss anything. Best regards, Ansgar Is this the case or I have not found it yet? Thanks for the help. Sean -- But beware of the Dark Side. Anger, fear, aggression - the Dark Side of the Force are they. -Yoda ___ 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
Re: [rules-users] How to include one .drl file from another .drl file
Am 09.03.2012 19:16 schrieb Shur, Bob robert.s...@hp.com: Is there something like #include for drl files? That is, something like this: rule 1 when then doSomething; end #include another.drl rule 2 when ... I know I can load multiple drl files into the knowledge base in Java. I'm just wondering whether someone writing a drl file can include other drls without having to copy and paste. If you want to achieve binary code reuse for your *.drl files (in contrast to source code reuse), you might want to have a closer look at the Maven Drools Plugin. [1] Kind regards, Ansgar [1] http://passion.forco.de/content/maven-drools-plugin ___ 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
Re: [rules-users] Drools 5.3 on Glassfish
Am 14.01.2012 10:42, schrieb Geoffrey De Smet: The tomcat war also works on jetty. The documentation says to use the tomcat war if there is no specific war. Maybe we should rename the tomcat war to generic war. +1 on the rename. Was a bit confused when I looked for a WAR to drop into my Jetty installation recently, but the one for tomcat worked flawlessly in Jetty7. Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Running rules from the past
Am 26.12.2011 18:08 schrieb Celso Junior celso...@gmail.com: Hi folks, I work at a bank Me too (sort of) and I am currently studying the best way to use JBoss Rules so that it fits our needs. Our loan analysis process can take several months depending on the type of the loan. Although our business rules can evolve, a loan must follow the rules valid at the time the loan application was made. In order to attend this requirement I thought about storing at the database the name of the current snapshot with the loan application data, so that it will possible run this rules in the future without freezing my rule database. * Is there a better way to attend this requirement? Don't use snapshots. Release your rules and store the rules' release number with the loan application data in your database. * How can I retrieve meta information from a snapshot, such as the date when the snapshot was created? Thanks in advance, Celso ___ 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
Re: [rules-users] Running rules from the past
Am 26.12.2011 18:16 schrieb Mauricio Salatino sala...@gmail.com: Did you try Guvnor? it already store the snapshots version. So you can get the right snapshot for running your rules against an old Loan again. @Ansgar: why do you recommend to not use snapshots? They change over time, making it more complex to track down the correct version. I'd preferr a stable loan application = rule set association. OTOH, it is probably *possible* to retrieve the correct snapshot version for a loan application if additional metadata is available. It's just more complicated: metadata needs to be available and sufficient to determine exactly *one* snapshot, snapshot needs to be available (not sure if Guvnor stores all snapshots forever or just a few). For releases, there is *one* figure you need to know to reference a certain ruleset (the version number). Releases are normally kept forever. Or, at least in my environment, deleting releases is done with extra extra care -if at all-, whereas snapshots older than a week or so get removed automatically on a daily basis. Best regards, Ansgar Cheers 2011/12/26 Ansgar Konermann ansgar.konerm...@googlemail.com: Am 26.12.2011 18:08 schrieb Celso Junior celso...@gmail.com: Hi folks, I work at a bank Me too (sort of) and I am currently studying the best way to use JBoss Rules so that it fits our needs. Our loan analysis process can take several months depending on the type of the loan. Although our business rules can evolve, a loan must follow the rules valid at the time the loan application was made. In order to attend this requirement I thought about storing at the database the name of the current snapshot with the loan application data, so that it will possible run this rules in the future without freezing my rule database. * Is there a better way to attend this requirement? Don't use snapshots. Release your rules and store the rules' release number with the loan application data in your database. * How can I retrieve meta information from a snapshot, such as the date when the snapshot was created? Thanks in advance, Celso ___ 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 -- - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jugargentina.org - Co-Founder @ http://www.jbug.com.ar - Salatino Salaboy Mauricio - ___ 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
Re: [rules-users] Running rules from the past
Hi, is there a distinction between snapshot and release versions at all in Guvnor? If I use snapshots only (referenced by an id) from my production code, how can I tell snapshots intended for development-only use and those for production use apart? How do I know which is the latest snapshot suitable for production use? Kind regards Ansgar Am 26.12.2011 18:49 schrieb Mauricio Salatino sala...@gmail.com: @Ansgar, it looks like you are doing in a database the work that it's being done by Guvnor, that keeps a lot of meta data for all the snapshots and it's ready to keep the snapshots forever, exposing them via a service, so you applications can get the right version. In the same way that you mention just knowing the ID of the snapshot that it's required. Using Guvnor, there is no need to remove snapshots, each snapshot will only contain the rules associated with it and not a complete application. Cheers 2011/12/26 Ansgar Konermann ansgar.konerm...@googlemail.com: Am 26.12.2011 18:16 schrieb Mauricio Salatino sala...@gmail.com: Did you try Guvnor? it already store the snapshots version. So you can get the right snapshot for running your rules against an old Loan again. @Ansgar: why do you recommend to not use snapshots? They change over time, making it more complex to track down the correct version. I'd preferr a stable loan application = rule set association. OTOH, it is probably *possible* to retrieve the correct snapshot version for a loan application if additional metadata is available. It's just more complicated: metadata needs to be available and sufficient to determine exactly *one* snapshot, snapshot needs to be available (not sure if Guvnor stores all snapshots forever or just a few). For releases, there is *one* figure you need to know to reference a certain ruleset (the version number). Releases are normally kept forever. Or, at least in my environment, deleting releases is done with extra extra care -if at all-, whereas snapshots older than a week or so get removed automatically on a daily basis. Best regards, Ansgar Cheers 2011/12/26 Ansgar Konermann ansgar.konerm...@googlemail.com: Am 26.12.2011 18:08 schrieb Celso Junior celso...@gmail.com: Hi folks, I work at a bank Me too (sort of) and I am currently studying the best way to use JBoss Rules so that it fits our needs. Our loan analysis process can take several months depending on the type of the loan. Although our business rules can evolve, a loan must follow the rules valid at the time the loan application was made. In order to attend this requirement I thought about storing at the database the name of the current snapshot with the loan application data, so that it will possible run this rules in the future without freezing my rule database. * Is there a better way to attend this requirement? Don't use snapshots. Release your rules and store the rules' release number with the loan application data in your database. * How can I retrieve meta information from a snapshot, such as the date when the snapshot was created? Thanks in advance, Celso ___ 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 -- - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jugargentina.org - Co-Founder @ http://www.jbug.com.ar - Salatino Salaboy Mauricio - ___ 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 -- - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jugargentina.org - Co-Founder @ http://www.jbug.com.ar - Salatino Salaboy Mauricio - ___ 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
Re: [rules-users] check if a Enum object is present in condition
Am 22.10.2011 20:28 schrieb Martin A wml...@gmail.com: Hello, I try to put a condition in my LHS, such as: rule initial_playground_dialog #agenda-group firstTimeUser #salience 99 when $gst : GameStateController(!hasEventOccurred(initial_playground_dialog)) $list : List() $screen : FrontendScreen.PLAYGROUND then end where 'FrontendScreen' is an enum and PLAYGROUND is its property. Is it actually a property of an enum or rather one of the enum literals? If it is actually a property, you will need to obtain an instance of the FrontendScreen enum first. If PLAYGROUND is actually an enum literal and you want to bind this literal to a variable, use: $screen: FrontendScreen( this == FrontendScreen.PLAYGROUND ) Regards Ansgar However I get a syntax error. What's the proper way to check for and assign such a session object? Any help is appreciated! Best regards, Martin ___ 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
Re: [rules-users] rule limit
Am 06.10.2011 18:48, schrieb slyfox: thanks for all of the responses, fun to read :) Sorry I thought it was pretty strait forward question. I would assume somehow the parser 'knows' how many rules are in a drl file I do not want an over ambitious user to just create rule after rule after rule (though I suppose he could technically do a lot even in one rule) You probably can't prevent him from doing it first hand. But when it comes to compiling/loading the rules, you can of course check the number of rules and issue an error message if it exceeds your limit. See answer by Davide Sottara for technical details. However I'm still not convinced that this rather technical measure will make your life easier in the long run. Still having the impression that educating the user of your system to find a useful structure in their rules will pay off more than just putting up road closed signs. Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rule limit
Hi Slyfox, nice to read you. Am 05.10.2011 23:49, schrieb slyfox: is this something I missed in the doc As you are talking about the doc, it seems you have a particular part of the solution already in mind (the product/tool you'd like to use to enforce the size limit). Up to now, you did not describe these ideas anywhere. If you really expect anyone to help you, please let us know your actual use case and what you have thought up so far. It is simply not possible to find a quality answer in reasonable time without this knowledge -- finding the correct answer would involve a lot of guessing what you *really* want to know and then answering the guessed question(s). When asking a very broad question like can it be done, the best you can expect to get is a very broad answer (Yes, it can be done in this case). or would you mind pointing me in the direction of how to accomplish this? If you give more details on what you're trying to *achieve*, I promise to give it a try. If not, oh well, ehm, let me put it like this: as you're certainly storing the file on some media like a hard disk which cannot be unlimited in capacity, the file it holds is also implicitly limited in the number of rules in that file. Of course, this is absolutely not the answer you were looking for, but hey, how can one know better with that little information you gave first hand? It's all good, and I'd really like to help you, but please please please allow me and the fellow list members to get a clue what problem you're actually trying to solve. Describe what you're trying to build, how the problem you're experiencing surfaced, maybe what you already tried to solve it, how you think a rule number limit could solve your problem, these sorts of things. Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rule limit
Am 04.10.2011 23:27, schrieb Bobby Richards: Is it possible to limit the number of rules in a drl file? Yes. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Maven Drools Plugin needs proper de-serialization support from DroolsStreamUtils
Hi all, I think I've found a bug in DroolsStreamUtils. It does not allow to deserialize a collection of KnowledgePackages with dependencies between the packages. In this case, it fails with ClassNotFoundException. Example: Package A contains a type declaration, package B contains a rule using this declaration. Compilation and serialization works fine, but deserialization fails (complains that it cannot find declared type). As it seems, the deserialization code does not consider classes resulting from declared types when resolving type references. This is true for Drools 5.2.0.Final, 5.3.0.CR1 and 5.3.0.Beta1. It works fine for 5.1.1. I was so bold to create a JIRA ticket for this problem right away: https://issues.jboss.org/browse/JBRULES-3225 (with unit tests attached). The functionality provided by class DroolsStreamUtils is essential for the Maven Drools Plugin (compiler needs to serialize stuff, which then needs to be *de-serializable* by applications). If anyone is interested in using the upcoming Maven Drools Plugin to compile rule source code into binary package files and *load* theses packages from your application, please *vote* for this JIRA ticket, as the maven plugin *must* rely on serialization functionality *provided by drools* (a re-implementation is certainly out of scope and would be more than prone to incompatibility). Without a fix or at least a workaround for this bug, the maven plugin will only be able to work with Drools 5.1.1 (newer versions are broken, older versions did not include DroolsStreamUtils at all AFAIK). Thanks in advance, to everyone who will contribute to a potential solution or workaround. Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Ant Build of PKG with Declared Types
Am 16.09.2011 16:15 schrieb TroyL troylparr...@aol.com: I am attempting to build a PKG utilizing an Ant Script. My DRL includes two declared types. When the declared types have only one field the PKG will compile but when the declared types have more than one field I get an error stating that a class of that name was already found on the class path : specifically the error states: [compiler] Duplicate type definition. A class with the name XXX was found in the classpath while trying to redefine the fields in the declare statement. Fields can only be defined for non-existing classes. Hi, please optimize your signal/noise ratio: * try to reduce your use case to a minimal test case which still exhibits the erroneous behaviour * a self contained unit test would be perfect * try compiling the files from your use case using a plain KnowledgeBuilder. As the Ant task is merely a wrapper around it, try to reproduce the erroneous behaviour with the simplest setup possible. * put the rule source code into your test as string literals. * reduce the rule source code as much as possible while still reproducing the error * then, identify the smallest rule source code delta which makes the error go away. If you finally manage to reproduce the error using this minimal setup, make sure to include complete information. In particular, don't XXX out parts of the error message. I'm quite sure if you follow at least some of these hints, you will probably get more feedback from this list. Best regards, Ansgar My ant script: ?xml version=1.0 encoding=UTF-8 ? project default=rules property name=projectPath value= / property name=droolsPath value=C:/Users/266571/Documents/drools-distribution-5.2.0.Final/binaries / property name=eclipsePath value=C:/Users/266571/Documents/eclipse/plugins / path id=drools.classpath pathelement location=${droolsPath}/drools-ant-5.2.0.FINAL.jar / pathelement location=${droolsPath}/drools-api-5.2.0.jar / pathelement location=${droolsPath}/drools-core-5.2.0.FINAL.jar / pathelement location=${droolsPath}/drools-compiler-5.2.0.FINAL.jar / pathelement location=${droolsPath}/antlr-runtime-3.3.jar / pathelement location=${droolsPath}/mvel2-2.0.19.jar / pathelement location=${droolsPath}/knowledge-api-5.2.0.Final.jar / pathelement location=${eclipsePath}/org.eclipse.jdt.core_3.6.2.v_A76_R36x.jar / /path path id=model.classpath pathelement location=bin / /path taskdef name=compiler classpathref=drools.classpath classname=org.drools.contrib.DroolsCompilerAntTask / target name=rules compiler srcdir=${projectPath}src/rules tofile=${projectPath}src/rules/rules.pkg binformat=package classpathref=model.classpath include name=supportObjects.drl / /compiler /target /project My DRL: package gov.ssa.codedObjects import gov.ssa.codedObjects.SupportObjectsCollection; declare SecondaryBrain name : String id : int end declare ICDCode code : String name : String end global SupportObjectsCollection supportObjectsList; rule Evaluate Coded Object when $codedObject : CodedObject(code == 191.0) then SecondaryBrain brain = new SecondaryBrain(); brain.setName(Brain Tumor, Cerebrum); insert (brain); end rule Evaluate Coded Object Malignent when $codedObject : CodedObject(code == 239.6 || code == C71.9, $code : code) then ICDCode code = new ICDCode(); code.setCode($code); code.setName(Neoplasm of uspecified nature of the Brain); insert(code); end rule Add Brain Neoplasm to List when $code : ICDCode(code == 239.6 || code == C71.9) then supportObjectsList.addToSupportObjects($code); end rule Megaduodenum when $codedObject : CodedObject(code == 537.3 || code == K59.3, $code : code) then ICDCode code = new ICDCode(); code.setCode($code); code.setName(Megaduodenum); insert(code); end rule Add Megaduodenum to List when $code : ICDCode(code == 537.3 || code == K59.3) then supportObjectsList.addToSupportObjects($code); end Any suggestions would be helpful. -- View this message in context: http://drools.46999.n3.nabble.com/Ant-Build-of-PKG-with-Declared-Types-tp3342041p3342041.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] Ant Build of PKG with Declared Types
Am 23.09.2011 20:03 schrieb TroyL troylparr...@aol.com: Thank you for the reply. I have run a number of much simpler applications in several environments, below are my results: My Ant Script remains unchanged. Next things to try could be: - increase verbosity of your ant compile so you can see what is actually being compiled. - make sure the Ant build is as similar as possible to your unit test (observe verbose output of Ant build carefully) Best regards, Ansgar *My Test Application*: KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder(); builder.add(ResourceFactory.newClassPathResource(declaredType.drl), ResourceType.DRL); if(builder.hasErrors()){ System.out.println(builder.getErrors().toString()); } KnowledgeBase base = KnowledgeBaseFactory.newKnowledgeBase(); base.addKnowledgePackages(builder.getKnowledgePackages()); StatefulKnowledgeSession session = base.newStatefulKnowledgeSession(); Test test = new Test(); test.setName(Test); session.insert(test); session.fireAllRules(); session.dispose(); *My DRL*: package com.test declare SubTest name : String id : int end rule Test Rule when Test(name == Test) then SubTest sTest = new SubTest(); sTest.setName(SubTest); sTest.setId(12); System.out.println(Test Ran); System.out.println(sTest.getName() + + sTest.getId()); end When I run my test application the drl compiles and I get the following output to the console: Test Ran SubTest 12 However I get the following error when trying to compile it with the Ant Script: [compiler] Duplicate type definition. A class with the name 'com.test.SubTest' was found in the classpath while trying to redefine the fields in the declare statement. Fields can only be defined for non-existing classes. BUILD FAILED C:\Users\troy.l\conceptsWorkspace\DeclaredType\build1.xml:23: RuleBaseTask failed: Duplicate type definition. A class with the name 'com.test.SubTest' was found in the classpath while trying to redefine the fields in the declare statement. Fields can only be defined for non-existing classes. This error goes away when the Declared Type has only one field IE: declare SubTest name : String end The drl compiles into a PKG and the I can successfully use the PKG in my test application when the Declared Type has only one field. Also I do not have this issue in other Drools versions (I have tried 5.1.1, 5.0.1 and 5.2.0.M2). This is a stand alone test application and the above represents almost the entire test project with the exception of the Test.java class which is a pojo. Thanks again for responding. -- View this message in context: http://drools.46999.n3.nabble.com/Re-rules-users-Ant-Build-of-PKG-with-Declared-Types-tp3362455p3362596.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
Re: [rules-users] Options for rule versioning
Hi Rob, another approach we're considering to version rulesets used to perform mortgage risk assessment looks roughly as follows: - each of the rulesets is versioned as a whole (i. e. compile all *.drl pertaining to a ruleset into a *.pkg file and give this *.pkg a version number). - the scoring service is aware that rules evolve and selects the ruleset which fits the processing date. the processing date is part of the scoring request we send to the service - scoring service loads selected ruleset and performs risk assessment, sending back risk indicators We don't like the idea of time-dependent rules very much, as this introduces *versioning* into the rule source code itself, which is additional complexity we'd like to keep out of the *.drl files. We want to be able to drop old rules from the source code once they are not valid any more, but still have them compiled with a version number somewhere in a repository, just in case a mortgage application needs re-scoring based on an older version of the rules. We can afford this rather static approach as our rules don't change too often (like a few rules every week or two). Best regards Ansgar Am 24.08.2011 21:42, schrieb Rob Fisher: Looking for best practice recommendations around the versioning of a rule. Our application will have 50-60 rule sets comprised of up to 70 rules each. The activation of many of the rules will be based on a processing date (inserted fact attribute). The application processing date can be prior, equal, or after the system date. For example, 2 rules, with slightly different logic Eligibility rule version 1 //to be potentially activated for application processing time period prior to 2011 When Car(color = blue) Then Terms(eligible = yes) Eligibility rule version 2 //to be potentially activated for application processing time period 2011 and forward When Car(color = blue, type=coupe) Then Terms(eligible = yes) We've come up with a couple of different ways to handle this: 1. Add Date logic to LHS of the rule . i.e add Control(processingDate '01/01/2011') to 1st rule and Control(processingDate = '01/01/2011') to 2^nd rule. First rule would activate with processing date = 12/31/2010 and 2^nd rule would activate with processing date = 07/31/2011. When originally authored, first rule would be written without date logic. When 2^nd rule is authored, data logic will need to get added to both. 2. We explored a way of setting the session clock to the processing date and using the 'date-effective' and 'date-expires' attributes to do the filtering. i.e. 1^st rule is effective until 12/31/2010 and 2^nd rule is effective from 01/01/2011 to 12/31/. However, we could only figure out how to do this with a stateful knowledge session. Is it possible in a Stateless? 3. We added metadata to the rules (@EffectiveDate and @ExpirationDate), and using agendafilter, we compared processing date to the metadata and return true or false dependent on comparison. What are your opinions on these three methods? What are other options? Thanks Rob ___ 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
Re: [rules-users] counting Facts
Am 25.07.2011 19:29, schrieb pamerida: if I insert int the WM the SegmentGruoup7 (that inside contains the SegmentGroup8) and then I insert SegmentGroup8 in the WM, wouldnt that be duplicating the information? or drools just holds a reference to this classes, IIRC, Drools creates an additional FactHandle for each object reference you insert into the working memory, but these handles are lightweight. So the actual 'data' is not duplicated, only Drools-internal references are. Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Compatibility of serialized KnowledgePackages?
Hi all, does anyone know if KnowledgePackages which have been compiled and serialized using Drools 5.0.1 can be de-serialized with 5.1.1 or 5.2.0.CR1? What about the other way round, serializing with a more recent version and de-serializing with an older version? Are there any obstacles here due to a change in internal representation of KnowledgePackages between versions, or is the serialized format designed to be an exchange format even between versions? Kind regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Reuse of rule
Am 30.05.2011 13:52, schrieb Küng Sabrina: Hello How can I write a rule, that can be used in several other packages resp. rulesets without copying the code? Hi Sabrina, the basic solution is to pre-compile the rule into a *.pkg file and load this file into any number of KnowledgeBase instances, then execute your sessions against the respective knowledge base(s). If you want to use declared types from a shared source code file, make sure to compile them into a binary and always load them from this single binary, since AFAICT otherwise the underlying java beans will belong to different ClassLoaders and thus lead to problems (AFAICT) at runtime. I'm working on a maven plugin which supports binary reuse of drools rules, plus automatic dependency resolution between JARs and pre-compiled knowledge modules. The web site for this plugin is located here, but is currently really out of date: http://passion.forco.de/content/maven-drools-plugin A working plugin should be available shortly, and of course documentation will be updated accordingly. You might want to bookmark this page or subscribe to the RSS feed. Best regards Ansgar ___ 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
Re: [rules-users] Reuse of rule
Am 30.05.2011 16:45, schrieb Ansgar Konermann: [...] java beans will belong to different ClassLoaders and thus lead to problems (AFAICT) at runtime. s/AFAICT/NoClassDefFound/ ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Is there a extends for the declare of a new type?
Am 28.05.2011 18:26, schrieb Edson Tirelli: Wolfgang, I think Davide's implementation supports extending existing java classes... did you tried? What is not possible is to implement interfaces, since you can't define methods in the declare statement. Hi, from a user's point of view, who has been using Drools Expert in production for years now, I'm wondering why there aren't *unit tests* which are capable of answering this basic question in no time? If test coverage is as low as it seems, can you recommend using Drools Expert in production with a clear conscience? Best regards Ansgar (the heretic ;-) Edson 2011/5/28 Wolfgang Laun wolfgang.l...@gmail.com mailto:wolfgang.l...@gmail.com There is, since 5.2.0, the option of extending a class declared in DRL: declare A i : int end declare B extends A ... end Any class origninating from Java code cannot be extended in DRL. -W On 28 May 2011 10:56, Tomas Olsson t...@sics.se mailto:t...@sics.se wrote: Hi, I have tried to look this up but cannot find any clear answer on the web. Does drools support extension of existing classes for new type declarations? That would be very nice if this would be possible. /Tomas ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com http://www.jboss.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
Re: [rules-users] drools dynamic LHS
Am 24.05.2011 21:17, schrieb marunam: Let's say, if the business want to modify the rules with more fact values, I want to be able to happen this dynamically rather than changing the code for fact values and adding it there. Smells like YAGNI and a lot of accidental complexity. I'd code in DRL exactly what your business requires when it requires it, and design my software process in a way that allows to release/deploy the rules on the fly (which is actually quite easy thanks to support in Drools). Think release/deploy to production three times a day. Exception to this rule of thumb might be if you want to re-use the same business rules for different customers but with different age limits, like maybe in a multi-tenant application. But that's a different story. In this case, you could define configuration facts which have to be defined for each tenant, and which are used in the actual rules like so: customer-a-configuration.drl: rule Configure age threshold when # fire always then insertLogical(new AgeThreshold(24)); end customer-b-configuration.drl: rule Configure age threshold when # fire always then insertLogical(new AgeThreshold(27)); end common-rules.drl: rule Check age threshold when AgeThreshold( $threshold: threshold ) Person( age $threshold ) then // do something end Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] drools dynamic LHS
Am 25.05.2011 00:34, schrieb marunam: What I was thinking was, creating fact object dynamically with its attributes being loaded from some properties file dynamically?? Any other solution/suggestions? Create pre-compiled rule packages: one for each state and one for the generic rules, and merge the latter with one of the facts per state when preparing the knowledge base. Works well for our use case (multiple customers), should do equally well for a number of states. Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Problem in compiling each rule separately
Am 19.04.2011 12:56, schrieb saurabh maheshwari: Hi sir , I have 10 rules . rules are created dynamically .Now if any of them is causing problem so none of them runs so I want to compile each rule separately , so that i can create knowledge base with rules which have no errors but can i do this ? Roughly like this: - create one file for each rule containing the rule code - create a KnowledgeBuilder instance (see documentation for details) - for each rule file: |- add file resource to knowledgeBuilder |- handle all errors Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Existing Test Harnesses for Drools?
On 12.04.2011 14:46, John Peterson wrote: I was wondering if anyone out there is aware of any Test Harnesses that could be used for regression testing Drools applications out there? We found this spreadsheet tester from Michael Neale: _https://github.com/michaelneale/rule-spreadsheet-tester/#readme_ Are there any others? Hi John, hi all, we used a similar approach (Excel) for some time, but dropped it well over a year ago because it's very hard to maintain. We're now using plain Java tests to load *.drl files and run a plethora of tiny unit tests against individual rules. A few larger tests load most of our rules and execute integration test scenarios. Regarding maintainability: we're using a pojo based fact model to represent our knowledge which needs to be changed from time to time, driven by new features. This is easier if tests are in Java than if they were Excel. Excel cannot be diffed or merged easily, as it is a binary format. Besides, you normally cannot use the search function(s) provided by modern IDEs to search inside Excel files. Plus you have code completion to code your test setup and the assertions if using Java-based tests. We do have our own (internal) test harness, which is basically a set of reusable test superclasses and helpers. I heard rumors from our legal dept. that it would be okay to open-source it one day, but due to lack of time nobody ever really did. If you want to follow this road, let me know. Maybe I can provide some more insights and/or code examples. That said, I think Excel-based tests might be okay in scenarios where the underlying fact model does not change frequently. For us, they have proven too heavy to maintain. Best regards Ansgar Thanks! ___ 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
Re: [rules-users] maven-drools-plugin, anyone?
Hi Geoffrey, On 10.03.2011 08:58, Geoffrey De Smet wrote: There's a jira for a maven-drools-plugin with possible requirements and I believe there already 2 implementations in the wild. IMHO: 1) It should be centralized into the droolsjbpm-tools repository. Make a pull request on that repository and I 'll peer review it. It's ASL licensed - if you feel like it, fork it, pull it, do whatever you like under this license. My team and I needed a starting point and we found it too complicated to work with the drools source code repository during the last few months/weeks. 2) The goals etc should follow maven naming conventions. 3) There should be integration tests. 4) It should use the latest maven 3 best practices. In short: it's best to start from a really good, existing, up-to-date, ASL-licensed other maven plugin that does non-java compiling. Is this just a write-down of your thoughts with no relation to the implementation described on the given web page, or should it actually referr to the given implementation? If it should be the latter, could you be a bit more concrete (except for maybe point 1)? Admitted, I'm new to maven plugin development, but I tried hard and thus can't see where points 2 to 4 are violated. If there are any points to be improved, I'd be glad to fix them, given some pointers to relevant information and a ticket in the bug tracker (also linked from the web page). Best regards Ansgar Op 09-03-11 22:42, Mauricio Salatino schreef: I will take a look on that right now.. I was planning to do the same for some of my example projects. I will come back with some feedback! Greetings. On Wed, Mar 9, 2011 at 6:29 PM, Ansgar Konermann ansgar.konerm...@googlemail.com mailto:ansgar.konerm...@googlemail.com wrote: Hi, I prepared a tiny drools compiler plugin for Maven 3. It currently contains the smallest feature-set which is potentially useful for my colleagues at work, so up to now it's no more than a starting point for my team. Nevertheless, I invite you to take a look at it, comment on it and suggest features _you_ would like to see in the plugin in one of its future releases. There's some inital documentation here: http://passion.forco.de/content/maven-drools-plugin Looking forward to your comments. Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.orgmailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jbug.com.ar - Salatino Salaboy Mauricio - ___ 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] maven-drools-plugin, anyone?
Hi, I prepared a tiny drools compiler plugin for Maven 3. It currently contains the smallest feature-set which is potentially useful for my colleagues at work, so up to now it's no more than a starting point for my team. Nevertheless, I invite you to take a look at it, comment on it and suggest features _you_ would like to see in the plugin in one of its future releases. There's some inital documentation here: http://passion.forco.de/content/maven-drools-plugin Looking forward to your comments. Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] unsolved myth regarding transitive closure using insertlogical...
On 21.02.2011 04:11, Mark Proctor wrote: On 21/02/2011 03:03, Simon Chen wrote: On Sun, Feb 20, 2011 at 8:20 PM, Ansgar Konermann ansgar.konerm...@googlemail.com wrote: On 19.02.2011 16:01, Simon Chen wrote: The example you gave seems to be the one-hop case. For the two-hop case, we need something like this when edge(a, b), reach(b, c), not exists reach(a, c) then insertLogical( reach(a,c) ) So, where do you put your logical around? It should include both edge(a,b) and reach(b,c), right? Another thought, can we have something like testExistsAndInsertLogical() to replace insertLogical()? But this may be buggy, as the conditions are all met, so the rule actually fired... Hi, from my experience, insertLogical does exactly what testExistsAndInsertLogical would suggest. If the same object is already in the working memory, it keeps this object and does not insert another instance. This behaviour is not stated explicitly in the documentation, but I did a learning test a few weeks ago and IIRC it clearly showed this behaviour (at least for 5.0.1). -- I consider this behaviour a feature and would like it to be kept this way. I am using Drools 5.1.1, and I don't think insertLogical prevents duplicates automatically. This also boils down to the question of how Drools decides whether two objects are indeed the same. For strings and integers, it is straightforward, but not much so for complex objects. Is there a way to pass in a comparison function? InsertLogical operates on equality mode, that is determined by the pojo's equals() method implementation. If an object already exists that is equal, it will use that and the justification counter for that existing object is increased. Mark With this, all which is necessary to implement transitive closure is to remove the contradicting part of the precondition to avoid oscillation. If it turns out that insertLogical does not perform a does fact already exist check and thus might potentially insert duplicates, put exists( ) around the two preconditions and also use exists( reach(x,y) ) to check whether y is reachable from x. I don't quite follow. Can you elaborate with an actual rule? Easy case (insertLogical does not introduce duplicate objects): when edge(a, b) reach(b, c) then insertLogical( reach(a,c) ) If insertLogical did introduce duplicate objects, we'd need this: when exists edge(a, b) exists reach(b, c) then insertLogical( reach(a,c) ) Kind regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] unsolved myth regarding transitive closure using insertlogical...
On 19.02.2011 16:01, Simon Chen wrote: The example you gave seems to be the one-hop case. For the two-hop case, we need something like this when edge(a, b), reach(b, c), not exists reach(a, c) then insertLogical( reach(a,c) ) So, where do you put your logical around? It should include both edge(a,b) and reach(b,c), right? Another thought, can we have something like testExistsAndInsertLogical() to replace insertLogical()? But this may be buggy, as the conditions are all met, so the rule actually fired... Hi, from my experience, insertLogical does exactly what testExistsAndInsertLogical would suggest. If the same object is already in the working memory, it keeps this object and does not insert another instance. This behaviour is not stated explicitly in the documentation, but I did a learning test a few weeks ago and IIRC it clearly showed this behaviour (at least for 5.0.1). -- I consider this behaviour a feature and would like it to be kept this way. With this, all which is necessary to implement transitive closure is to remove the contradicting part of the precondition to avoid oscillation. If it turns out that insertLogical does not perform a does fact already exist check and thus might potentially insert duplicates, put exists( ) around the two preconditions and also use exists( reach(x,y) ) to check whether y is reachable from x. Kind regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Can I deploy pre-compiled drools rules as OSGi bundles?
Hi, I heard that drools was called OSGi ready some time ago. As I am new to OSGi, I'd like to hear some opinions on whether the following scenario would work for rules deployment: For the drools part: - pre-compile all rules into a binary package file - include these file as a resource into an OSGi bundle - put a configuration file, say drools-rules.xml into META-INF, containing references to all the rule files/resources which should be loaded/used For the OSGi part: - create an extender bundle which uses the information from the configuration file of the above bundle - automatically de-serializes the rule packages and - registers a service which offers methods to run the rules contained in the rules bundle The service interface in my case would be project-specific, and would be the same for all rule bundles. We have multiple customers, each with their own implementation of a ruleset for risk estimation. Each service instance could carry a property configured in the META-INF/drools-rules.xml file, making it easy for client code to find the correct service instance to call. What I'm particularly interested in: - does Drools support being used in an OSGi setting as sketched above? - can anyone estimate whether I will I into class loading issues? Thanks in advance Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Negative Rules
On 15.12.2010 10:01, Diego San Esteban wrote: Greetings, How is itpossible to implement a rollbackin theKB? Suppose that when retracting a fact,I want toundo the changes made. A very simple, yet effective solution would be to exclusively use insertLogical(). No updates to facts which are already asserted, no normal insert. Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] I'd like to get Drools 5.0
On 31.08.2010 18:30, Mauricio Salatino wrote: probably you can build the old version using some branch. http://anonsvn.jboss.org/repos/labs/labs/jbossrules/branches/5.0.x/ No need to build drools yourself, see here: https://repository.jboss.org/nexus/ It's in the public JBoss maven repo, beneath org.drools... - just where it belongs. Direct URL: https://repository.jboss.org/nexus/content/groups/public/org/drools/ Kind regards Ansgar 2010/8/31 多田丈晃 t.take...@gmail.com mailto:t.take...@gmail.com Hi, Does anyone know where I can get older version Drools archive? On my work, I need to use Drools 5.0. but In Drools download page only have latest version. Please let me know where is older version archive download page. ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jbug.com.ar - Salatino Salaboy Mauricio - ___ 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
Re: [rules-users] Call for Vote: Drools support in IntelliJ IDEA
On 22.05.2010 03:09, Mark Proctor wrote: We'd love to see it, but no one seems willing to do the work, and we don't have the resources to do this within the core team. So unless someone such as yourself picks this up, hint hint ;), it's not going to happen :( This is about pushing the *IDEA* core team to implement Drools support, not the Drools core team. Just vote for this feature in their issue tracking system and then let's see what happens... Ansgar Mark On 21/05/2010 22:41, Ansgar Konermann wrote: Hi everyone, I'm wondering whether there are any Drools users on this list using IntelliJ IDEA to do their regular development work. As you might know, there is currently no Drools support in IntelliJ IDEA. However, it would be nice to have this support. Switching between your Java / Groovy / Scala / whatever project in IDEA and your rules project in a different tool is cumbersome. There must be one tool to rule them all! :-) There exists a feature request to add Drools support to one of the future releases of IntelliJ IDEA. Sadly, the feature request seems to have received only little attention from the IDEA developers. If you want to help out changing this, register a user account with the IntelliJ issue tracking system [1] and vote for this feature request [2]. Also feel free to add your comments or needs to the issue ticket. I'd be glad if some of you vote for this ticket. Thanks. Regards Ansgar [1] http://youtrack.jetbrains.net/registerUserForm [2] http://youtrack.jetbrains.net/issue/IDEA-24348 ___ 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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Java Enums in Guvnor
Hi Ian, I tried using Enums with Guvnor twice: once back in the 4.0 times of Drools, once again when we got the 5.0 update. My experience: Java enums and Guvnor simply don't work together. Stick with writing DRL rule files in a text editor, or even better, using the Eclipse plugin. This way, enums work somehow (still no code completion for enum values, even when using the Eclipse plugin). If for some reason you must use guvnor, you'll probably need to convert your beans properties now holding Java enums into properties of type String and use string constants to define the allowed value range. Guvnor experts: I'd be very happy to be proven wrong by someone of you. Some kind of HOWTO use Java Enums in Guvnor correctly blog post etc. very much appreciated ;-) Best regards Ansgar On 19.05.2010 18:36, ian-d.jo...@ubs.com wrote: Hi All, I've recently started using Drools and Guvnor, and so far really like it! I have one problem however, to do with Java enums in Guvnor. I have a simple enum as follows: ** *public* *enum* STPRuleAction { / UNKNOWN/, /ACCEPT/, /REJECT// /} I can hand write a rule that works fine with this enum as follows: ** *rule* Retract rejected * dialect* mvel * when * o : CtasOrder( stpRuleAction == STPRuleAction.REJECT ) * then * o.setStatus( 1 ); * retract*( o ); *end* However, if I create a rule with Guvnor, it always puts quotes around the condition, so seems to treat it as a string and it is never triggered. I have created a Guvnor enumeration as follows: 'CtasOrder.stpRuleAction' : ['STPRuleAction.UNKNOWN=UNKNOWN', 'STPRuleAction.ACCEPT=ACCEPT', 'STPRuleAction.REJECT=REJECT'] Which gives me the correct drop down values in the Business Rule editor, but the source of the rule looks like: *rule* Retract rejected * dialect* mvel * when * o : CtasOrder( stpRuleAction == *STPRuleAction.REJECT*) * then * o.setStatus( 1 ); * retract*( o ); *end* I've tried without the mapping in the enumeration (e.g ... : ['STPRuleAction.UNKNOWN', ...) and even removing the enumeration and adding the text manually as a literal value. I can't see any way to specfy a enum/qualifiedIdentifier as a condition in Guvnor. It works fine as a consequence and produces a rule without quotes around (e.g. o.setStpRuleAction( STPRuleAction.REJECT )...) Many thanks for any assistance you can give. Regards, Ian ___ 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] Rules packaging and (binary?) reuse: searching for best practices
Hi all, I'm in search of a better way to package rules into a binary format before they get deployed - one that eases rules reuse more than the technique currently in use at my employer. We're using drools expert to perform risk assessment and feasibility checks for mortgage loans of a significant number of different lenders (say, we have N lenders). Each lender has its own set of rules, but large parts of these rulesets are quite similar (e. g. compliance with customer protection laws). Of course we don't want to maintain N complete rulesets, because this would mean each bug in the common rules has to be done N times. We're already doing refactoring towards reusable subsets of these rules, however we feel as if we were running into some limitations of the drools compiler and/or our packaging. Regarding the skills of our team: we're all at least senior java developers with a fad for cool java technology. No need to enable busines analysts to write rules here. What we tried so far: 1) binary reuse: put related subsets of rules into their own pkg file (say: common.drl into common.pkg, plus for each lender-N.drl into lender-N.pkg) and load both the (one) common package and one lender-specific rule package into the rulebase at runtime. This leads to problems when using declared fact types. Imagine each lender computes the value of all the pledged securities a little different, but it is a common rule that the loan amount must not exceed 100% of this value. So we declare 'SecuritiesSum' in a separate file, but compile it into both drl files. The lender-specific rules can compute the value, add a fact of this type to the working memory and the common ruleset can issue a maximum loan sum exceeded message if the threshold is exceeded. Sounds nice, but did not work out for us: both rule packages contain their *own* compiled bean class for the 'SecuritiesSum' declared fact, each managed by a different classloader. So, we *cannot* pass parameters between rulesets using declares. 2) source code reuse: simply put all the source files that are required to form a complete ruleset for each lender into a fileset and compile this fileset into a pkg file. There are several problems with this: a) the ruleset is large and takes in the order of minutes to compile, even if you change only a single rule file. We really hate long turnaround times, this magnitude is not acceptable for us. b) dealing with the large number of rule files and managing them (which file belongs to which ruleset) becomes too complex. In reality, the ruleset for lender N contains not two files, but in the order of a few hundred. We're lacking a level of abstraction to group rules which relate to each other from a business point of view (e. g. 'securities assessment', 'consumer loan history checks', 'sum of yearly obligations'). Our hope was to achieve this with binary reuse (see above for why we failed). Questions: * can anyone of you report any best practices which have proven useful in an environment like this? * are there any plans to support maven as the primary build tool for rule artifacts? is maven the right tool to package rules? * does Guvnor have a silver bullet solution for our packaging problem? Could we improve the situation by switching to Guvnor? I'd be very glad if some of you could give some advice how to do better... Thanks in advance, best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Double Handling
Ade Timi wrote: Thanks guys for your responses. This should be as simple as it gets, which adds to my frustration. See the following code below: *Java classes:* *Individual* – *public* *class* Individual { *private double assetCost;* * * *public* *void* setAssetCost(*double* assetCost) { *this*.assetCost = assetCost; } *public* *double* getAssetCost() { *return* assetCost; } } *IndividualDecision* – *public* *class* IndividualDecision { *private double loanToValue;* * * *public* *void* setLoanToValue(*double* LoanToValue) { *this*.loanToValue = LoanToValue; } *public* *double* getLoanToValue() { *return* loanToValue; } *public* *void* calcValues(Individual ind){ *this*.loanToValue = ind.getAssetCost(); } } *Rule Resourse – * ***import* com...Individual *import* com...IndividualDecision *rule* G2 Equity in Asset *when* $d : IndividualDecision(loanToValue() 85.0) *then* System.out.println(loanToValue: + ($d.getLoanToValue())); *End* Hi, you might want to try to replace loanToValue() with loanToValue and report whether it works. I'm not sure whether the () are actually in your rules code or a copy/paste error, but if they are, it'll be worth a try. This would at least somehow match the error message you reported. When using the java dialect, you can simply use property names inside the constraints sections. No need to add parentheses. Kind regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Guvnor Testing Scenarios and Enums Instantiations
blinton wrote: Hello, Using the following imported enum: public enum Status { INCOMPLETE, COMPLETE } And the following rule: when status : Status(this == Status.COMPLETE) then // ... We're attempting to write a guvnor test scenario for this rule. But we can't seem to figure out the syntax for instantiating the given status object. Could someone point us in the correct direction? Many thanks. Hi, you don't need to instantiate Java enum values. In fact, the java syntax simply does not support it, because the enum values specified in the enum declaration are the only allowed instances of the enum class generated by the compiler behind the scenes. How to use them with drools? Just insert one of the enum values into your working memory, like so: workingMemory.insert(Status.INCOMPLETE); This of course also works with variable status values, e. g.: private void insertStatus(Status actualStatus) { workingMemory.insert(actualStatus); } Best regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Importing Fact model in Eclipse
On 02.04.2010 22:48, Shailesh Hedaoo wrote: Hi I have created a Drools project and trying to create a guided rule in Eclipse 3.5 and Drools 5.0.x. I have my own domain objects in another java project to be used by Drools project. I want to use the java domain model as the fact model in my Drools project. How is that done ? Do i have to go thru the web based guvnor first ? All I m planing to have is a simple java project which has java classes of my domain model of POJOs and in my Drools project i want to use them as fact model. How do i do it in eclipse IDE ? Should suffice to add the fact model jar to the classpath of the project containing your rules source code. That's how we did it when still working with Eclipse (now switched to IDEA). If you don't want to compile the jar beforehand, on the rules project's root folder, right-click build path - configure build path, select Projects tab, click Add, check your fact model project and confirm everything. Kind regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rules-users Digest, Vol 40, Issue 55
On 15.03.2010 13:46, Nilima R wrote: Can someone tell me how to use create enums with Dynamic values in Guvnor. For example I need enum which does not contain static value like A,B,C rather these A,B,C values come from database. Hi, if the set of allowable enum literals/values is altogether dynamic, this probably cannot be achieved without dynamic bytecode generation (i. e. generate the enum class at runtime). I'm not aware that Drools supports this, you'd probably have to code this on your own. If your database contains a known set of enum values (like A, B, C), you could create an enum with these values and perform string to enum mapping using YourEnumClass.valueOf(nameOfLiteral). If both approaches don't fit your need, you can still stick with ordinary strings. Most of the times I worked with enums in a database, there actually was a finite set of allowable values - sometimes it's hard to find out all the values in this set, but should be doable. Otherwise an enum seems kind of a mis-fit for the problem at hand, because an enum (short for enumeration) actually means the set of values can be enumerated. Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Accumulator function
On 10.03.2010 17:52, Glenn Macgregor wrote: What configuration file is this referring to and/or what system property can I set to make this work. This might be helpful: http://blog.athico.com/2009/06/how-to-implement-accumulate-functions.html Regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Using Collections in LHS
Am 24.02.2010 08:37, schrieb Wolfgang Laun: You really ought to read all the pertaining sections in the Drools Expert manual and experiment. Nobody can write complex rules without some exercise. 2010/2/24 dhari sdh...@hotmail.com mailto:sdh...@hotmail.com Thanks Jeffery. I'll try this but what if I have more complex condition e.g. Order ($discount : discount, $items : items) Item(grade 3 (quantity 5 || $discount 10)) from $items Again, you are using a condition on discount not next to the field in the fact where it occurs (i.e., Order); it's just not possible to write it this way. Order( discount 10, $items : items ) # all Orders where discount 10 Item( grade 3, quantity 5 ) from $items # and each of its Items where grade 3 and quantity 5 There is no need to use to combine two conditions for the same fact. Now if you need to detect Order Items with grade 3 where either the quantitiy of the Item is 5, or the Order's discount 10, (or both) you'd have to write Order( $discount : discount, $items : items ) # all Orders Item( grade 3, $quantity : quantity) from $items # and each of its Items where grade 3 eval( $discount 10 || $quantitiy 5 ) # and discount 10 or quantity 5 (or both) Hi! Another technique we commonly use at my employer to break up overly complex rules is to factor out subexpressions, preferrably using locally declared fact types to express the subexpressions, e. g.: declare ItemPreventingDiscount item: Item order: Order reason: String end rule Prevent discount 10 for items graded 3 when $order: Order(discount 10, $items: items) $item: Item(grade 3) from $items then ItemPreventingDiscount fact = new ItemPreventingDiscount(); fact.setItem($item); // optional fact.setOrder($order); // optional fact.setReason(discount percentage 10 not valid for items graded 3); insertLogical($fact); end // add more rules to prevent other combinations of discount, quantity, ... whatever rule Issue error message if items preventing discount exist when exists( ItemPreventingDiscount( $reason: reason, $item: item ) ) then System.out.println(Discount not allowed: Item '+ $item.getDescription() + ' prevents discount because + $reason + .); end One might debate whether it is already appropriate to factor out subexpressions for this still rather simple example, yet our experience is that in general it leads to code with an improved readability. I'd go so far to suggest that whenever you're struggling with the syntax of the language you're using to solve a problem, ask yourself whether you're trying to achieve too much with too little code. The answer is of course depending on your level of experience with the language, nevertheless you (the author of the code) probably want to be able to read and understand the code at any time. Kind regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Call for Vote: Drools support in IntelliJ IDEA
Hi everyone, I'm wondering whether there are any Drools users on this list using IntelliJ IDEA to do their regular development work. As you might know, there is currently no Drools support in IntelliJ IDEA. However, it would be nice to have this support. Switching between your Java / Groovy / Scala / whatever project in IDEA and your rules project in a different tool is cumbersome. There must be one tool to rule them all! :-) There exists a feature request to add Drools support to one of the future releases of IntelliJ IDEA. Sadly, the feature request seems to have received only little attention from the IDEA developers. If you want to help out changing this, register a user account with the IntelliJ issue tracking system [1] and vote for this feature request [2]. Also feel free to add your comments or needs to the issue ticket. I'd be glad if some of you vote for this ticket. Thanks. Regards Ansgar [1] http://youtrack.jetbrains.net/registerUserForm [2] http://youtrack.jetbrains.net/issue/IDEA-24348 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] memberOf mvel list
Hi Adam, try operator in instead of memberOf. AFAIK, in deals with list literals (which is what you want) whereas memberof can be used to check whether some value is part of a collection given as variable reference. Kind regards Ansgar Am 21.02.2010 23:14, schrieb deaddowney: I'm using a map because this is a legacy class that is quite dynamic and can contain arbitrary tag/values. Ideally, if I knew all the attributes I would declare them as fields, but I'm stuck with this map at the moment. Regardless, using your explanation, why does when $person : Person( props[“AGE”] 20, (props[“NAME”] ==Fred || props[NAME] == Barney || props[NAME] == Wilma]) ) work? Corneil du Plessis-2 wrote: You are expecting map values to be elevated somehow from Object to Integer and String. By using typed attributes in the Person class you can overcome your problem. Sent from my HTC (Android) On Feb 21, 2010 9:28 PM, Adam Kriegspamcont...@mac.com wrote: I’m new to Drools and having trouble accessing my Domain object which is basically a container around a map. class Person { Map props; public Map getProps(); …. Extra stuff } I want to create a rule that will match when Age is greater than 20 and name is one of “Fred”, “Barney”, or “Wilma”. These entries are stored in the Map props, so that to get age, you would call person.getProps().get(“AGE”) rule My Rule dialect mvel when $person : Person( props[“AGE”] 20, props[“NAME”] memberOf [“Fred”, “Wilma”, “Barney”] ) then System.out.println(found match”+$person); End But I am running into a parsing error: no viable alternative at input ')' in rule My Rule in pattern Person. The second condition seems to be the problem. Can I check for membership inside a List I create inline in mvel? ___ 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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Can I do a Collection contains Collection?
Hi, untested guess (replace ZipCode by actual type name of your ZIP code data): rule example when $validZipCodes: Set() from RefData.getValidZipCodes() Example( $actualZips: zips ) exists( ZipCode( this not memberof $validZipCodes ) from $actualZips ) then error() end Am 19.02.2010 16:38, schrieb EdenAEL20: I have an object coming in which contains a collection of id's. I want to verify these id's are in another collection. I'm looking for something like collection is a subset of another collection. any ideas?? zips below is a collection, i want to verify that each zip is in $e1. rule example when e1: Set() from RefData.getConstantValues() e2: Example( zips not in $e1) then error() ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Can I do a Collection contains Collection?
EdenAEL20 schrieb: when I replace Zipcode with type int as that is my type drools throws me an error saying it doesn't recognize the class. Is there some special way to declare primitive types? Use the wrapper classes, i. e. Integer instead of int. Since java does autoboxing/unboxing, this should not be too big of a problem. Kind regards Ansgar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users