hello sir
i have implemented SPLIT_RECORD component which read one record and write two to two differne toutput port.
but when i use SPLIT_RECORD in my graph its give fatal error in graph initialization.
here is my graph
<?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"/> import org.jetel.component.DataRecordTransform; import org.jetel.data.\*; import java.util.Date;public class reformatOrders extends DataRecordTransform{
int counter=1;
int field=0;
public boolean transform(DataRecord source, DataRecord target){
try{
Date saleDate=GetVal.getDate(source[0],“date”);
SetVal.setInt(target[0],“time_id”,counter);
SetVal.setInt(target[0],“day”,saleDate.getDate());
SetVal.setInt(target[0],“month”,saleDate.getMonth()+1);
switch(saleDate.getMonth()+1)
{
case 1:
SetVal.setString(target[0],“month_name”,“January”);
SetVal.setString(target[0],“quarter”,“Q1”);
break;
case 2:
SetVal.setString(target[0],“month_name”,“Fabruary”);
SetVal.setString(target[0],“quarter”,“Q1”);
break;
case 3:
SetVal.setString(target[0],“month_name”,“March”);
SetVal.setString(target[0],“quarter”,“Q1”);
break;
case 4:
SetVal.setString(target[0],“month_name”,“April”);
SetVal.setString(target[0],“quarter”,“Q2”);
break;
case 5:
SetVal.setString(target[0],“month_name”,“May”);
SetVal.setString(target[0],“quarter”,“Q2”);
break;
case 6:
SetVal.setString(target[0],“month_name”,“June”);
SetVal.setString(target[0],“quarter”,“Q2”);
break;
case 7:
SetVal.setString(target[0],“month_name”,“July”);
SetVal.setString(target[0],“quarter”,“Q3”);
break;
case 8:
SetVal.setString(target[0],“month_name”,“August”);
SetVal.setString(target[0],“quarter”,“Q3”);
break;
case 9:
SetVal.setString(target[0],“month_name”,“September”);
SetVal.setString(target[0],“quarter”,“Q3”);
break;
case 10:
SetVal.setString(target[0],“month_name”,“October”);
SetVal.setString(target[0],“quarter”,“Q4”);
break;
case 11:
SetVal.setString(target[0],“month_name”,“November”);
SetVal.setString(target[0],“quarter”,“Q4”);
break;
case 12:
System.out.println(“case 12:”+saleDate.getMonth());
SetVal.setString(target[0],“month_name”,“December”);
SetVal.setString(target[0],“quarter”,“Q4”);
}
SetVal.setInt(target[0],“year”,saleDate.getYear()+1900);
}catch(Exception ex){
errorMessage=ex.getMessage()+" ->occured with record :"+counter;
System.out.println(errorMessage);
ex.printStackTrace();
return false;
}
counter++;
return true;
}
}
here is run methode of split
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]);
// create array holding incoming records
DataRecord outputRecords;
outputRecords = new DataRecord[outPorts.length];
// initialize array of data records (for each input port one)
for (int i = 0; i < outPorts.length; i++)
{
outputRecords[i] = new DataRecord(outPorts[i].getMetadata());
outputRecords[i].init();
}
// numActive=inPorts.length;
int cou = new int[5];
while (runIt)
{
try
{
driverRecordread = inPort.readRecord(driverRecordread);
if(driverRecordread != null)
{
outputRecords[0]=driverRecordread.duplicate();
outputRecords[1]=driverRecordread.duplicate();
outputRecords[0].delField(0);
outputRecords[0].delField(2);
outputRecords[0].delField(3);
outputRecords[0].delField(4);
outputRecords[0].delField(5);
outputRecords[0].delField(6);
outputRecords[0].delField(7);
outputRecords[0].delField(8);
outputRecords[0].delField(9);
outputRecords[1].delField(1);
// This Function Will always Return zero.
int result_t = 0;
outPorts[0].writeRecord(outputRecords[0]);
outPorts[1].writeRecord(outputRecords[1]);
// System.out.println(“In Run: index” + result_t);
}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;
}
please help me quickly to implement this split record component