/** * Constructor that extracts the {@link ExecutorContext} internals and turns them into variables. * This method extracts the trasient variables, runtime arguments, environment it's running in and * the context in which it is running as identifiers that can be used within JEXL expression. * * @param context to be examined to be extracted into JEXL expression variables. */ public ELContext(ExecutorContext context) { if (context == null) { return; } // Adds the transient store variables. for (String variable : context.getTransientStore().getVariables()) { values.put(variable, context.getTransientStore().get(variable)); } values.put("runtime", context.getProperties()); values.put("environment", context.getEnvironment().name()); values.put("context", context.getContextName()); }
throws DirectiveExecutionException, ReportErrorAndProceed { if (context != null) { context.getTransientStore().increment("dq_total", 1); for (String variable : context.getTransientStore().getVariables()) { ctx.set(variable, context.getTransientStore().get(variable)); context.getTransientStore().increment("dq_failure", 1);
for (String variable : context.getTransientStore().getVariables()) { ctx.set(variable, context.getTransientStore().get(variable)); ELResult result = el.execute(ctx); if (context != null) { context.getTransientStore().set(variable, result.getObject());
@Override public List<Row> execute(List<Row> rows, ExecutorContext context) throws DirectiveExecutionException, ErrorRowException { for (Row row : rows) { // Move the fields from the row into the context. ELContext ctx = new ELContext(); ctx.set("this", row); for(String var : el.variables()) { ctx.set(var, row.getValue(var)); } // Transient variables are added. if (context != null) { for (String variable : context.getTransientStore().getVariables()) { ctx.set(variable, context.getTransientStore().get(variable)); } } // Execution of the script / expression based on the row data // mapped into context. try { ELResult result = el.execute(ctx); if (result.getBoolean()) { context.getTransientStore().increment(variable, incrementBy); } } catch (ELException e) { throw new DirectiveExecutionException(e.getMessage()); } } return rows; }
for (String variable : context.getTransientStore().getVariables()) { ctx.set(variable, context.getTransientStore().get(variable));