private String resolveVariable(String s, VariableResolverFactory factory) { Map<String, String> replacements = new HashMap<String, String>(); Matcher matcher = PatternConstants.PARAMETER_MATCHER.matcher(s); while (matcher.find()) { String paramName = matcher.group(1); if (replacements.get(paramName) == null) { Object variableValue = getVariable(paramName); if (variableValue != null) { String variableValueString = variableValue == null ? "" : variableValue.toString(); replacements.put(paramName, variableValueString); } else { try { variableValue = MVELSafeHelper.getEvaluator().eval(paramName, factory); String variableValueString = variableValue == null ? "" : variableValue.toString(); replacements.put(paramName, variableValueString); } catch (Throwable t) { logger.error("Could not find variable scope for variable {}", paramName); } } } } for (Map.Entry<String, String> replacement: replacements.entrySet()) { s = s.replace("#{" + replacement.getKey() + "}", replacement.getValue()); } return s; }
@Override public void copyFromSource() { if (this.id != null) { return; } this.compositeId = System.getProperty("org.kie.server.id", "") + "_" + source.getId(); this.containerId = ((WorkflowProcessInstance)source).getDeploymentId(); this.correlationKey = ((WorkflowProcessInstanceImpl)source).getCorrelationKey(); this.date = new Date(); this.id = source.getId(); this.initiator = (String) ((WorkflowProcessInstanceImpl)source).getVariable("initiator"); this.parentId = source.getParentProcessInstanceId(); this.processId = source.getProcessId(); this.processInstanceDescription = ((WorkflowProcessInstanceImpl)source).getDescription(); this.processName = source.getProcessName(); this.processVersion = source.getProcess().getVersion(); this.state = source.getState(); this.variables = ((WorkflowProcessInstanceImpl)source).getVariables(); }
@Override public void copyFromSource() { if (this.id != null) { return; } this.compositeId = System.getProperty("org.kie.server.id", "") + "_" + source.getId(); this.containerId = ((WorkflowProcessInstance)source).getDeploymentId(); this.correlationKey = ((WorkflowProcessInstanceImpl)source).getCorrelationKey(); this.date = new Date(); this.id = source.getId(); this.initiator = (String) ((WorkflowProcessInstanceImpl)source).getVariable("initiator"); this.parentId = source.getParentProcessInstanceId(); this.processId = source.getProcessId(); this.processInstanceDescription = ((WorkflowProcessInstanceImpl)source).getDescription(); this.processName = source.getProcessName(); this.processVersion = source.getProcess().getVersion(); this.state = source.getState(); this.variables = ((WorkflowProcessInstanceImpl)source).getVariables(); }
public String getProcessVarValue(ProcessInstance processInstance, String varName) { String actualValue = null; if (sessionPersistence) { List<VariableInstanceLog> log = logService.findVariableInstances(processInstance.getId(), varName); if (log != null && !log.isEmpty()) { actualValue = log.get(log.size()-1).getValue(); } } else { Object value = ((WorkflowProcessInstanceImpl) processInstance).getVariable(varName); if (value != null) { actualValue = value.toString(); } } return actualValue; }
private String resolveVariable(String s, VariableResolverFactory factory) { Map<String, String> replacements = new HashMap<String, String>(); Matcher matcher = PatternConstants.PARAMETER_MATCHER.matcher(s); while (matcher.find()) { String paramName = matcher.group(1); if (replacements.get(paramName) == null) { Object variableValue = getVariable(paramName); if (variableValue != null) { String variableValueString = variableValue == null ? "" : variableValue.toString(); replacements.put(paramName, variableValueString); } else { try { variableValue = MVELSafeHelper.getEvaluator().eval(paramName, factory); String variableValueString = variableValue == null ? "" : variableValue.toString(); replacements.put(paramName, variableValueString); } catch (Throwable t) { logger.error("Could not find variable scope for variable {}", paramName); } } } } for (Map.Entry<String, String> replacement: replacements.entrySet()) { s = s.replace("#{" + replacement.getKey() + "}", replacement.getValue()); } return s; }
public String getProcessVarValue(ProcessInstance processInstance, String varName) { String actualValue = null; if (sessionPersistence) { List<VariableInstanceLog> log = logService.findVariableInstances(processInstance.getId(), varName); if (log != null && !log.isEmpty()) { actualValue = log.get(log.size()-1).getValue(); } } else { Object value = ((WorkflowProcessInstanceImpl) processInstance).getVariable(varName); if (value != null) { actualValue = value.toString(); } } return actualValue; }