use of io.vertigo.dynamo.task.proxy.TaskInput in project vertigo by KleeGroup.
the class TaskProxyMethod method createTaskDefinition.
private static TaskDefinition createTaskDefinition(final Method method) {
final io.vertigo.dynamo.task.proxy.TaskAnnotation taskAnnotation = method.getAnnotation(io.vertigo.dynamo.task.proxy.TaskAnnotation.class);
final TaskDefinitionBuilder taskDefinitionBuilder = TaskDefinition.builder(taskAnnotation.name()).withEngine(taskAnnotation.taskEngineClass()).withRequest(taskAnnotation.request()).withDataSpace(taskAnnotation.dataSpace().isEmpty() ? null : taskAnnotation.dataSpace());
if (hasOut(method)) {
final Domain outDomain = findOutDomain(method);
if (isOutOptional(method)) {
taskDefinitionBuilder.withOutOptional("OUT", outDomain);
} else {
taskDefinitionBuilder.withOutRequired("OUT", outDomain);
}
}
for (final Parameter parameter : method.getParameters()) {
final TaskInput taskAttributeAnnotation = parameter.getAnnotation(TaskInput.class);
// test if the parameter is an optional type
final boolean optional = Optional.class.isAssignableFrom(parameter.getType());
if (optional) {
taskDefinitionBuilder.addInOptional(taskAttributeAnnotation.name(), resolveDomain(taskAttributeAnnotation.domain()));
} else {
taskDefinitionBuilder.addInRequired(taskAttributeAnnotation.name(), resolveDomain(taskAttributeAnnotation.domain()));
}
}
return taskDefinitionBuilder.build();
}
use of io.vertigo.dynamo.task.proxy.TaskInput in project vertigo by KleeGroup.
the class TaskProxyMethod method createTask.
private static Task createTask(final TaskDefinition taskDefinition, final Method method, final Object[] args) {
final TaskBuilder taskBuilder = Task.builder(taskDefinition);
for (int i = 0; i < method.getParameters().length; i++) {
final Parameter parameter = method.getParameters()[i];
final boolean optional = Optional.class.isAssignableFrom(parameter.getType());
final TaskInput taskAttributeAnnotation = parameter.getAnnotation(TaskInput.class);
final Object arg;
if (optional) {
arg = ((Optional) (args[i])).orElse(null);
} else {
arg = args[i];
}
taskBuilder.addValue(taskAttributeAnnotation.name(), arg);
}
return taskBuilder.build();
}
Aggregations