public void init() throws ElexisException { loadInterpreter(null); interpreter.setValue("finished", false); interpreter.setValue("init", true); interpreter.run(parse(getString(), new PersistentObject[0]), false); interpreter.setValue("init", false); }
/** * execute a script entered as string with the given interpreter * * @param objects optional Objects to replace in Variables like [Fall.Grund] in the script * @param params optional parameters. These can be of the form <i>name=value</i> or <i>value</i>. * if no name is given, the variables will be inserted for $1, $2 ... in the script. If a name * is given, $names in the script will be replaced with the respective values. * @return The result of the script interpreter * @throws ElexisException */ public static Object execute( Interpreter scripter, String script, String params, PersistentObject... objects) throws ElexisException { if (!StringTool.isNothing(script)) { if (params != null) { String var = "\\$"; String[] parameters = params.split("\\s*,\\s*"); for (int i = 0; i < parameters.length; i++) { String parm = parameters[i].trim(); String[] p = parm.split("="); if (p.length == 2) { script = script.replaceAll("\\" + p[0], p[1]); } else { script = script.replaceAll(var + i, p[0]); } } } String parsed = parse(script, objects); scripter.setValue("actPatient", ElexisEventDispatcher.getSelectedPatient()); scripter.setValue("actFall", ElexisEventDispatcher.getSelected(Fall.class)); scripter.setValue("actKons", ElexisEventDispatcher.getSelected(Konsultation.class)); scripter.setValue("actMandant", CoreHub.actMandant); scripter.setValue("actUser", CoreHub.actUser); scripter.setValue("Elexis", CoreHub.plugin); return scripter.run(parsed, true); } return null; }
public void setVariable(String name, Object value) throws ElexisException { loadInterpreter(null); interpreter.setValue(name, value); }