简体   繁体   中英

DMN - matching a Java enum by a FEEL expression

I have a Java enum as an input in a DMN decision table. The DMN call is embedded directly in the Java app . So take some enum:

public enum Foo {
    ONE, TWO
}

I pass an instance of this enum as an input - dmnContext.set("Foo", foo);

I hoped to be able to set a decision table input for foo of type string, and have a rule that matched "ONE". However, this doesn't work, because there is no POJO-String conversion. In the Java code, I could store foo as a String and validate it against the enumerated values (ie check foo is in the set ["ONE", "TWO"]), but this will complicate other parts of the application.

How can I achieve this while still using an enum type?

Please refer to this existing JIRA record comment section, for the explanation about:

  • why you are experiencing that behaviour
  • and why you should convert your Java-enum to the expected DMN type (which I guess) is a FEEL:string , and not an enum

You can use Jackson to achieve this, instead of resorting to custom code or DMN model modification.

Don't hesitate to Subscribe to the JIRA linked above, as we're hoping of making that work out-of-the-box; but is not trivial since the DMN RTF is thinking about introducing Enumerations directly in DMN eventually, so we need to take into account today what might happen tomorrow.

Since you are linking to Red Hat Product documentation, a reminder that you are strongly encouraged to open a Customer Portal ticket at https://access.redhat.com/support/cases/#/ if you have a Subscription.

I will appreciate your feedback following there references/pointers and I hope those helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM