[jboss-user] [jBPM] - Re: Transition rule EL Expression fails

Donald Walters do-not-reply at jboss.com
Sat Oct 2 08:11:18 EDT 2010


Donald Walters [http://community.jboss.org/people/dondragon2] created the discussion

"Re: Transition rule EL Expression fails"

To view the discussion, visit: http://community.jboss.org/message/564661#564661

--------------------------------------------------------------
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
[http://community.jboss.org/message/564661#564661]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20101002/c000354a/attachment-0001.html 


More information about the jboss-user mailing list