Commit 5ea40842 authored by steurwadkar's avatar steurwadkar

Changes committed for adding trace in XML upload utility.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104188 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 394968a7
...@@ -30,12 +30,17 @@ public class GenVal ...@@ -30,12 +30,17 @@ public class GenVal
File filePtr ; File filePtr ;
File logDir ; File logDir ;
String logDirName = ""; String logDirName = "";
HashMap<String, String> errorMap=new HashMap<String, String>(); //Commented by Santosh on 08/12/2016 to returm list of error map
//HashMap<String, String> errorMap=new HashMap<String, String>();
String formNo=""; String formNo="";
int Ctr=0; int Ctr=0;
//end added by msalam on 22/11/07 for appending log in jboss log //end added by msalam on 22/11/07 for appending log in jboss log
//Added by Santosh on 15/12/2016 to return list of error codes instead of HashMap
public HashMap genVal(String modName ,String objContext,Document data ) ArrayList<HashMap<String,String>> errList = new ArrayList<HashMap<String,String>>();
//Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//public HashMap genVal(String modName ,String objContext,Document data )
public ArrayList<HashMap<String,String>> genVal(String modName ,String objContext,Document data )
{ {
Connection conn = null; Connection conn = null;
boolean isGenValConn= false; boolean isGenValConn= false;
...@@ -50,7 +55,9 @@ public class GenVal ...@@ -50,7 +55,9 @@ public class GenVal
conn.setAutoCommit(false); conn.setAutoCommit(false);
isGenValConn=true; isGenValConn=true;
} }
errorMap = genVal(modName,objContext,data,conn); //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//errorMap = genVal(modName,objContext,data,conn);
errList = genVal(modName,objContext,data,conn);
} catch (Exception e) } catch (Exception e)
{ {
// TODO Auto-generated catch block // TODO Auto-generated catch block
...@@ -71,11 +78,15 @@ public class GenVal ...@@ -71,11 +78,15 @@ public class GenVal
} }
} }
return errorMap; //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//return errorMap;
return errList;
} }
//public String genVal(String modName ,String objContext,Document data ) //comment added by sagar on 24/12/14 //public String genVal(String modName ,String objContext,Document data ) //comment added by sagar on 24/12/14
public HashMap genVal(String modName ,String objContext,Document data, Connection conn ) //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//public HashMap genVal(String modName ,String objContext,Document data, Connection conn )
public ArrayList<HashMap<String,String>> genVal(String modName ,String objContext,Document data, Connection conn )
{ {
System.out.println("Generalized Validation Is In Process.************************************......."); System.out.println("Generalized Validation Is In Process.************************************.......");
Statement stmt = null; Statement stmt = null;
...@@ -92,6 +103,8 @@ public class GenVal ...@@ -92,6 +103,8 @@ public class GenVal
String colValue=""; String colValue="";
String colName1=""; String colName1="";
java.util.Vector sqlInputVec = new java.util.Vector(); java.util.Vector sqlInputVec = new java.util.Vector();
//Added by Santosh on 15/12/2016 to create error detail map
HashMap<String,String> errorMap = null;
//added by priyanka on 31/12/14 //added by priyanka on 31/12/14
if( this.isFromButton) if( this.isFromButton)
{ {
...@@ -220,7 +233,10 @@ public class GenVal ...@@ -220,7 +233,10 @@ public class GenVal
System.out.println(">>>>>>>>Before Adding to errorMap >fldName:"+fldName); System.out.println(">>>>>>>>Before Adding to errorMap >fldName:"+fldName);
System.out.println(">>>>>>>>Before Adding to errorMap >errMsg:"+errMsg); System.out.println(">>>>>>>>Before Adding to errorMap >errMsg:"+errMsg);
//errorMap.put(fldName.trim(), errMsg.trim()); //errorMap.put(fldName.trim(), errMsg.trim());
//Added by Santosh on 15/12/2016 to add errorMap in errList
errorMap = new HashMap<String,String>();
errorMap.put(errMsg.trim(), fldName.trim()); errorMap.put(errMsg.trim(), fldName.trim());
errList.add(errorMap);
errMsg=""; errMsg="";
} }
//ended by priyanka //ended by priyanka
...@@ -229,6 +245,10 @@ public class GenVal ...@@ -229,6 +245,10 @@ public class GenVal
if ( checkBlank( fldName, fldData, blankOpt) && valType.trim().equalsIgnoreCase( "M" ) ) if ( checkBlank( fldName, fldData, blankOpt) && valType.trim().equalsIgnoreCase( "M" ) )
{ {
errMsg = errCD;//user enter blank but blank option is Y errMsg = errCD;//user enter blank but blank option is Y
//Added by Santosh on 15/12/2016 to return error string with trace[Start]
errMsg = getTraceErrStrOnError(data, modName, objContext);
errMsg += "error_code="+errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[End]
} }
else else
{ {
...@@ -260,11 +280,19 @@ public class GenVal ...@@ -260,11 +280,19 @@ public class GenVal
if (fldValue < fldMinValue || fldValue > fldMaxValue) if (fldValue < fldMinValue || fldValue > fldMaxValue)
{ {
errMsg = errCD; errMsg = errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[Start]
errMsg = getTraceErrStrOnError(data, modName, objContext);
errMsg += "error_code="+errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[End]
} }
} }
catch(NumberFormatException noFormat) catch(NumberFormatException noFormat)
{ {
errMsg = errCD; errMsg = errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[Start]
errMsg = getTraceErrStrOnError(data, modName, objContext);
errMsg += "error_code="+errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[End]
} }
} }
...@@ -301,6 +329,10 @@ public class GenVal ...@@ -301,6 +329,10 @@ public class GenVal
if (dfldData < fldMinValue || dfldData > fldMaxValue) if (dfldData < fldMinValue || dfldData > fldMaxValue)
{ {
errMsg = errCD; errMsg = errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[Start]
errMsg = getTraceErrStrOnError(data, modName, objContext);
errMsg += "error_code="+errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[End]
} }
} }
//master Validation //master Validation
...@@ -309,7 +341,9 @@ public class GenVal ...@@ -309,7 +341,9 @@ public class GenVal
//System.out.println("Calling masterVal for module * * * * * [" + modName.trim() + "]"); //System.out.println("Calling masterVal for module * * * * * [" + modName.trim() + "]");
//***errMsg = masterVal( fldName, modName, fldData, errCD, conn ); //***errMsg = masterVal( fldName, modName, fldData, errCD, conn );
System.out.println(">>>>>>>If valType M:"+valType); System.out.println(">>>>>>>If valType M:"+valType);
errMsg = masterVal( fldName, modName, fldData, errCD, conn ); //Changed by Santosh on 15/12/2016 to add dom and objContext
//errMsg = masterVal( fldName, modName, fldData, errCD, conn );
errMsg = masterVal( fldName, modName, fldData, errCD, data, objContext, conn );
} }
//next line commented by msalam on 22/11/07 as validation is required on fldData blank also //next line commented by msalam on 22/11/07 as validation is required on fldData blank also
}//end of blank opt N }//end of blank opt N
...@@ -325,7 +359,7 @@ public class GenVal ...@@ -325,7 +359,7 @@ public class GenVal
fldData = getValueFromDom(data,fldName,objContext); fldData = getValueFromDom(data,fldName,objContext);
System.out.println("objContext********************["+objContext+"]"); System.out.println("objContext********************["+objContext+"]");
//if( flag == true ) //if( flag == true )
System.out.println("Fld Name :["+fldName+"] Value : "+fldData+"] Present["+flag+"]"); System.out.println("Fld Name :["+fldName+"] Value : ["+fldData+"] Present["+flag+"]");
//System.out.println("validation Type********************["+valType+"]"); //System.out.println("validation Type********************["+valType+"]");
if( flag == true ) if( flag == true )
{ {
...@@ -349,7 +383,6 @@ public class GenVal ...@@ -349,7 +383,6 @@ public class GenVal
{ {
System.out.println("Not from isFromButton===================="); System.out.println("Not from isFromButton====================");
errMsg = genVal( fldName, modName, data, objContext, fldMin, sqlInput, fldMax, errCD, conn ); errMsg = genVal( fldName, modName, data, objContext, fldMin, sqlInput, fldMax, errCD, conn );
} }
//slab validation //slab validation
else if( valType.equalsIgnoreCase( "S" ) ) else if( valType.equalsIgnoreCase( "S" ) )
...@@ -364,11 +397,19 @@ public class GenVal ...@@ -364,11 +397,19 @@ public class GenVal
if (fldValue < fldMinValue || fldValue > fldMaxValue) if (fldValue < fldMinValue || fldValue > fldMaxValue)
{ {
errMsg = errCD; errMsg = errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[Start]
errMsg = getTraceErrStrOnError(data, modName, objContext);
errMsg += "error_code="+errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[End]
} }
} }
catch(NumberFormatException noFormat) catch(NumberFormatException noFormat)
{ {
errMsg = errCD; errMsg = errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[Start]
errMsg = getTraceErrStrOnError(data, modName, objContext);
errMsg += "error_code="+errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[End]
} }
} }
...@@ -405,6 +446,10 @@ public class GenVal ...@@ -405,6 +446,10 @@ public class GenVal
if (dfldData < fldMinValue || dfldData > fldMaxValue) if (dfldData < fldMinValue || dfldData > fldMaxValue)
{ {
errMsg = errCD; errMsg = errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[Start]
errMsg = getTraceErrStrOnError(data, modName, objContext);
errMsg += "error_code="+errCD;
//Added by Santosh on 15/12/2016 to return error string with trace[End]
} }
} }
//master Validation //master Validation
...@@ -412,7 +457,9 @@ public class GenVal ...@@ -412,7 +457,9 @@ public class GenVal
{ {
//System.out.println("Calling masterVal for module * * * * * [" + modName.trim() + "]"); //System.out.println("Calling masterVal for module * * * * * [" + modName.trim() + "]");
//***errMsg = masterVal( fldName, modName, fldData, errCD, conn ); //***errMsg = masterVal( fldName, modName, fldData, errCD, conn );
errMsg = masterVal( fldName, modName, fldData, errCD, conn); //Changed by Santosh on 15/12/2016 to add dom and objContext
//errMsg = masterVal( fldName, modName, fldData, errCD, conn);
errMsg = masterVal( fldName, modName, fldData, errCD, data, objContext, conn);
} }
//next line commented by msalam on 22/11/07 as validation is required on fldData blank also //next line commented by msalam on 22/11/07 as validation is required on fldData blank also
}//end of blank opt N }//end of blank opt N
...@@ -428,7 +475,26 @@ public class GenVal ...@@ -428,7 +475,26 @@ public class GenVal
System.out.println(">>>>>>>>Before Adding to errorMap >fldName:"+fldName); System.out.println(">>>>>>>>Before Adding to errorMap >fldName:"+fldName);
System.out.println(">>>>>>>>Before Adding to errorMap >errMsg:"+errMsg); System.out.println(">>>>>>>>Before Adding to errorMap >errMsg:"+errMsg);
//errorMap.put(fldName.trim(), errMsg.trim()); //errorMap.put(fldName.trim(), errMsg.trim());
errorMap.put(errMsg.trim(), fldName.trim()); //Added by Santosh on 15/12/2016 to add error map in errlist[Start]
errorMap = new HashMap<String,String>();
String[] traceNodeArry = errMsg.split("~");
for(String traceNodeKeyValue : traceNodeArry)
{
String traceKey = traceNodeKeyValue.substring(0,traceNodeKeyValue.indexOf("="));
String traceValue = traceNodeKeyValue.substring(traceNodeKeyValue.indexOf("=")+1);
if(!"error_code".equalsIgnoreCase(traceKey))
{
errorMap.put(traceKey, traceValue);
}
else
{
errorMap.put(traceValue.trim(), fldName.trim());
}
}
System.out.println("final errorMap["+errorMap+"]");
//Added by Santosh on 15/12/2016 to add error map in errlist[Start]
errList.add(errorMap);
errMsg=""; errMsg="";
} }
} }
...@@ -448,11 +514,13 @@ public class GenVal ...@@ -448,11 +514,13 @@ public class GenVal
xFlag = false; xFlag = false;
//System.out.println("Calling genVal for module * * * * * [X]"); //System.out.println("Calling genVal for module * * * * * [X]");
//***errMsg = genVal("X",objContext,data ,conn); //***errMsg = genVal("X",objContext,data ,conn);
errorMap = genVal("X",objContext,data,conn );//code added by sagar on 25/12/14 //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
System.out.println(">>>>>>>>>>>>>errorMap from Mod Name=X :"+errorMap); //errorMap = genVal("X",objContext,data,conn );//code added by sagar on 25/12/14
errList = genVal("X",objContext,data,conn );//code added by sagar on 25/12/14
System.out.println(">>>>>>>>>>>>>errList from Mod Name=X :"+errList);
xFlag = true; xFlag = true;
} }
System.out.println(">>>>>>>>Final Return errorMap:"+errorMap); System.out.println(">>>>>>>>Final Return errList:"+errList);
} // end of try } // end of try
catch (SQLException sx) catch (SQLException sx)
{ {
...@@ -495,7 +563,9 @@ public class GenVal ...@@ -495,7 +563,9 @@ public class GenVal
//return stkOpt; //return stkOpt;
} }
//return errMsg; //return errMsg;
return errorMap;//return type changed by sagar on 25/12/14 //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//return errorMap;//return type changed by sagar on 25/12/14
return errList;
} }
//changed by msalam on 26/09/07 start //changed by msalam on 26/09/07 start
...@@ -504,8 +574,9 @@ public class GenVal ...@@ -504,8 +574,9 @@ public class GenVal
//public String genVal(String modName ,String objContext,Document data, String focusedRow, Connection conn) //public String genVal(String modName ,String objContext,Document data, String focusedRow, Connection conn)
//added by priyanka 4 //added by priyanka 4
//Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
public HashMap genVal(String modName ,String objContext,Document data, String focusedRow,boolean isFromButton) //public HashMap genVal(String modName ,String objContext,Document data, String focusedRow,boolean isFromButton)
public ArrayList<HashMap<String,String>> genVal(String modName ,String objContext,Document data, String focusedRow,boolean isFromButton)
{ {
Connection conn = null; Connection conn = null;
boolean isGenValConn= false; boolean isGenValConn= false;
...@@ -520,7 +591,9 @@ public class GenVal ...@@ -520,7 +591,9 @@ public class GenVal
conn.setAutoCommit(false); conn.setAutoCommit(false);
isGenValConn=true; isGenValConn=true;
} }
errorMap = genVal( modName , objContext, data, focusedRow, isFromButton, conn) ; //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
// errorMap = genVal( modName , objContext, data, focusedRow, isFromButton, conn) ;
errList = genVal( modName , objContext, data, focusedRow, isFromButton, conn) ;
} catch (Exception e) } catch (Exception e)
{ {
// TODO Auto-generated catch block // TODO Auto-generated catch block
...@@ -541,9 +614,13 @@ public class GenVal ...@@ -541,9 +614,13 @@ public class GenVal
} }
} }
return errorMap; //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//return errorMap;
return errList;
} }
public HashMap genVal(String modName ,String objContext,Document data, String focusedRow,boolean isFromButton, Connection conn) //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//public HashMap genVal(String modName ,String objContext,Document data, String focusedRow,boolean isFromButton, Connection conn)
public ArrayList<HashMap<String,String>> genVal(String modName ,String objContext,Document data, String focusedRow,boolean isFromButton, Connection conn)
{ {
System.out.println("focusedRow==========="+focusedRow); System.out.println("focusedRow==========="+focusedRow);
this.isFromButton=isFromButton; this.isFromButton=isFromButton;
...@@ -553,10 +630,14 @@ public class GenVal ...@@ -553,10 +630,14 @@ public class GenVal
//public String genVal(String modName ,String objContext,Document data, String focusedRow)//comment added by sagar on 25/12/14 //public String genVal(String modName ,String objContext,Document data, String focusedRow)//comment added by sagar on 25/12/14
public HashMap genVal(String modName ,String objContext,Document data, String focusedRow, Connection conn) //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//public HashMap genVal(String modName ,String objContext,Document data, String focusedRow, Connection conn)
public ArrayList<HashMap<String,String>> genVal(String modName ,String objContext,Document data, String focusedRow, Connection conn)
{ {
String errMsg =" "; String errMsg =" ";
HashMap<String, String> errorMsgMap= new HashMap<String, String>(); //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//HashMap<String, String> errorMsgMap= new HashMap<String, String>();
ArrayList<HashMap<String,String>> errList = new ArrayList<HashMap<String,String>>();
//changed by msalam on 26/09/07 start //changed by msalam on 26/09/07 start
if( focusedRow != null ) if( focusedRow != null )
{ {
...@@ -580,10 +661,14 @@ public class GenVal ...@@ -580,10 +661,14 @@ public class GenVal
//end changed by msalam on 22/11/07 for appending log //end changed by msalam on 22/11/07 for appending log
//***errMsg = genVal( modName, objContext, data, conn); //***errMsg = genVal( modName, objContext, data, conn);
//errMsg = genVal( modName, objContext, data);//comment added by sagar on 25/12/14 //errMsg = genVal( modName, objContext, data);//comment added by sagar on 25/12/14
errorMsgMap = genVal( modName, objContext, data,conn);//code added by sagar on 25/12/14 //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
System.out.println(">>>>>>>>>>>Return errorMsgMap in GenVal:"+errorMsgMap.toString()); //errorMsgMap = genVal( modName, objContext, data,conn);//code added by sagar on 25/12/14
errList = genVal( modName, objContext, data,conn);
System.out.println(">>>>>>>>>>>Return errList in GenVal:"+errList);
//return errMsg;//comment added by sagar on 25/12/14 //return errMsg;//comment added by sagar on 25/12/14
return errorMsgMap; //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//return errorMsgMap;
return errList;
} }
//changed by msalam on 26/09/07 end //changed by msalam on 26/09/07 end
...@@ -621,7 +706,9 @@ public class GenVal ...@@ -621,7 +706,9 @@ public class GenVal
} }
//master validation //master validation
//private String masterVal( String fldName, String modName, String fldData, String errCD, Connection conn ) //private String masterVal( String fldName, String modName, String fldData, String errCD, Connection conn )
private String masterVal( String fldName, String modName, String fldData, String errCD , Connection conn) //Changed by Santosh on 15/12/2016 to add dom and objContext
//private String masterVal( String fldName, String modName, String fldData, String errCD , Connection conn)
private String masterVal( String fldName, String modName, String fldData, String errCD , Document dom, String objContext, Connection conn)
{ {
String err = " "; String err = " ";
...@@ -630,6 +717,8 @@ public class GenVal ...@@ -630,6 +717,8 @@ public class GenVal
//Connection conn = null; //Connection conn = null;
int count=0; int count=0;
String sql =""; String sql ="";
//Added by Santosh on 15/12/2016 to add trace in error string
String traceNodeStr = "";
writeLog( filePtr, "fldData:::::::::"+fldData, true ); writeLog( filePtr, "fldData:::::::::"+fldData, true );
try try
{ {
...@@ -674,18 +763,28 @@ public class GenVal ...@@ -674,18 +763,28 @@ public class GenVal
} }
/*conn.close(); /*conn.close();
conn = null;*/ conn = null;*/
//Added by Santosh on 15/12/2016 to add errCode in traceNode xml[Start]
if(err.trim().length()>0 && err != null)
{
traceNodeStr = getTraceErrStrOnError(dom, modName, objContext);
traceNodeStr += "error_code="+err;
}
//Added by Santosh on 15/12/2016 to add errCode in traceNode xml[End]
} }
catch(Exception e){e.printStackTrace();} catch(Exception e){e.printStackTrace();}
//next line commented by msalam on 22/11/07 as validation is required on fldData blank also //next line commented by msalam on 22/11/07 as validation is required on fldData blank also
//}//end of blank opt N //}//end of blank opt N
//end commented by msalam on 22/11/07 as validation is required on fldData blank also //end commented by msalam on 22/11/07 as validation is required on fldData blank also
//Changed by Santosh on 15/12/2016 to return traceErrStr
return err; //return err;
return traceNodeStr;
} }
//private String genVal( String fldName, String modName, Document dom, String objContext, String queryFrDB, String sqlInput, String resultStr, String errcd, Connection conn ) //private String genVal( String fldName, String modName, Document dom, String objContext, String queryFrDB, String sqlInput, String resultStr, String errcd, Connection conn )
private String genVal( String fldName, String modName, Document dom, String objContext, String queryFrDB, String sqlInput, String resultStr, String errcd , Connection conn) private String genVal( String fldName, String modName, Document dom, String objContext, String queryFrDB, String sqlInput, String resultStr, String errcd , Connection conn) throws Exception
{ {
//System.out.println( "Result Should come as " + resultStr ); //System.out.println( "Result Should come as " + resultStr );
writeLog( filePtr, "Result Should come as " + resultStr, true ); writeLog( filePtr, "Result Should come as " + resultStr, true );
...@@ -701,6 +800,8 @@ public class GenVal ...@@ -701,6 +800,8 @@ public class GenVal
//Connection conn = null; //Connection conn = null;
String colType =""; String colType ="";
String colValue=""; String colValue="";
//Added by Santosh on 15/12/2016 to add trace in error string
String traceNodeStr = "";
try try
{ {
writeLog( filePtr, "Mod Name :::" + modName, true ); writeLog( filePtr, "Mod Name :::" + modName, true );
...@@ -944,9 +1045,18 @@ public class GenVal ...@@ -944,9 +1045,18 @@ public class GenVal
{ {
e.printStackTrace(); e.printStackTrace();
} }
System.out.println(">>>>>>>>>>>errCode from genVal:"+errCode); //Added by Santosh on 15/12/2016 to add errCode in traceNode xml[Start]
if(errCode.trim().length()>0 && errCode != null)
{
traceNodeStr = getTraceErrStrOnError(dom, modName, objContext);
traceNodeStr += "error_code="+errCode;
}
//Added by Santosh on 15/12/2016 to add errCode in traceNode xml[End]
System.out.println(">>>>>>>>>>>traceNodeStr from genVal:"+traceNodeStr);
System.out.println(">>>>>>>>>>>>>>>In genVal End>>>>>>>>>>>>>>>>>>>>"); System.out.println(">>>>>>>>>>>>>>>In genVal End>>>>>>>>>>>>>>>>>>>>");
return errCode; //Changed by Santosh on 15/12/2016 to return traceNodeXml instead of errCode
//return errCode;
return traceNodeStr;
} }
//******** Get the type of the field //******** Get the type of the field
private String getType(String winName,String objContext,String fldName) private String getType(String winName,String objContext,String fldName)
...@@ -1266,6 +1376,102 @@ public class GenVal ...@@ -1266,6 +1376,102 @@ public class GenVal
catch(Exception exWm){exWm.printStackTrace();} catch(Exception exWm){exWm.printStackTrace();}
} }
//end functions added by msalam on 22/11/07 for appending log in jboss logg //end functions added by msalam on 22/11/07 for appending log in jboss logg
//Added by Santosh on 15/12/2016 to get primary fields [Start]
private String getTraceErrStrOnError(Document dom, String modName, String objContext) throws Exception
{
String retTraceStr = "";
String objName = "", tempModName = "", fileName = "", nodeName = "", traceNodeValue = "", traceNodeStr = "";
Document dwDoc = null;
DocumentBuilderFactory dbf = null;
DocumentBuilder db = null;
File dwFile = null;
NodeList columnObjNodeList = null;
int nodeId = 0, colNodeListLen = 0, nodeIndex = 0;
String [] traceNodeArray = new String[4];
try
{
System.out.println("modName is ["+modName+"] objContext ["+objContext+"]");
if(! "X".equalsIgnoreCase(modName))
{
tempModName = modName.toLowerCase();
objName = tempModName.substring(tempModName.indexOf("w_")+2);
}
dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware( true );
dbf.setIgnoringComments( true );
db = dbf.newDocumentBuilder();
fileName = CommonConstants.JBOSSHOME + File.separator + "bin" + File.separator + "metadata" + File.separator + objName + "2" + objContext + ".xml";
dwFile = new File( fileName );
if( ! dwFile.exists() )
{
throw new Exception( "Metadata file :[" + dwFile.getAbsolutePath() + "] not found" );
}
dwDoc = db.parse( dwFile );
columnObjNodeList = dwDoc.getElementsByTagName("ColumnObject");
colNodeListLen = columnObjNodeList.getLength();
for(int i=0; i<colNodeListLen; i++)
{
Node eachColObjNode = columnObjNodeList.item(i);
NodeList eachColObjNodeList = eachColObjNode.getChildNodes();
for(int j=0; j<eachColObjNodeList.getLength();j++)
{
Node childNode = eachColObjNodeList.item(j);
if("id".equalsIgnoreCase(childNode.getNodeName()))
{
nodeId = Integer.parseInt(childNode.getTextContent());
}
else if ("name".equalsIgnoreCase(childNode.getNodeName()))
{
nodeName = childNode.getTextContent();
}
}
switch (nodeId)
{
case 1:
traceNodeArray[0] = nodeName;
break;
case 2:
traceNodeArray[1] = nodeName;
break;
case 3:
traceNodeArray[2] = nodeName;
break;
case 4:
traceNodeArray[3] = nodeName;
break;
}
}
for(String traceNode : traceNodeArray)
{
if(isFromButton)
{
traceNodeValue = getValueFromDom1( dom, traceNode, objContext,Ctr);
}
else
{
traceNodeValue = getValueFromDom( dom, traceNode, objContext);
}
retTraceStr += (++nodeIndex)+"."+traceNode+"="+traceNodeValue+"~";
}
}
catch(Exception e)
{
e.printStackTrace();
throw new Exception(e);
}
return retTraceStr;
}
//Added by Santosh on 15/12/2016 to get primary fields [End]
}//END OF EJB }//END OF EJB
...@@ -12,27 +12,24 @@ import ibase.webitm.utility.ITMException; ...@@ -12,27 +12,24 @@ import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import javax.ejb.CreateException; import java.util.Set;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext; import javax.ejb.SessionContext;
import javax.ejb.Stateless;
import org.w3c.dom.Document; import org.w3c.dom.Document;
/** /**
* @author ashah * @author ashah
* *
* TODO To change the template for this generated type comment go to * TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates * Window - Preferences - Java - Code Style - Code Templates
*/ */
// added for ejb3
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3 @Stateless // added for ejb3
public class GenValidate extends ValidatorEJB implements GenValidateLocal , GenValidateRemote // SessionBean{ public class GenValidate extends ValidatorEJB implements GenValidateLocal , GenValidateRemote // SessionBean{
...@@ -99,7 +96,10 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -99,7 +96,10 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
Document dom = null; Document dom = null;
String userId="", errCode = "",resultString = ""; String userId="", errCode = "",resultString = "";
String errString = "",errorType=""; String errString = "",errorType="";
HashMap<String , String > errorMap= new HashMap<String, String>(); //Commented by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//HashMap<String , String > errorMap= new HashMap<String, String>();
//Added by Santosh on 15/12/2016 to return list of error codes instead of HashMap
ArrayList<HashMap<String,String>> errList = new ArrayList<HashMap<String,String>>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>"); StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
// finalStr = mergeXml(xmlString, xmlString1, xmlString2); // finalStr = mergeXml(xmlString, xmlString1, xmlString2);
boolean isLocalConn= false; boolean isLocalConn= false;
...@@ -133,14 +133,59 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -133,14 +133,59 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
//****errCode = genVal.genVal(winName,objContext,dom, focusedRow, conn); //****errCode = genVal.genVal(winName,objContext,dom, focusedRow, conn);
GenVal genVal = new GenVal(); GenVal genVal = new GenVal();
//errCode = genVal.genVal(winName,objContext,dom, focusedRow);//comment added by sagar on 25/12/14 //errCode = genVal.genVal(winName,objContext,dom, focusedRow);//comment added by sagar on 25/12/14
errorMap = genVal.genVal(winName,objContext,dom, focusedRow,conn);//code added by sagar on 25/12/14 //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//errorMap = genVal.genVal(winName,objContext,dom, focusedRow,conn);//code added by sagar on 25/12/14
errList = genVal.genVal(winName,objContext,dom, focusedRow,conn);
genVal = null; genVal = null;
//changed by msalam on 27/09/07 end //changed by msalam on 27/09/07 end
/*if (errCode != null && errCode.trim().length() > 0) /*if (errCode != null && errCode.trim().length() > 0)
{ {
resultString = getErrorString("", errCode, userId); resultString = getErrorString("", errCode, userId);
}*/ }*/
//code added by sagar on 25/12/14 Start.... //Added by Santosh on 15/12/2016 to return error string from errList[Start]
System.out.println(">>>>>>>>Return errList in GenValidate:"+errList);
if(errList.size() > 0)
{
for(HashMap<String,String> eachErrorMap : errList)
{
String traceStr = "";
HashMap<String,String> traceStrMap = new HashMap<String,String>();
Iterator iterator = eachErrorMap.entrySet().iterator();
while (iterator.hasNext())
{
Map.Entry mapEntry = (Map.Entry) iterator.next();
errCode= (String) mapEntry.getKey();
errFldName= (String) mapEntry.getValue();
System.out.println(">>>>>>>>errFldName:"+errFldName);
System.out.println(">>>>>>>>errCode:"+errCode);
if(errCode.indexOf(".") == -1 && errCode != null && errCode.trim().length() > 0)
{
errString = getErrorString(errFldName, errCode, userId);
}
else
{
traceStrMap.put(errCode,errFldName);
}
}
traceStr = getTraceErrStr(traceStrMap);
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString += "<trace><![CDATA["+traceStr+"]]></trace>";
bifurErrString += errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
}
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
//Added by Santosh on 15/12/2016 to return error string from errList[End]
//Commented by Santosh on 15/12/2016 to return list of error codes instead of HashMap [Start]
/*code added by sagar on 25/12/14 Start....
System.out.println(">>>>>>>>Return errorMap in GenValidate:"+errorMap); System.out.println(">>>>>>>>Return errorMap in GenValidate:"+errorMap);
if(!errorMap.isEmpty()) if(!errorMap.isEmpty())
{ {
...@@ -170,8 +215,9 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -170,8 +215,9 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
else else
{ {
errStringXml = new StringBuffer(""); errStringXml = new StringBuffer("");
} }*/
//code added by sagar on 25/12/14 end. //code added by sagar on 25/12/14 end.
//Commented by Santosh on 15/12/2016 to return list of error codes instead of HashMap [End]
} }
catch (RemoteException e1) { catch (RemoteException e1) {
e1.printStackTrace(); e1.printStackTrace();
...@@ -252,7 +298,10 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -252,7 +298,10 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
Document dom = null; Document dom = null;
String userId="", errCode = "",resultString = ""; String userId="", errCode = "",resultString = "";
String errString = "",errorType=""; String errString = "",errorType="";
HashMap<String , String > errorMap= new HashMap<String, String>(); //Commented by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//HashMap<String , String > errorMap= new HashMap<String, String>();
//Added by Santosh on 15/12/2016 to return list of error codes instead of HashMap
ArrayList<HashMap<String,String>> errList = new ArrayList<HashMap<String,String>>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>"); StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
// finalStr = mergeXml(xmlString, xmlString1, xmlString2); // finalStr = mergeXml(xmlString, xmlString1, xmlString2);
boolean isLocalConn= false; boolean isLocalConn= false;
...@@ -287,15 +336,60 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -287,15 +336,60 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
//****errCode = genVal.genVal(winName,objContext,dom, focusedRow, conn); //****errCode = genVal.genVal(winName,objContext,dom, focusedRow, conn);
GenVal genVal = new GenVal(); GenVal genVal = new GenVal();
//errCode = genVal.genVal(winName,objContext,dom, focusedRow);//comment added by sagar on 25/12/14 //errCode = genVal.genVal(winName,objContext,dom, focusedRow);//comment added by sagar on 25/12/14
errorMap = genVal.genVal(winName,objContext,dom, focusedRow,true,conn);//code added by sagar on 25/12/14 //Changed by Santosh on 15/12/2016 to return list of error codes instead of HashMap
//errorMap = genVal.genVal(winName,objContext,dom, focusedRow,true,conn);
errList = genVal.genVal(winName,objContext,dom, focusedRow,true,conn);
genVal = null; genVal = null;
//changed by msalam on 27/09/07 end //changed by msalam on 27/09/07 end
/*if (errCode != null && errCode.trim().length() > 0) /*if (errCode != null && errCode.trim().length() > 0)
{ {
resultString = getErrorString("", errCode, userId); resultString = getErrorString("", errCode, userId);
}*/ }*/
//Added by Santosh on 15/12/2016 to return error string from errList[Start]
System.out.println(">>>>>>>>Return errList in GenValidate:"+errList);
if(errList.size() > 0)
{
for(HashMap<String,String> eachErrorMap : errList)
{
String traceStr = "";
HashMap<String,String> traceStrMap = new HashMap<String,String>();
Iterator iterator = eachErrorMap.entrySet().iterator();
while (iterator.hasNext())
{
Map.Entry mapEntry = (Map.Entry) iterator.next();
errCode= (String) mapEntry.getKey();
errFldName= (String) mapEntry.getValue();
System.out.println(">>>>>>>>errFldName:"+errFldName);
System.out.println(">>>>>>>>errCode:"+errCode);
if(errCode.indexOf(".") == -1 && errCode != null && errCode.trim().length() > 0)
{
errString = getErrorString(errFldName, errCode, userId);
}
else
{
traceStrMap.put(errCode,errFldName);
}
}
traceStr = getTraceErrStr(traceStrMap);
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>"));
bifurErrString += "<trace><![CDATA["+traceStr+"]]></trace>";
bifurErrString += errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
}
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
//Added by Santosh on 15/12/2016 to return error string from errList[End]
//Commented by Santosh on 15/12/2016 to return list of error codes instead of HashMap [Start]
//code added by sagar on 25/12/14 Start.... //code added by sagar on 25/12/14 Start....
System.out.println(">>>>>>>>Return errorMap in GenValidate:"+errorMap); /*System.out.println(">>>>>>>>Return errorMap in GenValidate:"+errorMap);
if(!errorMap.isEmpty()) if(!errorMap.isEmpty())
{ {
System.out.println(">>>>>>>>Return Non empty errorMap in GenValidate:"+errorMap.size()); System.out.println(">>>>>>>>Return Non empty errorMap in GenValidate:"+errorMap.size());
...@@ -325,7 +419,8 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -325,7 +419,8 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
{ {
errStringXml = new StringBuffer(""); errStringXml = new StringBuffer("");
} }
//code added by sagar on 25/12/14 end. //code added by sagar on 25/12/14 end.*/
//Commented by Santosh on 15/12/2016 to return list of error codes instead of HashMap [End]
} }
catch (RemoteException e1) { catch (RemoteException e1) {
e1.printStackTrace(); e1.printStackTrace();
...@@ -408,4 +503,54 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen ...@@ -408,4 +503,54 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
//System.out.println("compData ::::" + compData.toString()); //System.out.println("compData ::::" + compData.toString());
return compData.toString(); return compData.toString();
} }
//Added by Santosh on 15/12/2016 to return formatted trace string [Start]
private String getTraceErrStr(HashMap<String,String> traceDataMap) throws Exception
{
String retStr = "", traceLbl = "";
String [] traceDataArry = new String[4];
try
{
Set<String> traceKeys = traceDataMap.keySet();
for(String eachKey : traceKeys)
{
traceLbl = eachKey.substring(eachKey.indexOf(".")+1);
traceLbl = traceLbl.replaceAll("_", " ");
traceLbl = traceLbl.substring(0, 1).toUpperCase() + traceLbl.substring(1);
if(eachKey.indexOf("1.")!= -1)
{
traceDataArry[0] = traceLbl+" : "+traceDataMap.get(eachKey);
}
else if(eachKey.indexOf("2.")!= -1)
{
traceDataArry[1] = traceLbl+" : "+traceDataMap.get(eachKey);
}
else if(eachKey.indexOf("3.")!= -1)
{
traceDataArry[2] = traceLbl+" : "+traceDataMap.get(eachKey);
}
else if(eachKey.indexOf("4.")!= -1)
{
traceDataArry[3] = traceLbl+" : "+traceDataMap.get(eachKey);
}
}
for(int i=0; i<traceDataArry.length; i++)
{
retStr += traceDataArry[i];
if(i<(traceDataArry.length-1))
{
retStr += ", ";
}
}
}
catch(Exception e)
{
e.printStackTrace();
throw new Exception();
}
return retStr;
}
//Added by Santosh on 15/12/2016 to return formatted trace string [End]
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment