use of org.camunda.bpm.engine.cdi.annotation.ProcessVariable in project camunda-bpm-platform by camunda.
the class StartProcessInterceptor method extractVariables.
private Map<String, Object> extractVariables(StartProcess startProcessAnnotation, InvocationContext ctx) throws Exception {
VariableMap variables = new VariableMapImpl();
for (Field field : ctx.getMethod().getDeclaringClass().getDeclaredFields()) {
if (!field.isAnnotationPresent(ProcessVariable.class) && !field.isAnnotationPresent(ProcessVariableTyped.class)) {
continue;
}
field.setAccessible(true);
String fieldName = null;
ProcessVariable processStartVariable = field.getAnnotation(ProcessVariable.class);
if (processStartVariable != null) {
fieldName = processStartVariable.value();
} else {
ProcessVariableTyped processStartVariableTyped = field.getAnnotation(ProcessVariableTyped.class);
fieldName = processStartVariableTyped.value();
}
if (fieldName == null || fieldName.length() == 0) {
fieldName = field.getName();
}
Object value = field.get(ctx.getTarget());
variables.put(fieldName, value);
}
return variables;
}
Aggregations