private String resolveVariable(String s) { if (s == null) { return null; } 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) { VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, paramName); if (variableScopeInstance != null) { Object variableValue = variableScopeInstance.getVariable(paramName); String variableValueString = variableValue == null ? "" : variableValue.toString(); replacements.put(paramName, variableValueString); } } } for (Map.Entry<String, String> replacement: replacements.entrySet()) { s = s.replace("#{" + replacement.getKey() + "}", replacement.getValue()); } return s; }
public void signalEvent(String type, Object event) { if ("timerTriggered".equals(type)) { TimerInstance timerInstance = (TimerInstance) event; if (timerInstance.getId() == slaTimerId) { handleSLAViolation(); } } else if (("slaViolation:" + getId()).equals(type)) { handleSLAViolation(); } else { String variableName = getEventNode().getVariableName(); if (variableName != null) { VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, variableName); if (variableScopeInstance == null) { throw new IllegalArgumentException( "Could not find variable for event node: " + variableName); } EventTransformer transformer = getEventNode().getEventTransformer(); if (transformer != null) { event = transformer.transformEvent(event); } variableScopeInstance.setVariable(variableName, event); } triggerCompleted(); } }
private String resolveVariable(String s) { if (s == null) { return null; } 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) { VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, paramName); if (variableScopeInstance != null) { Object variableValue = variableScopeInstance.getVariable(paramName); String variableValueString = variableValue == null ? "" : variableValue.toString(); replacements.put(paramName, variableValueString); } } } for (Map.Entry<String, String> replacement: replacements.entrySet()) { s = s.replace("#{" + replacement.getKey() + "}", replacement.getValue()); } return s; }
public void signalEvent(String type, Object event) { if ("timerTriggered".equals(type)) { TimerInstance timerInstance = (TimerInstance) event; if (timerInstance.getId() == slaTimerId) { handleSLAViolation(); } } else if (("slaViolation:" + getId()).equals(type)) { handleSLAViolation(); } else { String variableName = getEventNode().getVariableName(); if (variableName != null) { VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, variableName); if (variableScopeInstance == null) { throw new IllegalArgumentException( "Could not find variable for event node: " + variableName); } EventTransformer transformer = getEventNode().getEventTransformer(); if (transformer != null) { event = transformer.transformEvent(event); } variableScopeInstance.setVariable(variableName, event); } triggerCompleted(); } }