apache / incubator-kie-drools

Drools is a rule engine, DMN engine and complex event processing (CEP) engine for Java.
http://www.drools.org
5.83k stars 2.49k forks source link

DSL Constraints Don't Work With OOPath #5961

Open piacenti opened 4 months ago

piacenti commented 4 months ago

If I try a simple

[when]with an object where=/a/b/c/d/object
[when]- type is "{type}"=type == "{type}"

I get this error No pattern was found to add the constraint to: - type is "ABC" it also doesn't matter if I add [] to the end of the OOPath

It seems that this functionality only works with legacy non OOPath approach

Expected behavior: replace

with an object where
   - type is "ABC"

with /a/b/c/d/object[type == "ABC"]

mariofusco commented 3 months ago

Can you please provide a complete reproducer for this issue? It seems that we already have at least one test demonstrating how this works.

piacenti commented 3 months ago

This is a problem specific when using the constrained fact functionality where the DSL line starts with a dash and is suppose to append the DSL to the preceding pattern condition. As shown in the documentation here it works with the pattern Cheese() rather than /cheese[]. Also I don't see any tests for the DSL constraint functionality. This would be helpful when going through nested properties like /cheese/flavor[] and have some DSL constraint like [when]- is sharp=type=="sharp"

tkobayas commented 1 week ago

Hi @piacenti ,

I noticed that you meant OOPath for RuleUnit. It's not supported yet. What @mariofusco mentioned was a test for OOPath in traditional syntax. I filed a document PR to remove the confusing section "Domain Specific Languages" from "Rule Language Reference" chapter: https://github.com/apache/incubator-kie-drools/pull/6066

I also filed an issue to support the feature: https://github.com/apache/incubator-kie-drools/issues/6065

I hope it clarifies the current situation.