Is there any work going on for Drools on .net?
by rahultechie
Hi,
I am currently working on Drools on .net. What I found that the latest
version of drool .net is 3.0 which was developed around 2007. After that
there is work no done on Drool .net.
On above investigation following are my some of questions,
1. Whatever information I got is correct?
2. I want to use drools in my .net project. Latest version of Drools is 5.0
in JAVA, in future can we see Drools 5.0 in .net?
3. Is there any work around for now to use Drools 5.0 in .net?
Any link to above question will be useful.
Thanks.
--
View this message in context: http://drools.46999.n3.nabble.com/Is-there-any-work-going-on-for-Drools-o...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Smart Templates
by ChrisMu
Hi,
I'm trying to get a template (.drt) to generate 2 rules (.drl) from 2
datasets but by doing a little bit more work than direct substitution.
Data (service,value):
DC, AAA
DC, XYZ
Idea for the template - if value is of type1 then create Type object with
'Type1' as name. If value is of type2, use 'Type2' as name:
rule "DC_(a){row.rowNumber}"
when
Service(name == "DC")
then
Type.setName(eval(Service.getType(@{value})))
Type.setAtt(0,@{value})
end template
eval(Service.getType(@{arg0})) should take 'AAA' or 'XYZ' etc as arg and
return a string Type1/Type2 etc.
This would then generate 2 rules that look like:
rule "DC_0"
when
Service(name == "DC", value == "AAA")
then
RiskType.setName("Type1")
RiskType.setAtt(0,"AAA")
rule "DC_1"
when
Service(name == "DC", value == "XYZ")
then
RiskType.setName("Type2")
RiskType.setAtt(0,"XYZ")
...is this possible at all? I'm trying to avoid the eval step being done in
the actual rule (.drl) .
Thanks
Chris
--
View this message in context: http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006479.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Clarification needed in writing DSL function mapping
by Bala
Is there a simplified way of mapping than what i have done???
Java function :
function boolean checkIfVia(Route route, String locationCode)
{
if(route != null)
{
Via[] viaArr = route.getViaArray();
for(int i=1; i < viaArr.length; i++)
{
if(viaArr[i].getLocation().equalsIgnoreCase(locationCode))
return true;
else
return false;
}
}
return false;
}
Dsl Mapping:
[keyword][][Ff][Uu][Nn][Cc]
[Cc][Hh][Ee][Cc][Kk][Ii][Ff][Vv][Ii][Aa]=function boolean checkIfVia(Route
route, String locationCode)\n{checkIfViaBody}
[keyword][]checkIfViaBody=\nif(route != null)\n{checkIfViaIfBlock}\nreturn
false;\n
[keyword][]checkIfViaIfBlock=\nVia[] viaArr = route.getViaArray();\nfor(int
i=1; i < viaArr.length; i++)\n{checkIfViaForBlock}\n
[keyword][]checkIfViaForBlock=\nif(viaArr[i].getLocationCode().equalsIgnoreCase(locationCode))\n
return true; \nelse \nreturn false;\n
-----
Thanks,
Bala
--
View this message in context: http://drools.46999.n3.nabble.com/Clarification-needed-in-writing-DSL-fun...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
How to convert and use JAVA drools 5.1 in .net
by rahultechie
Hi,
I am trying to access JAVA drools 5.1 in .net. To convert binary files of
JAVA drools 5.1 in .net, I use ikvm-0.46.0.1 tool.
I referred these dlls in my .net application and tried to write JAVA code
(referring to
http://techgrafitti.wordpress.com/2011/02/21/drools-%E2%80%93-getting-sta...
link ) in my .net application.
But not able to refer StatefulSession class from
"org.drools.StatefulSession" namespace. Actually not able to find
"org.drools.StatefulSession" namespace from "drools-core-5.1.1.dll".
While converting jar to dlls I got lots of warning, after Googling I found
that we have to neglect these warnings.
Have any body already wrote such code?
Please share the dlls if you are able to run the rules in .net using latest
drools 5.1.
If possible please share me the code (if your code is not similar to the
code referred in above link).
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-convert-and-use-JAVA-drools-5-1-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
field names containing underscore
by Samuli Saarinen
Hello,
Currently it seams that using underscore as part of a field makes it
impossible to use the field in a rule.
eg.
public class Bean {
private boolean my_boolean;
}
rule "Test"
dialect "mvel"
when
b: Bean(my_boolean == true)
....
When compiling the rule this results in "Unable to build constraint as
'my_boolean' is invalid" error using Drools 5.2.0.CR1
and "Unable to create Field Extractor for 'my_boolean' of
'[ClassObjectType class=com.test.Bean]'" using Drools 5.1.1
Is this the expected behavior?
Cheers,
Samuli
--
Remion Oy Etävalvontajärjestelmät liiketoiminnan
Samuli Saarinen tehostamiseen
gsm +358 (0)50 3560075
fax +358 (0)3 2125064 www.remion.com
13 years, 6 months
Reuse of rule
by Küng Sabrina
Hello
How can I write a rule, that can be used in several other packages resp. rulesets without copying the code?
13 years, 6 months
drools date compare not working as documented
by magaram
hi -
i am using drools-distribution-5.2.0.M2. Here is the drl i am using -
----------
dialect "mvel"
import com.deltadental.drools.sample.*
rule "Rule 01"
when
$underageCustomer : Customer(dob>"15-May-1993")
$order : Order(customerId == $underageCustomer.customerId)
eval($order.discountPercentage == 0)
then
$order.discountPercentage = 25;
System.out.println("Rule 01 fired. Applied discount
"+$order.discountPercentage);
end
------------------
I get a RuntimeDroolsException: Exception executing predicate dob >
"15-May-1993"
Caused by: java.lang.RuntimeException: uncomparable values <<Mon May 01
00:00:00 EDT 2000>> and <<15-May-1993>>
caused by a class cast exception - String cannot be converted to a Date.
I get the same exception with 5.1.1. I tried the same setting Locale and
drools.dateformat properties - no luck so far..
Am I missing something here?
Thanks
Muk
--
View this message in context: http://drools.46999.n3.nabble.com/drools-date-compare-not-working-as-docu...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Catch 22 ANTLR DSL matching issue
by jstroup
Hi Droolers,
Regarding this blurb from the 5.2 DSL reference:
"It is important to note that the compiler transforms DSL rule files line by
line. In the above example, all the text after "Something is " to the end of
the line is captured as the replacement value for "{colour}", and this is
used for interpolating the target string. This may not be exactly what you
want. For instance, when you intend to merge different DSL expressions to
generate a composite DRL pattern, you need to transform a DSLR line in
several independent operations. The best way to achieve this is to ensure
that the captures are surrounded by characteristic text - words or even
single characters. As a result, the matching operation done by the parser
plucks out a substring from somewhere within the line. In the example below,
quotes are used as distinctive characters. Note that the characters that
surround the capture are not included during interpolation, just the
contents between them."
Given this DSL (test_expander.dsl)
[when](C|c)heese is "{type}"=Cheese(type=="{type}")
[when](is|hails|comes) from {country}=Cheese(country=="{country}")
[then]Add the message {message}=System.out.println({message});
And this DSLR
package com.sample
import com.sample.DroolsTest.Cheese;
expander test_expander.dsl
rule "rule_1"
when
Cheese is "cheddar" and is from Italy
then
Add the message "Cheddar IS from Italy"
end
rule "rule_2"
when
cheese is cheddar and comes from Italy
then
Add the message "Cheddar COMES from Italy"
end
I know that rule_2 fails because I removed the “distinctive characters” so
ANTLR is confused on what to capture. It just seems so unnatural for a rule
author to have to somehow magically know to add quotes in order to merge
different DSL expressions to generate a composite DRL pattern. The
documentation suggests also surrounding it with distinctive words so I sneak
an “and” into the DSL entry.
[when](C|c)heese is {type} and=Cheese(type=="{type}")
This allows me to write my rules more naturally.
rule "rule_1"
when
Cheese is cheddar and is from Italy
then
Add the message "Cheddar IS from Italy"
end
rule "rule_2"
when
cheese is cheddar and comes from Italy
then
Add the message "Cheddar COMES from Italy"
end
In the first example the “and” in
Cheese is "cheddar" and is from Italy
is actually a logical AND - not a matching character – which is nice because
we can use it to logically connect the 2 expressions or just match the first
DSL expression by itself as in
Cheese is cheddar
And since the second expression is not present we can drop the quotes. (But
how on earth will a rule author know this?). But if we add the “and” as part
of the first DSL expression
1) It is no longer a connecting logical character but is part of the
expression to match (yuk)
2) We can no longer just write “Cheese is cheddar” by itself but are
forced to write “Cheese is cheddar and” if we want to match only the first
expression. You might as well just combined the two expressions into one
since there is no real advantage now to having two expressions!
One nice thing would be for the Guvnor DSL editor to
1)try the capture greedily first,
2)get the annoying “no viable alternative error”,
3)CATCH the error instead of just giving up,
4)capture non-greedily and match only the first word,
5)then search for matching DSL expressions beyond that.
Or something like that. The only time you should have to add quotes is if
the text you are matching actually contains multiple words. Anything else is
counter-intuitive. Please tell me the planned replacement for DSL addresses
this!
Jeff
--
View this message in context: http://drools.46999.n3.nabble.com/Catch-22-ANTLR-DSL-matching-issue-tp299...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 6 months
Rule Flow and Stateless Session
by John Peterson
I'm having some difficulty getting a rule flow with a stateless session to work. Essentially, it is just executing the first task and then stops. I'm using Drools 5.1.1 and I just built the sample Drools by creating a new Drools Project.
My rule flow is simple: Start-RuleGroup1-RuleGroup2-End
I use the 2 rules from example, putting the "Hello World" in RuleGroup1 and "Goodbye" in RuleGroup2.
Here's my code to run it:
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
// start a new process instance
Message message = new Message();
message.setMessage("Hello World");
message.setStatus(Message.HELLO);
ArrayList cmds = new ArrayList();
ArrayList dataList = new ArrayList();
dataList.add(message);
cmds.add(CommandFactory.newInsertElements(dataList));
cmds.add(CommandFactory.newStartProcess("com.sample.ruleflow"));
ksession.execute(CommandFactory.newBatchExecution(cmds));
logger.close();
When I run the rules, all I get is "Hello World" (no "Goodbye cruel world"). It does work with a Stateful Session using insert, startProcess, and fireAllRules, but this is a test using the rule flows with CommandFactory functionality, something we need for an application we are developing.
13 years, 6 months