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]

_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to