use of org.eclipse.winery.model.tosca.yaml.YTRequirementAssignment in project winery by eclipse.
the class ToCanonical method enhanceTopology.
/**
* Determines and updates the source and target for relationship templates in the given canonical topology based on
* the yaml node template definitions. Relationships are determined through the requirements of the given node
* templates.
*
* @param topology A canonical model TopologyTemplate
* @param nodeTemplates The node templates of the yaml topology template that was originally converted into the
* <tt>topology</tt>
*/
private void enhanceTopology(TTopologyTemplate topology, @NonNull Map<String, YTNodeTemplate> nodeTemplates) {
if (topology == null) {
return;
}
nodeTemplates.forEach((id, nt) -> {
@NonNull List<YTMapRequirementAssignment> reqs = nt.getRequirements();
if (reqs.isEmpty()) {
return;
}
for (YTMapRequirementAssignment map : reqs) {
for (Map.Entry<String, YTRequirementAssignment> data : map.getMap().entrySet()) {
final YTRequirementAssignment req = data.getValue();
TRelationshipTemplate relationship = topology.getRelationshipTemplate(req.getRelationship().getType().toString());
if (relationship == null) {
// requirement with a type that is not a RelationshipTemplate in the topology
continue;
}
relationship.setTargetNodeTemplate(topology.getNodeTemplate(req.getNode().toString()));
relationship.setSourceNodeTemplate(topology.getNodeTemplate(id));
}
}
});
}
Aggregations