use of org.opennms.features.topology.api.support.breadcrumbs.BreadcrumbStrategy in project opennms by OpenNMS.
the class BreadcrumbPathCalculatorTest method setUp.
@Before
public void setUp() {
final GraphProvider layer1 = new SimpleGraphBuilder("layer1").vertex("A1").vertex("A2").get();
final GraphProvider layer2 = new SimpleGraphBuilder("layer2").vertex("B1").vertex("B2").vertex("B3").vertex("B4").get();
final GraphProvider layer3 = new SimpleGraphBuilder("layer3").vertex("C1").vertex("C2").vertex("C3").vertex("C4").vertex("C5").vertex("C6").edge("e1", "C1", "C4").edge("e2", "C1", "C5").edge("e3", "C4", "C5").get();
final Map<VertexRef, List<VertexRef>> oppositesMap = Maps.newHashMap();
oppositesMap.put(new DefaultVertexRef("layer1", "A1"), Lists.newArrayList(new DefaultVertexRef("layer2", "B3"), new DefaultVertexRef("layer2", "B4")));
oppositesMap.put(new DefaultVertexRef("layer1", "A2"), Lists.newArrayList(new DefaultVertexRef("layer2", "B1"), new DefaultVertexRef("layer2", "B2")));
oppositesMap.put(new DefaultVertexRef("layer2", "B1"), Lists.newArrayList(new DefaultVertexRef("layer3", "C2")));
oppositesMap.put(new DefaultVertexRef("layer2", "B2"), Lists.newArrayList(new DefaultVertexRef("layer3", "C1")));
oppositesMap.put(new DefaultVertexRef("layer2", "B3"), Lists.newArrayList(new DefaultVertexRef("layer3", "C3")));
MetaTopologyProvider metaTopologyProvider = new MetaTopologyProvider() {
@Override
public GraphProvider getDefaultGraphProvider() {
return layer1;
}
@Override
public Collection<GraphProvider> getGraphProviders() {
return Lists.newArrayList(layer1, layer2, layer3);
}
@Override
public Collection<VertexRef> getOppositeVertices(VertexRef vertexRef) {
return Optional.ofNullable(oppositesMap.get(vertexRef)).orElse(Lists.newArrayList());
}
@Override
public GraphProvider getGraphProviderBy(String namespace) {
return getGraphProviders().stream().filter(p -> p.getNamespace().equals(namespace)).findFirst().orElse(null);
}
@Override
public BreadcrumbStrategy getBreadcrumbStrategy() {
return BreadcrumbStrategy.NONE;
}
@Override
public String getId() {
return getGraphProviders().stream().map(g -> g.getNamespace()).collect(Collectors.joining(":"));
}
};
DefaultTopologyService topologyService = new DefaultTopologyService();
topologyService.setServiceLocator(new SimpleServiceLocator(metaTopologyProvider));
DefaultTopologyServiceClient client = new DefaultTopologyServiceClient(topologyService);
client.setMetaTopologyId(metaTopologyProvider.getId());
client.setNamespace(metaTopologyProvider.getDefaultGraphProvider().getNamespace());
topologyServiceClient = client;
}
use of org.opennms.features.topology.api.support.breadcrumbs.BreadcrumbStrategy in project opennms by OpenNMS.
the class GeneratorConfigBuilder method build.
public GeneratorConfig build() {
final GeneratorConfig config = new GeneratorConfig();
if (label != null) {
config.setLabel(label);
}
if (providerId != null) {
config.setProviderId(providerId);
// if a label is not provided with new providerId
if (label == null)
config.setLabel(providerId);
}
if (preferredLayout != null) {
config.setPreferredLayout(preferredLayout);
}
if (hierarchy != null && !hierarchy.trim().isEmpty()) {
final List<String> layers = Arrays.asList(hierarchy.split(",")).stream().filter(h -> h != null && !h.trim().isEmpty()).map(h -> h.trim()).collect(Collectors.toList());
config.setLayerHierarchies(layers);
}
if (filter != null && !filter.trim().isEmpty()) {
final List<String> filters = Arrays.asList(filter.split(";")).stream().filter(h -> h != null && !h.trim().isEmpty()).map(h -> h.trim()).collect(Collectors.toList());
config.setFilters(filters);
}
if (breadcrumbStrategy != null) {
try {
BreadcrumbStrategy validValue = BreadcrumbStrategy.valueOf(breadcrumbStrategy);
config.setBreadcrumbStrategy(validValue.name());
} catch (IllegalArgumentException ex) {
LOG.warn("Given breadcrumbStrategy {} does not exist. Valid values are {}. Ignoring.", breadcrumbStrategy, BreadcrumbStrategy.values());
}
}
return config;
}
Aggregations