use of org.eclipse.winery.model.tosca.yaml.support.YTMapRequirementAssignment 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));
}
}
});
}
use of org.eclipse.winery.model.tosca.yaml.support.YTMapRequirementAssignment in project winery by eclipse.
the class YamlBuilder method buildMapRequirementAssignment.
@Nullable
public YTMapRequirementAssignment buildMapRequirementAssignment(Object object, Parameter<YTMapRequirementAssignment> parameter) {
if (Objects.isNull(object)) {
return null;
}
YTMapRequirementAssignment result = new YTMapRequirementAssignment();
put(result, stringValue(parameter.getValue()), buildRequirementAssignment(object, new Parameter<>(parameter.getContext())));
return result;
}
Aggregations