/** * Creates a new filter using the given parameters. * * @param configuration * The configuration to use. * @param projectContext * The project context to use. */ public OperationDependencyGraphAllocationFilter(final Configuration configuration, final IProjectContext projectContext) { super(configuration, projectContext, new OperationAllocationDependencyGraph(new AllocationComponentOperationPair( AbstractSystemSubRepository.ROOT_ELEMENT_ID, OperationRepository.ROOT_OPERATION, AllocationRepository.ROOT_ALLOCATION_COMPONENT))); }
private ElementGrouping groupElements(final OperationAllocationDependencyGraph graph) { final ConcurrentMap<ExecutionContainer, Set<AllocationComponent>> allocationComponentGrouping = new ConcurrentHashMap<>(); final ConcurrentMap<AllocationComponent, Set<DependencyGraphNode<AllocationComponentOperationPair>>> operationGrouping = new ConcurrentHashMap<>(); for (final DependencyGraphNode<AllocationComponentOperationPair> vertex : graph.getVertices()) { final AllocationComponent allocationComponent = vertex.getEntity().getAllocationComponent(); final ExecutionContainer executionContainer = allocationComponent.getExecutionContainer(); // Update map execution container -> allocation components Set<AllocationComponent> allocationComponents = allocationComponentGrouping.get(executionContainer); if (allocationComponents == null) { allocationComponents = new HashSet<>(); allocationComponentGrouping.put(executionContainer, allocationComponents); } allocationComponents.add(allocationComponent); // Update map allocation component -> operations Set<DependencyGraphNode<AllocationComponentOperationPair>> operations = operationGrouping.get(allocationComponent); if (operations == null) { operations = new HashSet<>(); operationGrouping.put(allocationComponent, operations); } operations.add(vertex); } return new ElementGrouping(allocationComponentGrouping, operationGrouping); }
@Override protected String formatDependencyGraph(final OperationAllocationDependencyGraph graph, final boolean includeWeights, final boolean useShortLabels, final boolean plotLoops) { final StringBuilder builder = new StringBuilder(); this.appendGraphHeader(builder); final ElementGrouping grouping = this.groupElements(graph); this.createGraph(grouping, builder, useShortLabels); graph.traverseWithVerticesFirst(new EdgeVisitor(builder, includeWeights, plotLoops, useShortLabels)); this.appendGraphFooter(builder); return builder.toString(); }