Search in sources :

Example 1 with AddRelationshipOperation

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);
}
Also used : RelationshipType(org.alien4cloud.tosca.model.types.RelationshipType) AddRelationshipOperation(org.alien4cloud.tosca.editor.operations.relationshiptemplate.AddRelationshipOperation)

Aggregations

AddRelationshipOperation (org.alien4cloud.tosca.editor.operations.relationshiptemplate.AddRelationshipOperation)1 RelationshipType (org.alien4cloud.tosca.model.types.RelationshipType)1