use of org.eclipse.winery.model.tosca.yaml.YTImplementation 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;
}
Aggregations