public ToscaNode getReferenceNode() { return vertexSet().stream().findAny().orElse(null); } }
public Map<ToscaNode, ToscaNode> getSubGraphMappingAsMap(GraphMapping mapping, ToscaGraph subGraph) { Map<ToscaNode, ToscaNode> result = new HashMap<>(); for (ToscaNode node : subGraph.vertexSet()) { Optional.of(mapping.getVertexCorrespondence(node, false)).map(vertex -> (ToscaNode) vertex).ifPresent(vertex -> result.put(node, vertex)); } return result; }
public ToscaNode getNode(String id) { return vertexSet().stream().filter(n -> StringUtils.equals(id, n.getId())).findFirst().orElse(null); }
public ArrayList<String> getNodeIdsToBeReplaced() { ArrayList<String> ids = new ArrayList<>(); this.detectorGraph.vertexSet().forEach(toscaNode -> ids.add(graphMapping.getVertexCorrespondence(toscaNode, false).getTemplate().getId()) ); return ids; } }
public boolean isApplicable(RefinementCandidate candidate, TTopologyTemplate topology) { return candidate.getDetectorGraph().vertexSet() .stream() .allMatch(vertex -> { TNodeTemplate matchingNode = candidate.getGraphMapping().getVertexCorrespondence(vertex, false).getTemplate(); return this.canRedirectExternalRelations(candidate, matchingNode, topology); }); }
private Map<String, Map<String, Integer>> calculateNewPositions(ToscaGraph detectorGraph, GraphMapping<ToscaNode, ToscaEdge> mapping, TTopologyTemplate refinementStructure) { HashMap<String, Map<String, Integer>> coordinates = new HashMap<>(); int[] topLeftOriginal = {-1, -1}; int[] topLeftReplacement = {-1, -1}; detectorGraph.vertexSet().forEach(toscaNode -> { ToscaNode node = mapping.getVertexCorrespondence(toscaNode, false); getTopLeft(node.getTemplate().getX(), node.getTemplate().getY(), topLeftOriginal); }); refinementStructure.getNodeTemplates().forEach( tNodeTemplate -> getTopLeft(tNodeTemplate.getX(), tNodeTemplate.getY(), topLeftReplacement) ); refinementStructure.getNodeTemplates().forEach(nodeTemplate -> { int x = Integer.parseInt(nodeTemplate.getX()); int y = Integer.parseInt(nodeTemplate.getY()); HashMap<String, Integer> newCoordinates = new HashMap<>(); newCoordinates.put("x", (x - topLeftReplacement[0]) + topLeftOriginal[0]); newCoordinates.put("y", (y - topLeftReplacement[1]) + topLeftOriginal[1]); coordinates.put(nodeTemplate.getId(), newCoordinates); }); return coordinates; }
refinement.getDetectorGraph().vertexSet() .forEach(vertex -> {