REFORMAT Component Throwing Null Values in OutPut

Support/help with CloverETL (4.9) and CloverDX (5.0 or newer) implementation problems

naveenvijay
Posts: 12
Joined: Thu Oct 13, 2011 6:49 pm

REFORMAT Component Throwing Null Values in OutPut

Postby naveenvijay » Wed Oct 19, 2011 6:50 pm

Hi All,

I am using DATA_READER -> REFORMAT -> DATA_WRITER to Read a File, Reformat it to a desired format and also adding logic to filder records so I do not get this in the output. But I am using the Reformat component to check for logic if the line contains the string I want to filer and based on that condition I am setting the Values for my Output.

The following is my code for Reformat (Java):

public int transform(DataRecord[] source, DataRecord[] target){

String OBJECTTYPE = GetVal.getString(source[0],"OBJECTTYPE");
String USERNAME = GetVal.getString(source[0],"USERNAME");
String NOVALUE = GetVal.getString(source[0],"NOVALUE");
String OBJECTNAME = GetVal.getString(source[0],"OBJECTNAME");
String EVENTDATETIME = GetVal.getString(source[0],"EVENTDATETIME");
String EVENTDESCRIPTION = GetVal.getString(source[0],"EVENTDESCRIPTION");
String RESOURCE = "3";

String FinalObjectName = null;
int i = 0;
String[] UName = null;
String FinalUName = null;

if (USERNAME.contains("\\"))

{
UName = USERNAME.split("\\\\");
FinalUName = UName[UName.length - 1];
System.out.println("<--PARSED USERNAME-->"+FinalUName);

}
else
{
FinalUName = GetVal.getString(source[0],"USERNAME");
System.out.println("<--FinalUNAME>"+FinalUName);
}

System.out.println("<--USERNAME-->" + UName);

String EDateTime = EVENTDATETIME.replace(".000", "");

System.out.println("<--EDateTime-->" + EDateTime);

if (OBJECTNAME.contains(".aspx") || OBJECTNAME.contains(".css") || OBJECTNAME.contains(".jpeg") || OBJECTNAME.contains(".png") || OBJECTNAME.contains(".JPG") || OBJECTNAME.contains(".gif") )
{
System.out.println("No Value");
}
else
{



String[] OName = OBJECTNAME.split("/");
FinalObjectName = OName[OName.length - 1];
String EVENTDESCRIPTION1 = EVENTDESCRIPTION.replace("\r\n", "");
String ACTION1 = EVENTDESCRIPTION1;
String TrxnText = "EVENTDESCRIPTION="+EVENTDESCRIPTION1 + "<-->" + "OBJECTNAME="+FinalObjectName + "<-->" + "OBJECTTYPE="+OBJECTTYPE + "<-->" +
"ACTION="+ACTION1;

SetVal.setString(target[0],"TRANSACTIONTEXT",TrxnText);
SetVal.setString(target[0],"USERNAME",FinalUName);
SetVal.setString(target[0],"EVENTDATETIME",EDateTime);
SetVal.setString(target[0],"RESOURCE",RESOURCE);

}


}

catch(Exception ex){
ex.printStackTrace();
// String errorMessage=ex.getMessage()+" ->occured with record :"+counter;
return SKIP;
}
}

The output I am getting is:

|||
|||
My Output Values
|||
|||

Basically if you see the above line. It puts an empty value with delimiter if the filer condition matches in REFORMAT component.

Can anyone help me with this please. IN A NUTSHELL my question is How will I read a TEXTFILE, 2) look for any matches in the line and Filter those lines 3) Output only the lines I wanted.

Thanks,
Naveen

julrych
Posts: 36
Joined: Mon Dec 13, 2010 6:52 pm

Re: REFORMAT Component Throwing Null Values in OutPut

Postby julrych » Wed Oct 19, 2011 9:45 pm

Hi Naveen,

the reason you are not getting any data on output is that you are missing a return statement in the transform() method. The value returned from transform() specifies to which output port should the data be sent. The

Code: Select all

return 0;
will cause CloverETL engine to push the output data to output port $0.

By the way, it seems to me that you could implement the same functionality directly in CTL2 which should make things easier to read. I don't think that you need java.
Jan Ulrych
Javlin Inc.
[email protected]

avackova
Posts: 841
Joined: Fri Jul 20, 2007 9:28 am

Re: REFORMAT Component Throwing Null Values in OutPut

Postby avackova » Thu Oct 20, 2011 12:25 pm

Hello Naveen,
you don't set any values to the output records if the condition matches. If you want just to copy the values from input to output, use defaultTransform(DataRecord[] inputRecords, DataRecord[] outputRecords) method:

Code: Select all

      if (OBJECTNAME.contains(".aspx") || OBJECTNAME.contains(".css")
            || OBJECTNAME.contains(".jpeg") || OBJECTNAME.contains(".png")
            || OBJECTNAME.contains(".JPG") || OBJECTNAME.contains(".gif")) {
         
         defaultTransform(source, target);
         
         System.out.println("No Value");
      }
Agata Vackova
Javlin a.s.
[email protected]


cron