Commit 2ba6b280 authored by caluka's avatar caluka

Generalized Master validation connection to be passed in genvalidate and genval[D16CSUN013]


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@103279 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 5ebe235f
......@@ -35,13 +35,52 @@ public class GenVal
int Ctr=0;
//end added by msalam on 22/11/07 for appending log in jboss log
//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 = null;
boolean isGenValConn= false;
try
{
if(conn==null)
{
System.out.println(" create genVal@ for wfValData ");
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
isGenValConn=true;
}
errorMap = genVal(modName,objContext,data,conn);
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}finally
{
if (isGenValConn && conn != null)
{
try
{
conn.close();
conn = null;
} catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return errorMap;
}
//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 )
{
System.out.println("Generalized Validation Is In Process.************************************.......");
Statement stmt = null;
ResultSet rs = null;
Connection conn = null;
//Connection conn = null;
String fldName ="",valType = "",fldMin = "",sqlInput = "",fldMax = "",errCD = "",blankOpt = "",fldData ="",fldType="";
String errCode ="";
String sql = " SELECT FLD_NAME,VAL_TYPE,FLD_MIN,SQL_INPUT,FLD_MAX,ERROR_CD,BLANK_OPT ,FLD_TYPE FROM GENMST WHERE MOD_NAME= '"+modName.toUpperCase()+"'";
......@@ -66,9 +105,9 @@ public class GenVal
//ended by added by priyanka
try
{
ConnDriver connDriver = new ConnDriver();
/*ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
connDriver = null;*/
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
......@@ -205,7 +244,7 @@ public class GenVal
if (valType.equalsIgnoreCase("Q"))
{
//***errMsg = genVal( fldName, modName, data, objContext, fldMin, sqlInput, fldMax, errCD, conn );
errMsg = genVal( fldName, modName, data, objContext, fldMin, sqlInput, fldMax, errCD );
errMsg = genVal( fldName, modName, data, objContext, fldMin, sqlInput, fldMax, errCD, conn );
System.out.println("Return error mesg if Found======="+errMsg);
}
//slab validation
......@@ -270,7 +309,7 @@ public class GenVal
//System.out.println("Calling masterVal for module * * * * * [" + modName.trim() + "]");
//***errMsg = masterVal( fldName, modName, fldData, errCD, conn );
System.out.println(">>>>>>>If valType M:"+valType);
errMsg = masterVal( fldName, modName, fldData, errCD );
errMsg = masterVal( fldName, modName, fldData, errCD, conn );
}
//next line commented by msalam on 22/11/07 as validation is required on fldData blank also
}//end of blank opt N
......@@ -309,7 +348,7 @@ public class GenVal
if (valType.equalsIgnoreCase("Q"))
{
System.out.println("Not from isFromButton====================");
errMsg = genVal( fldName, modName, data, objContext, fldMin, sqlInput, fldMax, errCD );
errMsg = genVal( fldName, modName, data, objContext, fldMin, sqlInput, fldMax, errCD, conn );
}
//slab validation
......@@ -373,7 +412,7 @@ public class GenVal
{
//System.out.println("Calling masterVal for module * * * * * [" + modName.trim() + "]");
//***errMsg = masterVal( fldName, modName, fldData, errCD, conn );
errMsg = masterVal( fldName, modName, fldData, errCD );
errMsg = masterVal( fldName, modName, fldData, errCD, conn);
}
//next line commented by msalam on 22/11/07 as validation is required on fldData blank also
}//end of blank opt N
......@@ -397,11 +436,11 @@ public class GenVal
rs = null;
stmt.close();
stmt = null;
if (conn != null)
/*if (conn != null)
{
conn.close();
conn = null;
}
}*/
if(errMsg.trim().length()==0 && xFlag == true)
{
......@@ -409,7 +448,7 @@ public class GenVal
xFlag = false;
//System.out.println("Calling genVal for module * * * * * [X]");
//***errMsg = genVal("X",objContext,data ,conn);
errorMap = genVal("X",objContext,data );//code added by sagar on 25/12/14
errorMap = genVal("X",objContext,data,conn );//code added by sagar on 25/12/14
System.out.println(">>>>>>>>>>>>>errorMap from Mod Name=X :"+errorMap);
xFlag = true;
}
......@@ -442,11 +481,11 @@ public class GenVal
stmt.close();
stmt=null;
}
if (conn != null)
/*if (conn != null)
{
conn.close();
conn = null;
}
}*/
}
catch(Exception ex)
{
......@@ -465,17 +504,56 @@ public class GenVal
//public String genVal(String modName ,String objContext,Document data, String focusedRow, Connection conn)
//added by priyanka 4
public HashMap genVal(String modName ,String objContext,Document data, String focusedRow,boolean isFromButton)
{
Connection conn = null;
boolean isGenValConn= false;
try
{
if(conn==null)
{
System.out.println(" create genVal @@ for wfValData ");
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
isGenValConn=true;
}
errorMap = genVal( modName , objContext, data, focusedRow, isFromButton, conn) ;
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}finally
{
if (isGenValConn && conn != null)
{
try
{
conn.close();
conn = null;
} catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return errorMap;
}
public HashMap genVal(String modName ,String objContext,Document data, String focusedRow,boolean isFromButton, Connection conn)
{
System.out.println("focusedRow==========="+focusedRow);
this.isFromButton=isFromButton;
return genVal(modName,objContext,data,focusedRow);
return genVal(modName,objContext,data,focusedRow,conn);
}
//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)
public HashMap genVal(String modName ,String objContext,Document data, String focusedRow, Connection conn)
{
String errMsg =" ";
HashMap<String, String> errorMsgMap= new HashMap<String, String>();
......@@ -502,7 +580,7 @@ public class GenVal
//end changed by msalam on 22/11/07 for appending log
//***errMsg = genVal( modName, objContext, data, conn);
//errMsg = genVal( modName, objContext, data);//comment added by sagar on 25/12/14
errorMsgMap = genVal( modName, objContext, data);//code added by sagar on 25/12/14
errorMsgMap = genVal( modName, objContext, data,conn);//code added by sagar on 25/12/14
System.out.println(">>>>>>>>>>>Return errorMsgMap in GenVal:"+errorMsgMap.toString());
//return errMsg;//comment added by sagar on 25/12/14
return errorMsgMap;
......@@ -543,22 +621,22 @@ public class GenVal
}
//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 )
private String masterVal( String fldName, String modName, String fldData, String errCD , Connection conn)
{
String err = " ";
Statement mst = null;
ResultSet mrs = null;
Connection conn = null;
//Connection conn = null;
int count=0;
String sql ="";
writeLog( filePtr, "fldData:::::::::"+fldData, true );
try
{
ConnDriver connDriver = new ConnDriver();
/*ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
connDriver = null;*/
//System.out.println("fldData:::::::::"+fldData);
//next 2 lines commented by msalam on 23/11/07 as validation is required on fldData blank also
......@@ -594,8 +672,8 @@ public class GenVal
err = errCD;
writeLog( filePtr, "Master validation record Not Found", true );
}
conn.close();
conn = null;
/*conn.close();
conn = null;*/
}
catch(Exception e){e.printStackTrace();}
//next line commented by msalam on 22/11/07 as validation is required on fldData blank also
......@@ -607,7 +685,7 @@ public class GenVal
}
//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 )
private String genVal( String fldName, String modName, Document dom, String objContext, String queryFrDB, String sqlInput, String resultStr, String errcd , Connection conn)
{
//System.out.println( "Result Should come as " + resultStr );
writeLog( filePtr, "Result Should come as " + resultStr, true );
......@@ -620,7 +698,7 @@ public class GenVal
StringTokenizer st = null;
String data="";
String errCode =" ";
Connection conn = null;
//Connection conn = null;
String colType ="";
String colValue="";
try
......@@ -781,9 +859,9 @@ public class GenVal
//Changed by msalam on 22/10/07 for colType = "DATETIME" end
}
}
ConnDriver connDriver = new ConnDriver();
/*ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
connDriver = null;*/
writeLog( filePtr, "After replace parameter Final Query[*********]:::" + QueryBuf.toString(), true );
pstmt1= conn.prepareStatement( QueryBuf.toString() );
rs1 = pstmt1.executeQuery();
......@@ -836,8 +914,8 @@ public class GenVal
rs1 = null;
pstmt1.close();
pstmt1 = null;
conn.close();
conn = null;
/*conn.close();
conn = null;*/
System.out.println(">>>>>>>resultStrVec:"+resultStrVec.toString());
for( int counter = 0; counter < resultStrVec.size(); counter++ )
{
......
......@@ -14,6 +14,7 @@ import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
......@@ -31,7 +32,7 @@ import org.w3c.dom.Document;
* Window - Preferences - Java - Code Style - Code Templates
*/
import javax.ejb.Stateless; // added for ejb3
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class GenValidate extends ValidatorEJB implements GenValidateLocal , GenValidateRemote // SessionBean{
......@@ -64,8 +65,34 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
public void setSessionContext(SessionContext arg0)
{
}
//Start Added by chandrshekar 06-sep-2016
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams) throws RemoteException
{
String errString = "";
Connection conn = null;
boolean isConn= false;
try
{
errString = this.wfValData(xmlString,xmlString1,xmlString2,objContext,winName, xtraParams, conn);
System.out.println("errString:::::"+errString);
}
catch(Exception e)
{
System.out.println("Exception in [GenValidate] confirm " + e.getMessage());
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
return errString;
}
//End Added by chandrshekar 06-sep-2016
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams, Connection conn) throws RemoteException
{
String finalStr = "";
String errFldName="";
......@@ -75,8 +102,18 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
HashMap<String , String > errorMap= new HashMap<String, String>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
// finalStr = mergeXml(xmlString, xmlString1, xmlString2);
boolean isLocalConn= false;
try
{
if(conn==null)
{
System.out.println(" create isLocalConn for wfValData ");
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
isLocalConn=true;
}
//***ConnDriver connDriver = new ConnDriver();
//***conn = connDriver.getConnectDB("DriverITM");
//**connDriver = null;
......@@ -96,7 +133,7 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
//****errCode = genVal.genVal(winName,objContext,dom, focusedRow, conn);
GenVal genVal = new GenVal();
//errCode = genVal.genVal(winName,objContext,dom, focusedRow);//comment added by sagar on 25/12/14
errorMap = genVal.genVal(winName,objContext,dom, focusedRow);//code added by sagar on 25/12/14
errorMap = genVal.genVal(winName,objContext,dom, focusedRow,conn);//code added by sagar on 25/12/14
genVal = null;
//changed by msalam on 27/09/07 end
/*if (errCode != null && errCode.trim().length() > 0)
......@@ -146,6 +183,22 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
{
e.printStackTrace();
}
finally
{
if(isLocalConn && conn !=null){
try
{
System.out.println("closing local connection>>>"+isLocalConn);
conn.close();
conn = null;
} catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/*finally
{
try
......@@ -164,10 +217,35 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
errString = errStringXml.toString(); //code added by sagar on 25/12/14
return errString;
}
//Start Added by chandrshekar 06-sep-2016
public String wfValData1(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams) throws RemoteException
{
String errString = "";
Connection conn = null;
boolean isConn= false;
try
{
errString = wfValData1(xmlString,xmlString1,xmlString2,objContext,winName, xtraParams, conn);
System.out.println("errString:::::"+errString);
}
catch(Exception e)
{
System.out.println("Exception in [GenValidate] confirm " + e.getMessage());
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
return errString;
}
//End Added by chandrshekar 06-sep-2016
//added by priyanka on 31/12/14 to execute genValidation based o form no on accept button
public String wfValData1(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams) throws RemoteException
public String wfValData1(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams, Connection conn) throws RemoteException
{
String finalStr = "";
String errFldName="";
......@@ -177,8 +255,18 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
HashMap<String , String > errorMap= new HashMap<String, String>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
// finalStr = mergeXml(xmlString, xmlString1, xmlString2);
boolean isLocalConn= false;
try
{
if(conn==null)
{
System.out.println(" create isLocalConn for wfValData1 ");
ConnDriver connDriver = null;
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
isLocalConn=true;
}
//***ConnDriver connDriver = new ConnDriver();
//***conn = connDriver.getConnectDB("DriverITM");
//**connDriver = null;
......@@ -199,7 +287,7 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
//****errCode = genVal.genVal(winName,objContext,dom, focusedRow, conn);
GenVal genVal = new GenVal();
//errCode = genVal.genVal(winName,objContext,dom, focusedRow);//comment added by sagar on 25/12/14
errorMap = genVal.genVal(winName,objContext,dom, focusedRow,true);//code added by sagar on 25/12/14
errorMap = genVal.genVal(winName,objContext,dom, focusedRow,true,conn);//code added by sagar on 25/12/14
genVal = null;
//changed by msalam on 27/09/07 end
/*if (errCode != null && errCode.trim().length() > 0)
......@@ -248,6 +336,20 @@ public class GenValidate extends ValidatorEJB implements GenValidateLocal , Gen
catch(Exception e)
{
e.printStackTrace();
}finally
{
if(isLocalConn){
try
{
conn.close();
conn = null;
} catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/*finally
{
......
......@@ -10,6 +10,7 @@ import ibase.webitm.ejb.*;
//import javax.ejb.EJBObject;
import java.rmi.RemoteException;
import java.sql.Connection;
/**
* @author ashah
......@@ -25,7 +26,8 @@ public interface GenValidateLocal extends ValidatorLocal //extends EJBObject
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams) throws RemoteException;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams, Connection conn) throws RemoteException;
public String wfValData1(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams) throws RemoteException;
public String wfValData1(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams, Connection conn) throws RemoteException;
}
......@@ -11,6 +11,7 @@ import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import java.sql.Connection;
/**
* @author ashah
......@@ -26,7 +27,7 @@ public interface GenValidateRemote extends ValidatorRemote //extends EJBObject {
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams) throws RemoteException;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams,Connection conn) throws RemoteException;
public String wfValData1(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams) throws RemoteException;
public String wfValData1(String xmlString, String xmlString1, String xmlString2, String objContext, String winName, String xtraParams,Connection conn) throws RemoteException;
}
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