Problem in spliting record

hello
i want to develope a component which split record into two different record

for example input is sales detail then one output is date and other is remaining data.

how to do this?
how can i create new empy dataRecord and asign new data value to each of its field in my run methode?

hello

i have created my SplitRecord class and modified component factory

then when i execute my testSplit graph i get exception that INPUT port has no out put port but there is in my graph.

i am providing full resources so

this is my graph
[testSplit.grf]

<?xml version="1.0" encoding="UTF-8"?> 0 and sv.current\_version and sv.sales\_representativ=em.id and em.person\_master\_id=pm.id and sd.sv\_id=sv.id"/>

here what i get on console

[console dump]
*** CloverETL framework/transformation graph runner ver1.7, (c) 2002-05 D.Pavlis, released under GNU Lesser General Public License ***

Graph definition file: E:/CloverETL/Examples/testSplit.txt
phase No. 0
phase No. 0
java.lang.NullPointerException
at org.jetel.graph.TransformationGraphXMLReaderWriter.instantiateNodes(TransformationGraphXMLReaderWriter.java:381)
at org.jetel.graph.TransformationGraphXMLReaderWriter.instantiatePhases(TransformationGraphXMLReaderWriter.java:348)
at org.jetel.graph.TransformationGraphXMLReaderWriter.read(TransformationGraphXMLReaderWriter.java:242)
at org.jetel.main.runGraph.main(runGraph.java:124)
Initializing DB connection: jdbc:postgresql://192.168.0.3/vtech0506 … OK
Initializing DB connection: jdbc:postgresql://192.168.0.3/olap … OK
[Clover] starting WatchDog thread …
[WatchDog] Thread started.
[WatchDog] Running on 1 CPU(s) max available memory for JVM 1639 KB
[Clover] Initializing phase: 0
initializing edges: all edges initialized successfully…
initializing nodes:
INPUT …FAILED !
Nov 12, 2005 5:12:02 PM org.jetel.graph.Phase init
SEVERE: At least one output port has to be defined for node INPUT
[WatchDog] !!! Phase finished with error - stopping graph run !!!
Failed starting graph !
[Clover] WatchDog thread finished - total execution time: 0 (sec)
[Clover] !!! Graph execution finished with errors !!!

here is my SplitRecord class

/*
* Created on Nov 10, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.jetel.component;

/**
* @author Deepak
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.io.IOException;

import org.jetel.data.DataRecord;
import org.jetel.exception.ComponentNotReadyException;
import org.jetel.graph.InputPort;
import org.jetel.graph.Node;
import org.jetel.graph.OutputPort;

/**
* @author Deepak
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class SplitRecord extends Node{

public static final String COMPONENT_TYPE=“SPLIT_RECORD”;

public SplitRecord(String id)
{
super(id);
}

public String getType() {
return COMPONENT_TYPE;
}

public void init() throws ComponentNotReadyException {
// test that we have at least one input port and one output
if (inPorts.size()<1){
throw new ComponentNotReadyException("At least one input port has to be defined for node " + id);
}else if (outPorts.size()<1){
throw new ComponentNotReadyException("At least one output port has to be defined for node " + id);
}
}

public void run()
{
boolean isDriverDifferent;

// get all ports involved
InputPort inPort = getInputPort(0);
DataRecord driverRecordread = new DataRecord(inPort.getMetadata());
driverRecordread.init();

int index=0;

// get array of all ports defined/connected - use collection Collection - getInPorts();
OutputPort outPorts;
outPorts = (OutputPort) getOutPorts().toArray(new OutputPort[0]);

System.out.println("the no. of out put pin in split is " + outPorts.length);

int cou = new int[5];
Integer timeid=new Integer (1);

while (runIt)
{
try
{
driverRecordread = inPort.readRecord(driverRecordread);
if(driverRecordread != null)
{
DataRecord record0 = new DataRecord(outPorts[0].getMetadata());
record0.init();
record0.getField(0).setValue(driverRecordread.getField(1).getValue());

DataRecord record1=new DataRecord(outPorts[1].getMetadata());
record1.init();
record1.getField(0).setValue(new Integer(1));
record1.getField(1).setValue(driverRecordread.getField(0).getValue());
record1.getField(2).setValue(timeid );
record1.getField(3).setValue(driverRecordread.getField(2).getValue());
record1.getField(4).setValue(driverRecordread.getField(3).getValue());
record1.getField(5).setValue(driverRecordread.getField(4).getValue());
record1.getField(6).setValue(driverRecordread.getField(5).getValue());
record1.getField(7).setValue(“KG”);
record1.getField(8).setValue(driverRecordread.getField(6).getValue());
record1.getField(9).setValue(driverRecordread.getField(7).getValue());
record1.getField(10).setValue(driverRecordread.getField(8).getValue());
record1.getField(11).setValue(driverRecordread.getField(9).getValue());

outPorts[0].writeRecord(record0 );
outPorts[1].writeRecord(record1 );

}else
{
break;
}
} catch (IOException ex)
{
resultMsg = ex.getMessage();
resultCode = Node.RESULT_ERROR;
closeAllOutputPorts();
System.out.println(“IO error in split:” + ex.getMessage());
ex.printStackTrace();
return;
} catch (Exception ex)
{
resultMsg = ex.getMessage();
resultCode = Node.RESULT_FATAL_ERROR;
System.out.println(“error in split:” + ex.getMessage());
ex.printStackTrace();
return;
}
}

broadcastEOF();

if (runIt) {
resultMsg = “OK”;
} else
{
resultMsg = “STOPPED”;
}
resultCode = Node.RESULT_OK;
}

public boolean checkConfig() {
return true;
}

}

i made this entry in component factory class

registerComponent(SplitRecord.COMPONENT_TYPE,“org.jetel.component.SplitRecord”);

so
there is two thing wrong here

  1. though there is output port in INPUT node
    the input node can’t initialise due to it not get any output port

  2. graphNode.setPhase(phaseNum);
    instruction in org.jetel.graph.TransformationGraphXMLReaderWriter.instantiateNodes() function throws nullpontexception

if any body figure out problem then inform me

thanks in advance

Creating a new data record is easy. Following example shows how to create metadata object first and then how to create data record based on this:

-----------------
DataRecordMetadata metadata=new DataRecordMetadata(“TestInput”,DataRecordMetadata.DELIMITED_RECORD);

metadata.addField(new DataFieldMetadata(“Name”,DataFieldMetadata.STRING_FIELD, “;”));
metadata.addField(new DataFieldMetadata(“Age”,DataFieldMetadata.NUMERIC_FIELD, “|”));
metadata.addField(new DataFieldMetadata(“City”,DataFieldMetadata.STRING_FIELD, “\n”));

DataRecord record = new DataRecord(metadata);
record.init();

// assign value to Name field:
record.getField(0).setValue(“John Brown”);

// assign value to Age field:
record.getField(“Age”).setValue(31);

-----------------
Note: Unless you want to use the record
to be output to text file, it does not matter
whether you create DELIMITED_RECORD
and which delimiters you assign to fields - any
character(s) will work.

Internally, the data (record) is stored as
variable-length data structure. You may
later redefine the (text) formatting by
creating record with the same structure but
different delimiters.

For info about custom components building, see "Step-by-step component building " on
Clover’s web site. Documentation section.