Commit efa87ccd authored by ysawant's avatar ysawant

*Added PfNumberPostSave component on [23-10-19]

PfNumberprs.java
PfNumberPostSave.java
PfNumberPostSaveLocal.java
PfNumberPostSaveRemote.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@210486 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 553c2bcb
/**Developed by Santosh Gupta
* **/
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
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.ITMException;
public class PfNumberPostSave extends ValidatorEJB implements PfNumberPostSaveLocal,PfNumberPostSaveRemote
{
@Override
public String postSave() throws RemoteException, ITMException {
// TODO Auto-generated method stub
return null;
}
@Override
public String postSave( String domString, String editFlag, String xtraParams, Connection conn )throws RemoteException, ITMException
{
System.out.println("@V@ In post save of PfNumberPostSave");
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node childNode = null;
Node parentNode = null;
String retString = "";
int parentNodeListLength = 0;
int childNodeListLength = 0;
String sql = "";
String childNodeName = "";
String errString = null;
Document domStr = null;
String updtFlag="";
ResultSet rs = null;
PreparedStatement pstmt = null ;
int count=0;
boolean isError = false;
String termId ="",userCode="";
String sqlStr = null;
String empCode = "";
String pfNum = "";
String chgType="",uanNum="";
Statement stmt = null;
String tranDate = null;
//modified by Yashwant on 30-07-2019[Start]
//GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility();
//modified by Yashwant on 30-07-2019[End]
termId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" );
userCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
System.out.println("termId["+termId+"][userCode]["+userCode+"]");
try
{
System.out.println("Post_Save start");
DateFormat dateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
java.util.Date todayDt = new java.util.Date();
String todayDateStr = dateFormat.format(todayDt);
System.out.println("currDate1::::::"+todayDateStr);
Timestamp currentDateTime =null;
currentDateTime=Timestamp.valueOf(genericUtility.getValidDateString(todayDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat())
+ " 00:00:00.0");
System.out.println("@S@currendatetime PFNO Post"+currentDateTime);
if (domString != null && domString.trim().length() != 0 )
{
domStr = parseString(domString);
}
parentNodeList = domStr.getElementsByTagName("Detail1");
parentNodeListLength = parentNodeList.getLength();
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode = parentNodeList.item(selectedRow);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName();
// updtFlag = getAttribValue(parentNode,"attribute", "updateFlag");
if(!updtFlag.equalsIgnoreCase("D"))
{
if(childNode.getFirstChild()!=null)
{
if (childNodeName.equals("emp_code"))
{
empCode = (childNode.getFirstChild().getNodeValue().trim());
System.out.println("Inside presave empCode"+empCode);
}
else if (childNodeName.equals("tran_date"))
{
tranDate = (childNode.getFirstChild().getNodeValue().trim());
System.out.println("Inside presave tranDate"+tranDate);
}
//Modified by santosh A16JSUN009 on 14/JUL/2017 to get uan,pf_no,change type[Start]
else if (childNodeName.equals("chg_type"))
{
chgType = (childNode.getFirstChild().getNodeValue().trim());
System.out.println("Inside presave change type["+chgType+"]");
}
else if (childNodeName.equals("pf_no"))
{
pfNum = (childNode.getFirstChild().getNodeValue().trim());
System.out.println("Inside presave pfNum["+pfNum+"]");
}
else if (childNodeName.equals("uan_no"))
{
uanNum = (childNode.getFirstChild().getNodeValue().trim());
System.out.println("Inside presave uanNum["+uanNum+"]");
}
}
}
}
}
if(tranDate == null || tranDate.trim().length() <= 0 )
{
String errCode = "VTBLKCHDTE";
errString=getError("Tran date should not be left blank",errCode,conn);
return errString;
}
if(empCode == null || empCode.trim().length() <= 0 )
{
String errCode = "VTBLKCHODN";
errString=getError("Employee code should not be left blank",errCode,conn);
return errString;
}
else if(empCode != null && empCode.trim().length() > 0)
{
sql = "SELECT COUNT(*) AS COUNT FROM EMPLOYEE WHERE EMP_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt("COUNT");
}
pstmt.close();
pstmt=null;
rs.close();
rs=null;
if (count == 0)
{
String errCode = "VTINVCHODN";
errString=getError("Invalid employee code, please enter valid employee code",errCode,conn);
return errString;
}
}
if(("P".equalsIgnoreCase(chgType)|| "B".equalsIgnoreCase(chgType))&&(pfNum == null || pfNum.trim().length() <= 0 ))
{
String errCode = "VTBLKPFODN";
errString=getError("Pf number should not be left blank",errCode,conn);
return errString;
}
if(("U".equalsIgnoreCase(chgType)||"B".equalsIgnoreCase(chgType)) && (uanNum == null || uanNum.trim().length() <=0 ))
{
String errCode = "VTBLKUANNO";
System.out.println("@S@UAN number should not be left blank");
errString=getError("UAN number should not be left blank",errCode,conn);
return errString;
}
if(empCode != null && empCode.trim().length() > 0)
{
if(chgType != null && chgType.trim().length() > 0)
{
if("P".equalsIgnoreCase(chgType) && (pfNum != null && pfNum.trim().length() > 0))
{
System.out.println("===IF chgType is P==");
sqlStr =" UPDATE EMPLOYEE SET PF_NO = ? , CHG_DATE =? , CHG_TERM = ? , CHG_USER = ? ";
}
else if("U".equalsIgnoreCase(chgType) && (uanNum != null && uanNum.trim().length() > 0))
{
System.out.println("===IF chgType is U==");
sqlStr =" UPDATE EMPLOYEE SET PF_UAN = ? , CHG_DATE =? , CHG_TERM = ? , CHG_USER = ? ";
}
else if("B".equalsIgnoreCase(chgType) && (uanNum != null && uanNum.trim().length() > 0) && (pfNum != null && pfNum.trim().length() > 0) )
{
System.out.println("===IF chgType is B==");
sqlStr =" UPDATE EMPLOYEE SET PF_NO = ?, PF_UAN = ? , CHG_DATE =? , CHG_TERM = ? , CHG_USER = ? " ;
}
sqlStr = sqlStr + " WHERE EMP_CODE = ?";
System.out.println("@S@sqlStr.........:: " + sqlStr);
pstmt = conn.prepareStatement(sqlStr);
if("P".equalsIgnoreCase(chgType) && (pfNum != null && pfNum.trim().length() > 0))
{
pstmt.setString(1, pfNum);
pstmt.setTimestamp(2, currentDateTime);
pstmt.setString(3, termId);
pstmt.setString(4, userCode);
pstmt.setString(5,empCode);
}
else if("U".equalsIgnoreCase(chgType) && (uanNum != null && uanNum.trim().length() > 0))
{
pstmt.setString(1, uanNum);
pstmt.setTimestamp(2, currentDateTime);
pstmt.setString(3, termId);
pstmt.setString(4, userCode);
pstmt.setString(5,empCode);
}
else if("B".equalsIgnoreCase(chgType) && (uanNum != null && uanNum.trim().length() > 0) && (pfNum != null && pfNum.trim().length() > 0) )
{
pstmt.setString(1, pfNum);
pstmt.setString(2, uanNum);
pstmt.setTimestamp(3, currentDateTime);
pstmt.setString(4, termId);
pstmt.setString(5, userCode);
pstmt.setString(6,empCode);
System.out.println("termId["+termId+"][userCode]["+userCode+"]");
}
pstmt.executeUpdate();
pstmt.close();
pstmt=null;
}
}
}//End Of Try Block
catch (SQLException sqe)
{
System.out.println("The SQLException occurs in [EmpAdPrsEJB] :: [executepreSaveRec] :"+sqe);
sqe.printStackTrace();
isError = true;
throw new ITMException(sqe);
}
catch(Exception e)
{
System.out.println("The Exception occurs in [EmpAdPrsEJB] :: [executepreSaveRec] :"+e);
e.printStackTrace();
isError = true;
throw new ITMException(e);
}
finally
{
try
{
if(isError)
{
//conn.rollback();
//System.out.println("PFNumber connection rollback");
}
else
{
//conn.commit();
//System.out.println("PFNumber connection Commit");
}
System.out.println("Closing stmt and pstmt In [executepreSaveRec]......");
if (rs != null)
{
rs.close();
rs = null;
}
if(stmt != null)
{
stmt.close();
stmt = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.err.println("Exception :[EmpAdPrsEJB] :: [executepreSaveRec] :\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
return retString;
}
private String getError(String descr,String Code,Connection conn)
throws ITMException, Exception
{
String mainStr ="";
try
{
String errString = "";
errString = new ITMDBAccessEJB().getErrorString("",Code,"","",conn);
String begPart = errString.substring(0,errString.indexOf("<message>")+9);
String endDesc = errString.substring(errString.indexOf("</description>"));
mainStr= begPart+"Invalid Data"+"</message><description>";
mainStr= mainStr+" "+descr+" "+endDesc;
System.out.println("mainStr:::::::::::::::::: "+mainStr);
begPart = null;
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
return mainStr;
}
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ValidatorLocal;
public interface PfNumberPostSaveLocal extends ValidatorLocal
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Connection;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
public interface PfNumberPostSaveRemote extends ValidatorRemote
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
......@@ -125,12 +125,12 @@ public class PfNumberprs extends ValidatorEJB implements PfNumberprsLocal,PfNum
System.out.println("status date testing"+statusDate + " 00:00:00");
System.out.println("editFlag="+editFlag);
userId = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
//Yashwant
//modified by Yashwant on 30-07-2019[Start]
//ConnDriver connDriver = null;
//connDriver = new ConnDriver();
//connObject = connDriver.getConnectDB("DriverValidator");
connObject = getConnection();
//Yashwant
//modified by Yashwant on on 30-07-2019[End]
parentNodeList = currDom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
......
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