/** * * <!-- begin-user-doc --> * This method adds the {@link Edge}s, {@link Node}s, {@link Label}s and {@link Decorator} from * another graph to the collections maintained by this graph. * * <p>It does not attempt to resolve connections between Edges and the Nodes they reference. * <!-- end-user-doc --> * * @generated NOT */ public void addGraph(final Graph graph, IdentifiableFilter filter) { IdentifiableFilterImpl _filter = (IdentifiableFilterImpl) filter; EMap<URI, Edge> edges = graph.getEdges(); EMap<URI, Node> nodes = graph.getNodes(); EMap<URI, NodeLabel> nodeLabels = graph.getNodeLabels(); EMap<URI, Label> graphLabels = graph.getGraphLabels(); if (filter != null) { _filter.filterEdges(edges); _filter.filterNodes(nodes); _filter.filterNodeLabels(nodeLabels); _filter.filterLabels(graphLabels); } getEdges().addAll(edges); getNodes().addAll(nodes); getNodeLabels().addAll(nodeLabels); getDecorators().addAll(graph.getDecorators()); // We need to update the graph labels to the new graph for (final Iterator<Label> graphLabelIter = graphLabels.values().iterator(); graphLabelIter.hasNext(); ) { final Label graphLabel = graphLabelIter.next(); graphLabel.setURIOfIdentifiableToBeLabeled(getURI()); putGraphLabel(graphLabel); } // for each new graph label getDynamicLabels().addAll(graph.getDynamicLabels()); getUnresolvedIdentifiables().addAll(graph.getUnresolvedIdentifiables()); } // addGraph
/** * @see org.eclipse.stem.common.impl.IdentifiableImpl#setURI(org.eclipse.emf.common.util.URI) * @generated NOT */ @Override public void setURI(URI newURI) { super.setURI(newURI); // Now go through all the graph labels and update then to reference the // new URI for (final Iterator<Label> labelIter = getGraphLabels().values().iterator(); labelIter.hasNext(); ) { final Label label = labelIter.next(); label.setURIOfIdentifiableToBeLabeled(newURI); } // for } // setURI
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated NOT */ public void putGraphLabel(Label label) { getGraphLabels().put(label.getURI(), label); // Dynamic? if (label instanceof DynamicLabel) { // Yes addDynamicLabel((DynamicLabel) label); } // if DynamicLabel } // putGraphLabel
/** @see org.eclipse.stem.common.impl.IdentifiableImpl#sane() */ @Override public boolean sane() { boolean retValue = super.sane(); // This is the number of labels that each node references int nodeLabelCount = 0; int dynamicLabelCount = 0; // Nodes if (nodes != null) { // Yes for (final Iterator<Node> nodeIter = getNodes().values().iterator(); nodeIter.hasNext() && retValue; ) { final Node node = nodeIter.next(); retValue = retValue && node.sane(); assert retValue; nodeLabelCount += node.getLabels().size(); // How many dynamic labels? for (final Iterator<NodeLabel> labelIter = node.getLabels().iterator(); labelIter.hasNext(); ) { final Label label = labelIter.next(); if (label instanceof DynamicLabel) { dynamicLabelCount++; retValue = false; // The dynamic label should be in the collection of // dynamic labels maintained by the graph for (DynamicLabel dl : getDynamicLabels()) { if (dl == label) { retValue = true; break; } } // for each dynamic label assert retValue; } // if DynamicLabel // The label should be in the collection of node labels retValue = retValue && getNodeLabels().containsKey(label.getURI()); assert retValue; } // for each label of the node } // for each node } // if // Edges? if (edges != null) { // Yes for (final Iterator<Edge> edgeIter = getEdges().values().iterator(); edgeIter.hasNext() && retValue; ) { final Edge edge = edgeIter.next(); retValue = retValue && edge.sane(); assert retValue; // Is the edge's label dynamic? if (edge.getLabel() instanceof DynamicLabel) { // Yes dynamicLabelCount++; } } // for each edge } // if // Node Labels? if (nodeLabels != null) { // Yes // The number of node labels should match the number we counted // above...not true for graph fragments that might have labels for // nodes in other (sub) graph fragments. // retValue = retValue && nodeLabelCount == // getNodeLabels().getSize(); // assert retValue; for (final Iterator<NodeLabel> labelIter = getNodeLabels().values().iterator(); labelIter.hasNext() && retValue; ) { final NodeLabel nodeLabel = labelIter.next(); retValue = retValue && nodeLabel.sane(); assert retValue; } // for each node label } // if if (graphLabels != null) { // Yes for (final Iterator<Label> graphLabelIter = getGraphLabels().values().iterator(); graphLabelIter.hasNext(); ) { final Label graphLabel = graphLabelIter.next(); retValue = retValue && graphLabel.sane(); assert retValue; if (graphLabel instanceof DynamicLabel) { dynamicLabelCount++; } } } // if graphLabels // Dynamic Labels? if (dynamicLabels != null) { // Yes // The number of dynamic labels should equal the count retValue = dynamicLabelCount == getNumDynamicLabels(); assert retValue; for (final Iterator<DynamicLabel> dynamiclIter = getDynamicLabels().iterator(); dynamiclIter.hasNext() && retValue; ) { final DynamicLabel dynamicLabel = dynamiclIter.next(); retValue = retValue && dynamicLabel.sane(); assert retValue; } // for each dynamic label } // if return retValue; } // sane