Commit f2ca5544 authored by sgadve's avatar sgadve

updated bussiness component for the scheme approval

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@195231 ce508802-f39f-4f6c-b175-0d175dae99d5
parent cbac57db
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
public class SchemeApprv extends ValidatorEJB
{
E12GenericUtility genericUtility=new E12GenericUtility();
public String wfValData() throws RemoteException, ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("*************schemeApprv wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams)********");
String errString = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
System.out.println("xmlString:-" + xmlString );
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
System.out.println("xmlString1:-"+xmlString1);
dom2=parseString(xmlString2);
System.out.println("xmlString2:-"+xmlString2);
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
System.out.println("errString[" + errString+"]" );
}
catch(Exception e)
{
throw new ITMException( e );
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
NodeList parentNodeList = null;NodeList childNodeList = null;
Node parentNode = null;Node childNode = null;
String childNodeName = null;
Connection conn = null;
PreparedStatement pstmt = null ;
ResultSet rs = null , rs1 = null;
int cnt = 0, currentFormNo=0,childNodeListLength ,ctr=0;
ConnDriver connDriver = new ConnDriver();
String sql = "",errString = "", errCode = "",userId = "";
ArrayList <String> errList = new ArrayList<String>();
ArrayList <String>errFields = new ArrayList <String> ();
String errorType = "";
String custCode = "",salesPeron="";
//String rate=null,unit=null;
StringBuffer errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
try
{
connDriver = null;
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("userId:- " + userId);
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("current Form No:"+currentFormNo);
}
switch(currentFormNo)
{
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
int parentNodeListLen = parentNodeList.getLength();
System.out.println("Number of node in parentNodeListLen : "+parentNodeListLen);
for ( int rowCnt=0; rowCnt < parentNodeListLen; rowCnt++ )
{
parentNode = parentNodeList.item(rowCnt);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName R : "+childNodeName);
if (childNodeName.equalsIgnoreCase("cust_code"))
{
custCode = E12GenericUtility.checkNull(genericUtility.getColumnValue("cust_code", dom));
System.out.println("Customer code:"+custCode);
if(E12GenericUtility.checkNull(custCode).length() <= 0)
{
errCode = "VTCUSTBLNK";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
String str = "select count(1) from customer where cust_code = ?";
int count = 0;
pstmt = conn.prepareStatement(str);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
System.out.println("count : "+count);
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if(count == 0)
{
errCode = "CUSTNOTEXT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
else if(childNodeName.equalsIgnoreCase("sales_pers"))
{
salesPeron=E12GenericUtility.checkNull(genericUtility.getColumnValue("sales_pers", dom));
System.out.println("salesPerson:"+salesPeron);
if(E12GenericUtility.checkNull(salesPeron).length() <= 0)
{
errCode = "VTSLPER1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
String str = "select count(1) from sales_pers where sales_pers = ?";
int count = 0;
pstmt = conn.prepareStatement(str);
pstmt.setString(1, salesPeron);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
System.out.println("count : "+count);
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if(count == 0)
{
errCode = "VMSLPERS1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
else if (childNodeName.equalsIgnoreCase("cust_code__bill"))
{
custCode = E12GenericUtility.checkNull(genericUtility.getColumnValue("cust_code__bill", dom));
System.out.println("Stockiest code:"+custCode);
if(E12GenericUtility.checkNull(custCode).length() <= 0)
{
errCode = "VTSTCKBLNK";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
String str = "select count(1) from customer where cust_code = ?";
int count = 0;
pstmt = conn.prepareStatement(str);
pstmt.setString(1, custCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
System.out.println("count : "+count);
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if(count == 0)
{
errCode = "VMSTCK";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
}
}
}
}
break;
}
int errListSize = errList.size();
cnt =0;
String errFldName = null;
if ( errList != null && errListSize > 0 )
{
System.out.println("Inside errList >"+errList);
for (cnt = 0; cnt < errListSize; cnt++)
{
errCode = (String)errList.get(cnt);
System.out.println("errCode :"+errCode);
int pos = errCode.indexOf("~");
System.out.println("pos :"+pos);
if(pos>-1)
{
errCode=errCode.substring(0,pos);
}
System.out.println("error code is :"+errCode);
errFldName = (String)errFields.get(cnt);
System.out.println(" cnt [" + cnt + "] errCode [" + errCode + "] errFldName [" + errFldName + "]");
errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn, errCode);
System.out.println("errorType :"+errorType);
if (errString.length() > 0)
{
String bifurErrString = errString.substring(errString.indexOf("<Errors>") +
8, errString.indexOf("<trace>"));
bifurErrString = bifurErrString +
errString.substring(errString.indexOf("</trace>") +
8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
errString = "";
}
if (errorType.equalsIgnoreCase("E"))
{
break;
}
}
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer( "" );
}
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::"+e);
e.printStackTrace();
errString=e.getMessage();
throw new ITMException( e );
}
finally
{
try
{
if(conn!=null)
{
if(rs != null )rs.close();
if(rs1 != null )rs.close();
rs = null;
rs1 = null;
if(pstmt != null )pstmt.close();
pstmt =null;
conn.close();
}
conn = null;
}catch(Exception d)
{
d.printStackTrace();
throw new ITMException( d );
}
}
System.out.println("ErrString ::[ "+errStringXml.toString()+" ]");
return errStringXml.toString();
}
public String itemChanged() throws RemoteException, ITMException
{
return "";
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
E12GenericUtility genericUtility = new E12GenericUtility();
try
{
if ( xmlString != null && xmlString.trim().length()!=0 )
{
dom = genericUtility.parseString(xmlString);
}
if ( xmlString1 != null && xmlString1.trim().length()!=0 )
{
dom1 = genericUtility.parseString(xmlString1);
}
if ( xmlString2 != null && xmlString2.trim().length()!=0 )
{
dom2 = genericUtility.parseString(xmlString2);
}
errString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
System.out.println ( "ErrString :" + errString);
}
catch ( Exception e )
{
System.out.println ( "Exception :itemChanged(String,String):" + e.getMessage() + ":" );
errString = genericUtility.createErrorString(e);
}
System.out.println ( "returning from AsnLotStatIC itemChanged" );
return (errString);
}
/**
* The public overloded method is used for itemchange of required fields
* Returns itemchange string in XML format
* @param dom contains the current form data
* @param dom1 contains always header form data
* @param dom2 contains all forms data
* @param objContext represents form no
* @param editFlag the mode of the transaction(A-Add or E-Edit)
* @param xtraParams contains additional information such as loginCode etc
*/
public String itemChanged( Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String sql = "";
String columnValue = "";
String loginSiteCode = "";
String custName="",salesPerName="",custName1="";
String userId="";
String itemCode="";
Date currentDate = null;
SimpleDateFormat sdf = null;
int initValue=0;
Connection conn = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0;
E12GenericUtility genericUtility = new E12GenericUtility();
try
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
columnValue = genericUtility.getColumnValue( currentColumn, dom );
conn = getConnection();
if( objContext != null && objContext.trim().length() > 0 )
{
currentFormNo = Integer.parseInt( objContext );
}
valueXmlString = new StringBuffer( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header>\r\n<editFlag>" );
valueXmlString.append( editFlag ).append( "</editFlag>\r\n</Header>\r\n" );
switch( currentFormNo )
{
case 1:
valueXmlString.append( "<Detail1>\r\n" );
if("itm_default".equalsIgnoreCase(currentColumn))
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" );
String loginCode=getValueFromXTRA_PARAMS(xtraParams,"loginCode");
String chg_term=getValueFromXTRA_PARAMS( xtraParams, "chgTerm" );
currentDate = new Date();
valueXmlString.append( "<tran_date><![CDATA[" ).append(sdf.format(currentDate).toString()).append( "]]></tran_date>\r\n" );
valueXmlString.append( "<chg_date><![CDATA[" ).append(sdf.format(currentDate).toString()).append( "]]></chg_date>\r\n" );
valueXmlString.append( "<chg_user><![CDATA[" ).append(loginCode).append( "]]></chg_user>\r\n" );
valueXmlString.append( "<chg_term><![CDATA[" ).append(chg_term).append( "]]></chg_term>\r\n" );
valueXmlString.append( "<site_code><![CDATA[" ).append(loginSiteCode).append( "]]></site_code>\r\n" );
valueXmlString.append( "<confirmed><![CDATA[" ).append("N").append( "]]></confirmed>\r\n" );
}
else if( "cust_code".equalsIgnoreCase(currentColumn) )
{
sql = "select cust_name from customer where cust_code =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
custName = checkNull(rs.getString("cust_name"));
}
valueXmlString.append( "<cust_name><![CDATA[" ).append(custName).append( "]]></cust_name>\r\n" );
}
else if("sales_pers".equalsIgnoreCase(currentColumn))
{
sql="SELECT SP_NAME FROM SALES_PERS WHERE SALES_PERS=?";
pStmt=conn.prepareStatement(sql);
pStmt.setString(1,columnValue);
rs=pStmt.executeQuery();
if(rs.next())
{
salesPerName=rs.getString("SP_NAME");
System.out.println("sales person name:"+salesPerName);
}
valueXmlString.append("<sp_name><![CDATA[").append(salesPerName).append("]]></sp_name>");
}
else if( "cust_code__bill".equalsIgnoreCase(currentColumn) )
{
sql = "select cust_name from customer where cust_code =?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, columnValue);
rs = pStmt.executeQuery();
if( rs.next() )
{
custName1 = checkNull(rs.getString("cust_name"));
}
valueXmlString.append( "<customer_cust_name><![CDATA[" ).append(custName1).append( "]]></customer_cust_name>\r\n" );
}
valueXmlString.append( "</Detail1>\r\n" );
}
}
catch( Exception e )
{
throw new ITMException(e);
}
finally
{
try
{
if( rs != null )
{
rs.close();
rs = null;
}
if( pStmt != null && !pStmt.isClosed() )
{
pStmt.close();
pStmt = null;
}
if( conn != null && !conn.isClosed() )
{
conn.close();
conn = null;
}
}
catch( Exception e )
{
System.out.println( "Exception :AsnLotStatIC:itemChanged :==>\n"+e.getMessage());
throw new ITMException(e);
}
}
valueXmlString.append( "</Root>\r\n" );
return valueXmlString.toString();
}//end of itemchange
private String checkNull( String input )
{
if ( input == null )
{
input = "";
}
return input;
}
private String errorType( Connection conn , String errorCode )
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
try
{
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
while( rs.next() )
{
msgType = rs.getString("MSG_TYPE");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch ( Exception e )
{
e.printStackTrace();
}
}
return msgType;
}
}
package ibase.webitm.ejb.dis.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.ibm.db2.jcc.b.co;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.GenericWorkflowClass;
import ibase.webitm.utility.ITMException;
public class SchemeApprvWF extends ActionHandlerEJB
{
String responseFlag = "";
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("SchemeConf.confirm() :: ");
String retString = "";
Connection conn = null;
try
{
retString = this.confirm(tranID, xtraParams, forcedFlag, conn);
}
catch(Exception e)
{
System.out.println("SchemeConf Exception.confirm() : "+e);
throw new ITMException(e);
}
return retString;
}
public String confirm(String tranID,String xtraParams, String forcedFlag,String userInfoStr,String responseFlag) throws RemoteException,ITMException
{
System.out.println("SchemeConf.confirm() userInfo responseFlag : "+responseFlag);
String retString = "";
String appResult="", userId = "";
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null;
ValidatorEJB validatorEJB = new ValidatorEJB();
try
{
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
UserInfoBean userInfo = new UserInfoBean(userInfoStr);
String transDB = userInfo.getTransDB();
System.out.println("#### TransDB connection in : "+transDB);
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
conn.setAutoCommit(false);
connDriver = null;
System.out.println("Response flag:"+responseFlag);
/*retString = this.confirm(tranID, xtraParams, forcedFlag, conn, responseFlag);*/
String updateResponseFlag="UPDATE SCHEME_APPRV SET APRV_STATUS= ?, EMP_CODE_APPRV = ? WHERE TRAN_ID = ?";
pStmt=conn.prepareStatement(updateResponseFlag);
pStmt.setString(1, responseFlag);
pStmt.setString(2, userId);
pStmt.setString(3, tranID);
int i=pStmt.executeUpdate();
System.out.println("Uodated : "+i);
pStmt.close();
if(i>0)
{
conn.commit();
}
if(responseFlag.equalsIgnoreCase("A"))
{
SchemeConf sc=new SchemeConf();
sc.confirm(tranID, xtraParams, forcedFlag,conn);
}
System.out.println("appresult:"+appResult);
//return retString;
}
catch(Exception e)
{
System.out.println("Exception in [IndentReqConf] confirm " + e.getMessage());
throw new ITMException(e);
}
//return retString;
return "1";
}
/*public String confirm(String tranID, String xtraParams, String forcedFlag, Connection conn, String responseFlag) throws RemoteException,ITMException
{
this.responseFlag = responseFlag;
return confirm(tranID, xtraParams, forcedFlag, conn);
}*/
public String confirm(String tranID, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException
{
System.out.println("================ SchemeApprvWF : confirm ================");
String userId = "";
String errString = "";
ValidatorEJB validatorEJB = null;
ITMDBAccessEJB itmDBAccessEJB = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = "";
String confirmed = "",retString = "", apprvStatus= "", wf_status = "";
String[] authencate = new String[2];
authencate[0] = "";
authencate[1] = "";
boolean isError = false;
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
validatorEJB = new ValidatorEJB();
if(conn == null)
{
conn = getConnection();
conn.setAutoCommit(false);
}
userId = validatorEJB.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("tran_id ..> " + tranID+" userId: "+userId+" xtraParams: "+xtraParams+" forcedFlag: "+forcedFlag);
sql = "SELECT CONFIRMED, APRV_STATUS FROM SCHEME_APPRV WHERE TRAN_ID = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, tranID);
rs = pStmt.executeQuery();
if (rs.next())
{
confirmed = E12GenericUtility.checkNull(rs.getString("CONFIRMED"));
apprvStatus = E12GenericUtility.checkNull(rs.getString("APRV_STATUS"));
}
System.out.println("confirmed : "+confirmed);
rs.close();
pStmt.close();
if(!"Y".equalsIgnoreCase(confirmed) || confirmed.length() <= 0)
{
GenericWorkflowClass wfGenericClass = new GenericWorkflowClass();
retString = wfGenericClass.invokeWorkflow(conn, tranID, xtraParams, "w_scheme_apprv", "scheme_apprv");
System.out.println("return String : "+retString);
errString = new ITMDBAccessEJB().getErrorString("", "VTSUCORDER", "","",conn);
}
else
{
errString = new ITMDBAccessEJB().getErrorString("", "VTMWFALCNF", "","",conn);
}
}
catch (Exception e)
{
isError = true;
System.out.println("SchemeApprvWF.confirm() : "+e);
e.printStackTrace();
//errString = itmDBAccessEJB.getErrorString("", "VFMWRKFLWF", userId,"",conn);
throw new ITMException(e);
}
finally
{
if (conn != null)
{
try
{
if (isError)
{
conn.rollback();
System.out.println("SchemeApprvWF: confirm: Connection Rollback");
}
else
{
conn.commit();
System.out.println("SchemeApprvWF: confirm: Connection Commit");
}
conn.close();
conn = null;
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
return errString;
}
private String checkNull(String str)
{
if(str == null)
{
str = "";
}
else
{
str = str.trim();
}
return str;
}
private void closePstmtRs(PreparedStatement pStmt, ResultSet rs)
{
if (pStmt != null)
{
try
{
pStmt.close();
} catch (SQLException localSQLException1) {
}
pStmt = null;
}
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
rs = null;
}
}
}
/********************************************************
Title : SchemeConf []
Date : 27/12/16
Developer: Pankaj R
Purpose: To conf scheme
********************************************************/
package ibase.webitm.ejb.dis.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.ejb.Stateless;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.adv.GenericWorkflowClass;
import ibase.webitm.utility.ITMException;
@Stateless
public class SchemeConf extends ActionHandlerEJB
{
public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("SchemeConf.confirm() :: ");
String retString = "";
Connection conn = null;
try
{
retString = this.confirm(tranID, xtraParams, forcedFlag, conn);
}
catch(Exception e)
{
System.out.println("SchemeConf.confirm() : "+e);
throw new ITMException(e);
}
return retString;
}
public String confirm(String tranID,String xtraParams, String forcedFlag,String userInfoStr) throws RemoteException,ITMException
{
System.out.println("SchemeConf.confirm() userInfo : ");
String retString = "";
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
try
{
UserInfoBean userInfo = new UserInfoBean(userInfoStr);
String transDB = userInfo.getTransDB();
System.out.println("#### TransDB connection in : "+transDB);
if (transDB != null && transDB.trim().length() > 0)
{
conn = connDriver.getConnectDB(transDB);
}
else
{
conn = connDriver.getConnectDB("DriverITM");
}
conn.setAutoCommit(false);
connDriver = null;
retString = this.confirm(tranID, xtraParams, forcedFlag, conn);
//return retString;
return "1";
}
catch(Exception e)
{
System.out.println("Exception in [SchemeConf] confirm " + e.getMessage());
throw new ITMException(e);
}
}
public String confirm(String tranId, String xtraParams, String forcedFlag, Connection conn) throws RemoteException,ITMException
{
System.out.println("SchemeConf.confirm() connectuion ");
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
String isConfirmed = "", returnStr = "", loginEmpCode = "";
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
E12GenericUtility genericUtility = new E12GenericUtility();
boolean isError = false;
try
{
Date currentDate = new java.sql.Date(new java.util.Date().getTime());
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
if ( conn == null )
{
conn = getConnection();
}
String checkConf = "SELECT CONFIRMED FROM SCHEME_APPRV WHERE TRAN_ID = ?";
preparedStatement = conn.prepareStatement(checkConf);
preparedStatement.setString(1, tranId);
resultSet = preparedStatement.executeQuery();
if(resultSet.next())
{
isConfirmed = E12GenericUtility.checkNull(resultSet.getString("CONFIRMED"));
}
resultSet.close();
resultSet = null;
preparedStatement.close();
preparedStatement = null;
if(isConfirmed.length() > 0 && isConfirmed.equalsIgnoreCase("Y"))
{
returnStr = itmDBAccess.getErrorString("","VTINDCONF","","",conn);
return returnStr;
}
else
{
String updateScheme = "UPDATE SCHEME_APPRV SET CONFIRMED = ?, CONF_DATE = ? WHERE TRAN_ID = ?";
preparedStatement = conn.prepareStatement(updateScheme);
preparedStatement.setString(1, "Y");
preparedStatement.setDate(2, currentDate);
preparedStatement.setString(3, tranId);
int updateCount = preparedStatement.executeUpdate();
if(updateCount > 0)
{
returnStr = itmDBAccess.getErrorString("CONFIRMED", "VTMCONF2", loginEmpCode);
conn.commit();
}
}
}
catch(Exception e)
{
isError = true;
System.out.println("Exception in SchemeConf.confirm(4 param) : "+e);
}
finally
{
try
{
System.out.println("isError in Finally SchemeConf="+isError);
if( !isError )
{
System.out.println("----------commmit-----------");
conn.commit();
}
else if ( isError )
{
System.out.println("--------------rollback------------");
conn.rollback();
}
if ( preparedStatement != null )
{
preparedStatement.close();
preparedStatement= null;
}
if (conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return returnStr;
}
}
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