Commit c44fb80c authored by sanashaikh's avatar sanashaikh

Sana S:modified on 22/08/2019

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@206260 ce508802-f39f-4f6c-b175-0d175dae99d5
parent bd4c2967
package ibase.webitm.ejb.adm.adv;
import java.rmi.RemoteException;
import java.rmi.RemoteException;
import javax.naming.InitialContext;
import java.sql.*;
import java.text.*;
import ibase.system.config.*;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
// Created by Sana Shaikh on 20/08/2019 for holiday Precancellation of employee [START]
public class HolChangePreCanc extends ActionHandlerEJB implements HolChangePreCancLocal,HolChangePreCancRemote
{
public String actionHandler() throws RemoteException,ITMException
{
return "";
}
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
ITMDBAccessEJB itmDBAccess = null;
int updStatus = 0;
String sql = "";
String empCode = "";
String holDateFor = "";
String holDateTo = "";
String holType = "";
String holTable = "";
String confirm = "";
String retString = "";
java.sql.Timestamp holDateForSql = null;
java.sql.Timestamp holDateToSql = null;
E12GenericUtility genericUtility = new E12GenericUtility();
String userID = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"LoginCode");
String siteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
try
{
System.out.println("call HolCahngeCanc [actionHandler] method .....for tran id"+ tranId);
System.out.println(" xtraParams [" + xtraParams + "] ");
System.out.println(" forcedFlag [" + forcedFlag + "] ");
itmDBAccess = new ITMDBAccessEJB();
System.out.println(" I N S I D E C A S E ");
System.out.println("tranId [" + tranId + "]");
String tranIDArray[] = tranId.split("\\:");
empCode = tranIDArray[0];
holDateFor = tranIDArray[1];
holDateTo = tranIDArray[2];
holType = tranIDArray[3];
System.out.println("FROM DATE STRING BEFORE DBDATE [" + holDateFor + "]");
holDateForSql = java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString(holDateFor,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()));
System.out.println("FROM DATE STRING AFTER DBDATE [" + holDateForSql + "]");
System.out.println("TO DATE STRING BEFORE DBDATE [" + holDateTo + "]");
holDateToSql = java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString(holDateTo,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()));
System.out.println("TO DATE STRING AFTER DBDATE [" + holDateToSql + "]");
conn=getConnection();
System.out.println("emp Code [" + empCode + "] hol date for [" + holDateForSql + "] hol date to [" + holDateToSql + "] hol type" +holType );
sql = "SELECT CONFIRMED AS CONF FROM CHANGE_HOLIDAY WHERE EMP_CODE = ? AND HOL_DATE_FOR = ? AND HOL_DATE_TO = ? AND HOL_TYPE = ?";
pstmt = conn.prepareStatement(sql);
System.out.println("[HolCahngeCanc][confirm]sqlStatus::" + sql);
pstmt.setString(1, checkNull(empCode));
pstmt.setTimestamp(2, holDateForSql);
pstmt.setTimestamp(3, holDateToSql);
pstmt.setString(4, checkNull(holType));
rs = pstmt.executeQuery();
if (rs.next())
{
confirm = rs.getString("CONF");
}
else
{
retString = itmDBAccess.getErrorString("emp_code","VTHOLCHG20",userID,"",conn);
}
System.out.println(" confirm [" + confirm + "] ");
closePstmtRset(pstmt, rs);
/*if (retString == null || retString.trim().length() == 0)
{*/
//if (confirm == null || !confirm.equalsIgnoreCase("C") )
if(!"C".equalsIgnoreCase(confirm) || confirm == null)
{
sql = "UPDATE CHANGE_HOLIDAY SET CONFIRMED = ? WHERE EMP_CODE = ? AND HOL_DATE_FOR = ? AND HOL_DATE_TO = ? AND HOL_TYPE = ?";
System.out.println("[EmpTranPromCanc][confirm]sqlStatus::"+ sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "C");
pstmt.setString(2, checkNull(empCode));
pstmt.setTimestamp(3, holDateForSql);
pstmt.setTimestamp(4, holDateToSql);
pstmt.setString(5, checkNull(holType));
updStatus = pstmt.executeUpdate();
System.out.println("canceled the request [::" + updStatus);
if(updStatus != 0)
{
retString = itmDBAccess.getErrorString("emp_code","DS000",userID,"",conn);
conn.commit();
}
else if(updStatus != 1)
{
retString = itmDBAccess.getErrorString("emp_code","DS000NR",userID,"",conn);
conn.rollback();
}
}
else
{
retString = itmDBAccess.getErrorString("emp_code","VTCANC2",userID,"",conn);
}
//}
}
catch (Exception e)
{
try
{
conn.rollback();
System.out.println("Exception " + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
catch (Exception e1)
{
e1.printStackTrace();
throw new ITMException(e1);
}
} finally {
try {
itmDBAccess = null;
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();
throw new ITMException(e);
}
}
System.out.println(" retString.. [" + retString + "] ");
return retString;
}
private void closePstmtRset(PreparedStatement pstmt, ResultSet rset)throws Exception {
System.out.println("Closing PreparedStatement and result.........");
try
{
if (rset != null)
{
rset.close();
rset = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception exp)
{
System.out.println("Inside Exception [HolCahngeCanc][closePstmtRset]::"+ exp.getMessage());
exp.printStackTrace();
throw new Exception(exp);
}
}
private String checkNull(String input) {
if (input == null) {
input = "";
} else {
input = input.trim();
}
return input;
}
}
// Created by Sana Shaikh on 20/08/2019 for holiday Precancellation of employee [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