use of org.eclipse.winery.model.tosca.TActivityDefinition in project winery by eclipse.
the class ToCanonical method convert.
public TActivityDefinition convert(YTMapActivityDefinition node) {
if (Objects.isNull(node) || node.getMap().isEmpty()) {
return null;
}
for (YTActivityDefinition value : node.getMap().values()) {
if (value instanceof YTCallOperationActivityDefinition) {
YTCallOperationActivityDefinition yamlDef = (YTCallOperationActivityDefinition) value;
TCallOperationActivityDefinition canonicalDef = new TCallOperationActivityDefinition(yamlDef.getOperation());
List<ParameterDefinition> inputs = yamlDef.getInputs().entrySet().stream().map(entry -> convert(entry.getValue(), entry.getKey())).collect(Collectors.toList());
canonicalDef.setInputs(inputs);
return canonicalDef;
}
}
return null;
}
use of org.eclipse.winery.model.tosca.TActivityDefinition in project winery by eclipse.
the class FromCanonical method convert.
public YTMapActivityDefinition convert(TActivityDefinition node) {
if (Objects.isNull(node)) {
return null;
}
// TODO support other activity definition types
if (node instanceof TCallOperationActivityDefinition) {
TCallOperationActivityDefinition canonicalDef = (TCallOperationActivityDefinition) node;
YTCallOperationActivityDefinition yamlDef = new YTCallOperationActivityDefinition(canonicalDef.getOperation());
Map<String, YTParameterDefinition> inputs = canonicalDef.getInputs().stream().map(this::convert).flatMap(m -> m.entrySet().stream()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
yamlDef.setInputs(inputs);
return new YTMapActivityDefinition().setMap(Collections.singletonMap(YamlSpecKeywords.CALL_OPERATION, yamlDef));
}
return new YTMapActivityDefinition();
}
Aggregations