Commit c623f0c0 authored by pbhosale's avatar pbhosale

Merged on [24-12-2019]

EmpCompletePos.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@214011 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 93b17a76
package ibase.webitm.ejb.adm;
import java.rmi.RemoteException;
import java.sql.Array;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
@Stateless
public class EmpCompletePos extends ValidatorEJB implements EmpCompletePosLocal , EmpCompletePosRemote
{
public String postSave( String domString, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException
{
Document dom = null;
String empCode = "";
String errString = "";
boolean isError = false;
int count = 0;
String sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
int lineNo = 0;
int i = 0,j = 0;
int rows = 0,delRows = 0;
String roleProfiles = "",roleProfile = "";
String[] roleProfilesList;
try
{
System.out.println("Inside Emp Complete post save:::::::"+domString);
conn.setAutoCommit(false);
E12GenericUtility genericUtility = new E12GenericUtility();
dom = genericUtility.parseString(domString);
if(editFlag.equalsIgnoreCase("E") || editFlag.equalsIgnoreCase("A"))
{
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
System.out.println("empCode::::==>" + empCode);
sql = "update employee set status = (case when status is null then ' ' else status end) where emp_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode);
count = pstmt.executeUpdate();
if( pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
//Added by Shital on 09/12/2019 [Start]
empCode = checkNull(genericUtility.getColumnValue("emp_code", dom));
roleProfiles = checkNull(genericUtility.getColumnValue("role_profiles", dom));
System.out.println(":::::empCode:::::::::::"+empCode);
System.out.println("::::roleProfile:::::::::::"+roleProfiles);
sql = "DELETE FROM EMP_ROLE_PROFILE WHERE EMP_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, empCode );
delRows = pstmt.executeUpdate();
System.out.println(" Deleted Rows :::" + delRows);
if( pstmt != null)
{
pstmt.close();
pstmt = null;
}
roleProfilesList = roleProfiles.split(",");
System.out.println("roleProfilesList----------"+roleProfilesList.toString());
System.out.println("lenght----------"+roleProfilesList.length);
sql = "INSERT INTO EMP_ROLE_PROFILE (EMP_CODE,LINE_NO,ROLE_PROFILE) "
+ "VALUES (?,?,?)";
pstmt = conn.prepareStatement(sql);
System.out.println("roleProfiles2:::::::::"+roleProfiles);
for(i = 0; i < roleProfilesList.length; i++)
{
if(roleProfilesList[i] == null || roleProfilesList[i].trim().length() == 0)
{
continue;
}
lineNo++;
pstmt.setString( 1, empCode );
pstmt.setInt( 2, lineNo );
pstmt.setString( 3, roleProfilesList[i] );
rows = pstmt.executeUpdate();
System.out.println(" Inserted Rows :::" + rows);
pstmt.clearParameters();
}
if( pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added by Shital on 09/12/2019 [End]
}
catch (Exception e)
{
System.out.println("Exception :EmpCompletePos : :==>\n"+e.getMessage());
e.printStackTrace();
isError = true;
throw new ITMException(e);
}
finally
{
try
{
System.out.println("isError ["+isError+"]");
if( conn != null )
{
if(isError)
{
conn.rollback();
}
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception :EmpCompletePos : :==>\n"+e.getMessage());
try
{
System.out.println("Before rollback");
conn.rollback();
}
catch(SQLException sqle)
{
System.out.println(sqle);
}
throw new ITMException(e);
}
}
return errString;
}
public String checkNull(String input)
{
if (input == null || "null".equalsIgnoreCase(input))
{
input= "";
}
return input.trim();
}
}
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