Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-2286

[DMN engine] Java Object in DMNContext not working properly with Filter function.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • None
    • 7.4.1.Final, 7.5.0.Final
    • dmn engine
    • None

    Description

      When trying to evaluate a FEEL expression like:

      personList[name = "John"]
      

      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.

      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();
              }
          }
      

      Also attatched java and DMN test files that showcases the issue.

      Attachments

        Issue Links

          Activity

            People

              mmortari@redhat.com Matteo Mortari
              thomas.mantegazzi Thomas Mantegazzi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: