/** * Adds a parameter. * * @param parameter the name of the parameter as referenced in the SQL statement (${name} or #{name}). * @param value the value of the parameter * @return the query itself to support fluent calls */ public SQLQuery set(String parameter, Object value) { params.put(parameter, value); return this; }
/** * Returns all values defined in this extension as {@link Context}. * * @return a context containing all values defined by this extension or the <tt>default</tt> extension. */ @Nonnull public Context getContext() { Context ctx = Context.create(); for (Map.Entry<String, ConfigValue> entry : config.entrySet()) { ctx.put(entry.getKey(), get(entry.getKey()).get()); } return ctx; }
private Script computeUpdateScript(Entity parent, boolean updateParent) { sirius.kernel.commons.Context ctx = sirius.kernel.commons.Context.create(); StringBuilder sb = new StringBuilder(); for (Reference ref : references) { sb.append("ctx._source."); sb.append(ref.getLocalProperty().getName()); sb.append("=params."); sb.append(ref.getLocalProperty().getName()); sb.append(";"); ctx.put(ref.getLocalProperty().getName(), parent == null ? null : ref.getRemoteProperty().writeToSource(parent)); } if (updateParent) { sb.append("ctx._source."); sb.append(getName()); sb.append("=params."); sb.append(getName()); sb.append(";"); ctx.put(getName(), parent != null ? parent.getId() : null); } return new Script(ScriptType.INLINE, LANGUAGE_PAINLESS, sb.toString(), ctx); }