Commit dbd72cfb authored by sghate's avatar sghate

*Done Changes On PayarrToProc Master Component.

PayarrToProc.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@204788 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c29a24f4
......@@ -9,19 +9,23 @@ import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
@Stateless
public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,PayarrToProcRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
//modified by Shital on 12/07/2019 [Start]
//GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = null;
//modified by Shital on 12/07/2019[End]
ITMDBAccessEJB itmDbAccess = new ITMDBAccessEJB();
AdmCommon admCommon = new AdmCommon();
public String wfValData() throws RemoteException, ITMException
{
......@@ -30,39 +34,41 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
//added wfValData method by Varsha V on 24-08-18 for Arrears to processed validation[START] A17ESUN001
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String retString = "";
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);
}
retString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
System.out.println("retString of PayarrToProc--> wfValData:::"+retString);
}
catch(Exception e)
{
System.out.println("::: PayarrToProc ::"+ e.getMessage());
e.getMessage();
}
return retString;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String retString = "";
try
{
genericUtility = new E12GenericUtility();
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);
}
retString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
System.out.println("retString of PayarrToProc--> wfValData:::"+retString);
}
catch(Exception e)
{
System.out.println("::: PayarrToProc ::"+ e.getMessage());
e.getMessage();
throw new ITMException(e);
}
return retString;
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
//ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
int childNodeLength = 0;
int childNodeLength = 0;
int currentFormNo=0;
int ctr = 0, cnt = 0;
Connection conn = null;
......@@ -74,84 +80,164 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
Node childNode = null;
String childNodeName = "";
String errString="";
String userId = "", errCode = "", errorType = "", loginCode = "";
String userId = "";
String errCode = "";
String errorType = "";
String loginCode = "";
String msgType = "";//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
StringBuffer errStringXml = null;
String sql = "";
String empCode = "", status = "", prdCode = "", procType = "", paySite = "", tranId = "";
String empCode = "";
String status = "";
String prdCode = "";
String procType = "";
String paySite = "";
String tranId = "";
int userLevel = 0;
Date fromDate = null, relieveDate = null, toDate = null, joinDate = null;
Date fromDate = null;
Date relieveDate = null;
Date toDate = null;
Date joinDate = null;
try
{
conn = getConnection();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
if(objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo:::"+currentFormNo);
switch(currentFormNo)
{
case 1:
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println(">>>>>> childNodeName: "+childNodeName);
if("emp_code".equalsIgnoreCase(childNodeName))
switch(currentFormNo)
{
case 1:
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println(">>>>>> childNodeName: "+childNodeName);
if("emp_code".equalsIgnoreCase(childNodeName))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
if(empCode == null || empCode.trim().length() == 0)
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
if(empCode == null || empCode.trim().length() == 0)
errCode = "VTPAYARR04";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
errCode = "VTPAYARR04";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
break;
}
else if("A".equalsIgnoreCase(editFlag))// added condition by varsha V to execute validation on add mode 02-11-18
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
else if("A".equalsIgnoreCase(editFlag))// added condition by varsha V to execute validation on add mode 02-11-18
{
if(empCode != null && empCode.trim().length() > 0)
{
if(empCode != null && empCode.trim().length() > 0)
cnt = 0;
sql = "select status, pay_site from employee where emp_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
status = checkNull(rs.getString("status"));
paySite = checkNull(rs.getString("pay_site"));
cnt++;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTPAYARR04";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
if(status.equalsIgnoreCase("S"))
{
errCode = "VTPAYARR01";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
sql = "select usr_lev from users where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginCode);
rs = pstmt.executeQuery();
if(rs.next())
{
userLevel = rs.getInt("usr_lev");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(userLevel > 1)
{
cnt = 0;
sql = "select status, pay_site from employee where emp_code = ?";
sql = "select count(*) as cnt from user_site where user_id = ? and site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(1, loginCode);
pstmt.setString(2, paySite);
rs = pstmt.executeQuery();
if(rs.next())
{
status = checkNull(rs.getString("status"));
paySite = checkNull(rs.getString("pay_site"));
cnt++;
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
pstmt.close();
pstmt = null;
}
if(cnt == 0)
if(cnt <= 0)
{
errCode = "VTPAYARR04";
errList.add(errCode);
errCode = "VTPAYARR06";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
......@@ -161,10 +247,93 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
if(status.equalsIgnoreCase("S"))
}
}
}
}
else if("prd_code".equalsIgnoreCase(childNodeName))
{
prdCode = checkNull(genericUtility.getColumnValue("prd_code", dom));
if(prdCode == null || prdCode.trim().length() == 0)
{
errCode = "VTPAYARR05";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
else if("A".equalsIgnoreCase(editFlag))
{
if(prdCode != null && prdCode.trim().length() > 0)
{
cnt = 0;
sql = "select fr_date, to_date from period where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
fromDate = rs.getDate("fr_date");
toDate = rs.getDate("to_date");
cnt++;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTPAYARR05";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
sql = "select RELIEVE_DATE, DATE_JOIN from employee where EMP_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
relieveDate = rs.getDate("RELIEVE_DATE");
joinDate = rs.getDate("DATE_JOIN");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(fromDate != null && relieveDate != null)
{
if(fromDate.after(relieveDate))
{
errCode = "VTPAYARR01";
errList.add(errCode);
errCode = "VTPAYARR02";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
......@@ -174,74 +343,54 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
sql = "select usr_lev from users where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginCode);
rs = pstmt.executeQuery();
if(rs.next())
{
userLevel = rs.getInt("usr_lev");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(userLevel > 1)
}
//Added below code by Varsha V to check whether period code is before joining date or not 02-11-18
if(toDate != null && joinDate != null)
{
if(toDate.before(joinDate))
{
cnt = 0;
sql = "select count(*) as cnt from user_site where user_id = ? and site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginCode);
pstmt.setString(2, paySite);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt <= 0)
errCode = "VTPAYARR08";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
errCode = "VTPAYARR06";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
}
//Ended below code by Varsha V to check whether period code is before joining date or not 02-11-18
}
}
else if("prd_code".equalsIgnoreCase(childNodeName))
{
prdCode = checkNull(genericUtility.getColumnValue("prd_code", dom));
if(prdCode == null || prdCode.trim().length() == 0)
procType = checkNull(genericUtility.getColumnValue("proc_type", dom));
cnt = 0;
sql = "select count(*) as cnt from payarr_to_proc where EMP_CODE = ?"
+ " and prd_code = ? and proc_type = ? and (status is null or status = 'U')";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, procType);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt > 0)
{
errCode = "VTPAYARR05";
errList.add(errCode);
errCode = "VTPAYARR03";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
......@@ -251,109 +400,28 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
else if("A".equalsIgnoreCase(editFlag))
}
//Added by Jaffar S. for validation while editing same record on 19-11-18 [Start]
else if("E".equalsIgnoreCase(editFlag))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
procType = checkNull(genericUtility.getColumnValue("proc_type", dom));
tranId = checkNull(genericUtility.getColumnValue("tran_id", dom));
status = checkNull(genericUtility.getColumnValue("status", dom));
cnt = 0;
//Modified by Rohini on 03-Dec-2018[System should check for duplicate entries only in case of new Status is 'U']start
if(status.equalsIgnoreCase("U") )
{
if(prdCode != null && prdCode.trim().length() > 0)
{
cnt = 0;
sql = "select fr_date, to_date from period where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
rs = pstmt.executeQuery();
if(rs.next())
{
fromDate = rs.getDate("fr_date");
toDate = rs.getDate("to_date");
cnt++;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt == 0)
{
errCode = "VTPAYARR05";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
sql = "select RELIEVE_DATE, DATE_JOIN from employee where EMP_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
relieveDate = rs.getDate("RELIEVE_DATE");
joinDate = rs.getDate("DATE_JOIN");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(fromDate != null && relieveDate != null)
{
if(fromDate.after(relieveDate))
{
errCode = "VTPAYARR02";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
}
//Added below code by Varsha V to check whether period code is before joining date or not 02-11-18
if(toDate != null && joinDate != null)
{
if(toDate.before(joinDate))
{
errCode = "VTPAYARR08";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
}
//Ended below code by Varsha V to check whether period code is before joining date or not 02-11-18
}
procType = checkNull(genericUtility.getColumnValue("proc_type", dom));
cnt = 0;
sql = "select count(*) as cnt from payarr_to_proc where EMP_CODE = ?"
+ " and prd_code = ? and proc_type = ? and (status is null or status = 'U')";
+ " and prd_code = ? and proc_type = ? and (status = ? )"
+ "and tran_id <> ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, procType);
pstmt.setString(4, status);
pstmt.setString(5, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
......@@ -362,84 +430,35 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
if(rs != null)
{
rs.close();
rs = null;
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
pstmt.close();
pstmt = null;
}
if(cnt > 0)
{
errCode = "VTPAYARR03";
errList.add(errCode);
errCode = "VTPAYARR09";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]start
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
//Modified by Ahmed on 31-AUG-2018[To break and return error message when validation fails]end
}
}
//Added by Jaffar S. for validation while editing same record on 19-11-18 [Start]
else if("E".equalsIgnoreCase(editFlag))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
procType = checkNull(genericUtility.getColumnValue("proc_type", dom));
tranId = checkNull(genericUtility.getColumnValue("tran_id", dom));
status = checkNull(genericUtility.getColumnValue("status", dom));
cnt = 0;
//Modified by Rohini on 03-Dec-2018[System should check for duplicate entries only in case of new Status is 'U']start
if(status.equalsIgnoreCase("U") )
{
sql = "select count(*) as cnt from payarr_to_proc where EMP_CODE = ?"
+ " and prd_code = ? and proc_type = ? and (status = ? )"
+ "and tran_id <> ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, prdCode);
pstmt.setString(3, procType);
pstmt.setString(4, status);
pstmt.setString(5, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt > 0)
{
errCode = "VTPAYARR09";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
msgType = errorType(conn, errCode);
if (msgType.equalsIgnoreCase("E"))
{
break;
}
}
}
}
//Modified by Rohini on 03-Dec-2018[System should check for duplicate entries only in case of new Status is 'U']end
//Added by Jaffar S. for validation while editing same record on 19-11-18 [End]
}
}
}
}
int errListSize = errList.size();
System.out.println("errListSize::::::::::"+errListSize);
//Modified by Rohini on 03-Dec-2018[System should check for duplicate entries only in case of new Status is 'U']end
//Added by Jaffar S. for validation while editing same record on 19-11-18 [End]
}
}
}
}
int errListSize = errList.size();
System.out.println("errListSize::::::::::"+errListSize);
int count = 0;
String errFldName = null;
if (errList != null && errListSize > 0)
......@@ -449,7 +468,10 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
errCode = errList.get(count);
errFldName = errFields.get(count);
System.out.println(" testing :errCode .:" + errCode);
errString = getErrorString(errFldName, errCode, userId);
//modified by Shital on 12/07/2019[Start]
//errString = getErrorString(errFldName, errCode, userId);
errString = itmDbAccess.getErrorString(errFldName, errCode, userId, "", conn);
//modified by Shital on 12/07/2019[End]
System.out.println("errString>>>>>>>>>"+errString);
errorType = errorType(conn, errCode);
if (errString.length() > 0)
......@@ -468,13 +490,15 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
}
else
{
errStringXml = new StringBuffer("");
}
}
errStringXml.append("</Errors> </Root> \r\n");
}
catch(SQLException se)
{
......@@ -495,21 +519,25 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
finally
{
try {
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if ( conn != null )
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
//modified by Shital on 12/07/2019[Start]
conn.close();
conn = null;
//modified by Shital on 12/07/2019[End]
}
}
catch(Exception e)
{
......@@ -533,9 +561,13 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
Document dom1 = null;
Document dom2 = null;
String errFields = null;
GenericUtility genericUtility = GenericUtility.getInstance();
//modified by Shital Start Date 12/07/2019
//GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = null;
//modified by Shital End Date 12/07/2019
try
{
genericUtility = new E12GenericUtility();
System.out.println("xmlString [" + xmlString + "]");
System.out.println("xmlString1 [" + xmlString1 + "]");
System.out.println("xmlString2 [" + xmlString2 + "]");
......@@ -558,6 +590,7 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
{
System.out.println("Exception :PayarrToProc :" + e.getMessage()+ ":");
errFields = genericUtility.createErrorString(e);
throw new ITMException(e);
}
return errFields;
}
......@@ -576,23 +609,29 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
String descr="";
String procType="";
String tranId="";
String empName = "", paySite = "", loginCode = "";
String empName = "";
String paySite = "";
String loginCode = "";
int userLevel = 0, cnt = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
StringBuffer xmlString = new StringBuffer();
StringBuffer xmlString = null;
Connection conn = null;
int currentFormNo = 0;
try
{
conn = getConnection();
chgUser = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "userId"));
conn= getConnection();
xmlString = new StringBuffer();
genericUtility = new E12GenericUtility();
//chgUser = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "userId"));
chgUser = checkNull(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = getValueFromXTRA_PARAMS(xtraParams, "termId");
java.util.Date currDate = new java.util.Date();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
chgDate = sdf.format(currDate);
int currentFormNo = 0;
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
......@@ -604,232 +643,252 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
System.out.println("xtraparam is [" + xtraParams + "]");
switch ( currentFormNo )
{
case 1:
case 1:
{
xmlString.append("<Detail1 domID='1' dbID=''>\r\n");
//added itm_default itemchange by Varsha V on 24-08-18 [START] A17ESUN001
if (currentColumn.trim().equalsIgnoreCase("itm_default"))
{
xmlString.append("<emp_code protect=\"0\"><![CDATA[").append("").append("]]></emp_code>\r\n");
xmlString.append("<site protect=\"1\"><![CDATA[").append("").append("]]></site>\r\n");
xmlString.append("<descr protect=\"1\"><![CDATA[").append("").append("]]></descr>\r\n");
xmlString.append("<prd_code protect=\"0\"><![CDATA[").append("").append("]]></prd_code>\r\n");
xmlString.append("<status protect=\"1\"><![CDATA[").append("U").append("]]></status>\r\n");
xmlString.append("<prd_code__acc protect=\"1\"><![CDATA[").append("").append("]]></prd_code__acc>\r\n");
xmlString.append("<proc_date protect=\"1\"><![CDATA[").append("").append("]]></proc_date>\r\n");
xmlString.append("<proc_type protect=\"0\"><![CDATA[").append("PY").append("]]></proc_type>\r\n");
xmlString.append("<tran_id protect=\"1\"><![CDATA[").append("").append("]]></tran_id>\r\n");
}//Ended itm_default itemchange by Varsha V on 24-08-18 [END]
else if (currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
xmlString.append("<Detail1 domID='1' dbID=''>\r\n");
//added itm_default itemchange by Varsha V on 24-08-18 [START] A17ESUN001
if (currentColumn.trim().equalsIgnoreCase("itm_default"))
//modified by Shital on 12/07/2019[Start]
//empCode=checkNull(genericUtility.getColumnValue("emp_code", dom1));
empCode=checkNull(genericUtility.getColumnValue("emp_code", dom));
System.out.println("Emp_Code: ["+empCode+"]");
//site=checkNull(genericUtility.getColumnValue("site", dom1));
site=checkNull(genericUtility.getColumnValue("site", dom));
System.out.println("Site_Code: ["+site+"]");
//descr=checkNull(genericUtility.getColumnValue("descr", dom1));
descr=checkNull(genericUtility.getColumnValue("descr", dom));
System.out.println("Description: ["+descr+"]");
//prdCode=checkNull(genericUtility.getColumnValue("prd_code", dom1));
prdCode=checkNull(genericUtility.getColumnValue("prd_code", dom));
System.out.println("Prd_Code: ["+prdCode+"]");
//status=checkNull(genericUtility.getColumnValue("status", dom1));
status=checkNull(genericUtility.getColumnValue("status", dom));
System.out.println("Status: ["+status+"]");
//prdCodeAcc=checkNull(genericUtility.getColumnValue("prd_code__acc", dom1));
prdCodeAcc=checkNull(genericUtility.getColumnValue("prd_code__acc", dom));
System.out.println("prd_code__acc: ["+prdCodeAcc+"]");
//procDate=checkNull(genericUtility.getColumnValue("proc_date", dom1));
procDate=checkNull(genericUtility.getColumnValue("proc_date", dom));
System.out.println("proc_Date: ["+procDate+"]");
//procType=checkNull(genericUtility.getColumnValue("proc_type", dom1));
procType=checkNull(genericUtility.getColumnValue("proc_type", dom));
System.out.println("proc_type: ["+procType+"]");
//tranId=checkNull(genericUtility.getColumnValue("tran_id", dom1));
tranId=checkNull(genericUtility.getColumnValue("tran_id", dom));
//modified by Shital on 12/07/2019[End]
System.out.println("tran_id: ["+tranId+"]");
System.out.println("Current column is[" + currentColumn + "]");
xmlString.append("<emp_code protect=\"1\"><![CDATA[").append(checkNull(empCode)).append("]]></emp_code>\r\n");
xmlString.append("<site protect=\"1\"><![CDATA[").append(checkNull(site)).append("]]></site>\r\n");
xmlString.append("<descr protect=\"1\"><![CDATA[").append(checkNull(descr)).append("]]></descr>\r\n");
xmlString.append("<prd_code protect=\"1\"><![CDATA[").append(checkNull(prdCode)).append("]]></prd_code>\r\n");
xmlString.append("<prd_code__acc protect=\"1\"><![CDATA[").append(checkNull(prdCodeAcc)).append("]]></prd_code__acc>\r\n");
xmlString.append("<proc_date protect=\"1\"><![CDATA[").append(checkNull(procDate)).append("]]></proc_date>\r\n");
//Modified by Rohini on 03-Dec-2018[To set user required process type]start
//xmlString.append("<proc_type protect=\"1\"><![CDATA[").append("PY").append("]]></proc_type>\r\n");
xmlString.append("<proc_type protect=\"1\"><![CDATA[").append(procType).append("]]></proc_type>\r\n");
//Modified by Rohini on 03-Dec-2018[To set user required process type]end
xmlString.append("<tran_id protect=\"1\"><![CDATA[").append(checkNull(tranId)).append("]]></tran_id>\r\n");
xmlString.append("<chg_date><![CDATA[").append(checkNull(chgDate)).append("]]></chg_date>\r\n");
xmlString.append("<chg_user><![CDATA[").append(checkNull(chgUser)).append("]]></chg_user>\r\n");
xmlString.append("<chg_term><![CDATA[").append(checkNull(chgTerm)).append("]]></chg_term>\r\n");
// if((prdCodeAcc != null && prdCodeAcc.trim().length()>0 ) && status.trim().equalsIgnoreCase("P") )
// {
//
// System.out.println("IN IF CONDITION::::::::::");
// xmlString.append("<status protect=\"1\"><![CDATA[").append(checkNull(status)).append("]]></status>\r\n");
// }
if((status.trim().equalsIgnoreCase("P") ))
{
System.out.println("IN IF CONDITION::::::::::");
xmlString.append("<status protect=\"1\"><![CDATA[").append(checkNull(status)).append("]]></status>\r\n");
}
else
{
xmlString.append("<emp_code protect=\"0\"><![CDATA[").append("").append("]]></emp_code>\r\n");
xmlString.append("<site protect=\"1\"><![CDATA[").append("").append("]]></site>\r\n");
xmlString.append("<descr protect=\"1\"><![CDATA[").append("").append("]]></descr>\r\n");
xmlString.append("<prd_code protect=\"0\"><![CDATA[").append("").append("]]></prd_code>\r\n");
xmlString.append("<status protect=\"1\"><![CDATA[").append("U").append("]]></status>\r\n");
xmlString.append("<prd_code__acc protect=\"1\"><![CDATA[").append("").append("]]></prd_code__acc>\r\n");
xmlString.append("<proc_date protect=\"1\"><![CDATA[").append("").append("]]></proc_date>\r\n");
xmlString.append("<proc_type protect=\"0\"><![CDATA[").append("PY").append("]]></proc_type>\r\n");
xmlString.append("<tran_id protect=\"1\"><![CDATA[").append("").append("]]></tran_id>\r\n");
}//Ended itm_default itemchange by Varsha V on 24-08-18 [END]
else if (currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
xmlString.append("<status protect=\"0\"><![CDATA[").append(checkNull(status)).append("]]></status>\r\n");
System.out.println("IN ELSE CONDITION::::::::::");
}
}
//added emp_code itemchange by Varsha V on 24-08-18 [START] A17ESUN001
else if (currentColumn.trim().equalsIgnoreCase("emp_code"))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
site = ""; empName = ""; paySite = "";
if(empCode != null && empCode.trim().length() > 0)
{
empCode=checkNull(genericUtility.getColumnValue("emp_code", dom1));
System.out.println("Emp_Code: ["+empCode+"]");
site=checkNull(genericUtility.getColumnValue("site", dom1));
System.out.println("Site_Code: ["+site+"]");
descr=checkNull(genericUtility.getColumnValue("descr", dom1));
System.out.println("Description: ["+descr+"]");
prdCode=checkNull(genericUtility.getColumnValue("prd_code", dom1));
System.out.println("Prd_Code: ["+prdCode+"]");
status=checkNull(genericUtility.getColumnValue("status", dom1));
System.out.println("Status: ["+status+"]");
prdCodeAcc=checkNull(genericUtility.getColumnValue("prd_code__acc", dom1));
System.out.println("prd_code__acc: ["+prdCodeAcc+"]");
procDate=checkNull(genericUtility.getColumnValue("proc_date", dom1));
System.out.println("proc_Date: ["+procDate+"]");
procType=checkNull(genericUtility.getColumnValue("proc_type", dom1));
System.out.println("proc_type: ["+procType+"]");
tranId=checkNull(genericUtility.getColumnValue("tran_id", dom1));
System.out.println("tran_id: ["+tranId+"]");
System.out.println("Current column is[" + currentColumn + "]");
xmlString.append("<emp_code protect=\"1\"><![CDATA[").append(checkNull(empCode)).append("]]></emp_code>\r\n");
xmlString.append("<site protect=\"1\"><![CDATA[").append(checkNull(site)).append("]]></site>\r\n");
xmlString.append("<descr protect=\"1\"><![CDATA[").append(checkNull(descr)).append("]]></descr>\r\n");
xmlString.append("<prd_code protect=\"1\"><![CDATA[").append(checkNull(prdCode)).append("]]></prd_code>\r\n");
xmlString.append("<prd_code__acc protect=\"1\"><![CDATA[").append(checkNull(prdCodeAcc)).append("]]></prd_code__acc>\r\n");
xmlString.append("<proc_date protect=\"1\"><![CDATA[").append(checkNull(procDate)).append("]]></proc_date>\r\n");
//Modified by Rohini on 03-Dec-2018[To set user required process type]start
//xmlString.append("<proc_type protect=\"1\"><![CDATA[").append("PY").append("]]></proc_type>\r\n");
xmlString.append("<proc_type protect=\"1\"><![CDATA[").append(procType).append("]]></proc_type>\r\n");
//Modified by Rohini on 03-Dec-2018[To set user required process type]end
xmlString.append("<tran_id protect=\"1\"><![CDATA[").append(checkNull(tranId)).append("]]></tran_id>\r\n");
xmlString.append("<chg_date><![CDATA[").append(checkNull(chgDate)).append("]]></chg_date>\r\n");
xmlString.append("<chg_user><![CDATA[").append(checkNull(chgUser)).append("]]></chg_user>\r\n");
xmlString.append("<chg_term><![CDATA[").append(checkNull(chgTerm)).append("]]></chg_term>\r\n");
// if((prdCodeAcc != null && prdCodeAcc.trim().length()>0 ) && status.trim().equalsIgnoreCase("P") )
// {
//
// System.out.println("IN IF CONDITION::::::::::");
// xmlString.append("<status protect=\"1\"><![CDATA[").append(checkNull(status)).append("]]></status>\r\n");
// }
if((status.trim().equalsIgnoreCase("P") ))
sql = "SELECT EMP_SITE, FN_GET_EMP_NAME( EMP_CODE,'X')AS EMP_NAME, PAY_SITE FROM EMPLOYEE WHERE EMP_CODE= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
System.out.println("IN IF CONDITION::::::::::");
xmlString.append("<status protect=\"1\"><![CDATA[").append(checkNull(status)).append("]]></status>\r\n");
site = checkNull(rs.getString("EMP_SITE"));
empName = checkNull(rs.getString("EMP_NAME"));
paySite = checkNull(rs.getString("PAY_SITE"));
}
else
if(rs != null)
{
xmlString.append("<status protect=\"0\"><![CDATA[").append(checkNull(status)).append("]]></status>\r\n");
System.out.println("IN ELSE CONDITION::::::::::");
rs.close();
rs = null;
}
}
//added emp_code itemchange by Varsha V on 24-08-18 [START] A17ESUN001
else if (currentColumn.trim().equalsIgnoreCase("emp_code"))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
site = ""; empName = ""; paySite = "";
if(empCode != null && empCode.trim().length() > 0)
if(pstmt != null)
{
sql = "SELECT EMP_SITE, FN_GET_EMP_NAME( EMP_CODE,'X')AS EMP_NAME, PAY_SITE FROM EMPLOYEE WHERE EMP_CODE= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if(rs.next())
{
site = checkNull(rs.getString("EMP_SITE"));
empName = checkNull(rs.getString("EMP_NAME"));
paySite = checkNull(rs.getString("PAY_SITE"));
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
// addec below code by Varsha V to check user rights 02-11-18
sql = "select usr_lev from users where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginCode);
rs = pstmt.executeQuery();
if(rs.next())
{
userLevel = rs.getInt("usr_lev");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
// Ended below code by Varsha V to check user rights 02-11-18
siteDescr = "";
if(site.trim().length() > 0 && !"null".equalsIgnoreCase(site) )
{
sql = "SELECT DESCR FROM SITE WHERE SITE_CODE = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, site );
rs = pstmt.executeQuery();
if(rs.next())
{
siteDescr = checkNull( rs.getString( "DESCR" ) );
}
System.out.println("Site description::: [:" + siteDescr+ ":]" );
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
pstmt.close();
pstmt = null;
}
// addec below code by Varsha V to check user rights 02-11-18
sql = "select usr_lev from users where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginCode);
rs = pstmt.executeQuery();
if(rs.next())
{
userLevel = rs.getInt("usr_lev");
}
// addec below code by Varsha V to check user rights on 02-11-18
if(userLevel > 1)
if(rs != null)
{
cnt = 0;
sql = "select count(*) as cnt from user_site where user_id = ? and site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginCode);
pstmt.setString(2, paySite);
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
// Ended below code by Varsha V to check user rights 02-11-18
siteDescr = "";
if(site.trim().length() > 0 && !"null".equalsIgnoreCase(site) )
{
sql = "SELECT DESCR FROM SITE WHERE SITE_CODE = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, site );
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
siteDescr = checkNull( rs.getString( "DESCR" ) );
}
if(rs != null)
System.out.println("Site description::: [:" + siteDescr+ ":]" );
if( rs != null )
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
rs = null;
}
if(cnt > 0)
if( pstmt != null )
{
xmlString.append("<name><![CDATA[").append(empName).append("]]></name>\r\n");
xmlString.append("<site><![CDATA[").append(site).append("]]></site>\r\n");
xmlString.append("<descr><![CDATA[").append(siteDescr).append("]]></descr>\r\n");
}
else
{
xmlString.append("<name><![CDATA[").append("").append("]]></name>\r\n");
xmlString.append("<site><![CDATA[").append("").append("]]></site>\r\n");
xmlString.append("<descr><![CDATA[").append("").append("]]></descr>\r\n");
}
pstmt.close();
pstmt = null;
}
}
else
}
// addec below code by Varsha V to check user rights on 02-11-18
if(userLevel > 1)
{
cnt = 0;
sql = "select count(*) as cnt from user_site where user_id = ? and site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginCode);
pstmt.setString(2, paySite);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(cnt > 0)
{
xmlString.append("<name><![CDATA[").append(empName).append("]]></name>\r\n");
xmlString.append("<site><![CDATA[").append(site).append("]]></site>\r\n");
xmlString.append("<descr><![CDATA[").append(siteDescr).append("]]></descr>\r\n");
}
// Ended below code by Varsha V to check user rights 02-11-18
else
{
xmlString.append("<name><![CDATA[").append("").append("]]></name>\r\n");
xmlString.append("<site><![CDATA[").append("").append("]]></site>\r\n");
xmlString.append("<descr><![CDATA[").append("").append("]]></descr>\r\n");
}
}
else
{
xmlString.append("<name><![CDATA[").append(empName).append("]]></name>\r\n");
xmlString.append("<site><![CDATA[").append(site).append("]]></site>\r\n");
xmlString.append("<descr><![CDATA[").append(siteDescr).append("]]></descr>\r\n");
}
//Ended emp_code itemchange by Varsha V on 24-08-18 [End]
xmlString.append("</Detail1>\r\n");
// Ended below code by Varsha V to check user rights 02-11-18
}
//Ended emp_code itemchange by Varsha V on 24-08-18 [End]
xmlString.append("</Detail1>\r\n");
}
}
xmlString.append("</Root>\r\n");
}
catch (Exception ex)
{
System.out.println("1st catch Exception::" + ex.getMessage());
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try {
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if ( conn != null )
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
//modified by Shital on 12/07/2019[start]
conn.close();
conn = null;
//modified by Shital on 12/07/2019[End]
}
}
catch(Exception e)
{
System.out.println("[PayarrToProc][itemChanged]Exception ::"+e);
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("value of xmlString::::" + xmlString);
xmlString.append("</Root>\r\n");
System.out.println("xmlString....[" + xmlString.toString());
return xmlString.toString();
}
......@@ -838,7 +897,8 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
if (input == null)
{
input = "";
} else
}
else
{
input = input.trim();
}
......@@ -859,10 +919,22 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
{
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
//modified by Shital on 12/07/2019[start]
//rs.close();
//rs = null;
//pstmt.close();
//pstmt = null;
if(rs != null)
{
rs.close();
rs = null;
}
//modified by Shital on 12/07/2019[End]
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception ex)
{
......@@ -895,4 +967,4 @@ public class PayarrToProc extends ValidatorEJB implements PayarrToProcLocal,Paya
}
//Created by Suraj [20/3/15] [To create a payarr_to_proc transaction][Ends]
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