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

Thomas Mantegazzi (JIRA) issues at jboss.org
Wed Jan 31 10:22:00 EST 2018


Thomas Mantegazzi created DROOLS-2286:
-----------------------------------------

             Summary: [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.5.0.Final, 7.4.1.Final
            Reporter: Thomas Mantegazzi
            Assignee: Edson Tirelli
         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