/**
 * Axelor Business Solutions
 *
 * Copyright (C) 2005-2017 Axelor (<http://axelor.com>).
 *
 * This program is free software: you can redistribute it and/or  modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.axelor.script;

import javax.script.Bindings;

import com.axelor.common.StringUtils;
import com.axelor.rpc.Context;

public class CompositeScriptHelper extends AbstractScriptHelper {

	private GroovyScriptHelper gsh;
	private ELScriptHelper esh;

	public CompositeScriptHelper(Bindings bindings) {
		this.setBindings(bindings);
	}

	public CompositeScriptHelper(Context context) {
		this(new ScriptBindings(context));
	}

	private ScriptHelper getGSH() {
		if (gsh == null) {
			gsh = new GroovyScriptHelper(this.getBindings());
		}
		return gsh;
	}

	private ScriptHelper getESH() {
		if (esh == null) {
			esh = new ELScriptHelper(this.getBindings());
		}
		return esh;
	}

	private String strip(String expr) {
		String str = expr.trim();
		return str.substring(2, str.length()-1);
	}

	private boolean isEL(String expr) {
		if (StringUtils.isBlank(expr)) {
			return true;
		}
		String str = expr.trim();
		return str.startsWith("#{") && str.endsWith("}");
	}

	@Override
	public Object call(Object obj, String methodCall) {
		// allways use EL
		return getESH().call(obj, methodCall);
	}

	@Override
	protected Object doCall(Object obj, String methodCall) {
		return null;
	}

	@Override
	public Object eval(String expr, Bindings bindings) throws Exception {
		final ScriptHelper helper = isEL(expr) ? getESH() : getGSH();
		return helper.eval(strip(expr), bindings);
	}
}

@@ -1979,35 +1979,14 @@
 %7B%0A%09%09
-final ScriptHelper helper =
+return
  isE
@@ -1992,17 +1992,21 @@
 EL(expr)
- 
+%0A%09%09%09%09
 ? getESH
@@ -2011,53 +2011,61 @@
 SH()
- : getGSH();%0A%09%09return helper.eval(strip
+.eval(strip(expr), bindings)%0A%09%09%09%09: getGSH().eval
 (expr
-)
 , bi

Fix regression