public BusinessServiceVertex(GraphVertex graphVertex) { this(graphVertex.getBusinessService(), graphVertex.getLevel()); }
private void createRowForVertex(BusinessServiceGraph graph, GraphVertex graphVertex, BusinessServiceRow parentRow) { final BusinessService businessService = graphVertex.getBusinessService(); if (businessService == null) { return; } final long rowId = rowIdCounter.incrementAndGet(); final Long parentBusinessServiceId = parentRow != null ? parentRow.getBusinessService().getId() : null; final BusinessServiceRow row = new BusinessServiceRow(rowId, businessService, parentBusinessServiceId); if (parentRow != null) { rowIdToParentRowIdMapping.put(rowId, parentRow.getRowId()); } addBean(row); // Recurse with all of the children graph.getOutEdges(graphVertex).stream() .map(e -> graph.getOpposite(graphVertex, e)) .filter(v -> v.getBusinessService() != null) .sorted((v1, v2) -> v1.getBusinessService().getName().compareTo(v2.getBusinessService().getName())) .forEach(v -> createRowForVertex(graph, v, row)); }
private void createRowForVertex(BusinessServiceGraph graph, GraphVertex graphVertex, BusinessServiceRow parentRow) { final BusinessService businessService = graphVertex.getBusinessService(); if (businessService == null) { return; } final long rowId = rowIdCounter.incrementAndGet(); final Long parentBusinessServiceId = parentRow != null ? parentRow.getBusinessService().getId() : null; final BusinessServiceRow row = new BusinessServiceRow(rowId, businessService, parentBusinessServiceId); if (parentRow != null) { rowIdToParentRowIdMapping.put(rowId, parentRow.getRowId()); } addBean(row); // Recurse with all of the children graph.getOutEdges(graphVertex).stream() .map(e -> graph.getOpposite(graphVertex, e)) .filter(v -> v.getBusinessService() != null) .sorted((v1, v2) -> v1.getBusinessService().getName().compareTo(v2.getBusinessService().getName())) .forEach(v -> createRowForVertex(graph, v, row)); }
@Override public String transform(GraphVertex vertex) { if (vertex.getBusinessService() != null) { return String.format("BS[%s]", vertex.getBusinessService().getName()); } if (vertex.getIpService() != null) { IpService ipService = vertex.getIpService(); return String.format("IP_SERVICE[%s,%s]", ipService.getId(), ipService.getServiceName()); } if (vertex.getReductionKey() != null) { return String.format("RK[%s]", vertex.getReductionKey()); } return "UNKNOWN"; } });
/** * Refreshes table entries. */ public void refresh() { final com.google.common.collect.Table<Long, Optional<Long>, Boolean> expandState = getCurrentExpandState(); final BusinessServiceContainer newContainer = new BusinessServiceContainer(); if (!Strings.isNullOrEmpty(businessServiceNameFilter)) { newContainer.addContainerFilter(new BusinessServiceFilter(newContainer, businessServiceNameFilter)); } // Build a graph using all of the business services stored in the database // We don't use the existing graph, since it only contains the services know by the state machine List<BusinessService> allBusinessServices = businessServiceManager.getAllBusinessServices(); final BusinessServiceGraph graph = businessServiceManager.getGraph(allBusinessServices); // Recursively generate the table rows, starting with the roots graph.getVerticesByLevel(0).stream() .filter(v -> v.getBusinessService() != null) .sorted((v1, v2) -> v1.getBusinessService().getName().compareTo(v2.getBusinessService().getName())) .forEach(v -> newContainer.addRow(graph, v)); // Make it hierarchical Hierarchical hierarchicalContainer = createHierarchicalContainer(newContainer); // Update datasource setContainerDataSource(hierarchicalContainer); setVisibleColumns("name", "links", "edit / delete"); // reset visible columns // Restore the previous collapsed state List<BusinessServiceRow> rows = getItemIds().stream().map(itemId -> getItem(itemId).getBean()).collect(Collectors.toList()); applyExpandState(expandState, rows); }
/** * Refreshes table entries. */ public void refresh() { final com.google.common.collect.Table<Long, Optional<Long>, Boolean> expandState = getCurrentExpandState(); final BusinessServiceContainer newContainer = new BusinessServiceContainer(); if (!Strings.isNullOrEmpty(businessServiceNameFilter)) { newContainer.addContainerFilter(new BusinessServiceFilter(newContainer, businessServiceNameFilter)); } // Build a graph using all of the business services stored in the database // We don't use the existing graph, since it only contains the services know by the state machine List<BusinessService> allBusinessServices = businessServiceManager.getAllBusinessServices(); final BusinessServiceGraph graph = businessServiceManager.getGraph(allBusinessServices); // Recursively generate the table rows, starting with the roots graph.getVerticesByLevel(0).stream() .filter(v -> v.getBusinessService() != null) .sorted((v1, v2) -> v1.getBusinessService().getName().compareTo(v2.getBusinessService().getName())) .forEach(v -> newContainer.addRow(graph, v)); // Make it hierarchical Hierarchical hierarchicalContainer = createHierarchicalContainer(newContainer); // Update datasource setContainerDataSource(hierarchicalContainer); setVisibleColumns("name", "links", "edit / delete"); // reset visible columns // Restore the previous collapsed state List<BusinessServiceRow> rows = getItemIds().stream().map(itemId -> getItem(itemId).getBean()).collect(Collectors.toList()); applyExpandState(expandState, rows); }
public static AbstractBusinessServiceVertex createTopologyVertex(GraphVertex graphVertex) { if (graphVertex.getBusinessService() != null) { return new BusinessServiceVertex(graphVertex); } if (graphVertex.getIpService() != null) { return new IpServiceVertex(graphVertex); } if (graphVertex.getReductionKey() != null) { return new ReductionKeyVertex(graphVertex); } if (graphVertex.getApplication() != null) { return new ApplicationVertex(graphVertex); } throw new IllegalArgumentException("Cannot convert GraphVertex to BusinessServiceVertex: " + graphVertex); } }
private void onStatusUpdated(BusinessServiceGraph graph, GraphVertex vertex, Status previousStatus) { BusinessService businessService = vertex.getBusinessService(); if (businessService == null) { // Only send updates for business services (and not for reduction keys) return; } if (graph != m_g) { // We're working with a new graph, only send a status update if the new status is different // than the one in the previous graph GraphVertex previousVertex = m_g.getVertexByBusinessServiceId(businessService.getId()); if (previousVertex != null && vertex.getStatus().equals(previousVertex.getStatus())) { // The vertex for this business service in the previous graph // had the same status, don't issue any notifications return; } } for (BusinessServiceStateChangeHandler handler : m_handlers) { handler.handleBusinessServiceStateChanged(businessService, vertex.getStatus(), previousStatus); } }