[jboss-jira] [JBoss JIRA] (DROOLS-2486) Drools Runtime does not recognize Custom Operator Parameter
bharath mogali (JIRA)
issues at jboss.org
Fri Apr 20 13:52:00 EDT 2018
bharath mogali created DROOLS-2486:
--------------------------------------
Summary: Drools Runtime does not recognize Custom Operator Parameter
Key: DROOLS-2486
URL: https://issues.jboss.org/browse/DROOLS-2486
Project: Drools
Issue Type: Feature Request
Components: core engine
Affects Versions: 7.7.0.Final
Reporter: bharath mogali
Assignee: Mario Fusco
Problem Statement:
We have few custom operators for Date and Strings, which are implemented looking at Str operator like shown here: https://github.com/kiegroup/drools/blob/f7ab4ee3c88d767a8cbb372c2db1afa84b20a51d/drools-core/src/main/java/org/drools/core/base/evaluators/StrEvaluatorDefinition.java
with below configuration in kie.properties.conf:
drools.evaluator.str = com.company.drools.operators.StrEvaluatorDefinition
For Custom Str operator we created, Drools runtime is not able to make distinction between Str[begins] and Str[ends].
What this means is when we are running below tests, we expect Rule-1 to fail and Rule-2 to get activated. But what we noticed is, Rule-2 will not be activated.
// Facts input into drools :
// str1 = drools
// str2 = dr
rule "Rule-1"
when message : Customer( str1 str[endsWith] str2 )
then System.out.println("Rule - Str 1 - fired");
end
rule "Rule-2"
when message : Customer( str1 str[startsWith] str2 )
then System.out.println("Rule - Str 2 - fired");
end
Other Observations:
If we change RHS to a a string literal like shown below, then Rule-2 will be Activated.
// Facts input into drools :
// str1 = drools
// str2 = dr
rule "Rule-1"
when message : Customer( str1 str[endsWith] "abc" )
then System.out.println("Rule - Str 1 - fired");
end
rule "Rule-2"
when message : Customer( str1 str[startsWith] str2 )
then System.out.println("Rule - Str 2 - fired");
end
Finally
We removed Str custom operator, and then used the out of the box Str operator provided by drools. We ran below mentioned tests again, this time Rule-2 gets activated.
// Facts input into drools :
// str1 = drools
// str2 = dr
rule "Rule-1"
when message : Customer( str1 str[endsWith] str2 )
then System.out.println("Rule - Str 1 - fired");
end
rule "Rule-2"
when message : Customer( str1 str[startsWith] str2 )
then System.out.println("Rule - Str 2 - fired");
end
Based on our tests, it seems like custom operators are not processed correctly.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
More information about the jboss-jira
mailing list