Hello,
I'm using Drools 8.33.0.Final. I have code to parse RuleImpl and extract all Fields those are being used in the facts.
I found that Pattern and MVELConstraint have pretty different behaviors between '&&' expression and '||' expression.
For example, in the rule:
import com.MockObjectWithProjections
rule "test"
when
obj : MockObjectWithProjections(value1 == 1 || value2 == 2)
then
end
When I'm looking at kieBase.getKiePackages(), the obj is represented as a Pattern and it has only one MVELConstraint
* MVELConstraint (value1 == 1|| value2 == 2), constrainType = UNKNOWEN
However, if it is obj : MockObjectWithProjections(value1 == 1 && value2 == 2),
The pattern has 2 constraints:
* MVELConstraint (value1 == 1), constraintType = EQUAL
* MVELConstraint (value2 == 2), constraintType = EQUAL
The constraints are built by iterating deserialized object ConstraintConnectiveDescr descr, which is in a tree structure. However, this iteration only iterates the first layer of descr. All '&&' condition could be expanded into the first layer list but '||' could not. This caused that '||' expression could not parsed by MVELConstraint and the constraintType is UNKNOWN.
My code use constrains to find out which fields are being used.
Since '||' (double pipe) expression could not be built in MVELConstraint correctly, may I ask if there is any recommendation on how to find which fields are being used?
Thanks,