[rules-users] RE : Identity Mode?
Hi, I think you are talking about the assert behavior: KnowledgeBaseConfiguration configuration = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); configuration.setOption(AssertBehaviorOption.EQUALITY); But I think you will have to add a condition like... : p1 : Person() Person(this != p1) ... to make it work like you intended. Regards, Bruno. De : rules-users-boun...@lists.jboss.org [rules-users-boun...@lists.jboss.org] de la part de rjr201 [rich.j.ri...@gmail.com] Date d'envoi : jeudi 20 juin 2013 16:05 À : rules-users@lists.jboss.org Objet : [rules-users] Identity Mode? If I have a rule such as: When Person() Person() Then System.out.println(There are two people!) End I only want this to fire if there are two (or more) Person objects inserted into the session, however as default drools will fire even when there is just one Person object inserted (i.e. both Person patterns get matched to the same fact). I seem to remember there is a flag I can set that swaps between these two types of behavior, and seem to remember it's to do with Identity/Equality mode. However, I can't remember how or where to do this. Any help on this would be greatly appreciated.. Cheers, Rich. P.S I realise that I could add constraints to the patterns to explicitly check that the facts aren't the same.. however I'd rather not have to do that as I'm trying to make it as simple as possible for users to create rules.. -- View this message in context: http://drools.46999.n3.nabble.com/Identity-Mode-tp4024428.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] Accumulate / collect
Hi Wolfgang, hi Estaban, Many thanks for your insights! I'll stick to a custom accumulate function since it is more consice than the init/action/result approach. And since I am using Drools 5.1.1, I'll create functions named collectList and collectSet to be future proof :-) Best regards, Bruno. Le 16/11/2011 10:34, Esteban Aliverti a écrit : You already have 2 accumulate functions to do what you need: * collectList * collectSet So, your rule will look like this: $countries : HashSet(empty == false) from accumulate (City($name matches X.*, $country : country), collectSet($country)) Best Regards, Esteban Aliverti - Developer @ http://www.plugtree.com http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Accumulate / collect
Just tested and... you are right (although they are not mentioned in the documentation)! :-). Great! Thanks a lot Esteban! Bruno. Le 16/11/2011 10:50, Esteban Aliverti a écrit : As far as I know, these 2 functions already exist in 5.1.1. Don't they? Best Regards, Esteban Aliverti - Developer @ http://www.plugtree.com http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Accumulate / collect
Hi all, There is something I can't express using collect or accumulate and I would like to have your opinion. Let's imagine I have the following types : # a country type *declare Country name : String end * # a city type holding a reference to its country *declare City name : String country : Country end * Let's imagine I have all Country and City objects into the working memory. I want to get the set of Countries corresponding to Cities whose name starts with X. I have the impression that I need a kind of (nonexistent right?) collect syntax that would look like the accumulate syntax (a kind of anonymous accumulate function): # meaning I want to collect $country objects and not City objects $countries : HashSet() from collect (City($name matches X.*, $country : country)*, $country*) Or a home made accumulate function that builds a set of countries: # custom buildset accumulate function $countries : HashSet() from accumulate (City($name matches X.*, $country : country), *buildset*($country)) Do you see any other (possibly out of the box) solution? Many thanks in advance for your answers, Best regards, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] A little suggestion about the 'ResourceFactory', 'DrlParser' API
Maybe there is something I don't understand, but I also have the impression that encoding management is strange in Drools. The lexer = new DRLLexer( new ANTLRInputStream( is ) ); line indeed leads to using the default encoding of the machine. It is the same for the CSV parser (rule templates, Drools 5.1.1): public void parseFile(final InputStream inStream) { final BufferedReader reader = new BufferedReader(new InputStreamReader(inStream)); It means that if I write my rule on a Windows machine (CP1252) and deploy it on a Linux server (UTF-8), it will not work as expected. Conditions like...: Person(firstname == Béatrice) ... will become things like (CP1252 file transported onto a UTF-8 platform and read as UTF-8) : Person(firstname == B¤atrice) I wonder how you deal with that in Guvnor. Best regards, Bruno. Le 10/11/2011 06:47, Miles Wen a écrit : Would you please provide a method in 'org.drools.io.ResourceFactory' like this: public static Resource newReaderResource(InputStream stream, String encoding); then I can use this method to load drl files as a stream while explicitly specify its ecoding? And in line: 287 of class 'org.drools.compiler.DrlParser': lexer = new DRLLexer( new ANTLRInputStream( is ) ); no encoding specified as well. The ANTLRInputStream has constructors which allows you to specify the encoding, otherwise it would figure out the encoding according to the environment, which is unpredictable some times. I'm using drools 5.3.0, the newest version. Thosse problems exists for quite a while during previous versions. I'm fainting to see they are almost there after upgraded to the new version. -- Regards. Miles. Wen ___ 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] Data Modeling for medical expert system
Hi Dirk, Good to see that I am not the only one fighting with that question :-). I guess the general answer is: it depends on how large your enums might grow. For instance if your application is eventually supposed to help diagnosing (say) all MeSH diseases based on all MeSH symptoms, then an approach where every symptom and disease is a Java class is not an option; this would lead to so many classes that I doubt Drools user interface will handle that, or will be useful anyway (drop-down lists with thousands of items). The opposite approach consists in creating a few root Java classes like (say) Disease and Symptom and to store the MeSH hierarchy into a name attribute. The obvious drawback of the approach is that when your end-users will have to write the rules, they will be left with problems like: when Symptom(name == well... what's the name of this MeSH category??) then Disease(name == hmmm... can't remember the exact name of the disease as normalized in MeSH...) end I've posted a message on this topic (subject: Thoughts about rule authoring) and Michael Anstis kindly suggested a technical answer. I am afraid it did not fit my needs, but it could fit yours :-). For the moment I have no solution (like an intermediate approach) to my problem: I am stuck with approach #2. I have the impression that my problem requires a very tight integration between my database (MeSH) and the Drools suggestion engine. If you have another approach, I would love to know it ;-). Best regards, Bruno. Le 08/11/2011 17:43, Dirk Conzelmann a écrit : Hi everybody, I am using Drools as a part of my Bachelor Thesis. My job is to build an expert system for medical diagnoses. My Question: Is there a best practice known in modeling a variable list of questions and answers in Drools? Up to now I modeled the list of questions implementing Java Classes and Enums for each question/answer pair. But to be able to change those options easyly I need a higher abstraction level than simple Java Classes and Enums. Could someone show me an example how to implement this? I hope I have explained my question understandable :) ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Bugs in rule templates?
Hi all, I am writing rules using Drools Templates and I noticed strange problems (ocurring when I slightly modify a DRT that works well): 1. the template instanciation depends on the declarations order of the parameters in the template header 2. if the rule template does not contain a package declaration (default package) the instanciation of the template fails I am working with Drools 5.1.1 but those problems occur in 5.2.0.Final and in 5.3.0.Final as well. Do you think it is worth posting a JIRA? Anyway let me tell you that Drools Templates are great! Our users like that feature a lot! They start writing a rule in DRL format and, once it works, they transform it into a DRT and put data into a tsv file. It is quite a natural way of working. The general perception here is that it is easier to templatize an existing DRL than to write a decision table from scratch. Best regards, Bruno. PS: _DRT that works well_: template header *name message package templates; * import org.drools.bug.Entity; template TestTemplate rule Test1 @{row.rowNumber} dialect mvel when Entity( $name : name == @{name} ) then System.out.println(@{message} + $name); insert($name); end end template _DRT that does not work_ (first case): template header *message name package templates; * import org.drools.bug.Entity; template TestTemplate rule Test1 @{row.rowNumber} dialect mvel when Entity( $name : name == @{name} ) then System.out.println(@{message} + $name); insert($name); end end template _DRT that does not work_ (second case): template header *name message * import org.drools.bug.Entity; template TestTemplate rule Test1 @{row.rowNumber} dialect mvel when Entity( $name : name == @{name} ) then System.out.println(@{message} + $name); insert($name); end end template ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Thoughts about rule authoring
Hi Michael, Thanks for taking time answering my message. Now I realize it was not very clear. Person was never provided as an option, but I would love it did so :-). If you had time, let me explain in a few words. For the moment, Drools completion engine provides quite the same functionality for the rule language an IDE provides for the Java language. Don't get me wrong, as a Java developper I think it is really fantastic! And, as a Java developer, I know that know the code completion engine cannot suggest anything about the value of a String (/Person/Jim). What I wanted to say is: as Drools is not only targetted to Java developers, business users might expect (and they actually do) something more. They know that rules will apply on their data. Data exists and business users know their data (they know about that /Person/Jim does exist). However, as they don't know anything about the impossibility in Java to suggest the content of a String (they are not Java developers), they don't understand why the completion engine can't keep on suggesting /Person/Jim. Somehow they have Google search in mind, that starts suggesting words as soon as you type your query. Here in Drools it could be even more accurate since the suggestion engine knows that the /Person/name String is wanted for the name field of the Annotation class. So maybe it could offer a suggestion hook method, even for Strings. As a Java developer, I could implement it for my business users. This would prevent business users from having to write Java-developer-oriented solutions you proposed (and I thank you for your proposals by the way :-)). I say I have the impression to be in the middle because I could have a Person class (and I probably should), but I can't have a class for every first name (Jim) I know this is completely out of the scope of a rule engine, however it would fit Drools editor so well that I wanted to say it. Anyway, sorry for bothering you with my delirium ;-). Best regards, Bruno. Le 16/09/2011 17:53, Michael Anstis a écrit : You could externalise the paths for the annotations:- MyConfigurationSettings( $jimPath : pathToJimAnnotations ) jim : Annotation( name = $jimPath ) (where MyConfigurationSettings is a fact inserted into WM). or MyConfigurationSettings( $jimPath : pathToJimAnnotations ) from $globalServiceObject.getMeMySettings( ) jim : Annotation( name = $jimPath ) (where MyConfigurationSettings is available from a - perhaps - Hibernate query). I am surprised Person was provided as an option (without knowing the auto-complete code in any detail). Perhaps it is a class on your classpath? With kind regards, Mike On 16 September 2011 16:37, Bruno Freudensprung bruno.freudenspr...@temis.com mailto:bruno.freudenspr...@temis.com wrote: Hi, I have a remark, maybe its just out of scope... however as it is in the perspective of enabling end users to deal with their business domain, leaving appart the technical aspects (which is one of strong points of Drools), here it is. Drools is great because it enables to express things simply. For instance, in my company, we are annotating text. So our rules look like: when jim: Annotation (name = /Person/Jim) boston: Annotation (name = /City/Boston) ... However, in the end, it turns out that what is inside Strings is part as well of our business domain. Maybe it is probably stored into a database or whatever. So, in my dreams (and, surprisingly, so said the customer I saw yesterday and that didn't know anything about Drools!!), when I Ctrl-space at the beginning of the String (after /P), the rule authoring environment suggests /Person, juste because it knows, somehow, that annotations can be one of those (maybe in absolute, or in that particular context). Would you say that I completely lost my mind? :-) Or more prosaically that there is a design flaw in my data model? Personnally I have the impression to be somewhere in the middle... Best regards, Bruno. ___ 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 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] Questions about Drools, Eclipse, Guvnor
Hi Michael, Thanks for you answer! Best regards, Bruno. Le 16/09/2011 17:48, Michael Anstis a écrit : Hi Bruno, The decision to withdraw the graphical BRL editor in Eclipse was made because it's functionality had waned and we, as a team, were unable to maintain it sufficiently to keep it consistent with Guvnor due to a lack of resources. If any eager community members are willing to get involved and bring the aforementioned editor up to date, and continue to maintain it, I am sure we would welcome it's return. As for your last question. The feature is lacking in Guvnor too; but we have already identified the need: https://issues.jboss.org/browse/GUVNOR-1402 Unfortunately it is on the list and I (we) can't commit to a time-frame in which it'll be fixed... pull requests always welcome :) With kind regards, Mike On 16 September 2011 16:26, Bruno Freudensprung bruno.freudenspr...@temis.com mailto:bruno.freudenspr...@temis.com wrote: Hi, I've taken an look at the Roadmap in JIRA but, as I haven't found what I'm looking for, here I am :-). Today I read a message of Michael Anstis telling that BRL editor support has been dropped since 5.2, and I have a question: how do you see the future concerning rule authoring within Eclipse? Would you say that, in a near future, there will be only one authoring environment left - Guvnor? Or does Eclipse support has a chance to last and to be kept in sync with Guvnor? One last question: when working with Drools Eclipse plugin, I realized that it is not possible to declare custom operators, accumulator functions... so they appear in the drop down lists of the UI (or in the DRL suggestion engine). Is it the same in Guvnor? Thanks in advance for your insights, Cheers, Bruno. ___ 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 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] Questions about Drools, Eclipse, Guvnor
Hi, I've taken an look at the Roadmap in JIRA but, as I haven't found what I'm looking for, here I am :-). Today I read a message of Michael Anstis telling that BRL editor support has been dropped since 5.2, and I have a question: how do you see the future concerning rule authoring within Eclipse? Would you say that, in a near future, there will be only one authoring environment left - Guvnor? Or does Eclipse support has a chance to last and to be kept in sync with Guvnor? One last question: when working with Drools Eclipse plugin, I realized that it is not possible to declare custom operators, accumulator functions... so they appear in the drop down lists of the UI (or in the DRL suggestion engine). Is it the same in Guvnor? Thanks in advance for your insights, Cheers, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Thoughts about rule authoring
Hi, I have a remark, maybe its just out of scope... however as it is in the perspective of enabling end users to deal with their business domain, leaving appart the technical aspects (which is one of strong points of Drools), here it is. Drools is great because it enables to express things simply. For instance, in my company, we are annotating text. So our rules look like: when jim: Annotation (name = /Person/Jim) boston: Annotation (name = /City/Boston) ... However, in the end, it turns out that what is inside Strings is part as well of our business domain. Maybe it is probably stored into a database or whatever. So, in my dreams (and, surprisingly, so said the customer I saw yesterday and that didn't know anything about Drools!!), when I Ctrl-space at the beginning of the String (after /P), the rule authoring environment suggests /Person, juste because it knows, somehow, that annotations can be one of those (maybe in absolute, or in that particular context). Would you say that I completely lost my mind? :-) Or more prosaically that there is a design flaw in my data model? Personnally I have the impression to be somewhere in the middle... Best regards, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Question about custom accumulation functions
Hi Edson, Good news: the problem does not happen, neither with the 5.2.0.Final nor with the latest snapshot. Best regards, Bruno. Le 08/09/2011 17:17, Edson Tirelli a écrit : Bruno, Can you please test it with latest snapshot? If it is still a problem, then please open a JIRA and provide the test to reproduce it... https://hudson.jboss.org/jenkins/view/Drools%20jBPM/job/drools/lastSuccessfulBuild/artifact/drools-distribution/target/ Thanks, Edson ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Question about custom accumulation functions
Hi Edson, hi all, To stick to the subject, I have a strange problem (stack trace in PS) with a rule containing two accumulate calls, the result of the first one is re-injected as the input of the second one. Those accumulate functions are home made. The first one (tokenize) returns an ArrayList of Token objects built by tokenizing the text of the Sentence objects. The second one (build10windows) returns an ArrayList of Window objects, each one them containing 10 consecutive tokens. Here is the rule when $budget : ManualAnnotation(text == something) *$tokens* : java.util.ArrayList() *from accumulate *($s : Sentence(), *tokenize*($s)) $windows : java.util.ArrayList() *from accumulate *($t : Token() *from $tokens*, *build10windows*($t)) # removed a part here but the problem occurs even without this part then retract($budget); Is there anything else one should be aware of when implementing their own accumulate function? I mean things related to the fact that classical accumulate functions (sum, average) return an immutable object that does not share anything with the context object. Although accumulate, reverse, and getResult methods of my functions are unit tested, I suspect something that could be related to stateless/stateful considerations. What do you think? Many thanks, Bruno. PS : The stack trace is: at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:927) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856) at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1071) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:785) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:751) at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218) at org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:99) at org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:33) at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:159) at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:81) at org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:262) ... 5 more Caused by: java.lang.NullPointerException at org.drools.reteoo.AccumulateNode.getFirstMatch(AccumulateNode.java:967) at org.drools.reteoo.AccumulateNode.splitList(AccumulateNode.java:920) at org.drools.reteoo.AccumulateNode.removePreviousMatchesForLeftTuple(AccumulateNode.java:874) at org.drools.reteoo.AccumulateNode.retractLeftTuple(AccumulateNode.java:205) at org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:238) at org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateRetractLeftTupleDestroyRightTuple(CompositeLeftTupleSinkAdapter.java:138) at org.drools.reteoo.AccumulateNode.retractLeftTuple(AccumulateNode.java:212) at org.drools.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:240) at org.drools.reteoo.EntryPointNode.retractObject(EntryPointNode.java:231) at org.drools.common.AbstractWorkingMemory.retract(AbstractWorkingMemory.java:1288) at org.drools.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:201) at org.drools.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:214) at defaultpkg.Rule_Display_windows_0.defaultConsequence(Rule_Display_windows_0.java:21) at defaultpkg.Rule_Display_windows_0DefaultConsequenceInvoker.evaluate(Rule_Display_windows_0DefaultConsequenceInvoker.java:29) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917) ... 15 more Bruno. Le 24/08/2011 16:21, Edson Tirelli a écrit : Yes, evaluation is incremental, so for every new fact, it will call accumulate() and getResult(). We do want to reduce the calls to getResult(), improving performance, but it is not easy to figure out a way, as from an engine perspective, it never knows when the application is done inserting facts and it is time to calculate the final result. Edson 2011/8/24 Bruno Freudensprung bruno.freudenspr...@temis.com mailto:bruno.freudenspr...@temis.com Hi, While testing my custom accumulation function I noticed an unexpected behavior (th'ats of course a personal point of view). It seems that Drools 5.1 calls accumulate(...) and getResult(...) as many times as the number of accumulated facts (accumulate, getResult, accumulate, getResult, etc...). Is it supposed to work like this? Best regards, Bruno
Re: [rules-users] Question about custom accumulation functions
I am using Drools 5.1.1. Do you want me to package a small maven project exhibiting that error, and post a Jira? Bruno. Le 08/09/2011 15:04, Edson Tirelli a écrit : It looks like a bug, as it should not raise a NPE no matter what which version of Drools are you using? Edson 2011/9/8 Bruno Freudensprung bruno.freudenspr...@temis.com mailto:bruno.freudenspr...@temis.com Hi Edson, hi all, To stick to the subject, I have a strange problem (stack trace in PS) with a rule containing two accumulate calls, the result of the first one is re-injected as the input of the second one. Those accumulate functions are home made. The first one (tokenize) returns an ArrayList of Token objects built by tokenizing the text of the Sentence objects. The second one (build10windows) returns an ArrayList of Window objects, each one them containing 10 consecutive tokens. Here is the rule when $budget : ManualAnnotation(text == something) *$tokens* : java.util.ArrayList() *from accumulate *($s : Sentence(), *tokenize*($s)) $windows : java.util.ArrayList() *from accumulate *($t : Token() *from $tokens*, *build10windows*($t)) # removed a part here but the problem occurs even without this part then retract($budget); Is there anything else one should be aware of when implementing their own accumulate function? I mean things related to the fact that classical accumulate functions (sum, average) return an immutable object that does not share anything with the context object. Although accumulate, reverse, and getResult methods of my functions are unit tested, I suspect something that could be related to stateless/stateful considerations. What do you think? Many thanks, Bruno. PS : The stack trace is: at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:927) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856) at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1071) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:785) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:751) at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218) at org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:99) at org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:33) at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:159) at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:81) at org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:262) ... 5 more Caused by: java.lang.NullPointerException at org.drools.reteoo.AccumulateNode.getFirstMatch(AccumulateNode.java:967) at org.drools.reteoo.AccumulateNode.splitList(AccumulateNode.java:920) at org.drools.reteoo.AccumulateNode.removePreviousMatchesForLeftTuple(AccumulateNode.java:874) at org.drools.reteoo.AccumulateNode.retractLeftTuple(AccumulateNode.java:205) at org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:238) at org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateRetractLeftTupleDestroyRightTuple(CompositeLeftTupleSinkAdapter.java:138) at org.drools.reteoo.AccumulateNode.retractLeftTuple(AccumulateNode.java:212) at org.drools.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:240) at org.drools.reteoo.EntryPointNode.retractObject(EntryPointNode.java:231) at org.drools.common.AbstractWorkingMemory.retract(AbstractWorkingMemory.java:1288) at org.drools.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:201) at org.drools.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:214) at defaultpkg.Rule_Display_windows_0.defaultConsequence(Rule_Display_windows_0.java:21) at defaultpkg.Rule_Display_windows_0DefaultConsequenceInvoker.evaluate(Rule_Display_windows_0DefaultConsequenceInvoker.java:29) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917) ... 15 more Bruno. Le 24/08/2011 16:21, Edson Tirelli a écrit : Yes, evaluation is incremental, so for every new fact, it will call accumulate() and getResult(). We do want to reduce the calls to getResult
[rules-users] Decision table empty action cell
Hi, I am implementing a decision table that looks like: *CONDITION* *ACTION* *$p : Person* *name == $1* *retract($p);* *Person name* *Retract the person* Fred N/A Kenny N/A The problem is generated rules have an empty RHS unless I put a string (here N/A) on each line of the Action column, and I'd like to hide this column in my final spreadsheet. Does anyone know a way to instruct Drools to generate the LHS even if the cell is empty? If it is not possible, do you know any Excel trick to automatically fill the Action cell with an arbitrary value (here N/A) when a new line is inserted in my table? Many thanks in advance for your help, Best regards, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] From in decision table
Hi guys, As you have probably noticed, today is my decision tables day :-). Before telling you what is going wrong, let me show you what kind of rule I try to put in my Drools 5.1 decision table: # for each window $window : Window($elements : elements) from $windows # for each manual annotation $an1 : ManualAnnotation( this inside $window text == *ToMatch*) # if there is another manual annotation exists ManualAnnotation( this inside $window text == *ToMatch2*) The only things I would like to parametrize are strings in bold. My decision table looks like this: CONDITION CONDITION CONDITION CONDITION CONDITION $an1 : ManualAnnotation exists ManualAnnotation $window : Window($elements... this inside $window text == $1 this inside $window text == $1 for each window annotation inside window Textannotation inside windowText N/A N/A ToMatch N/A ToMatch2 N/A N/A ToMatch3N/A ToMatch4 Here are the problems (in bold) with the generated rule: $an1 : ManualAnnotation( *this inside $window == N/A* text == **ToMatch**) exists ManualAnnotation( *this inside $window == N/A* text == **ToMatch2**) *$window : Window($elements : elements) from $windows* * The order of the LHS fact lines of the generated rules is the not same as the order of appearance in the spreadsheet * The this inside $window is considered as a field name Do you know if I can solve those problems? I have tried to find a way to tell the decision table to extend another rule but I haven't found a keyword for that in the documentation. Maybe do I have to use rule templates? Many thanks, Best regards, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table empty action cell
Thanks for your answer. Merging the cells is a good idea! Bruno. Le 07/09/2011 14:09, Swindells, Thomas a écrit : There's no easy option. One solution is to merge the cell across from your condition column -- if someone duplicates a row they'll still have the value merged and it looks nicer than having a column of N/A The other approach I tend to use is just to set the column heading to be must be N/A rather than retract the person. Thomas ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Question about custom accumulation functions
Hi, While testing my custom accumulation function I noticed an unexpected behavior (th'ats of course a personal point of view). It seems that Drools 5.1 calls accumulate(...) and getResult(...) as many times as the number of accumulated facts (accumulate, getResult, accumulate, getResult, etc...). Is it supposed to work like this? Best regards, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] To accumulate or not to accumulate
Hi Wolfgang, I finally decided to test different implementations: * first based on an accumulation function * second (your suggestion) relying on drools to 1) build all SentenceWindows then to 2) locate ManualAnnotations inside those Windows * third (your suggestion as well) relying on drools to 1) build only SentenceWindows that might be interesting (containing one of the ManualAnnotations I am looking for) then to 2) locate ManualAnnotations inside those Windows First implementation performs quite well but I am stuck on the parametrization (I need to to define build2windows, build3windows, build4windows... functions): 47 milliseconds on 100 sentences, 94 ms sentences with 1000 sentences Second implementations is of course sub optimal since it creates many useless windows: 125 ms on 100 sentences, 14400 ms on 1000 sentences Third implementation is very versatile and its performances are comparable to the accumulator solution: 93 ms on 100 sentences, 125 ms on 1000 sentences So thanks again for your suggestion; it was definitely useful :-). Regards, Bruno. Le 19/08/2011 17:25, Wolfgang Laun a écrit : 2011/8/19 Bruno Freudensprung bruno.freudenspr...@temis.com mailto:bruno.freudenspr...@temis.com I am not sure I understand what you mean by random order but I guess it has to do with my ArrayList result type. What I had in mind is to put all sentences in a TreeSet during the action method, and finally issue an ArrayList result object by iterating over the TreeSet and grouping sentences. Heh :) I clean forgot that I had done this sort of thing not too long ago. My first guess was that such an accumulator might be faster than a construction of windows using rules. However I admit your suggestion is very elegant, and I thank you for that! I am probably still too imperative-minded... Well, a procedural solution would be a reasonable alternative for this problem. -W Regards, Bruno. Le 19/08/2011 16:05, Wolfgang Laun a écrit : How would you write buildwindows, given that its action method would be called once for each Sentence, in random order? It's very simple to write a very small set of rules to construct all SentenceWindow facts of size 1 and then to extend them to any desired size, depending on some parameter. 1. Given a Sentence and no Window beginning with it, create a Window of length 1. 2. Given a Window of size n desiredSize and given a Sentence immediately following it, extend the Window to one of size n+1. 3a. For any Window of desiredSize, inspect it for closely situated ManualAnnotations. 3b. If ManualAnnotations have been associated with their containing Sentences up-front, you just need to find Windows with more than 1 ManualAnnotation, adding them in the RHS of rule 2 above. -W 2011/8/19 Bruno Freudensprung bruno.freudenspr...@temis.com mailto:bruno.freudenspr...@temis.com Hi Wolfgang, Thanks for your answer. Sentences are not contiguous (might be some space characters in between) but manual annotations cannot overlap sentences (interpret overlap in terms of Drools Fusion terminology). If I had an inside operator, do you think the following accumulate option could be better? when *$result : ArrayList() from accumulate ( $s: Sentence(), buildwindows($s))* *$w : SentenceWindows () **from $result* a1 : ManualAnnotation (this *inside *$w) a2 : ManualAnnotation (this != a1, this *inside *$w) then ... do something with a1 and a2 since they are close to each other end Does anyone know something about accumulator parametrization (looking at the source code it does not seem to be possible, though)? Maybe a syntax inspired of operator parametrization could be nice: $result : ArrayList() from accumulate ( $s: Sentence(), *buildwindows[3]($s)*) Best regards, Bruno. Le 19/08/2011 13:55, Wolfgang Laun a écrit : There are some details that one should consider before deciding on a particular implementation technique. * Are all Sentences contiguous, i.e., s1.end = pred( s2.start ) * Can a ManualAnnotation start on one Sentence and end in the next or any further successor? As in all problems where constraints depend on an order between facts, performance is going to be a problem with increasing numbers of Sentences and ManualAnnotations. Your accumulate plan could be a very inefficient approach. Creating O(N*N) pairs and then looking for an overlapping window is much worse than looking at each window, for instance. But it depends on the expected numbers for both
Re: [rules-users] To accumulate or not to accumulate
Hi Wolfgang, Thanks for your answer. Sentences are not contiguous (might be some space characters in between) but manual annotations cannot overlap sentences (interpret overlap in terms of Drools Fusion terminology). If I had an inside operator, do you think the following accumulate option could be better? when *$result : ArrayList() from accumulate ( $s: Sentence(), buildwindows($s))* *$w : SentenceWindows () **from $result* a1 : ManualAnnotation (this *inside *$w) a2 : ManualAnnotation (this != a1, this *inside *$w) then ... do something with a1 and a2 since they are close to each other end Does anyone know something about accumulator parametrization (looking at the source code it does not seem to be possible, though)? Maybe a syntax inspired of operator parametrization could be nice: $result : ArrayList() from accumulate ( $s: Sentence(), *buildwindows[3]($s)*) Best regards, Bruno. Le 19/08/2011 13:55, Wolfgang Laun a écrit : There are some details that one should consider before deciding on a particular implementation technique. * Are all Sentences contiguous, i.e., s1.end = pred( s2.start ) * Can a ManualAnnotation start on one Sentence and end in the next or any further successor? As in all problems where constraints depend on an order between facts, performance is going to be a problem with increasing numbers of Sentences and ManualAnnotations. Your accumulate plan could be a very inefficient approach. Creating O(N*N) pairs and then looking for an overlapping window is much worse than looking at each window, for instance. But it depends on the expected numbers for both. -W 2011/8/19 Bruno Freudensprung bruno.freudenspr...@temis.com mailto:bruno.freudenspr...@temis.com Hello, I am trying to implement rules handling Sentence, ManualAnnotation objects (imagine someone highligthing words of the document). Basically Sentence objects have start and end positions (fields) into the text of a document, and they are Comparable according to their location into the document. I need to write rules using the notion window of consecutive sentences. Basically I am not very interested by those SentenceWindow objects, I just need them to define a kind of proximity between ManualAnnotation objects. What I eventually need in the when of my rule is something like: when ... maybe something creating the windows a1 : ManualAnnotation () a2 : ManualAnnotation (this != a1) SentenceWindow (this includes a1, this includes a2) then ... do something with a1 and a2 since they are close to each other end As I don't know the internals of Drools, I would like to have your opinion about what the best idiom: * create all SentenceWindow objects and insert them in the working memory, then write rules against all the facts (SentenceWindow and ManualAnnotation) * implement an accumulator that will create a list of SentenceWindow object The first option could look like: |||rule Create sentence windows when # find 3 consecutive sentences s1 : Sentence() s2 : Sentence(this s1) s3 : Sentence(this s2) not Sentence(this != s2 s1 s3) then SentenceWindow swindow = new SentenceWindow(); swindow.setStart(s1.getStart()); swindow.setTheend(s3.getEnd()); insert(swindow); end| ... Then use the first rule as is. The accumulator option could look like (I am not really sure the syntax is correct) : when *$result : ArrayList() from accumulate ( $s: Sentence(), buildwindows($s))* a1 : ManualAnnotation () a2 : ManualAnnotation (this != a1) *SentenceWindows (this includes a1, this includes a2) **from $result* then ... do something with a1 and a2 since they are close to each other end Is it possible to decide if one way is best than the other? And one last question: it is possible to parametrize an accumulator (in order to provide the number of sentences that should be put in the windows)? I mean something like: when $result : ArrayList() from accumulate ( $s: Sentence(), *buildwindows(3,* $s)) Thanks in advance for you insights, Best regards, Bruno. ___ 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 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] To accumulate or not to accumulate
I am not sure I understand what you mean by random order but I guess it has to do with my ArrayList result type. What I had in mind is to put all sentences in a TreeSet during the action method, and finally issue an ArrayList result object by iterating over the TreeSet and grouping sentences. My first guess was that such an accumulator might be faster than a construction of windows using rules. However I admit your suggestion is very elegant, and I thank you for that! I am probably still too imperative-minded... Regards, Bruno. Le 19/08/2011 16:05, Wolfgang Laun a écrit : How would you write buildwindows, given that its action method would be called once for each Sentence, in random order? It's very simple to write a very small set of rules to construct all SentenceWindow facts of size 1 and then to extend them to any desired size, depending on some parameter. 1. Given a Sentence and no Window beginning with it, create a Window of length 1. 2. Given a Window of size n desiredSize and given a Sentence immediately following it, extend the Window to one of size n+1. 3a. For any Window of desiredSize, inspect it for closely situated ManualAnnotations. 3b. If ManualAnnotations have been associated with their containing Sentences up-front, you just need to find Windows with more than 1 ManualAnnotation, adding them in the RHS of rule 2 above. -W 2011/8/19 Bruno Freudensprung bruno.freudenspr...@temis.com mailto:bruno.freudenspr...@temis.com Hi Wolfgang, Thanks for your answer. Sentences are not contiguous (might be some space characters in between) but manual annotations cannot overlap sentences (interpret overlap in terms of Drools Fusion terminology). If I had an inside operator, do you think the following accumulate option could be better? when *$result : ArrayList() from accumulate ( $s: Sentence(), buildwindows($s))* *$w : SentenceWindows () **from $result* a1 : ManualAnnotation (this *inside *$w) a2 : ManualAnnotation (this != a1, this *inside *$w) then ... do something with a1 and a2 since they are close to each other end Does anyone know something about accumulator parametrization (looking at the source code it does not seem to be possible, though)? Maybe a syntax inspired of operator parametrization could be nice: $result : ArrayList() from accumulate ( $s: Sentence(), *buildwindows[3]($s)*) Best regards, Bruno. Le 19/08/2011 13:55, Wolfgang Laun a écrit : There are some details that one should consider before deciding on a particular implementation technique. * Are all Sentences contiguous, i.e., s1.end = pred( s2.start ) * Can a ManualAnnotation start on one Sentence and end in the next or any further successor? As in all problems where constraints depend on an order between facts, performance is going to be a problem with increasing numbers of Sentences and ManualAnnotations. Your accumulate plan could be a very inefficient approach. Creating O(N*N) pairs and then looking for an overlapping window is much worse than looking at each window, for instance. But it depends on the expected numbers for both. -W 2011/8/19 Bruno Freudensprung bruno.freudenspr...@temis.com mailto:bruno.freudenspr...@temis.com Hello, I am trying to implement rules handling Sentence, ManualAnnotation objects (imagine someone highligthing words of the document). Basically Sentence objects have start and end positions (fields) into the text of a document, and they are Comparable according to their location into the document. I need to write rules using the notion window of consecutive sentences. Basically I am not very interested by those SentenceWindow objects, I just need them to define a kind of proximity between ManualAnnotation objects. What I eventually need in the when of my rule is something like: when ... maybe something creating the windows a1 : ManualAnnotation () a2 : ManualAnnotation (this != a1) SentenceWindow (this includes a1, this includes a2) then ... do something with a1 and a2 since they are close to each other end As I don't know the internals of Drools, I would like to have your opinion about what the best idiom: * create all SentenceWindow objects and insert them in the working memory, then write rules against all the facts (SentenceWindow and ManualAnnotation) * implement an accumulator that will create a list of SentenceWindow object The first option could look like: |||rule Create sentence windows when # find 3 consecutive sentences
Re: [rules-users] Question / problem
Hi, In my understanding it is normal. However if you told Drools that your FirstRule modified the $testDrools object, it should no longer be the case: then System.out.println(Set my value to 1); $testDrools.setMyValue(1); update($testDrools); Regards, Bruno. Le 12/05/2011 10:58, Nico ROEDERER a écrit : Hi, I've got a little question. I've got a drl file which contains two rules : rule FirstRule salience 99 when $testDrools : TestDroolsDto() eval ( 1 == 1 ) then System.out.println(Set my value to 1); $testDrools.setMyValue(1); end rule SecondRule salience 1 when $testDrools : TestDroolsDto() eval( $testDrools.getMyValue().equals() ) then System.out.println(My Value : + $testDrools.getMyValue() ); end Is it normal that in my second rule is verified ? - eval( $testDrools.getMyValue().equals() ) is true but : System.out.println(My Value : + $testDrools.getMyValue() ); show me that myValue == 1 Perhaps I did something wrong ? Thanks for your helping me. N. PS : Here is me TestDroolsDto : public class TestDroolsDto { private String myValue; public TestDroolsDto() { myValue=; } public String toString() { return -- + myValue; } /** * @return the myValue */ public String getMyValue() { if ( myValue == null ) { myValue = ; } return myValue; } /** * @param myValue the myValue to set */ public void setMyValue( String myValue ) { this.myValue = myValue; } } ___ 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] Question / problem
You are right; your probably need to set a no-loop atttribute on your rule. Or, preferably, put additional conditions to the LHS of your FirstRule (it would probably be the case in a real-life rule). As Wolfgang suggested, take some time to read Drools expert documentation: I found it very well designed for beginners (like me). Regards, Bruno. Le 12/05/2011 11:19, Nico ROEDERER a écrit : Ok, but when I did this, the first rule has no ending. If I don't want to, I've got to retract the object, but my second rule is never fired. Should I make two different files ? Thanks for the help. (Sorry for such a poor English writing :( ) Le 12/05/2011 11:12, Bruno Freudensprung a écrit : Hi, In my understanding it is normal. However if you told Drools that your FirstRule modified the $testDrools object, it should no longer be the case: then System.out.println(Set my value to 1); $testDrools.setMyValue(1); update($testDrools); Regards, Bruno. Le 12/05/2011 10:58, Nico ROEDERER a écrit : Hi, I've got a little question. I've got a drl file which contains two rules : rule FirstRule salience 99 when $testDrools : TestDroolsDto() eval ( 1 == 1 ) then System.out.println(Set my value to 1); $testDrools.setMyValue(1); end rule SecondRule salience 1 when $testDrools : TestDroolsDto() eval( $testDrools.getMyValue().equals() ) then System.out.println(My Value : + $testDrools.getMyValue() ); end Is it normal that in my second rule is verified ? - eval( $testDrools.getMyValue().equals() ) is true but : System.out.println(My Value : + $testDrools.getMyValue() ); show me that myValue == 1 Perhaps I did something wrong ? Thanks for your helping me. N. PS : Here is me TestDroolsDto : public class TestDroolsDto { private String myValue; public TestDroolsDto() { myValue=; } public String toString() { return -- + myValue; } /** * @return the myValue */ public String getMyValue() { if ( myValue == null ) { myValue = ; } return myValue; } /** * @param myValue the myValue to set */ public void setMyValue( String myValue ) { this.myValue = myValue; } } ___ 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] Unable to find implementation for BusinessRuleProvider
Hi, If it is not the case already, could you try adding the drools-ide-common jar (along with its dependencies) to the classpath of your project? Best regards, Bruno. John Peterson a écrit : Hi, I've been experimenting with the Guided Rule Editor plug-in in Eclipse. I've built a Drools Project using the default Hello World sample application. I've created a new Guided Rule in my project called GuidedRule.brl and get the associated drools.package with it. The rule is simple: WHEN THEN System.out.println(Rule has fired); I build the knowledge base as follows: * private** static* KnowledgeBase readKnowledgeBase()* throws* Exception { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory./newKnowledgeBuilder/(); kbuilder.add(ResourceFactory./newClassPathResource/(SampleGuided.drl), ResourceType./BRL/); KnowledgeBuilderErrors errors = kbuilder.getErrors(); * if* (errors.size() 0) { * for* (KnowledgeBuilderError error: errors) { System./err/.println(error); } * throw** new* IllegalArgumentException(Could not parse knowledge.); } KnowledgeBase kbase = KnowledgeBaseFactory./newKnowledgeBase/(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); * return* kbase; } The only line changed is adding the resource of type BRL. When I try to run, I get the following error: _java.lang.RuntimeException_:_ org.drools.compiler.DroolsParserException_:_ org.drools.CheckedDroolsException_: Unable to find implementation for BusinessRuleProvider at org.drools.compiler.PackageBuilder.addKnowledgeResource(_PackageBuilder.java:544_) at org.drools.builder.impl.KnowledgeBuilderImpl.add(_KnowledgeBuilderImpl.java:28_) at com.sample.DroolsTest.readKnowledgeBase(_DroolsTest.java:41_) at com.sample.DroolsTest.main(_DroolsTest.java:23_) Caused by:_ org.drools.compiler.DroolsParserException_:_ org.drools.CheckedDroolsException_: Unable to find implementation for BusinessRuleProvider at org.drools.compiler.PackageBuilder.addPackageFromBrl(_PackageBuilder.java:386_) at org.drools.compiler.PackageBuilder.addKnowledgeResource(_PackageBuilder.java:470_) ... 3 more Caused by:_ org.drools.CheckedDroolsException_: Unable to find implementation for BusinessRuleProvider at org.drools.compiler.BusinessRuleProviderFactory.throwNoImplementationFound(_BusinessRuleProviderFactory.java:66_) at org.drools.compiler.BusinessRuleProviderFactory.loadProvider(_BusinessRuleProviderFactory.java:42_) at org.drools.compiler.BusinessRuleProviderFactory.getProvider(_BusinessRuleProviderFactory.java:25_) at org.drools.compiler.PackageBuilder.addPackageFromBrl(_PackageBuilder.java:366_) ... 4 more I've tried variations to add the drools.package as a PKG type, I've had the rules (and package) in both com.sample and /src/main/rules, but I can't seem to resolve the problem. drools.package has been updated to include the package name (package com.sample;) and I import the message class as well (even though it isn't being used currently). I suspect the issue is simple, but I haven't been able to figure it out. Any help would be appreciated. ___ 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] JUnit Test failure when Eclipse library present on classpath
Hi, Unfortunately I have no answer to your question. However I actually run JUnit 4 tests calling drools 5.1.1 in Eclipse 3.5 and it works with the following classpath. Please note that it contains jars that are not Drools-specific (my project-specific jars): +- org.drools:drools-core:jar:5.1.1:compile | \- org.mvel:mvel2:jar:2.0.16:compile +- org.drools:drools-api:jar:5.1.1:compile +- org.drools:drools-compiler:jar:5.1.1:runtime | +- org.antlr:antlr-runtime:jar:3.1.3:runtime | \- org.eclipse.jdt.core.compiler:ecj:jar:3.5.1:runtime +- org.eclipse.jdt:core:jar:3.4.2.v_883_R34x:compile +- trove:trove:jar:2.1.0:compile +- org.mockito:mockito-core:jar:1.8.5:test | +- org.hamcrest:hamcrest-core:jar:1.1:test | \- org.objenesis:objenesis:jar:1.0:test +- commons-lang:commons-lang:jar:2.4:compile +- commons-io:commons-io:jar:1.4:compile +- org.drools:drools-ide-common:jar:5.1.1:runtime +- org.apache.lucene:lucene-core:jar:2.3.1:runtime +- com.thoughtworks.xstream:xstream:jar:1.3.1:runtime | \- xpp3:xpp3_min:jar:1.1.4c:runtime +- log4j:log4j:jar:1.2.15:compile | \- javax.mail:mail:jar:1.4:compile +- dom4j:dom4j:jar:1.6.1:compile | \- xml-apis:xml-apis:jar:1.0.b2:compile +- jgrapht:jgrapht:jar:0.8.1:compile +- org.drools:drools-bpmn2:jar:5.1.1:compile +- jaxen:jaxen:jar:1.1-beta-4:compile | \- xerces:xercesImpl:jar:2.6.2:compile \- junit:junit:jar:4.8.1:test HTH, Regards, Bruno. StormeHawke a écrit : I'm not really sure what to make of this, but when the Drools Runtime library is present on my project classpath, any of my junit tests that reference Drools fail, but if I remove the runtime library from that same classpath, everything runs as expected. The output in the console: Build groovy files option has not been set one way or the other: use 'options.put(CompilerOptions.OPTIONG_BuildGroovyFiles, CompilerOptions.ENABLED);' (I'm not using groovy files of any kind) But then I also get a really long stack trace in the JUnit output pane (truncated once it reaches my code): java.lang.NoClassDefFoundError: org/eclipse/core/runtime/Plugin at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at org.eclipse.jdt.internal.compiler.Compiler.initializeParser(Compiler.java:737) at org.eclipse.jdt.internal.compiler.Compiler.init(Compiler.java:294) at org.eclipse.jdt.internal.compiler.Compiler.init(Compiler.java:159) at org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:349) at org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:51) at org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:389) at org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:56) at org.drools.compiler.PackageRegistry.compileAll(PackageRegistry.java:74) at org.drools.compiler.PackageBuilder.compileAll(PackageBuilder.java:677) at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:640) at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:266) at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:458) at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28) at net.intellidata.pricing.PricingEngine.cacheKnowledgeBase(PricingEngine.java:136) To top it off, the same test runs fine on my boss's computer, but not on mine. Neither of us is sure why. What am I missing? ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Eclipse IDE not validating .drl files
Hi, Did you try to add the Drools nature to your project? I mean something like : right-click on the project | configure | Convert to Drools project Bruno. StormeHawke a écrit : StormeHawke wrote: Travis Smith wrote: I'm assuming you're using Seam here (which is a variation on Eclipse) No, I'm using eclipse Galileo Travis Smith wrote: Have you made sure to update your Runtime? Window Preferences Drools Installed Drools Runtimes The runtime is used for rules validation through the IDE. I hadn't done this because I wasn't aware that you had to - syntax coloring was working, just not validation, so I wasn't sure what the problem was. However, creating a new Eclipse runtime has caused even syntax coloring to stop working - now all I get is a plain text editor, and still no validation. These are the steps I followed: ol liOpened Window Preferences Drools Installed Drools Runtimes/li liThere were no Installed Drools Runtimes listed, so I clicked Add.../li liClicked Create a new Drools 5 Runtime.../li liCreated a new folder under UserRoot/.eclipse/ called DroolsRuntime and clicked OK/li liSelected the new Drools Runtime in the list and clicked OK/li liRestarted Eclipse/li /ol Thoughts? I just right clicked and manually opened my rule file with the associated editor and syntax coloring came back; however still no validation, regardless of whether I use the .drl extension or .dslr extension. the .dslr extension does open in the DSL Rule Editor rather than Rule Editor. Manually right-clicking and clicking validate has no effect either. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to write a rule that fires when it matches against specific facts in working memory.
Hi, I finally noticed a forall keyword that might be useful (see section 5.1.4.1. Syntax of templates). Maybe can you try something like: [forall(){Option(code == $)}] Bruno. Bruno Freudensprung a écrit : Hi Gurvinder, I've just taken a look at chapter 5.1 of Drools Expert about decision tables but I've been unable to find out how to do that. If you find a solution, could you please post it here? I'm pretty sure I will need that as well ;-). Best regards, Bruno. groovenarula a écrit : Thanks for the options, Bruno and Wolfgang. But is there a more 'generic' way to do the matches ? The problem I have is that the # of instances that might match could vary. And I have to provide a means for the business users to be able to provide that 'option's code' using a decision table. Basically I need to be able to provide a construct that's would look something like : Options P1,P2 P1,P4,P5 So in the above decision table had 2 rules where in the first row represents a rule that matches against Options with Codes P1 and P2. And the second rule would match against options with codes P1, P4 and P5. Is it possible to represent this using Drools decision tables ? Thanks Gurvinder ___ 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] looping over list
Hi, Maybe can you try the collect keyword? According to what I see in the documentation (4.8.3.9. Conditional Element collect) it seems to fit your needs. I'll probably give this a try: rule Select Officer ruleflow-group select_officer no-loop true salience 20 when $processInstance: WorkflowProcessInstance() $requestData: RequestData($genre : genre, $cost : cost) $sublist : ArrayList() from collect( Officer( minimumCost = $cost, $cost = maximumCost ) from $genre) then System.out.println(Hey!); List shrunkOfficersWithGenre = $sublist; end Best regards, Bruno (newbie). odelyaholiday a écrit : I have a list of officers: public static final MapString, ListOfficer officersPerGenre = new HashMapString, ListOfficer(); Where the Officer with: String name; Integer mininumCost; Integer maximumCost; in officersPerGenre I fill for each genre list of officers. In my drools: rule Select Officer ruleflow-group select_officer no-loop true salience 20 when $processInstance: WorkflowProcessInstance() $requestData: RequestData(); then System.out.println(Hey!); List officersWithGenre = (List)officers.get($requestData.getGenre()); end Now I need to shrink the officersWithGenre only to officers that $requestData.cost is between their mininumCost and maximum cost. How do I write it in drools? In java i will simply iterate over the collection. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Doubt in converting .brl to .drl format in java
Hi, Don't know if it may help but I've just had a similar error (java.lang.RuntimeException: com.thoughtworks.xstream.mapper.CannotResolveClassException: definitions : definitions) when adding a bpmn2 rule flow file (an XML file) as a BRL resource in a KnowledgeBuilder (no comment... :-)). My2cts, Bruno. Kamal Thiyagarajan a écrit : Hello, I had try to convert .brl file to .drl format using java code i got an error in conversion. my java code is String fileName = c:/Sampleguide.brl; File file = new File(fileName); //System.out.println(hello); String content = FileUtils.readFileToString(file); System.out.println(content); BRXMLPersistence read = (BRXMLPersistence) BRXMLPersistence.getInstance(); BRDRLPersistence write = (BRDRLPersistence) BRDRLPersistence.getInstance(); //BRDRLPersistence.getInstance(); String outputDRL = write.marshal(read.unmarshal(content)); System.out.println(outputDRL); I got error like this com.thoughtworks.xstream.converters.ConversionException: metadataList : metadataList : metadataList : metadataList Debugging information message : metadataList : metadataList cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException cause-message : metadataList : metadataList class : org.drools.brms.client.modeldriven.brl.RuleModel required-type : org.drools.brms.client.modeldriven.brl.RuleModel path: /rule/metadataList --- at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:89) at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63) at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:76) at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:60) at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:137) at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:33) at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:923) at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:909) at com.thoughtworks.xstream.XStream.fromXML(XStream.java:853) at com.thoughtworks.xstream.XStream.fromXML(XStream.java:845) at org.drools.brms.server.util.BRXMLPersistence.unmarshal(BRXMLPersistence.java:91) at com.sample.DroolsTest.main(DroolsTest.java:30) Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: metadataList : metadataList at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:68) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:71) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:86) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:96) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:38) at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:52) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.determineType(AbstractReflectionConverter.java:347) at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:208) at
Re: [rules-users] Decision table rework, progress
Indeed! The decision table was something pretty obscure to me. Now it is much clearer! Do you know if that UI will be available in the Drools Eclipse plugin? In any case thanks for sharing that with us! Bruno. plugtreelabs a écrit : Awesome work Mike. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to write a rule that fires when it matches against specific facts in working memory.
Hi Gurvinder, I've just taken a look at chapter 5.1 of Drools Expert about decision tables but I've been unable to find out how to do that. If you find a solution, could you please post it here? I'm pretty sure I will need that as well ;-). Best regards, Bruno. groovenarula a écrit : Thanks for the options, Bruno and Wolfgang. But is there a more 'generic' way to do the matches ? The problem I have is that the # of instances that might match could vary. And I have to provide a means for the business users to be able to provide that 'option's code' using a decision table. Basically I need to be able to provide a construct that's would look something like : Options P1,P2 P1,P4,P5 So in the above decision table had 2 rules where in the first row represents a rule that matches against Options with Codes P1 and P2. And the second rule would match against options with codes P1, P4 and P5. Is it possible to represent this using Drools decision tables ? Thanks Gurvinder ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Get maximum
Hi, It might be a naive approach (assuming Person objects are facts), but did you try something like: when $oldest : Person($age : age) not Person(age $age) then System.out.println(Oldest person is + $oldest.getName()); Best regards, Bruno. nemo a écrit : Hi all, I'm a newbie here and have a problem which seems to be quite simple, but I just can't solve it. I have a set of peoples with the attribute age and want to get the oldest person from these set. I would really appreciate, if somebody tells me how can I do it with jdrools. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Problem implementing dynamic regular expression
Hi, Can you give a try with the eval keyword? Here is a code fragment from Drools Expert documentation (Example 4.53), I have the impression (I am a Drools beginner) that it can be adapted to your needs: Person( girlAge : age, sex = F ) Person( eval( age == girlAge + 2 ), sex = 'M' ) Maybe something like: MyEvent(prop1 matches eval(This event is for+getPropName()+ and is sent to blah blah blah)) Best regards, Bruno. Ayush a écrit : Hi, I'm trying to implement regular expression using matches. The regular expression is dynamic and retrieved from a java function. In my first approach I'm tried to call the java function for matches like MyEvent(prop1 matches This event is for+getPropName()+ and is sent to blah blah blah) Now when I try to execute the above expression it gives error as illegal statement (I even tried back-slash to escape it). It also gives error like Expecting ')' instead of '(' . So I declared a function which takes two string parameters and returns me the concatenated one. function String concatenate(String str1, String str2) { return str1+str2; } $matchStr : String() from concatenate(This event is for,getPropName()+ and is sent to blah blah blah) Now when I'm using this variable in my rule it is not getting executed. Please note that there is no problem in regex because when I put the regex as string (i.e. without using any function to retreive it) it works fine. MyEvent(prop1 matches $matchStr) Can anyone please let me know how can I solve it. Thanks in advance. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Problem implementing dynamic regular expression
Thanks Wolfgang! My sincere apologies for the wrong answer. Does it mean that (probably at the price of a performance penalty) one could handle the variable results of getPropName() over time and write (?): MyEvent(eval (prop1 matches (This event is for+getPropName()+ and is sent toblah blah blah))) Best regards, Bruno. Wolfgang Laun a écrit : 2011/1/24 Bruno Freudensprung bruno.freudenspr...@temis.com MyEvent(prop1 matches eval(This event is for+getPropName()+ and is sent to blah blah blah)) You cannot use eval() like this. It is a conditional element. If getPropName() is a function that is constant over time (!) then you should be able to MyEvent(prop1 matches (This event is for+getPropName()+ and is...)) If you need to match against a value that should change during execution, put the value into a fact and make sure to update/modify that fact when you change the value: MyPattern( $v: value ) MyEvent( prop1 matches (This event is for+$v + and is...)) In both cases, the parentheses around the concatenaion are essential. -W Best regards, Bruno. Ayush a écrit : Hi, I'm trying to implement regular expression using matches. The regular expression is dynamic and retrieved from a java function. In my first approach I'm tried to call the java function for matches like MyEvent(prop1 matches This event is for+getPropName()+ and is sent to blah blah blah) Now when I try to execute the above expression it gives error as illegal statement (I even tried back-slash to escape it). It also gives error like Expecting ')' instead of '(' . So I declared a function which takes two string parameters and returns me the concatenated one. function String concatenate(String str1, String str2) { return str1+str2; } $matchStr : String() from concatenate(This event is for,getPropName()+ and is sent to blah blah blah) Now when I'm using this variable in my rule it is not getting executed. Please note that there is no problem in regex because when I put the regex as string (i.e. without using any function to retreive it) it works fine. MyEvent(prop1 matches $matchStr) Can anyone please let me know how can I solve it. Thanks in advance. ___ 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] XML to DRL
Hi, I don't know if it is related but it reminds me a problem I had with the changet-set XML. Drools 5.1 documentation mentions (example 3.8): change-set xmlns='http://drools.org/drools-5.0/change-set' xmlns:xs='http://www.w3.org/2001/XMLSchema-instance' xs:schemaLocation='http://drools.org/drools-5.0/change-set*.xsd* http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd' /change-set But it refused to work until I changed it to (please note the removal): change-set xmlns=http://drools.org/drools-5.0/change-set; xmlns:xs=http://www.w3.org/2001/XMLSchema-instance; xs:schemaLocation=http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd; /change-set Hope that helps, Bruno. T-Otte a écrit : Sry i am new to this mailing list system. Since my edit doesn't get send to the mailing list i will mention it again: The output .drl gets created and looks valid despite the errors. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] KnowledgeAgent, change-set and BRL
Hi Esteban, Thank you for your fast answer! I am planning to integrate the Drools Eclipse plugin into an RCP application (that will be used to create rules, but not only). Maybe I am wrong but I would like to avoid using Guvnor that seems to be complicated from a deployment point of view (an additional server into our architecture). That's why I planned to build the KnowledgeBase (based on the files generated by the Drools Eclipse plugin in my application) and to fire the rules using the API. I have the impression (but maybe it is just a consequence of my inexperience) that Drools' API lacks some kind of put the pieces together feature that would ease the KnowledgeBase building. Something like a KnowledgeAgent that would take a directory as input, build DRLs from BRLs + drools packages (expected next to BRLs), etc... I also have the impression that the directory layout and file extensions could be enforced (a bit like javac that expects .java files located in directories corresponding to packages). There seems to be conventions like that in Guvnor (sub-directories in packages containing technical rules, business rules, dsls... rule inheritance from a parent package to sub-package, and useful things like that) but they do not seem to have any equivalent in the Drools' Core API. And that's exactly where I am :-). Anyway, I have tried adding the drools.package as a DRL into the change-set... : add resource source=classpath:misc/drools.package type=DRL / resource source=classpath:misc/KBuilder_Test.brl type=BRL / /add ...but it does not work (I still get the KnowledgeAgent has KnowledgeBuilder errors object=Unable to resolve ObjectType... error). Best regards, Bruno. Esteban Aliverti a écrit : Why are you trying to work with BRL format? This format is only used to store rules in guvnor/eclipse and it is not prepared to be used in any environment. The main problem is that BRL doesn't contain all the information needed to be compiled. For example, it doesn't contain any package nor import definition. What you could try is to add a DRL in your change-set (before the BRL) containing only the import statements. Could you please try it and tell me the results? Best Regards, Esteban Aliverti - Developer @ http://www.plugtree.com http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] activation-group issue
Hi, I don't know if it is the best solution since I am very new to Drools but you could use a logical insert of a Skip fact. Something like: rule A1 salience 100 ruleflow-group A activation-group A when xxx1 then yyy1 * insertLogical(new Skip()); *end rule A2 salience 90 ruleflow-group A activation-group A when *not Skip() *xxx2 then yyy2 end Bruno. Yaniv Itzhaki a écrit : any ideas anyone? On Thu, Dec 16, 2010 at 12:36 PM, Yaniv Itzhaki iya...@gmail.com mailto:iya...@gmail.com wrote: Hi, I have a group of rules with salience which I would like that only the first activated rule will fire. I cant use the activation-group attribute because each rule can fire number of times, and i want only this rule to be fired in that group: rule A1 salience 100 ruleflow-group A activation-group A when xxx1 then yyy1 end rule A2 salience 90 ruleflow-group A activation-group A when xxx2 then yyy2 end If Rule A1 run (activated number of times), rule A2 should not run. Is there a way to do that? (no global flags etc.) Thanks Yaniv ___ 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] Identity, equality, hashing and indexing
Hi, I have some existential questions about Drools Expert's magic :-). When reading the documentation it is clear that, by default, facts are stored in an IdentityHashMap. If I understand things correctly it means that the objects I put in the working memory don't have to implement the hashCode() and equals() method. They should implement them only if I tell Drools to use the equality mode. So here is my first question: in equality mode, if a fact field is used by the hashCode method, and if that field is modified by a rule action, should I expect a weird behavior since facts are stored in a HashMap? When digging into rules-users' archives I also found posts of Mark Proctor, talking about field indexing and alpha node hashing, that lead to my second question: should I expect a weird behavior if 2 fields are related to each other? For instance (not a good example but it gives an idea): a Person type has a getFirstName() method, a getLastName() method and a getName() method that return the concatenation of getFirstName() and getLastName(). Is it problematic if one rule has a Person(name == John Doe) fact in its LHS and if another rule modifies the firstName of that Person fact (John - Jane)? Does it depend on the equality vs. identity mode (I don't think so... unless the field itself is a also a fact)? Many thanks in advance for your answers, Best regards, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Identity, equality, hashing and indexing
Hi Thomas, Thanks for your answer! You actually describe the behavior what I was hoping for :-). Bruno. Swindells, Thomas a écrit : Drools only cares about facts, not the fields within it - when you tell Drools you have updated a fact object then it re-evaluates all the rules that uses the fact, you don't tell it which fields have actually changed. Therefore you can have inter-related fields without any problems. I don't know for sure but I think that when you use update to tell drools the object has been updated it will update the hashcode to the new value and so maintain the checking of equality. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Bruno Freudensprung Sent: 08 December 2010 14:00 To: Rules Users List Subject: [rules-users] Identity, equality, hashing and indexing Hi, I have some existential questions about Drools Expert's magic :-). When reading the documentation it is clear that, by default, facts are stored in an IdentityHashMap. If I understand things correctly it means that the objects I put in the working memory don't have to implement the hashCode() and equals() method. They should implement them only if I tell Drools to use the equality mode. So here is my first question: in equality mode, if a fact field is used by the hashCode method, and if that field is modified by a rule action, should I expect a weird behavior since facts are stored in a HashMap? When digging into rules-users' archives I also found posts of Mark Proctor, talking about field indexing and alpha node hashing, that lead to my second question: should I expect a weird behavior if 2 fields are related to each other? For instance (not a good example but it gives an idea): a Person type has a getFirstName() method, a getLastName() method and a getName() method that return the concatenation of getFirstName() and getLastName(). Is it problematic if one rule has a Person(name == John Doe) fact in its LHS and if another rule modifies the firstName of that Person fact (John - Jane)? Does it depend on the equality vs. identity mode (I don't think so... unless the field itself is a also a fact)? Many thanks in advance for your answers, Best regards, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ 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] Insert new facts in WorkingMemory event handler
Hi everyone, Do you know if it is possible to insert/modify/retract facts in a working memory event handler? Here is my use case actually: I want my users to be able to write rules like When ... Then retract X without having to bother with the consequences of retracting X on the other objects of the sessions (some of them might be retracted as well). These consequences can be expressed by rules, but I would like them to be kind of part of the framework and it would be easier for users if those rules were implicitly defined. Many thanks in advance for any hint, Best regards, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Insert new facts in WorkingMemory event handler
Hi Michael, Thanks for you answer! Following you suggestion I've taken a look at at logical insertions and on one hand I have to say that it looks like what I need, but on the other hand it is not clear to me how to implement it. If you have some time to take a look, here are the objects in my session: - one T object (something that can be considered as a type object) - many I objects (something that can be considered as instance objects), I objects have one type field beeing a T (there is no link from T to Is) Those facts are inserted into the session and I have the impression that we are not speaking here of logical insertions: they have to be here, it is the input data the user has to write rules on. The user can decide to retract the T object: in this case all I objects have to be retracted as well. The user can decide to retract some I objects: when all of them have been retracted, the T object should be retracted as well. The first solution I imagined was to have high-salience rules: rule 1 when t : T not I(type == t) then retract t rule 2 when i : I(t : type) not Type (this == t) then retract i The other solution I imagined (that I have not tried) was to retract facts using a WorkingMemoryEventHandler. However as I am a Drools' absolute beginner (not only to Drools, but to the rule paradigm itself), I was wondering what is the most natural way for you guys to implement that behavior :-). Bruno. Michael Anstis a écrit : Would the other retractions be automatically provided for by Drools' Truth Maintenance? Otherwise, passing a StatefulKnowledgeSession to a WorkingMemoryEventHandler subclass and invoking it's methods should, IMO, not be an issue. Have you tried it and experienced issues? On 6 December 2010 09:32, Bruno Freudensprung bruno.freudenspr...@temis.com mailto:bruno.freudenspr...@temis.com wrote: Hi everyone, Do you know if it is possible to insert/modify/retract facts in a working memory event handler? Here is my use case actually: I want my users to be able to write rules like When ... Then retract X without having to bother with the consequences of retracting X on the other objects of the sessions (some of them might be retracted as well). These consequences can be expressed by rules, but I would like them to be kind of part of the framework and it would be easier for users if those rules were implicitly defined. Many thanks in advance for any hint, Best regards, Bruno. ___ 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 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] Insert new facts in WorkingMemory event handler
Hi, Yes, I see what you mean! That's why, before starting, I wanted to make sure that I was not completly mistaken ;-). Please find my answers below. Bruno. Gabor Szokoli a écrit : That looks like a drools retelling of the chicken and egg problem to me: how do you intend to insert new Instances or Types ? Yes, I must admit I've had the same feeling too :-). I have an XML containing those Instances (many) and Types (few and unique), all of them being XML elements : type id=1/ type id=2/ instance typeRefid=1 / instance typeRefid=1 / instance typeRefid=2 / instance typeRefid=2 / instance typeRefid=2 / and I simply plan to read my XML and add the corresponding objects into the session, then to fire the rules. From the logical point of view, why do you need to retract unreferenced facts? Do you see performance issues from too many facts? Well... I wanted to delegate the whole logic to Drools and I imagined that I could listen to Drools' WorkingMemory's retraction events in order to remove the corresponding elements from the input XML. Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Insert new facts in WorkingMemory event handler
Hi Wolfgang, Thank you for your advice! Indeed, this logic is part of my application domain. Best regards, Bruno. Wolfgang Laun a écrit : The initially posted rules 1 and 2 are best practice. You are using a Production Rule Engine, and these rules are what they are made for. Doing it in an event handler is not impossible, but it requires you to implement logic which is (apparently) part of the application domain (There must not be a T without at least one I. and There must not be an I without its T.) and, moreover, logic which is readily available by the Engine's workings. Don't reinvent the wheel, just start rolling along. -W ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] WorkingMemoryEventListener and Stateless sessions in sequential mode
Hi, I am using Drools 5.1.1 and I have the impression that the WorkingMemoryEventListener is not called when using a StatelessKnowledgeSession configured in Sequential mode. Does anyone have experienced such a behavior? When using the SequentialOption.NO option, the little program below (in PS) displays: Retracting: to-be-removed Retracted: to-be-removed When using the SequentialOption.YES option, the program displays: Retracting: to-be-removed Many thanks in advance, Bruno. PS : Here is the sample code // DRL: rule Retract to-be-removed string when $s : String(this == to-be-removed) then System.out.println(Retracting: + $s); retract($s); end // listener: public class MyListener implements org.drools.event.rule.WorkingMemoryEventListener { public void objectInserted( org.drools.event.rule.ObjectInsertedEvent event) { } public void objectRetracted(org.drools.event.rule.ObjectRetractedEvent event) { System.out.println(Retracted: + event.getOldObject().toString()); } public void objectUpdated(org.drools.event.rule.ObjectUpdatedEvent event) { } } // main: KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder(); builder.add(ResourceFactory.newFileResource(new File(simpleRule.drl)),ResourceType.DRL); KnowledgeBaseConfiguration configuration = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); configuration.setOption(SequentialOption.YES); // change this line to change the program behavior KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(configuration); knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages()); StatelessKnowledgeSession session = knowledgeBase.newStatelessKnowledgeSession(); MyListener handler = new MyListener(); ListCommand? commands = new ArrayListCommand?(); commands.add(CommandFactory.newInsert(to-be-removed)); commands.add(new AddEventListenerCommand(handler)); session.execute(CommandFactory.newBatchExecution(commands)); ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Building a rule base from the content of a directory
Hi Toni, Thanks a lot for your investigations. What I've noticed so far is: when you add a drools.package file in the KnowledgeBuilder (as a DRL resource), then add the BRL file in the KB (as a BRL), the KB has errors. When both are concatenated then added (as a DRL) it works well. Best reagrds, Bruno. Toni Rikkola a écrit : Can't remember what the issue was with BRL back then. I can take a second look at the TODO next week. Toni Rikkola On Nov 19, 2010, at 2:26 PM, Bruno Freudensprung wrote: Hi, Many thanks for you answer! Are you talking about DroolsCompilerAntTask and DroolsVerifierAntTask Ant tasks (that I discovered after having read you email)? I've taken a look at the code of the DroolsCompiler task (Drools 5.1.1) and it also concatenates (into a single string) the package file and the BRL file (transformed into DRL) before adding it to the KnowledgeBuilder. The code comes along with the following comment: // TODO: Right now I have to first change this to String. Change to // use KnowledgeBuilder directly when the support for that is done. // -Toni Rikkola- I really wonder if there is a more straighforward way to handle that package file + BRL file association. This is quite fair however compared to the following case: the Drools RCP plugin enables to create rule resources, either rule packages (a DRL file with package, import, globals...) in a single DRL file, or individual rules in a single DRL file as well. An individual rule seems to be kinda like a BRL file: something without any package, import, globals... and with one rule. The problem is I don't see a clever way (when listing the content of a directory) to make the distinction between individual rules and rule packages. For the moment I tend to think that, like in Guvnor UI, the solution is to have conventions (this directory contains individual rules, that directory contains rule packages, that one business rules...). Bruno. Justin Case a écrit : I'm happily using an Ant task for that - registered as Eclipse external builder. But I don't feel it exactly like cutting edge... HTH, JC ___ 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 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Building a rule base from the content of a directory
Hi, Many thanks for you answer! Are you talking about DroolsCompilerAntTask and DroolsVerifierAntTask Ant tasks (that I discovered after having read you email)? I've taken a look at the code of the DroolsCompiler task (Drools 5.1.1) and it also concatenates (into a single string) the package file and the BRL file (transformed into DRL) before adding it to the KnowledgeBuilder. The code comes along with the following comment: // TODO: Right now I have to first change this to String. Change to // use KnowledgeBuilder directly when the support for that is done. // -Toni Rikkola- I really wonder if there is a more straighforward way to handle that package file + BRL file association. This is quite fair however compared to the following case: the Drools RCP plugin enables to create rule resources, either rule packages (a DRL file with package, import, globals...) in a single DRL file, or individual rules in a single DRL file as well. An individual rule seems to be kinda like a BRL file: something without any package, import, globals... and with one rule. The problem is I don't see a clever way (when listing the content of a directory) to make the distinction between individual rules and rule packages. For the moment I tend to think that, like in Guvnor UI, the solution is to have conventions (this directory contains individual rules, that directory contains rule packages, that one business rules...). Bruno. Justin Case a écrit : I'm happily using an Ant task for that - registered as Eclipse external builder. But I don't feel it exactly like cutting edge... HTH, JC ___ 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] accessing a drools variable
Hi, I've never tried this but there is a getGlobals() method on the StatelessKnowledgeSession and on the StatefulKnowledgeSession (actually on KnowledgeRuntime). Maybe worth giving a try :-). Best regards, Bruno. rajivharris a écrit : Hi, I am setting a String variable as global. And trying the access the same in my Java program. Can anyone help on how to do this. code snippet: global String prodName; rule Your First Rule when #conditions eval (true) then #actions prodName= getName(); System.out.println( name: +prodName); end Thanks, Rajiv. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Building a rule base from the content of a directory
Hello, I plan to use the Drools Eclipse plugin in order to create rules with both the Guided rule editor and the Rule resource editor, and I would like to write a rather generic piece of code (using a KnowledgeBuilder) in order to setup a KnowledgeBase from the rule files contained in a directory. Would you say that am I completly re-inventing something that already exists? If not, is there is a convention related to building a rule base from a directory containing a mix of Drools files (drools.package, BRL, DRL...) created with the Drools Eclipse plugin? My first experiments showed that, in a directory containing only a BRL file and its associated drools.package file: * If I add both the drools.package file (as a DRL resource), then the BRL file (as a BRL resource) into the KnowledgeBuilder, I get a compilation error telling Unable to resolve ObjectType 'Document' * If I concatenate the content of the drools.package file and the result of the BRL 2 DRL conversion into a single DRL file, then add that unique DRL file (as a DRL resource) into the KnowledgeBuilder, everything is fine. Does any of you have an idea where I am mistaken? Many thanks in advance, Best regards, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Building a rule base from the content of a directory
Hello, Sorry for the duplicate post, the previous one got inserted into another thread (also sorry for that). So here it is... in its own thread :-). I plan to use the Drools Eclipse plugin in order to create rules with both the Guided rule editor and the Rule resource editor, and I would like to write a rather generic piece of code (using a KnowledgeBuilder) in order to setup a KnowledgeBase from the rule files contained in a directory. Would you say that am I completly re-inventing something that already exists? If not, is there is a convention related to building a rule base from a directory containing a mix of Drools files (drools.package, BRL, DRL...) created with the Drools Eclipse plugin? My first experiments showed that, in a directory containing only a BRL file and its associated drools.package file: * If I add both the drools.package file (as a DRL resource), then the BRL file (as a BRL resource) into the KnowledgeBuilder, I get a compilation error telling Unable to resolve ObjectType 'Document' * If I concatenate the content of the drools.package file and the result of the BRL 2 DRL conversion into a single DRL file, then add that unique DRL file (as a DRL resource) into the KnowledgeBuilder, everything is fine. Does any of you have an idea where I am mistaken? Many thanks in advance, Best regards, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Reuse statless session
Alright... The test case was delivered with the following documentation (extract of the Drools JBoss Rules 5.0 Developer's Guide book): org.drools.runtime.StatelessKnowledgeSession This is a type of knowledge session that doesn't keep any state between invocations (an invocation is a call of the execute method). From the rules perspective, a stateless session is no different than a stateful session---the rules look exactly the same. The benefit that statelessness brings is that the rule engine can do more optimizations. StatelessKnowledgeSession as well as stateful session support a command interface (command design pattern). There is no need to dispose a stateless session after it has been used. Bruno. Patrick van Kann a écrit : I might be putting too simplistic an interpretation on this, but this is what the Javadoc says for StatelessKnowledgeSession StatelessKnowledgeSession provides a convenience API, wrapping StatefulKnowledgeSession. It avoids the need to call dispose(). Stateless sessions do not support iterative insertions and fireAllRules from Java code, the act of calling execute(...) is a single shot method that will internally instantiate a StatefulKnowledgeSession, add all the user data and execute user commands, call fireAllRules, and then call dispose(). So I'm not sure why you just wouldn't just directly use a StatefulKnowledgeSession instead of trying to re-use a stateless one. You can then update the Facts via their handles and update or retract and reinsert as needed. Cheers, Pat On Tue, Oct 26, 2010 at 3:50 PM, Bruno Freudensprung bruno.freudenspr...@temis.com mailto:bruno.freudenspr...@temis.com wrote: Hi, According to what I've read so far, you can reuse Stateless sessions. In particlar I've seen unit tests creating a Stateless session in a @BeforeClass method, then this session was re-used across multiple tests methods pushing different data-sets into that unique session instance using commands (created with the org.drools.command.CommandFactory class). Regards, Bruno. espen a écrit : Hi, we have an application with a lot of rules in a cached rulebase. When we profile our application we see that about 30% of the time is used in rulebase.newStatlessSession(). The time is basically used loading classes. The question is, is it possible to create a pool of StalessSessions and reuse them, or will this create problems. Regards Espen ___ 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 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 statless session
You are right; so far (still haven't finished reading the book) it is unclear whether the stateless session really implements some kind of optimization. Bruno. Wolfgang Laun a écrit : Ha! I've been trying to find out about exactly this reputed distinction between stateful and stateless sessions, NOT to be confused with sequential mode, which does introduce optimizations. No success so far. -W ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Custom operator
Many thanks for your answers Edson! Bruno. Edson Tirelli a écrit : That is a mistake as one will override the other. Since they are the same, no harm done though It should suffice to use the configuration file. I am not familiar with eclipse/guvnor code, so can't really help you with the integration, but I would say, the SuggestionCompletionEngine could simply query the current KBuilderConfiguration to obtain the list of available operators. By that I mean, the core compiler provides the functionality, so the tools should be able to use that without any problems. Edson ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Reuse statless session
Hi, According to what I've read so far, you can reuse Stateless sessions. In particlar I've seen unit tests creating a Stateless session in a @BeforeClass method, then this session was re-used across multiple tests methods pushing different data-sets into that unique session instance using commands (created with the org.drools.command.CommandFactory class). Regards, Bruno. espen a écrit : Hi, we have an application with a lot of rules in a cached rulebase. When we profile our application we see that about 30% of the time is used in rulebase.newStatlessSession(). The time is basically used loading classes. The question is, is it possible to create a pool of StalessSessions and reuse them, or will this create problems. Regards Espen ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Less than greater than operator
Hi, From what I see in the code (org.drools.base.evaluators.ComparableEvaluatorsDefinition class), comparison operators have different implementations depending on the type of the arguments. For Integer, it uses the intValue() and the operator. There a many pre-defined type but, in the end, the Object type seems to be implemented by casting arguments to Comparable then using the compareTo() method. Bruno. Ji Oh Yoo a écrit : Hi, In drools rules, we can use or (also = and ) to write conditions with numbers and strings. But how does it work? My question is, does it call the compareTo() method? If it does, will those operators work with any objects inherited from ComparableT? Thanks. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Custom operator
Hi Edson, Many thanks for you answer! It is surprising that, on one hand, the drools.default.packagebuilder.conf file contains... : drools.evaluator.soundslike = org.drools.base.evaluators.SoundslikeEvaluatorsDefinition ... and on the other hand, EvaluatorRegistry.java contains: this.addEvaluatorDefinition( new SoundslikeEvaluatorsDefinition() ); and the source code for the Soundslike operator contains: public static final Operator SOUNDSLIKE = Operator.addOperatorToRegistry( soundslike, false ); All of this, at first sight, let me puzzled on how to really plug a custom operator. I'll give a try with the property file! Any intuition ;-) of how difficult it might be to modify (besides SuggestionCompletionEngine and HumanReadable) the business rule editor Eclipse plugin for a gentle integration of the operator? Best regards, Bruno. Edson Tirelli a écrit : The instantiation is done automatically, based on configuration or API call. More details in here: http://blog.athico.com/2010/06/creating-pluggable-oprators.html But basically, for eclipse to pick it up, best to add to a configuration file: drools.evaluator.MyIdentifierForMyOperators = my.pkg.MyEvaluatorDefinition Please note that all drools operators are implemented like that and wired through configuration file as seen here: https://svn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/main/resources/META-INF/drools.default.packagebuilder.conf So, adding your own custom operators is no different. Just define your own configuration file in the META-INF directory of your application package and it will work. Edson 2010/10/25 Swindells, Thomas tswinde...@nds.com: For that to work the class also needs to be instantiated - ie it would only get created once something in eclipse has touched the class. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Edson Tirelli Sent: 25 October 2010 14:58 To: Rules Users List Subject: Re: [rules-users] Custom operator If you look at the implementation of one of the existing operators (e.g. MatchesEvaluatorDefinition) you will see this in the beginning of the class: public static final Operator MATCHES = Operator.addOperatorToRegistry( matches, false ); Do the same on your own implementations and it should be fine. Edson 2010/10/25 Bruno Freudensprung bruno.freudenspr...@temis.com: Hello, It seems that the logic behind the operator drop-down list comes from the org.drools.ide.common.client.modeldriven.SuggestionCompletionEngine and org.drools.eclipse.rulebuilder.modeldriven.HumanReadable classes. That's for the rule authoring perspective. I've also seen that the business rule editor involves the DrlParser class. So, in a rule parsing perspective, I guess I need to find a way to register my custom operator into the EvaluatorRegistry used by the Eclipse plugin (and I don't know where this can be done). Do you think I am on the right track? Is there a risk that code modifications will involve so many classes that, in the end, adding a custom operator to the business rule editor will be a difficult task for someone very new to Drools (like me)? Thanks in advance, Best regards, Bruno. Bruno Freudensprung a écrit : Hello, I'd like to implement a custom lucenematches operator that would enable writing conditions like: $d : Doc(text lucenematches (foo AND bar) OR roam~0.8) As I've taken a look at the following post on athico (http://blog.athico.com/2009/05/imperfect-evaluations.html), and seen that the appendix B of the Drools JBoss Rules 5.0 Developer's Guide book that deals with custom operators, I am rather confident that I will find my way in implementing my operator (if not, I'll post here again :-)). However, I wonder if it will be possible to add my lucenematches operator to the operator drop-down list of the Eclipse's Business Rule Editor. Does anyone have an idea? Best regards, Bruno. ___ 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 -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data
Re: [rules-users] Drools examples don't run
Hello, I think you have to add the xstream jar to your classpath. Here is the Maven dependency : dependency groupIdcom.thoughtworks.xstream/groupId artifactIdxstream/artifactId version1.3.1/version /dependency Best regards, Bruno. ??? a écrit : Hello, I checked out the latest source from svn repository. It compiled OK and imported the example projects to my eclipse workspace but the examples run with error. The two example projects are namely drools-examples-drl drools-examples-fusion. org.drools.examples.pacman.Main gives the errors: Exception in thread main java.lang.NoClassDefFoundError: com/thoughtworks/xstream/XStream at org.drools.audit.KnowledgeRuntimeLoggerProviderImpl.newThreadedFileLogger(KnowledgeRuntimeLoggerProviderImpl.java:34) at org.drools.logger.KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(KnowledgeRuntimeLoggerFactory.java:69) at org.drools.examples.pacman.Main.initKsession(Main.java:88) at org.drools.examples.pacman.Main.main(Main.java:39) Caused by: java.lang.ClassNotFoundException: com.thoughtworks.xstream.XStream at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 4 more org.drools.examples.broker.Main gives the errors: java.lang.NullPointerException at org.drools.compiler.PackageBuilder.addProcessFromXml(PackageBuilder.java:432) at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:468) at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28) at org.drools.examples.broker.Broker.loadRuleBase(Broker.java:95) at org.drools.examples.broker.Broker.createSession(Broker.java:80) at org.drools.examples.broker.Broker.init(Broker.java:57) at org.drools.examples.broker.Main.main(Main.java:53) Does anyone experience the similar issues and know how to fix that? Best Regards, Kevin ___ 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] DrlParser problem with soundslike and matches
Hi, I am using Drools 5.1.1 (but also tried with 5.2.0.SNAPSHOT) to achieve the following scenario: 1 - use the Drools' Eclipse graphical rule editor to create a BRL file 2 - convert the BRL to DRL using the org.drools.ide.common.server.util.BRXMLPersistence and org.drools.ide.common.server.util.BRDRLPersistence classes 3 - parse the DRL with the org.drools.compiler.DrlParser class (in order to do some things) I have a problem with DrlParser class that does not seem to accept the matches and soundslike operators. With the following rule... : rule TestRule dialect mvel when Document( text soundslike drink ) then // some end ... I get that error message from the DrlParser: src/main/resources/org/drools/lang/DescrBuilderTree.g: node from line 0:0 mismatched tree node: unexpected: [...@15,55:64='soundslike',83,4:17], resync=soundslike expecting UP Does anyone has an idea of what's going on? Many thanks, Bruno. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] DrlParser problem with soundslike and matches
Hi Wolfgang, Many thanks for you answer! I finally decided to download Drools sources in order to debug my program. Following your advice (starting from EvaluatorRegistry), I finally found that adding a simple PackageBuilder builder = new PackageBuilder(); statement at the beginning of my program does the trick. For a reason that I don't understand (maybe a ClassLoader or static initialization side-effect), even though that builder variable is not used afterwards, it helps my DrlParser accepting the matches operator. So the final code is (for those interested in): PackageBuilder builder = new PackageBuilder(); // not used Resource brlresource = ResourceFactory.newClassPathResource(com/sample/TestRule.brl); BusinessRuleProvider provider = BusinessRuleProviderFactory.getInstance().getProvider(); Reader knowledge = provider.getKnowledgeReader(brlresource); DrlParser parser = new DrlParser(); PackageDescr pkg = parser.parse(knowledge); Cheers, Bruno. Wolfgang Laun a écrit : All the operators that are represented as Keywords must be made known to the parser; this includes all the predefined ones. This is done in class EvaluatorRegistry.. See org/drools/base/evaluators/EvaluatorRegistry,java and org/drools/compiler/PackageBuilderConfiguration.java. Best -W On 18 October 2010 11:05, Bruno Freudensprung bruno.freudenspr...@temis.com wrote: Hi, I am using Drools 5.1.1 (but also tried with 5.2.0.SNAPSHOT) to achieve the following scenario: 1 - use the Drools' Eclipse graphical rule editor to create a BRL file 2 - convert the BRL to DRL using the org.drools.ide.common.server.util.BRXMLPersistence and org.drools.ide.common.server.util.BRDRLPersistence classes 3 - parse the DRL with the org.drools.compiler.DrlParser class (in order to do some things) I have a problem with DrlParser class that does not seem to accept the matches and soundslike operators. With the following rule... : rule TestRule dialect mvel when Document( text soundslike drink ) then // some end ... I get that error message from the DrlParser: src/main/resources/org/drools/lang/DescrBuilderTree.g: node from line 0:0 mismatched tree node: unexpected: [...@15,55:64='soundslike',83,4:17], resync=soundslike expecting UP Does anyone has an idea of what's going on? Many thanks, Bruno. ___ 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