JBoss Community

Re: Transition rule EL Expression fails

created by Donald Walters in jBPM - View the full discussion

I am using version 4.4

The issue is in the ExpressionCondition class

 

public boolean evaluate(OpenExecution execution) {

        Object result = Expression.create(expression, language).evaluate();

        if (result instanceof Boolean) {

            return ((Boolean) result).booleanValue();

        }

             throw new JbpmException("expression condition '" + expression + "' did not return a boolean: " + result);

    }

 

Apparently the value that is returned by the Expression.create is a String " true " which would fail based on the conditions above. I had to modify the code to reflect the following.

public boolean evaluate(OpenExecution execution) {

        Object result = Expression.create(expression, language).evaluate();

        if (result instanceof Boolean) {

            return ((Boolean) result).booleanValue();

        }

        if (result instanceof String) {

            if(result == null)

                return false;

            return Boolean.valueOf(((String) result).trim());

        }

        throw new JbpmException("expression condition '" + expression + "' did not return a boolean: " + result);

    }

After doing that it is evaluated properly. This an issue that needs to resolved in the official distribution.

public boolean evaluate(OpenExecution execution) {
        Object result = Expression.create(expression, language).evaluate();
        if (result instanceof Boolean) {
            return ((Boolean) result).booleanValue();
        }
        if (result instanceof String) {
            if(result == null)
                return false;
            return Boolean.valueOf(((String) result).trim());
        }
        throw new JbpmException("expression condition '" + expression + "' did not return a boolean: " + result);
    }

Reply to this message by going to Community

Start a new discussion in jBPM at Community