use of org.eclipse.winery.model.tosca.yaml.YTNodeTemplate in project winery by eclipse.
the class FromCanonical method convert.
@NonNull
public Map<String, YTNodeTemplate> convert(TNodeTemplate node, @NonNull List<TRelationshipTemplate> rTs) {
if (Objects.isNull(node)) {
return new LinkedHashMap<>();
}
Metadata meta = new Metadata();
if (Objects.nonNull(node.getX()) && Objects.nonNull(node.getY())) {
meta.add(org.eclipse.winery.model.converter.support.Defaults.X_COORD, node.getX());
meta.add(org.eclipse.winery.model.converter.support.Defaults.Y_COORD, node.getY());
}
if (Objects.nonNull(node.getName())) {
meta.add(org.eclipse.winery.model.converter.support.Defaults.DISPLAY_NAME, node.getName());
}
return Collections.singletonMap(node.getIdFromIdOrNameField(), new YTNodeTemplate.Builder(convert(node.getType(), new NodeTypeId(node.getType()))).setProperties(convert(node.getProperties())).setMetadata(meta).setRequirements(convertRequirements(node.getRequirements())).setCapabilities(convert(node.getCapabilities())).setArtifacts(convert(node.getArtifacts())).build());
}
use of org.eclipse.winery.model.tosca.yaml.YTNodeTemplate in project winery by eclipse.
the class ToCanonical method convert.
/**
* Converts TOSCA YAML NodeTemplates to TOSCA XML NodeTemplates Additional TOSCA YAML element metadata is put into
* TOSCA XML documentation element Additional TOSCA YAML elements directives and copy are not converted
*
* @param node TOSCA YAML NodeTemplate
* @return TOSCA XML NodeTemplate
*/
private TNodeTemplate convert(YTNodeTemplate node, String id) {
if (Objects.isNull(node)) {
return null;
}
this.currentNodeTemplate = node;
this.currentNodeTemplateName = id;
TNodeTemplate.Builder builder = new TNodeTemplate.Builder(id, node.getType()).addDocumentation(node.getDescription()).addDocumentation(node.getMetadata()).setName(node.getMetadata().getOrDefault(Defaults.DISPLAY_NAME, id)).setX(node.getMetadata().getOrDefault(Defaults.X_COORD, "0")).setY(node.getMetadata().getOrDefault(Defaults.Y_COORD, "0")).setProperties(convertPropertyAssignments(node.getProperties())).addRequirements(convert(node.getRequirements())).addCapabilities(convert(node.getCapabilities())).setArtifacts(convert(node.getArtifacts()));
TNodeTemplate nodeTemplate = builder.build();
this.nodeTemplateMap.put(id, nodeTemplate);
return nodeTemplate;
}
Aggregations