Commits

tbrugz  committed 16fa9af

resultset2graphml: added optional column EDGE_LABEL

  • Participants
  • Parent commits af73776

Comments (0)

Files changed (2)

File src_graphml/tbrugz/sqldump/graph/DumpResultSetGraphMLModel.java

 	@Override
 	public void outEdgeContents(Edge l, int level) {
 		WeightedEdge we = (WeightedEdge) l;
+		String label = we.getName();
+		String snippetId = (label==null || label.trim().equals(""))?
+				getSnippetId(we, "edge.nolabel"):getSnippetId(we, "edge");
 		if(we.getWidth()!=null) {
-			outSnippet(getSnippetId(we, "edge"), level, we.getName(), ""+we.getWidth());
+			outSnippet(snippetId, level, we.getName(), ""+we.getWidth());
 		}
 		else {
-			outSnippet(getSnippetId(we, "edge.nolabel"), level, we.getName(), ""+1);
+			outSnippet(snippetId, level, we.getName(), ""+1);
 		}
 	}
 }

File src_graphml/tbrugz/sqldump/graph/ResultSet2GraphML.java

 	public void setWidth(Double width) {
 		this.width = width;
 	}
+	
 }
 
 /*
 	static final String COL_TARGET = "TARGET";
 	static final String COL_EDGE_TYPE = "EDGE_TYPE"; //optional
 	static final String COL_EDGE_WIDTH = "EDGE_WIDTH"; //optional
+	static final String COL_EDGE_LABEL = "EDGE_LABEL"; //optional
 	
 	//edge-only cols
 	static final String COL_SOURCE_TYPE = "SOURCE_TYPE"; //optional
 		boolean hasTargetType = false;
 		boolean hasEdgeWidth = false;
 		boolean hasEdgeType = false;
+		boolean hasEdgeLabel = false;
 		if(edgeOnlyStrategy) {
 			//List<String> newAllCols = new ArrayList<String>();
 			//newAllCols.addAll(allCols); newAllCols.addAll(Arrays.asList(EDGEONLY_XTRA_COLS));
 		}
 		hasEdgeWidth = hasOptionalColumn(rsEdges.getMetaData(), COL_EDGE_WIDTH, qid);
 		hasEdgeType = hasOptionalColumn(rsEdges.getMetaData(), COL_EDGE_TYPE, qid);
+		hasEdgeLabel = hasOptionalColumn(rsEdges.getMetaData(), COL_EDGE_LABEL, qid);
 		if(!hasAllColumns(rsEdges.getMetaData(), allCols)) { return null; }
 		
 		while(rsEdges.next()) {
 			}
 			if(hasEdgeWidth) {
 				edgeWidth = rsEdges.getDouble(COL_EDGE_WIDTH);
-				edge.setName(nf.format(edgeWidth));
+				if(!hasEdgeLabel) {
+					edge.setName(nf.format(edgeWidth));
+				}
 				edge.setWidth(edgeWidth);
 
 				double width = useAbsolute? Math.abs(edgeWidth) : edgeWidth;
 			if(hasEdgeType) {
 				edgeType = rsEdges.getString(COL_EDGE_TYPE);
 			}
+			if(hasEdgeLabel) {
+				edge.setName(rsEdges.getString(COL_EDGE_LABEL) 
+					//+ ((edge.getName()!=null)?" / "+edge.getName():"")
+					);
+			}
 			edge.setSource(source);
 			edge.setTarget(target);
 			edge.setStereotype(edgeType);