use of org.eclipse.winery.model.tosca.yaml.YTInterfaceDefinition in project winery by eclipse.
the class YamlRepository method removeRelationshipArtifact.
/**
* Deletes artifact from yaml relationship type
*
* @param relationshipType TRelationshipType
* @param targetArtifactName targeted artifact name
* @return updated node type
*/
private YTRelationshipType removeRelationshipArtifact(YTRelationshipType relationshipType, String targetArtifactName) {
Map<String, YTInterfaceDefinition> interfaces = relationshipType.getInterfaces();
for (Map.Entry<String, YTInterfaceDefinition> interfaceDefinition : interfaces.entrySet()) {
Map<String, YTOperationDefinition> operations = interfaceDefinition.getValue().getOperations();
YTOperationDefinition operationWithImplementation = operations.get(targetArtifactName);
if (operationWithImplementation != null) {
operationWithImplementation.setImplementation(null);
operations.replace(targetArtifactName, operationWithImplementation);
} else {
for (Map.Entry<String, YTOperationDefinition> operation : operations.entrySet()) {
YTOperationDefinition operationDefinition = operation.getValue();
if (operationDefinition != null) {
YTImplementation implementation = operationDefinition.getImplementation();
if (implementation != null) {
if (implementation.getPrimaryArtifactName() != null) {
if (implementation.getPrimaryArtifactName().equalsIgnoreCase(targetArtifactName)) {
operationDefinition.setImplementation(null);
} else {
if (implementation.getDependencyArtifactNames() != null) {
List<String> names = implementation.getDependencyArtifactNames();
for (String name : implementation.getDependencyArtifactNames()) {
if (name.equalsIgnoreCase(targetArtifactName)) {
names.remove(name);
}
}
implementation.setDependencyArtifactNames(names);
}
}
operationDefinition.setImplementation(implementation);
}
}
operation.setValue(operationDefinition);
}
}
YTInterfaceDefinition tInterfaceDefinition = interfaceDefinition.getValue();
tInterfaceDefinition.setOperations(operations);
interfaceDefinition.setValue(tInterfaceDefinition);
}
relationshipType.setInterfaces(interfaces);
}
return relationshipType;
}
use of org.eclipse.winery.model.tosca.yaml.YTInterfaceDefinition in project winery by eclipse.
the class YamlRepository method removeImplementation.
/**
* Deletes artifact from yaml node type interfaces
*
* @param nodeType TNodeType
* @param targetArtifactName targeted artifact name
* @return updated node type
*/
private YTNodeType removeImplementation(YTNodeType nodeType, String targetArtifactName) {
Map<String, YTInterfaceDefinition> interfaces = nodeType.getInterfaces();
for (Map.Entry<String, YTInterfaceDefinition> interfaceDefinition : interfaces.entrySet()) {
Map<String, YTOperationDefinition> operations = interfaceDefinition.getValue().getOperations();
for (Map.Entry<String, YTOperationDefinition> operation : operations.entrySet()) {
YTOperationDefinition operationDefinition = operation.getValue();
if (operationDefinition != null) {
YTImplementation implementation = operationDefinition.getImplementation();
if (implementation != null) {
if (implementation.getPrimaryArtifactName() != null) {
// TODO
if (implementation.getPrimaryArtifactName().equalsIgnoreCase(targetArtifactName)) {
operationDefinition.setImplementation(null);
} else {
if (implementation.getDependencyArtifactNames() != null) {
List<String> names = implementation.getDependencyArtifactNames();
for (String name : implementation.getDependencyArtifactNames()) {
if (name.equalsIgnoreCase(targetArtifactName)) {
names.remove(name);
}
}
implementation.setDependencyArtifactNames(names);
}
}
}
operationDefinition.setImplementation(implementation);
}
operation.setValue(operationDefinition);
}
}
YTInterfaceDefinition tInterfaceDefinition = interfaceDefinition.getValue();
tInterfaceDefinition.setOperations(operations);
interfaceDefinition.setValue(tInterfaceDefinition);
}
nodeType.setInterfaces(interfaces);
return nodeType;
}
use of org.eclipse.winery.model.tosca.yaml.YTInterfaceDefinition in project winery by eclipse.
the class ToCanonical method convert.
private TInterfaceDefinition convert(YTInterfaceDefinition node, String id) {
if (Objects.isNull(node)) {
return null;
}
TInterfaceDefinition def = new TInterfaceDefinition();
def.setId(id);
def.setName(id);
def.setType(node.getType());
def.setInputs(convert(node.getInputs()));
def.setOperations(convert(node.getOperations()));
return def;
}
use of org.eclipse.winery.model.tosca.yaml.YTInterfaceDefinition in project winery by eclipse.
the class YamlReaderTest method testSupportedInterfaceDefinitions.
@Test
public void testSupportedInterfaceDefinitions() throws Exception {
YamlReader reader = new YamlReader();
InputStream is = getClass().getClassLoader().getResourceAsStream("yaml/supported_interfaces.yml");
YTServiceTemplate template = reader.parse(is);
Assertions.assertNotNull(template);
YTNodeType server = template.getNodeTypes().get("server");
Assertions.assertEquals(2, server.getArtifacts().size());
YTInterfaceDefinition standard = server.getInterfaces().get("Standard");
Assertions.assertEquals(2, standard.getOperations().size());
Assertions.assertEquals(1, standard.getInputs().size());
}
Aggregations