Customer Portal

"An edge without source node cannot be added into the g

Comments 6

  • Avatar
    avackova
    0
    Comment actions Permalink
    Hi, you need to assign edges to nodes:
          nodeEingabe.addOutputPort(0, inEdge);
    nodeCopy.addInputPort(0, inEdge);
    nodeCopy.addOutputPort(0, outEdge);
    nodeAusgabe.addInputPort(0, outEdge);
    and switch over order of adding elements to graph: first nodes, then edges.
    Example for creating graph in java code is javaExamples\testGraphSort.java
  • Avatar
    crazybird
    0
    Comment actions Permalink
    Hi!

    Thanks for that quick answer.

    But I already had the assignment in my code, just below the line

    // Data - Flows erstellen...


    I now changed this to the code you wrote, but I still get the same

    "Edge cannot be added into the phase without source component." - error message.

    Thanks a lot!
  • Avatar
    avackova
    0
    Comment actions Permalink
    Try in such order:
          TransformationGraph graph= new TransformationGraph();

    Phase phase= new Phase(0);

    Edge inEdge = new Edge("InEdge",eingabeStruktur);
    Edge outEdge=new Edge("OutEdge",eingabeStruktur);

    Node nodeEingabe = new DelimitedDataReader("csvLesen","c:/blz.csv"); //TODO TEST
    Node nodeCopy = new SimpleCopy("SIMPLE_COPY");
    Node nodeAusgabe = new XLSWriter("excelSchreiben","c:/out.xls",false);

    nodeEingabe.addOutputPort(0, inEdge);
    nodeCopy.addInputPort(0, inEdge);
    nodeCopy.addOutputPort(0, outEdge);
    nodeAusgabe.addInputPort(0, outEdge);

    try {
    // Phase zum Graphen hinzufügen:
    graph.addPhase(phase);

    // Knoten hinzufügen

    phase.addNode(nodeEingabe);
    phase.addNode(nodeCopy);
    phase.addNode(nodeAusgabe);


    // Kanten hinzufügen

    phase.addEdge(inEdge);
    phase.addEdge(outEdge);

    GraphRuntimeContext ctx= new GraphRuntimeContext();
    ctx.setVerboseMode(true);

    GraphExecutor executor= new GraphExecutor();
    GraphExecutor.initGraph(graph);

    executor.runGraph(graph,ctx);
  • Avatar
    crazybird
    0
    Comment actions Permalink
    Thanks very much, but in time I got the code working, but now when I change the DelimitedDataWriter to XLSWriter , it only outputs a 0-byte .XLS - File, the DelimetedDataWriter works.

    Any ideas? Thank you again!

    Here my code:

    package at.sozvers.bva.loewe;

    import java.util.concurrent.Future;

    import org.jetel.component.DelimitedDataReader;
    import org.jetel.component.DelimitedDataWriter;
    import org.jetel.component.SimpleCopy;
    import org.jetel.component.XLSWriter;
    import org.jetel.data.Defaults;
    import org.jetel.exception.ComponentNotReadyException;
    import org.jetel.graph.Edge;
    import org.jetel.graph.Node;
    import org.jetel.graph.Phase;
    import org.jetel.graph.Result;
    import org.jetel.graph.TransformationGraph;
    import org.jetel.graph.runtime.GraphExecutor;
    import org.jetel.graph.runtime.GraphRuntimeContext;
    import org.jetel.metadata.DataFieldMetadata;
    import org.jetel.metadata.DataRecordMetadata;
    import org.jetel.plugin.Plugins;

    public class BlzCloverTransform {

    private static final Phase _PHASE_1=new Phase(1);
    private static final Phase _PHASE_2=new Phase(2);

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Defaults.init(""); //TODO anpassen

    Plugins.init("c:/cloverETL/plugins"); //TODO dir anpassen

    // Struktur des Eigabefiles:
    DataRecordMetadata eingabeStruktur = new DataRecordMetadata("CSVein",DataRecordMetadata.DELIMITED_RECORD);

    // "null" deshalb, weil defaul- Delimiter benutzt werden (unten)
    eingabeStruktur.addField(new DataFieldMetadata("blz",DataFieldMetadata.STRING_FIELD,null));
    eingabeStruktur.addField(new DataFieldMetadata("bankname",DataFieldMetadata.STRING_FIELD,null));

    eingabeStruktur.setFieldDelimiter(";");
    eingabeStruktur.setRecordDelimiters("\n");


    TransformationGraph graph= new TransformationGraph();

    Edge inEdge = new Edge("InEdge",eingabeStruktur);
    Edge outEdge= new Edge("OutEdge",eingabeStruktur);

    Node nodeRead = new DelimitedDataReader("DataParser","c:/blz.csv"); //TODO TEST
    Node nodeCopy = new SimpleCopy("EinfachKopieren");
    Node nodeWrite = new XLSWriter("DataWriter","c:/out.xls",false);

    nodeRead.addOutputPort(0,inEdge);
    nodeCopy.addInputPort(0,inEdge);
    nodeCopy.addOutputPort(0, outEdge);
    nodeWrite.addInputPort(0,outEdge);


    try {
    // Phase zum Graphen hinzufügen:
    graph.addPhase(_PHASE_1);

    _PHASE_1.addNode(nodeRead);
    _PHASE_1.addNode(nodeCopy);

    graph.addPhase(_PHASE_2);
    _PHASE_2.addNode(nodeWrite);
    graph.addEdge(inEdge);
    graph.addEdge(outEdge);

    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    GraphRuntimeContext runtimeContext = new GraphRuntimeContext();
    runtimeContext.setUseJMX(false);
    runtimeContext.setVerboseMode(true);

    GraphExecutor executor = new GraphExecutor();

    try {
    GraphExecutor.initGraph(graph);
    } catch (ComponentNotReadyException e) {
    System.out.println("Failed graph initialization!\n" + e.getMessage());
    return;
    }

    Future<Result> result;
    try{
    result = executor.runGraph(graph, runtimeContext);
    while (result.isDone()) {;}
    if (!result.get().equals(Result.FINISHED_OK)){
    System.out.println(result.get().message());
    System.out.println("Failed graph execution!");
    return;
    }
    }catch (Exception e) {
    System.out.println("Failed graph execution!\n" + e.getMessage());
    return;
    }

    System.out.println("ende");

    }

    }
  • Avatar
    avackova
    0
    Comment actions Permalink
    The file is empty, because XLSWriter flushes all data to file during graph freeing. After graph execution you have to close graph resources by free method:
    graph.free();
  • Avatar
    crazybird
    0
    Comment actions Permalink
    thank you very much, you helped me much.

    Unfortunately the documentation of CloverETL is incomplete, especially the docu about using Clover within Java.

    For example I can't find anything about GraphExecutor- class within the wiki.

    Stefan

Please sign in to leave a comment.