Commit a96c6ca4 authored by sanashaikh's avatar sanashaikh

Sana S: Added on 01/10/2019

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@208689 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8c978610
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
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.ejb.sys.UtilMethods;
import ibase.webitm.utility.ITMException;
//Created by Sana S on 23/09/2019 [start]
public class PayrollRemarksProcIC extends ValidatorEJB implements PayrollRemarksProcICLocal,PayrollRemarksProcICRemote
{
String chgUser = null;
String chgTerm = null;
String loginSite = null;
String userId = null;
String taxClass=null;
String taxChap=null;
String taxEnv=null;
String prdCode = null;
Connection con = null;
String sql = "";
E12GenericUtility e12GenericUtility = new E12GenericUtility();
ITMDBAccessEJB itmDbAcess = new ITMDBAccessEJB();
UtilMethods utilMethod = new UtilMethods();
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
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = "";
System.out.println("xmlString : " + xmlString);
System.out.println("xmlString1 : " + xmlString1);
System.out.println("xmlString2 : " + xmlString2);
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
dom = e12GenericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length()!=0)
{
dom1 = e12GenericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
dom2 = e12GenericUtility.parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
System.out.println("ErrString :" + errString);
}
catch(Exception e)
{
System.out.println("Exception :PayrollRemarksEJB :wfValData(String xmlString):" + e.getMessage() + ":");
errString = e12GenericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning from PayrollRemarksEJB wfValData");
return (errString);
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
NodeList parentNodeList = null,childNodeList = null;
Node parentNode = null, childNode = null;
String childNodeName="",userId="";
String sql="";
String prdCodeFrom="",prdCodeTo="";
int currentFormNo=0,cnt=0;
PreparedStatement pstmt = null;
ResultSet rs= null;
int childNodeListLength;
StringBuffer errStringXml = null;
int prdFrom=0,prdTo=0;
String errCode= "";
errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>");
try
{
con = getConnection();
if(objContext!=null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1:
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (int ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
if (childNode.getNodeType() != Node.ELEMENT_NODE)
{
continue;
}
childNodeName = childNode.getNodeName();
System.out.println("childNodeName.editFlag." + childNodeName + ".." + editFlag);
if (childNodeName.equalsIgnoreCase("prd_code__fr") || childNodeName.equalsIgnoreCase("prd_code__to"))
{
String codefrom = checkNull(e12GenericUtility.getColumnValue("prd_code__fr", dom));
String codeto = checkNull(e12GenericUtility.getColumnValue("prd_code__to", dom));
sql = " select count(1) as cnt from period where code = ? OR code= ? ";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, codefrom);
pstmt.setString(2, codeto);
rs = pstmt.executeQuery();
System.out.println(" SQL :: " + sql);
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 = itmDbAcess.getErrorString("", "VMPRD1", userId, "", con);
return errCode;
}
else
{
prdCodeFrom=checkNull(e12GenericUtility.getColumnValue("prd_code__fr", dom));
prdCodeTo=checkNull(e12GenericUtility.getColumnValue("prd_code__to", dom));
prdFrom=Integer.parseInt(prdCodeFrom);
prdTo=Integer.parseInt(prdCodeTo);
if(prdFrom > prdTo)
{
errCode = itmDbAcess.getErrorString("", "VMPRD2", userId, "", con);
return errCode;
}
}
}
else if (childNodeName.equalsIgnoreCase("remarks"))
{
String remark = checkNull(e12GenericUtility.getColumnValue("remarks", dom));
System.out.println("Remark Value:"+remark);
if (remark.trim().length() == 0 || remark == null )
{
System.out.println("Remark is null");
errCode = itmDbAcess.getErrorString("", "NULLREM", userId, "", con);
return errCode;
}
}
}
break;
}
System.out.println("errStringXml.toString()---1= "+errStringXml.toString());
errStringXml.append("</Errors></Root>\r\n");
System.out.println("errStringXml.toString()---2= "+errStringXml.toString());
}
catch(Exception e)
{
System.out.println("Exception :ShiftPatternEJB :wfValData(Document dom):" + e.getMessage() + ":");
errCode = e12GenericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (con != null)
{
con.close();
con = null;
}
}
catch(Exception e1)
{
System.out.println("Exception during closing the connections :ShiftPatternEJB :wfValData(Document dom):" + e1.getMessage() + ":");
errCode = e12GenericUtility.createErrorString(e1);
e1.printStackTrace();
}
}
System.out.println("error :"+errCode);
return errCode;
}
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 valueXmlString = "";
try
{
System.out.println("xmlString :"+xmlString+ "\n xmlString1 :"+xmlString1+ " \nxmlString2 :"+xmlString2);
if(xmlString != null && xmlString.trim().length()!=0)
{
dom = e12GenericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length()!=0)
{
dom1 = e12GenericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length()!=0)
{
dom2 = e12GenericUtility.parseString(xmlString2);
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception :PayrollRemarksItmChngEJB :itemChanged(String,String) :==>\n"+e.getMessage());
valueXmlString = e12GenericUtility.createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
return valueXmlString.toString();
}
@SuppressWarnings("null")
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String empCodeFrom = "",empCodeTo="";
String lName="",fName="",fullName="";
String prdCodeFrom="",prdCodeTo="";
String siteCodeTo="",siteCodeFrom="";
String procGroupFrom="",procGroupTo="";
int mlev=0;
String columnValue = "";
String site_code = "",descr="";
String userId="";
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
StringBuffer valueXmlString = new StringBuffer();
E12GenericUtility e12GenericUtility = new E12GenericUtility();
try
{
conn=getConnection();
columnValue = checkNull(e12GenericUtility.getColumnValue(currentColumn,dom));
System.out.println("columnValue :"+columnValue);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><Header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></Header>");
valueXmlString.append("<Detail1>");
userId = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (currentColumn.trim().equals("itm_default"))
{
System.out.println("xtraParamsitemchange:---------------"+xtraParams);
site_code = e12GenericUtility.getValueFromXTRA_PARAMS(xtraParams,"site_code");
if(site_code!=null || site_code.trim().length()>0)
{
valueXmlString.append("<site_code__fr>").append(site_code).append("</site_code__fr>\r\n");
valueXmlString.append("<site_code__to>").append(site_code).append("</site_code__to>\r\n");
sql="select descr from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, site_code);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString("descr");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<fr_site_descr>").append(descr).append("</fr_site_descr>\r\n");
valueXmlString.append("<to_site_descr>").append(descr).append("</to_site_descr>\r\n");
sql="select usr_lev from users where code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, userId);
rs = pstmt.executeQuery();
if(rs.next())
{
mlev = rs.getInt("usr_lev");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (mlev > 1 )
{
valueXmlString.append("<fr_site_descr protect=\"1\"><![CDATA[").append(site_code).append("]]></fr_site_descr>\r\n");
valueXmlString.append("<to_site_descr protect=\"1\"><![CDATA[").append(site_code).append("]]></to_site_descr>\r\n");
}
}
}
else if ("emp_code__fr".equalsIgnoreCase(currentColumn) )
{
empCodeFrom = e12GenericUtility.getColumnValue("emp_code__fr", dom);
sql="select emp_fname, emp_lname from employee where emp_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCodeFrom);
rs = pstmt.executeQuery();
if(rs.next())
{
fName = rs.getString("emp_fname");
lName = rs.getString("emp_lname");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
fullName = fName +" "+ lName;
valueXmlString.append("<emp_name__fr>").append(fullName).append("</emp_name__fr>\r\n");
}
else if ("emp_code__to".equalsIgnoreCase(currentColumn) )
{
empCodeTo = e12GenericUtility.getColumnValue("emp_code__to", dom);
sql="select emp_fname, emp_lname from employee where emp_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCodeTo);
rs = pstmt.executeQuery();
if(rs.next())
{
fName = rs.getString("emp_fname");
lName = rs.getString("emp_lname");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
fullName = fName +" "+ lName;
valueXmlString.append("<emp_name__to>").append(fullName).append("</emp_name__to>\r\n");
}
else if ("prd_code__fr".equalsIgnoreCase(currentColumn) )
{
prdCodeFrom = e12GenericUtility.getColumnValue("prd_code__fr", dom);
sql="select descr from period where code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCodeFrom);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString("descr");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<fr_prd_descr>").append(descr).append("</fr_prd_descr>\r\n");
}
else if ("prd_code__to".equalsIgnoreCase(currentColumn) )
{
prdCodeTo = e12GenericUtility.getColumnValue("prd_code__to", dom);
sql="select descr from period where code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCodeTo);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString("descr");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<to_prd_descr>").append(descr).append("</to_prd_descr>\r\n");
}
else if ("site_code__fr".equalsIgnoreCase(currentColumn) )
{
siteCodeFrom = e12GenericUtility.getColumnValue("site_code__fr", dom);
sql="select descr from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCodeFrom);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString("descr");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<fr_site_descr>").append(descr).append("</fr_site_descr>\r\n");
}
else if ("site_code__to".equalsIgnoreCase(currentColumn) )
{
siteCodeTo = e12GenericUtility.getColumnValue("site_code__to", dom);
sql="select descr from site where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCodeTo);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString("descr");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<to_site_descr>").append(descr).append("</to_site_descr>\r\n");
}
else if ("proc_group__from".equalsIgnoreCase(currentColumn) )
{
procGroupFrom = e12GenericUtility.getColumnValue("proc_group__from", dom);
sql="select descr from gencodes where fld_name= ? and fld_value = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "PROC_GROUP");
pstmt.setString(2, procGroupFrom);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString("descr");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<proc_group__fr_name>").append(descr).append("</proc_group__fr_name>\r\n");
}
else if ("proc_group__to".equalsIgnoreCase(currentColumn) )
{
procGroupTo = e12GenericUtility.getColumnValue("proc_group__to", dom);
sql="select descr from gencodes where fld_name= ? and fld_value = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "PROC_GROUP");
pstmt.setString(2, procGroupTo);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString("descr");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<proc_group__to_name>").append(descr).append("</proc_group__to_name>\r\n");
}
valueXmlString.append("</Detail1>\r\n");
valueXmlString.append("</Root>\r\n");
}
catch(Exception e)
{
System.out.println("Exception in PayrollRemarksItmChngEJB.java occured");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
System.out.println("Return XML" + valueXmlString.toString() );
return valueXmlString.toString();
}
private String checkNull(String input)
{
if (input == null)
{
input = "";
}
else
{
input =input.trim();
}
return input;
}
private String errorType(Connection conn, String errorCode) throws ITMException
{
String msgType = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
if (conn == null)
{
System.out.println("Connection is null");
} else
{
System.out.println("Connection is not null");
}
sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, errorCode);
rs = pstmt.executeQuery();
if (rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
}
//Created by Sana S on 23/09/2019 [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