use of com.netflix.conductor.common.metadata.tasks.TaskResult in project orkesworkers by orkes-io.
the class TaxCalculator method execute.
@Override
public TaskResult execute(Task task) {
String zipCode = (String) task.getInputData().get("zipCode");
if (zipCode == null || StringUtils.isEmpty(zipCode)) {
task.setStatus(Task.Status.FAILED);
task.setReasonForIncompletion("missing zip code");
}
Number amount = (Number) task.getInputData().get("amount");
if (amount == null) {
task.setStatus(Task.Status.FAILED);
task.setReasonForIncompletion("missing amount");
}
// 10% tax
BigDecimal tax = new BigDecimal(amount.doubleValue()).multiply(new BigDecimal(0.1));
task.getOutputData().put("tax", tax);
task.setStatus(Task.Status.COMPLETED);
return new TaskResult(task);
}
Aggregations