Quantcast
Channel: Pentaho Community Forums
Viewing all articles
Browse latest Browse all 16689

Table to GraphML (Recursive XML)

$
0
0
I am attempting to convert a table into GraphML and view it in yED. This is an XML-based graph format.

Since the depth/height of the stack can vary, I need a recursive solution. I am not sure the standard XML Add/Join will work due to this requirement.



Here is a sample input:
Node Type Height Parent
g1 group 2 NULL
g2 group 1 g1
n1 node 0 n1

Here is the expected output:
Code:

<node id="g1">
    <graph>
        <node id="g1::g2">
            <graph>
                <node id="g2:n1">
                </node>
            </graph>
        </node>   
    </graph>
</node>

In yED:
yED.PNG


Non-working recursive solution:
Code:

public String AutosysToGraphML(Object[] row) throws KettleException {
    String nodeID = row.node;
    if (!row.parent.isEmpty()) {
        nodeID = row.parent + "::" + row.node;
    }
   
    AutosysToGraphML = AutosysToGraphML + "<node id=\"" + nodeID + "\">";
   
    if (row.isGroup) {
        AutosysToGraphML = AutosysToGraphML + "<graph>";
    }
           
    if (row.height) {
        return AutosysToGraphML;
    } else {
        row.next;
        AutosysToGraphML(row);
    }
   
   
    if (row.isGroup) {
        AutosysToGraphML = AutosysToGraphML + "</graph>";
    }   
    AutosysToGraphML = AutosysToGraphML + "</node>";   
}

Would anyone be able to point in the right direction?
Attached Images

Viewing all articles
Browse latest Browse all 16689

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>