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