Search in sources :

Example 1 with YTNodeTemplate

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());
}
Also used : Metadata(org.eclipse.winery.model.tosca.yaml.support.Metadata) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) LinkedHashMap(java.util.LinkedHashMap) YTNodeTemplate(org.eclipse.winery.model.tosca.yaml.YTNodeTemplate) NonNull(org.eclipse.jdt.annotation.NonNull)

Example 2 with YTNodeTemplate

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;
}
Also used : YTNodeTemplate(org.eclipse.winery.model.tosca.yaml.YTNodeTemplate) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate)

Aggregations

YTNodeTemplate (org.eclipse.winery.model.tosca.yaml.YTNodeTemplate)2 LinkedHashMap (java.util.LinkedHashMap)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)1 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)1 Metadata (org.eclipse.winery.model.tosca.yaml.support.Metadata)1