use of io.kaoto.backend.model.deployment.kamelet.KameletBindingSpec in project kaoto-backend by KaotoIO.
the class KameletBindingDeploymentGeneratorService method parse.
@Override
public String parse(final List<Step> steps, final Map<String, Object> metadata) {
if (!appliesTo(steps)) {
return "";
}
KameletBindingSpec spec = new KameletBindingSpec();
int i = 0;
if (!steps.isEmpty()) {
Step step = steps.get(i);
if ("START".equalsIgnoreCase(step.getType())) {
spec.setSource(createKameletBindingStep(steps.get(i++)));
}
}
for (; i < steps.size() - 1; i++) {
spec.getSteps().add(createKameletBindingStep(steps.get(i)));
}
if (spec.getSteps().isEmpty()) {
spec.setSteps(null);
}
if (steps.size() > 1) {
spec.setSink(createKameletBindingStep(steps.get(steps.size() - 1)));
}
KameletBinding binding = new KameletBinding(String.valueOf(metadata.getOrDefault("name", "")), spec);
Yaml yaml = new Yaml(new Constructor(KameletBinding.class), new KameletRepresenter());
return yaml.dumpAsMap(binding);
}
Aggregations