Skip to content
Snippets Groups Projects
Commit 78c007dc authored by sebastien Curt's avatar sebastien Curt
Browse files

Add workaround for dotFileGraphExporter if no entry Node has been set for a...

Add workaround for dotFileGraphExporter if no entry Node has been set for a referenced subgraph. Get first existing node in the first relation that reference the expected subgraph.
parent 266ddec8
Branches
No related tags found
1 merge request!11Resolve "Echec création du dot/svg graphviz"
Pipeline #242 passed
......@@ -97,15 +97,17 @@ public class Graph {
return graphNode;
}
// public GraphNode getNodesWithinSubgraph(String graphNumber){
// if (null == graphNumber) throw new IllegalArgumentException("GraphNumber cannot be null");
//
// var result = this.relations.stream().filter(e -> graphNumber.equals(e.getSubGraphReferenceLabel())).findFirst().get();
// if (null != result.getNode1()) return result.getNode1();
// if (null != result.getNode2()) return result.getNode2();
//
// throw new RuntimeException(String.format("Cannot find any graph node within '%s' subgraph", graphNumber));
// }
public GraphNode getNodesWithinSubgraph(String graphNumber){
if (null == graphNumber) throw new IllegalArgumentException("GraphNumber cannot be null");
var result = this.relations.stream().filter(e -> graphNumber.equals(e.getSubGraphReferenceLabel())).findFirst();
if (result.isPresent()) {
if (null != result.get().getNode1()) return result.get().getNode1();
if (null != result.get().getNode2()) return result.get().getNode2();
}
throw new RuntimeException(String.format("Cannot find any graph node within '%s' subgraph", graphNumber));
}
@Override
public java.lang.String toString() {
......
......@@ -70,10 +70,9 @@ public class DotFileGraphExporter implements GraphExporter {
* @param scope The current scope name
* @param g The graph to export
* @throws IOException An I/O error occurred
* @throws NoEntryNodeException Inconsistent nodes reference inside the graph
* @see IOException
*/
private void WriteCluster(String scope, Graph g) throws IOException, NoEntryNodeException {
private void WriteCluster(String scope, Graph g) throws IOException {
writer.append(String.format("subgraph cluster_%s{\n", scope.substring(1)))
.append(" color = black;\n")
.append(String.format(" label = \"%s\"", scope));
......@@ -133,11 +132,10 @@ public class DotFileGraphExporter implements GraphExporter {
*
* @param graphRelation A GraphRelation inside graph g
* @param g The current graphe to export
* @throws NoEntryNodeException One node in graphRelation is not found in g
* @throws IOException An I/O error occurred
* @see IOException
*/
private void write(GraphRelation graphRelation, Graph g) throws NoEntryNodeException, IOException {
private void write(GraphRelation graphRelation, Graph g) throws IOException {
GraphNode n1 = graphRelation.getNode1();
GraphNode n2 = graphRelation.getNode2();
......@@ -162,16 +160,15 @@ public class DotFileGraphExporter implements GraphExporter {
* @param g the global graph
* @return if graphNode is SubGraphRelationNode the node number of the referenced node in g,
* otherwise the node number of the current node in graphNode
* @throws NoEntryNodeException No corresponding node found in g for the corresponding inside graphNode
*/
private String getTextForSubGraphRelationOrGetNodeNumber(GraphNode graphNode, Graph g) throws NoEntryNodeException {
private String getTextForSubGraphRelationOrGetNodeNumber(GraphNode graphNode, Graph g) {
if (graphNode instanceof SubGraphReferenceNode) {
// try{
try{
return Integer.toString(g.getEntryNode(((SubGraphReferenceNode) graphNode).getReferenceNumber()).getNodeNumber());
// }
// catch (NoEntryNodeException ex){
// return Integer.toString(g.getNodesWithinSubgraph(((SubGraphReferenceNode) graphNode).getReferenceNumber()).getNodeNumber());
// }
}
catch (NoEntryNodeException ex){
return Integer.toString(g.getNodesWithinSubgraph(((SubGraphReferenceNode) graphNode).getReferenceNumber()).getNodeNumber());
}
} else {
return Integer.toString(graphNode.getNodeNumber());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment