package org.onap.so.bpmn.core;
import java.util.Optional;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static Environment environment;
@Autowired
- public void setEnvironment(Environment environment) {
- this.environment = environment;
- }
- /**
- * Return the URN property value
- * if property is present in the execution object, return the same
- * else search in the environment object. If found, add it to the execution object and return the value
- * otherwise return null
+ public void setEnvironment(Environment environment) {
+ this.environment = environment;
+ }
+
+ /**
+ * Return the URN property value if property is present in the execution object, return the same else search in the
+ * environment object. If found, add it to the execution object and return the value otherwise return null
*
* @param variableName URN property name
- * @param execution The flow's execution instance.
+ * @param execution The flow's execution instance.
* @return URN property value
*/
public static String getVariable(String variableName, DelegateExecution execution) {
Object value = execution.getVariable(variableName);
if (value != null) {
logger.trace("Retrieved value for the URN variable, {}, from the execution object: {}", variableName,
- String.valueOf(value));
+ String.valueOf(value));
return String.valueOf(value);
}
String variableValue = null;
if (environment != null && environment.getProperty(variableName) != null) {
variableValue = environment.getProperty(variableName);
logger.trace("Retrieved value for the URN variable, {}, from the environment variable: {}", variableName,
- variableValue);
+ variableValue);
execution.setVariable(variableName, variableValue);
return variableValue;
}
/**
* Return the URN property value from the environment object
+ *
* @param variableName URN property name
* @return URN property value
*/
- public static String getVariable(String variableName){
+ public static String getVariable(String variableName) {
if (environment != null) {
return environment.getProperty(variableName);
} else {
return null;
}
}
-
+
/**
* Return the String array URN property value from the environment object
+ *
* @param variableName URN property name
* @return URN property value
*/
- public static String[] getVariablesArray(String variableName){
+ public static String[] getVariablesArray(String variableName) {
if (environment != null) {
return environment.getProperty(variableName, String[].class);
} else {
return null;
}
}
-
+
public static String getVariable(String variableName, String defaultValue) {
- return Optional.ofNullable(getVariable(variableName)).orElse(defaultValue);
+ return Optional.ofNullable(getVariable(variableName)).orElse(defaultValue);
}
}