[jboss-jira] [JBoss JIRA] (DROOLS-2286) [DMN engine] Java Object in DMNContext not working properly with Filter function.

Matteo Mortari (JIRA) issues at jboss.org
Wed Feb 7 10:59:00 EST 2018


     [ https://issues.jboss.org/browse/DROOLS-2286?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matteo Mortari resolved DROOLS-2286.
------------------------------------
    Resolution: Done


Fixed with https://github.com/kiegroup/drools/pull/1745/commits/7e8d26a596e5ef5cebe2d16b2676cc20a9603023

> [DMN engine] Java Object in DMNContext not working properly with Filter function.
> ---------------------------------------------------------------------------------
>
>                 Key: DROOLS-2286
>                 URL: https://issues.jboss.org/browse/DROOLS-2286
>             Project: Drools
>          Issue Type: Bug
>          Components: dmn engine
>    Affects Versions: 7.4.1.Final, 7.5.0.Final
>            Reporter: Thomas Mantegazzi
>            Assignee: Matteo Mortari
>         Attachments: FilterJohns.dmn, FilterOnObjectListBug.java
>
>
> When trying to evaluate a FEEL expression like: 
> {code:java}
> personList[name = "John"]
> {code}
> by inserting into the _DMNContext_ a _Java Object_, the _DMN engine_ doesn't seem to be able to fetch the  _name_ field from the object. This doesn't happen if instead of _Java Objects_ we insert a Map.
> While trying to debug, it seems that the problem is happening in the following method of  _FilterExpressionNode_.
> {code:java}
> private void evaluateExpressionInContext(EvaluationContext ctx, List results, Object v) {
>         try {
>             ctx.enterFrame();
>             // handle it as a predicate
>             ctx.setValue( "item", v );
>             // if it is a Map, need to add all string keys as variables in the context
>             if( v instanceof Map ) {
>                 Set<Map.Entry> set = ((Map) v).entrySet();
>                 for( Map.Entry ce : set ) {
>                     if( ce.getKey() instanceof String ) {
>                         ctx.setValue( (String) ce.getKey(), ce.getValue() );
>                     }
>                 }
>             }
>             Object r = this.filter.evaluate( ctx );
>             if( r instanceof Boolean && ((Boolean)r) == Boolean.TRUE ) {
>                 results.add( v );
>             }
>         } finally {
>             ctx.exitFrame();
>         }
>     }
> {code}
> Also attatched java and DMN test files that showcases the issue.



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list