/** * Create a document reference from an expression, an id or a path. * * @return the document reference */ public static Object createDocumentRefOrExpression(String value) { if (value.startsWith(".")) { return Scripting.newExpression("Document.resolvePathAsRef(\"" + value + "\")"); } else { return createDocumentRef(value); } }
public void setParam(String key, String value) { if (value.startsWith("expr:")) { value = value.substring(5).trim(); if (value.contains("@{")) { params.put(key, Scripting.newTemplate(value)); } else { params.put(key, Scripting.newExpression(value)); } } else { params.put(key, value); } }
@OperationMethod public BlobList run() throws CompileException, RuntimeException { if (expr == null) { String text = script.replaceAll("<", "<"); text = text.replaceAll(">", ">"); text = text.replaceAll("&", "&"); expr = Scripting.newExpression(text); } return (BlobList) expr.eval(ctx); }
@OperationMethod public void run() throws CompileException, RuntimeException { if (expr == null) { String text = script.replaceAll("<", "<"); text = text.replaceAll(">", ">"); text = text.replaceAll("&", "&"); expr = Scripting.newExpression(text); } expr.eval(ctx); }
@OperationMethod public Blob run() throws CompileException, RuntimeException { if (expr == null) { String text = script.replaceAll("<", "<"); text = text.replaceAll(">", ">"); text = text.replaceAll("&", "&"); expr = Scripting.newExpression(text); } return (Blob) expr.eval(ctx); }
@OperationMethod public DocumentModel run() throws CompileException, RuntimeException { if (expr == null) { String text = script.replaceAll("<", "<"); text = text.replaceAll(">", ">"); text = text.replaceAll("&", "&"); expr = Scripting.newExpression(text); } return (DocumentModel) expr.eval(ctx); }
@OperationMethod public DocumentModelList run() throws CompileException, RuntimeException { if (expr == null) { String text = script.replaceAll("<", "<"); text = text.replaceAll(">", ">"); text = text.replaceAll("&", "&"); expr = Scripting.newExpression(text); } return (DocumentModelList) expr.eval(ctx); }
public ChainExceptionFilter(String id, String value) { this.id = id; if (value.startsWith("expr:")) { value = value.substring(5).trim(); // Unescape xml checking value = StringEscapeUtils.unescapeXml(value); if (value.contains("@{")) { this.value = Scripting.newTemplate(value); } else { this.value = Scripting.newExpression(value); } } }
public OperationParameters set(String key, Object valueRef) { if (valueRef instanceof String) { if (((String) valueRef).startsWith("expr:")) { valueRef = ((String) valueRef).substring(5).trim(); // Unescape xml checking valueRef = StringEscapeUtils.unescapeXml(((String) valueRef)); if (((String) valueRef).contains("@{")) { params.put(key, Scripting.newTemplate(((String) valueRef))); } else { params.put(key, Scripting.newExpression(((String) valueRef))); } return this; } } params.put(key, valueRef); return this; }
public ChainExceptionFilter(AutomationFilterDescriptor automationFilterDescriptor) { id = automationFilterDescriptor.getId(); String value = automationFilterDescriptor.getValue(); if (value.startsWith("expr:")) { value = value.substring(5).trim(); // Unescape xml checking value = StringEscapeUtils.unescapeXml(value); if (value.contains("@{")) { this.value = Scripting.newTemplate(value); } else { this.value = Scripting.newExpression(value); } } }
v = v.trim(); if (v.length() > 0) { expr = Scripting.newExpression(v);
protected <T> T valueOrExpression(Class<T> klass, String v, OperationContext context, String kind) throws DocumentRouteException { if (!v.startsWith(EXPR_PREFIX)) { return (T) v; } v = v.substring(EXPR_PREFIX.length()).trim(); Expression expr; if (v.contains(TEMPLATE_START)) { expr = Scripting.newTemplate(v); } else { expr = Scripting.newExpression(v); } Object res = null; try { res = expr.eval(context); // stupid eval() method throws generic Exception } catch (RuntimeException e) { throw new DocumentRouteException("Error evaluating expression: " + v, e); } if (!(klass.isAssignableFrom(res.getClass()))) { throw new DocumentRouteException( kind + " of node '" + getId() + "' of graph '" + graph.getName() + "' does not evaluate to " + klass.getSimpleName() + " but " + res.getClass().getName() + ": " + v); } return (T) res; }
Expression expr = Scripting.newExpression(taskAssigneesVar); Object res = expr.eval(context);
protected Date evaluateDueDate() throws DocumentRouteException { String taskDueDateExpr = getTaskDueDateExpr(); if (StringUtils.isEmpty(taskDueDateExpr)) { return new Date(); } try (OperationContext context = getExecutionContext(getSession())) { Expression expr = Scripting.newExpression(taskDueDateExpr); Object res = expr.eval(context); if (res instanceof DateWrapper) { return ((DateWrapper) res).getDate(); } else if (res instanceof Date) { return (Date) res; } else if (res instanceof Calendar) { return ((Calendar) res).getTime(); } else if (res instanceof String) { return DateParser.parseW3CDateTime((String) res); } else { throw new DocumentRouteException( "The following expression can not be evaluated to a date: " + taskDueDateExpr); } } catch (DocumentRouteException e) { throw e; } catch (RuntimeException e) { throw new DocumentRouteException("Error evaluating task due date: " + taskDueDateExpr, e); } }
params.set(param.name, Scripting.newTemplate(value)); } else { params.set(param.name, Scripting.newExpression(value));
Expression expr = Scripting.newExpression(condition); try { if (!Boolean.TRUE.equals(expr.eval(ctx))) {