use of org.alien4cloud.tosca.editor.operations.relationshiptemplate.AddRelationshipOperation in project alien4cloud by alien4cloud.
the class TopologyModifierSupport method addRelationshipTemplate.
protected RelationshipTemplate addRelationshipTemplate(Csar csar, Topology topology, NodeTemplate sourceNode, String targetNodeName, String relationshipTypeName, String requirementName, String capabilityName) {
AddRelationshipOperation addRelationshipOperation = new AddRelationshipOperation();
addRelationshipOperation.setNodeName(sourceNode.getName());
addRelationshipOperation.setTarget(targetNodeName);
RelationshipType relationshipType = ToscaContext.get(RelationshipType.class, relationshipTypeName);
addRelationshipOperation.setRelationshipType(relationshipType.getElementId());
addRelationshipOperation.setRelationshipVersion(relationshipType.getArchiveVersion());
addRelationshipOperation.setRequirementName(requirementName);
addRelationshipOperation.setTargetedCapabilityName(capabilityName);
String relationShipName = TopologyCompositionService.ensureNodeNameIsUnique(safe(sourceNode.getRelationships()).keySet(), sourceNode.getName() + "_" + targetNodeName, 0);
addRelationshipOperation.setRelationshipName(relationShipName);
addRelationshipProcessor.process(csar, topology, addRelationshipOperation);
return sourceNode.getRelationships().get(relationShipName);
}
Aggregations