@Override public String getSubRouteModelId() throws DocumentRouteException { String subRouteModelExpr = (String) getProperty(PROP_SUB_ROUTE_MODEL_EXPR); if (StringUtils.isBlank(subRouteModelExpr)) { return null; } try (OperationContext context = getExecutionContext(getSession())) { String res = valueOrExpression(String.class, subRouteModelExpr, context, "Sub-workflow id expression"); return StringUtils.defaultIfBlank(res, null); } }
return taskAssignees; try (OperationContext context = getExecutionContext(getSession())) { Expression expr = Scripting.newExpression(taskAssigneesVar); Object res = expr.eval(context);
protected Map<String, Serializable> getSubRouteInitialVariables() { ListProperty props = (ListProperty) document.getProperty(PROP_SUB_ROUTE_VARS); Map<String, Serializable> map = new HashMap<>(); try (OperationContext context = getExecutionContext(getSession())) { for (Property p : props) { MapProperty prop = (MapProperty) p; String key = (String) prop.get(PROP_KEYVALUE_KEY).getValue(); String v = (String) prop.get(PROP_KEYVALUE_VALUE).getValue(); Serializable value = valueOrExpression(Serializable.class, v, context, "Sub-workflow variable expression"); map.put(key, value); } } return map; }
public void executeChain(String chainId, String transitionId) throws DocumentRouteException { // TODO events if (StringUtils.isEmpty(chainId)) { return; } // get base context try (OperationContext context = getExecutionContext(getSession())) { if (transitionId != null) { context.put("transition", transitionId); } AutomationService automationService = Framework.getService(AutomationService.class); automationService.run(context, chainId); setAllVariables(context); } catch (OperationException e) { throw new DocumentRouteException("Error running chain: " + chainId, e); } }
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); } }
@Override public List<EscalationRule> evaluateEscalationRules() { List<EscalationRule> rulesToExecute = new ArrayList<>(); // add specific helpers for escalation for (EscalationRule rule : getEscalationRules()) { try (OperationContext context = getExecutionContext(getSession())) { Expression expr = new RoutingScriptingExpression(rule.condition, new RoutingScriptingFunctions(context, rule)); Object res = expr.eval(context); if (!(res instanceof Boolean)) { throw new DocumentRouteException("Condition for rule " + rule + " of node '" + getId() + "' of graph '" + graph.getName() + "' does not evaluate to a boolean: " + rule.condition); } boolean bool = Boolean.TRUE.equals(res); if ((!rule.isExecuted() || rule.isMultipleExecution()) && bool) { rulesToExecute.add(rule); } } catch (DocumentRouteException e) { throw e; } catch (RuntimeException e) { throw new DocumentRouteException("Error evaluating condition: " + rule.condition, e); } } saveDocument(); return rulesToExecute; }
List<Transition> trueTrans = new ArrayList<>(); for (Transition t : getOutputTransitions()) { try (OperationContext context = getExecutionContext(getSession())) { context.put("transition", t.id); Expression expr = new RoutingScriptingExpression(t.condition, new RoutingScriptingFunctions(context));