use of org.alien4cloud.tosca.model.definitions.Interface in project alien4cloud by alien4cloud.
the class TopologyUtils method filterInterfaces.
/**
* Extract all interfaces that have given operations, and filter out all operations that are not in the includedOperations
*
* @param interfaces interfaces to filter
* @param includedOperations operations that will be included in the result
* @return filter interfaces
*/
public static Map<String, Interface> filterInterfaces(Map<String, Interface> interfaces, Set<String> includedOperations) {
Map<String, Interface> result = Maps.newHashMap();
for (Map.Entry<String, Interface> interfaceEntry : interfaces.entrySet()) {
Map<String, Operation> operations = Maps.newHashMap();
for (Map.Entry<String, Operation> operationEntry : interfaceEntry.getValue().getOperations().entrySet()) {
if (includedOperations.contains(operationEntry.getKey())) {
operations.put(operationEntry.getKey(), operationEntry.getValue());
}
}
if (!operations.isEmpty()) {
Interface inter = new Interface();
inter.setDescription(interfaceEntry.getValue().getDescription());
inter.setOperations(operations);
result.put(interfaceEntry.getKey(), inter);
}
}
return result;
}
use of org.alien4cloud.tosca.model.definitions.Interface in project alien4cloud by alien4cloud.
the class ToscaSerializerUtils method formatRepositories.
public static String formatRepositories(String topologyArchiveName, String topologyArchiveVersion, Topology topology) {
StringBuilder buffer = new StringBuilder();
Set<String> repositoriesName = Sets.newHashSet();
for (NodeTemplate node : safe(topology.getNodeTemplates()).values()) {
for (DeploymentArtifact artifact : safe(node.getArtifacts()).values()) {
// Only generate repositories for the current topology
if (isInternalRepoArtifact(artifact, topologyArchiveName, topologyArchiveVersion)) {
buffer.append(" ").append(artifact.getRepositoryName()).append(":");
buffer.append("\n").append(formatRepository(artifact, 2)).append("\n");
}
}
for (Interface anInterface : safe(node.getInterfaces()).values()) {
for (Operation operation : safe(anInterface.getOperations()).values()) {
if (operation.getImplementationArtifact() != null && isInternalRepoArtifact(operation.getImplementationArtifact(), topologyArchiveName, topologyArchiveVersion)) {
buffer.append(" ").append(operation.getImplementationArtifact().getRepositoryName()).append(":");
buffer.append("\n").append(formatRepository(operation.getImplementationArtifact(), 2)).append("\n");
}
}
}
}
if (MapUtils.isNotEmpty(topology.getInputArtifacts())) {
topology.getInputArtifacts().values().forEach(inputArtifact -> {
if (StringUtils.isNotBlank(inputArtifact.getRepositoryURL()) && repositoriesName.add(inputArtifact.getRepositoryName())) {
buffer.append(" ").append(inputArtifact.getRepositoryName()).append(":");
buffer.append("\n").append(formatRepository(inputArtifact, 2)).append("\n");
}
});
}
buffer.setLength(buffer.length() - 1);
return buffer.toString();
}
use of org.alien4cloud.tosca.model.definitions.Interface in project alien4cloud by alien4cloud.
the class InterfacesParser method addInterfaceFromType.
private void addInterfaceFromType(ScalarNode node, Map<String, Interface> interfaces, ParsingContextExecution context) {
// FIXME look for interface type in the REPO
String interfaceType = InterfaceParser.getInterfaceType(node.getValue());
Interface interfaz = new Interface();
interfaz.setType(interfaceType);
interfaces.put(interfaceType, interfaz);
}
Aggregations