Re: [rules-users] How to create a drl file or decision table dynamically?
Thank your for your reply~ I am developing the Identity and Access management. I have finished the basic requirement, but the pre-condition part is what I am doing. The website sends the pre-condition(like what IP address or the time period can user access) that user sets. The pre-conditions are what I mentioned (expression). The difficulty is one expression may consist of several pre-conditions and every condition may be related to different rules. So here is the problem, how to verify users' authorization based on the expression which contains many operators("AND", "OR"). The number of "AND", "OR" in the expression are set by users. This is why I thought to create a rule file for each expression when the expression is created. In this case, I won't bother how many "AND", "OR" a expression contains. By the way, I also thought about parsing the expression in Java, then inserting every single condition into working memory. But it seems Drool can not be fully used in this way. Because it only looks like a if-else block Do you have any other solution for this requirement? Cheers laune wrote > > A (dynamic) "request" with a "logical expression" that is to be evaluated > as > a rule is very much like a (dynamic) SQL query to be evaluated on a > database. > > Are you sure that Drools is the right platform? > > If "someone" wants to send a logical expression in a formal language of > their > own, you'll have to parse that expression and translate it into the Drools > Rule > Language (aka DRL). Perhaps a Domain Specific Language might help, but > there's no telling from the very sparse information you've provided. (In > any case > "someone" and Drools will have to agree on the data model and the way to > refer to the data, or else you'll have to do more work.) > > -W > > > On 26 February 2012 16:00, shawnwrote: > >> Sorry, I forget to mention one thing. >> What's really difficult for me is to translate the "AND","OR"(Condition 1 >> AND Condition 2 OR Condition 3) to the drool. >> Because someone will send the request with the expression(Condition 1 AND >> Condition 2 OR Condition 3) to me. For each request the expression is >> different. They hope I can translate the "AND","OR" to rule file >> automatically. They don't want drool to parse the expression(maybe >> string) >> to pick "AND", "OR". This is why they want to have a rule file for each >> request. They want to trigger the function to make a rule file when they >> are >> making the expression, not only simply send me the expression and verify >> it.. >> >> -- >> View this message in context: >> http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3777057.html >> Sent from the Drools: User forum mailing list archive at Nabble.com. >> ___ >> rules-users mailing list >> rules-users@.jboss >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > ___ > rules-users mailing list > rules-users@.jboss > https://lists.jboss.org/mailman/listinfo/rules-users > -- View this message in context: http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3777398.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
Thank your for your reply~ I am developing the Identity and Access management. I have finished the basic requirement, but the pre-condition part is what I am doing. The website sends the pre-condition(like what IP address or the time period can user access) that user sets. The pre-conditions are what I mentioned (expression). The difficulty is one expression may consist of several pre-conditions and every condition may be related to different rules. So here is the problem, how to verify users' authorization based on the expression which contains many operators("AND", "OR"). The number of "AND", "OR" in the expression are set by users. This is why I thought to create a rule file for each expression when the expression is created. In this case, I won't bother how many "AND", "OR" a expression contains. By the way, I also thought about parsing the expression in Java, then inserting every single condition into working memory. But it seems Drool can not be fully used in this way. Because it only looks like a if-else block Do you have any other solution for this requirement? Cheers -- View this message in context: http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3777389.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
A (dynamic) "request" with a "logical expression" that is to be evaluated as a rule is very much like a (dynamic) SQL query to be evaluated on a database. Are you sure that Drools is the right platform? If "someone" wants to send a logical expression in a formal language of their own, you'll have to parse that expression and translate it into the Drools Rule Language (aka DRL). Perhaps a Domain Specific Language might help, but there's no telling from the very sparse information you've provided. (In any case "someone" and Drools will have to agree on the data model and the way to refer to the data, or else you'll have to do more work.) -W On 26 February 2012 16:00, shawn wrote: > Sorry, I forget to mention one thing. > What's really difficult for me is to translate the "AND","OR"(Condition 1 > AND Condition 2 OR Condition 3) to the drool. > Because someone will send the request with the expression(Condition 1 AND > Condition 2 OR Condition 3) to me. For each request the expression is > different. They hope I can translate the "AND","OR" to rule file > automatically. They don't want drool to parse the expression(maybe string) > to pick "AND", "OR". This is why they want to have a rule file for each > request. They want to trigger the function to make a rule file when they > are > making the expression, not only simply send me the expression and verify > it.. > > -- > View this message in context: > http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3777057.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] How to create a drl file or decision table dynamically?
Sorry, I forget to mention one thing. What's really difficult for me is to translate the "AND","OR"(Condition 1 AND Condition 2 OR Condition 3) to the drool. Because someone will send the request with the expression(Condition 1 AND Condition 2 OR Condition 3) to me. For each request the expression is different. They hope I can translate the "AND","OR" to rule file automatically. They don't want drool to parse the expression(maybe string) to pick "AND", "OR". This is why they want to have a rule file for each request. They want to trigger the function to make a rule file when they are making the expression, not only simply send me the expression and verify it.. -- View this message in context: http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3777057.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
Thank you ~ I will learn the documentation more. -- View this message in context: http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3777002.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
You don't need a file, you need a String (not to say you couldn't use a File if you really, really wanted - just that you don't have to). Other than the Fluent API already mentioned there is no Drools API to construct a DRL String. Read the manual, understand *your* data and build DRL applicable. I get the feeling you don't know what DRL actually is nor how to use Drools to any extent. Please do read the excellent documentation I am sure things will become clearer to you. sent on the move On 26 Feb 2012 11:37, "shawn" wrote: > Hi Michael, > Thank you for your reply~ > Now, I understand some mechanism of building dynamic class. > Back to my question, > if I understand correct, those methods you mentioned is to add a drl > file(exist) to the knowledgeBase dynamically, right? > But how about the file? > I mean if I need to write "Condition 1 AND Condition 2 OR Condition 3" > into the file, does drool have API to do it. > Because the content that I write into the file is also dynamic. What I > really want to do is how to make the drl file exist first? Does it mean I > have to create the file myself, and after finished creation I can add it > dynamically? > > -- > View this message in context: > http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3776811.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] How to create a drl file or decision table dynamically?
Hi Michael, Thank you for your reply~ Now, I understand some mechanism of building dynamic class. Back to my question, if I understand correct, those methods you mentioned is to add a drl file(exist) to the knowledgeBase dynamically, right? But how about the file? I mean if I need to write "Condition 1 AND Condition 2 OR Condition 3" into the file, does drool have API to do it. Because the content that I write into the file is also dynamic. What I really want to do is how to make the drl file exist first? Does it mean I have to create the file myself, and after finished creation I can add it dynamically? -- View this message in context: http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3776811.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
Hi~ Do you have any example about using stringBuilder? Cheers -- View this message in context: http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3774707.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
There is one (1) sentence and a dozen (12) lines of example in the section about "What is New and Noteworhty in Drools 5.2.0" in the Introduction manual. Given that this nano-documentation doesn't tell you what to do with the resulting PackageDescr and that this "fluent API" is part of the unstable API, I'd put my money on StringBuilder and create rules as DRL text. YMMV. -W On 24/02/2012, Leonardo Gomes wrote: > Hi Michael, > > Do you have a link to the Fluent API documentation? I wanted to answer to > this question and couldn't find the link anywhere. > > Thanks, > Leo. > > 2012/2/24 Michael Anstis > >> Yes. >> >> If the data "defines" the rules then there are numerous options:- >> >>- Construct a DRL String yourself and pass this to a KnowledgeBuilder >>- Use the fluent API to build rules programmatically >>- Construct an XLS decision table using your favourite XLS (Java) API >>and look at drools-decisiontables >>- Construct a Guvnor decision table using classes in >>droolsjbpm-ide-common (bundled with Guvnor) >> >> If the data is to be plugged into place-holders in statically defined >> rules:- >> >>- Look at the use of Drools Expert Templates >> >> Decision tables do not lend themselves well to "OR" as there is an >> implicit "AND" between columns. >> >> There might be other solutions, these are those that came readily to mind. >> >> With kind regards, >> >> Mike >> >> >> On 24 February 2012 14:31, shawn wrote: >> >>> If it is possible to create a drl file or decision table dynamically in >>> drool >>> or java? >>> Like the drool received data then create drl or decision table based on >>> the >>> data? >>> Data: Condition 1 AND Condition 2 OR Condition 3 . >>> Can the above data be stored in the rule file which also contains the >>> operators "AND", "OR"? >>> >>> >>> -- >>> View this message in context: >>> http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3772708.html >>> Sent from the Drools: User forum mailing list archive at Nabble.com. >>> ___ >>> rules-users mailing list >>> rules-users@lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/rules-users >>> >> >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
The reason it is not in the manual yet is because it was not promoted to the public API yet. Nevertheless, you can use it, but be aware that there might still be changes on it from version to version until it is promoted to the public API. I am hoping Mark will give me the go ahead to make it public soon. Examples are here: https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/lang/api/DescrBuilderTest.java The javadoc is not complete, but what is there is correct. Classes are: https://github.com/droolsjbpm/drools/tree/master/drools-compiler/src/main/java/org/drools/lang/api The API is completely typesafe, so you can trust the code completion of you java editor... :) Edson 2012/2/24 Michael Anstis > 1) No you don't have to save it; just use one of the overloaded methods on > KnowledgeBuilder that takes a StringReader, or String or something else > similar. > > 2) I understand there to be one for Drools Expert too, which I'd expect to > be in one of the drools-xxx JARs however am having trouble finding it! > > Re#2, I've asked Edson Tirelli (the author of the Drools Expert Fluent > API) to advise further... > > > On 24 February 2012 17:35, shawn wrote: > >> Thank you~ >> Does it mean I have to write a file in java and saved it as .drl? >> fluent API is in jbpm, right? >> >> -- >> View this message in context: >> http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3773187.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 > > -- 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
Re: [rules-users] How to create a drl file or decision table dynamically?
Thanks a lot~ Looking forward to hearing from you. -- View this message in context: http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3773255.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
1) No you don't have to save it; just use one of the overloaded methods on KnowledgeBuilder that takes a StringReader, or String or something else similar. 2) I understand there to be one for Drools Expert too, which I'd expect to be in one of the drools-xxx JARs however am having trouble finding it! Re#2, I've asked Edson Tirelli (the author of the Drools Expert Fluent API) to advise further... On 24 February 2012 17:35, shawn wrote: > Thank you~ > Does it mean I have to write a file in java and saved it as .drl? > fluent API is in jbpm, right? > > -- > View this message in context: > http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3773187.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] How to create a drl file or decision table dynamically?
Thank you~ Does it mean I have to write a file in java and saved it as .drl? fluent API is in jbpm, right? -- View this message in context: http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3773187.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
Quite simply, use a StringBuilder and create the DRL you need from the data you receive. @Leonardo, erm, erm... no. TBH I thought I'd be able to Google for it.. but no luck. Edson? Is there anything - or am I promoting something I shouldn't ;) On 24 February 2012 16:43, shawn wrote: > Thanks for your reply. > Sorry, I am not quite clear about your first option. > What's the meaning of 'Construct a DRL String'? > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3773060.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] How to create a drl file or decision table dynamically?
Is it from JBPM or ? -- View this message in context: http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3773142.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
Hi Michael, Do you have a link to the Fluent API documentation? I wanted to answer to this question and couldn't find the link anywhere. Thanks, Leo. 2012/2/24 Michael Anstis > Yes. > > If the data "defines" the rules then there are numerous options:- > >- Construct a DRL String yourself and pass this to a KnowledgeBuilder >- Use the fluent API to build rules programmatically >- Construct an XLS decision table using your favourite XLS (Java) API >and look at drools-decisiontables >- Construct a Guvnor decision table using classes in >droolsjbpm-ide-common (bundled with Guvnor) > > If the data is to be plugged into place-holders in statically defined > rules:- > >- Look at the use of Drools Expert Templates > > Decision tables do not lend themselves well to "OR" as there is an > implicit "AND" between columns. > > There might be other solutions, these are those that came readily to mind. > > With kind regards, > > Mike > > > On 24 February 2012 14:31, shawn wrote: > >> If it is possible to create a drl file or decision table dynamically in >> drool >> or java? >> Like the drool received data then create drl or decision table based on >> the >> data? >> Data: Condition 1 AND Condition 2 OR Condition 3 . >> Can the above data be stored in the rule file which also contains the >> operators "AND", "OR"? >> >> >> -- >> View this message in context: >> http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3772708.html >> Sent from the Drools: User forum mailing list archive at Nabble.com. >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
Thanks for your reply. Sorry, I am not quite clear about your first option. What's the meaning of 'Construct a DRL String'? -- View this message in context: http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3773060.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to create a drl file or decision table dynamically?
Yes. If the data "defines" the rules then there are numerous options:- - Construct a DRL String yourself and pass this to a KnowledgeBuilder - Use the fluent API to build rules programmatically - Construct an XLS decision table using your favourite XLS (Java) API and look at drools-decisiontables - Construct a Guvnor decision table using classes in droolsjbpm-ide-common (bundled with Guvnor) If the data is to be plugged into place-holders in statically defined rules:- - Look at the use of Drools Expert Templates Decision tables do not lend themselves well to "OR" as there is an implicit "AND" between columns. There might be other solutions, these are those that came readily to mind. With kind regards, Mike On 24 February 2012 14:31, shawn wrote: > If it is possible to create a drl file or decision table dynamically in > drool > or java? > Like the drool received data then create drl or decision table based on the > data? > Data: Condition 1 AND Condition 2 OR Condition 3 . > Can the above data be stored in the rule file which also contains the > operators "AND", "OR"? > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3772708.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] How to create a drl file or decision table dynamically?
If it is possible to create a drl file or decision table dynamically in drool or java? Like the drool received data then create drl or decision table based on the data? Data: Condition 1 AND Condition 2 OR Condition 3 . Can the above data be stored in the rule file which also contains the operators "AND", "OR"? -- View this message in context: http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3772708.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