Commit 9541f48f authored by dsawant's avatar dsawant

table name change (acct to allo)


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93202 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 24983e91
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
@Stateless
public class BudgetGroupAllo extends ValidatorEJB implements BudgetGroupAlloLocal,BudgetGroupAlloRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
public String wfValData(String xmlString, String xmlString1, String xmlString2,String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("------------ BudgetGroupAcct wfvalData method called-----------------");
System.out.println("xmlString --->>> [["+xmlString+" ]]");
String errString = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
dom2 = parseString(xmlString2);
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : BudgetGroupAcct.java : wfValData(String xmlString) : ==>\n"+e.getMessage());
throw new ITMException(e);
}
return errString;
} //end of wfValData
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;;
int ctr = 0,cnt = 0;
String childNodeName = null, errString = "",errCode="",userId = "";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int currentFormNo=0;
int childNodeListLength;
try
{
ConnDriver connDriver = new ConnDriver();
GenericUtility genericUtility = GenericUtility.getInstance();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
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(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("budget_id"))
{
String budgetId="";
budgetId = genericUtility.getColumnValue("budget_id",dom);
if (budgetId == null || budgetId.trim().length() == 0 )
{
errCode = "VMBDEMPY";
errString = getErrorString("budget_id",errCode,userId);
break;
}
else
{
cnt= getDBRowCount(conn,"budgets","budget_id",budgetId);
if(cnt == 0)
{
errCode = "VMBDNTFND";
errString = getErrorString("budget_id",errCode,userId);
break;
}
}
}
else if (childNodeName.equalsIgnoreCase("remarks"))
{
String remarks="";
remarks = genericUtility.getColumnValue("remarks",dom);
if (remarks == null || remarks.trim().length() == 0 )
{
errCode = "VMREMNN";
errString = getErrorString("remarks",errCode,userId);
break;
}
}
}// for loop end
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("------Detail2 --- child Node : "+childNodeName);
if (childNodeName.equalsIgnoreCase("bud_group_code"))
{
String budGroupCode="";
budGroupCode = genericUtility.getColumnValue("bud_group_code",dom);
if (budGroupCode == null || budGroupCode.trim().length() == 0 )
{
errCode = "VMBDGREM";
errString = getErrorString("bud_group_code",errCode,userId);
break;
}
else
{
cnt= getDBRowCount(conn,"bud_group","bud_group_code",budGroupCode);
if(cnt == 0)
{
errCode = "VTBDGRNF";
errString = getErrorString("bud_group_code",errCode,userId);
break;
}
else
{
if(!editFlag.equalsIgnoreCase("E"))
{
String budgetId="";
budgetId = genericUtility.getColumnValue("budget_id",dom1);
System.out.println("for chaeck syXX"+budgetId);
// String sql1="select budgetacctdet.budget_amt " +
// " from bud_grp_allo budgetacct,bud_grp_allodet budgetacctdet " +
// " where budgetacct.tran_id = budgetacctdet.tran_id and budgetacct.budget_id = ? and budgetacctdet.bud_group_code = ?";
System.out.println("hddddd1111");
String sql1="select count(1) " +
" from bud_grp_allo budgetacct,bud_grp_allodet budgetacctdet " +
" where budgetacct.tran_id = budgetacctdet.tran_id and budgetacct.budget_id = ? and budgetacctdet.bud_group_code = ?";
System.out.println("dddd");
int cnt1 = 0;
System.out.println("SQL------ : ["+sql1+"]");
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1,budgetId);
pstmt.setString(2,budGroupCode);
rs = pstmt.executeQuery();
if(rs.next())
{
//bGroupCode=rs.getString(1)==null ? "" : rs.getString(1);
cnt1 = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt1 == 1)
{
errCode = "VMSCNPSM1";
errString = getErrorString("bud_group_code",errCode,userId);
break;
}
}
if(editFlag.equalsIgnoreCase("E"))
{
System.out.println("insert in E");
String budgetId="";
budgetId = genericUtility.getColumnValue("budget_id",dom1);
String tranid= genericUtility.getColumnValue("tran_id",dom1);
System.out.println("for chaeck syXX"+budgetId);
// String sql1="select budgetacctdet.budget_amt " +
// " from bud_grp_allo budgetacct,bud_grp_allodet budgetacctdet " +
// " where budgetacct.tran_id = budgetacctdet.tran_id and budgetacct.budget_id = ? and budgetacctdet.bud_group_code = ?";
System.out.println("hddddd1111");
String sql1="select count(1) " +
" from bud_grp_allo budgetacct,bud_grp_allodet budgetacctdet " +
" where budgetacct.tran_id = budgetacctdet.tran_id and budgetacct.budget_id = ? and budgetacctdet.bud_group_code = ? and budgetacctdet.tran_id <> ?";
System.out.println("dddd");
int cnt1 = 0;
System.out.println("SQL------ : ["+sql1+"]");
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1,budgetId);
pstmt.setString(2,budGroupCode);
pstmt.setString(3,tranid);
rs = pstmt.executeQuery();
if(rs.next())
{
//bGroupCode=rs.getString(1)==null ? "" : rs.getString(1);
cnt1 = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt1 == 1)
{
errCode = "VMSCNPSM1";
errString = getErrorString("bud_group_code",errCode,userId);
break;
}
}
}
}
}
if (childNodeName.equals("budget_amt"))
{
double budgetAmt=0.0;
String budgetAmtStr=genericUtility.getColumnValue("budget_amt",dom);
System.out.println("budgetAmtStr ----- :->> "+budgetAmtStr);
if (budgetAmtStr == null || budgetAmtStr.trim().length() == 0 )
{
errCode = "VTBDATNUL";
errString = getErrorString("bud_group_code",errCode,userId);
break;
}
else
{
budgetAmt= Double.parseDouble(budgetAmtStr);
if (budgetAmt < 1)
{
errCode = "VTBDAMTNL";
errString = getErrorString("budget_amt",errCode,userId);
break;
}
}
}
}// for loop end
break;
} //end switch
}//end try
catch(Exception e)
{
e.printStackTrace();
errString = e.getMessage();
}
finally
{
try
{
if(conn!=null)
{
conn.close();
conn = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(rs != null )
{
rs.close();
rs = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
return errString;
}
public String itemChanged(String xmlString,String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("------------------ itemChanged called------------------");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
dom2 = parseString(xmlString2);
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [BudgetGroupAcct ][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
//NodeList childNodeList = null;
//Node parentNode = null;
//Node childNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
//String childNodeName = null;
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
int currentFormNo =0;
String columnValue = null;
//int ctr=0;
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver=null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext.trim());
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("-------- currentFormNo : "+currentFormNo);
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
valueXmlString.append("<Detail1>");
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{
String confValue="N",budAmt="0.0";
valueXmlString.append("<confirmed><![CDATA[").append(confValue).append("]]></confirmed>");
valueXmlString.append("<budget_amt><![CDATA[").append(budAmt).append("]]></budget_amt>");
}
if((currentColumn.trim().equalsIgnoreCase("budget_id")))
{
String budgetId = genericUtility.getColumnValue("budget_id",dom);
System.out.println("budget Id ----- :->> "+budgetId);
if(budgetId != null && budgetId.trim().length()>0 )
{
String budgetIdDesc = "";
budgetIdDesc = getNameOrDescrForCode(conn, "budgets", "descr", "budget_id", budgetId);
valueXmlString.append("<budgets_descr>").append("<![CDATA[" + budgetIdDesc + "]]>").append("</budgets_descr>");
System.out.println("budgets_descr ---------- >> : "+budgetIdDesc);
}
else
{
valueXmlString.append("<budgets_descr>").append("<![CDATA[]]>").append("</budgets_descr>");
}
}
valueXmlString.append("</Detail1>");
break;
case 2:
valueXmlString.append("<Detail2>");
//SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail2");
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.trim().equals("bud_group_code"))
{
String budGrpCode = genericUtility.getColumnValue("bud_group_code",dom);
System.out.println("budGrp Code ----- :->> "+budGrpCode);
if(budGrpCode != null && budGrpCode.trim().length()>0 )
{
String budgetGrpCodeDesc = null;
budgetGrpCodeDesc = getNameOrDescrForCode(conn, "bud_group", "descr", "bud_group_code", budGrpCode);
valueXmlString.append("<descr>").append("<![CDATA[" + budgetGrpCodeDesc + "]]>").append("</descr>");
System.out.println("bud_group_descr ---------- >> : "+budgetGrpCodeDesc);
}
else
{
valueXmlString.append("<descr>").append("<![CDATA[]]>").append("</descr>");
}
}
valueXmlString.append("</Detail2>");
}// end switch
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn!=null)
{
conn.close();
conn = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private int getDBRowCount(Connection conn, String table_name, String whrCondCol, String whrCondVal)
{
int count=-1;
if(conn!=null){
ResultSet rs=null;
PreparedStatement pstmt = null;
String sql="select count(1) from "+table_name+" where "+whrCondCol+" = ?";
System.out.println("SQL in getDBRowCount method : "+sql);
try
{
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,whrCondVal);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
}
catch(SQLException e)
{
System.out.println("SQL Exception In getDBRowCount method of BudgetGroupAcct Class : "+e.getMessage());
e.printStackTrace();
}
catch(Exception ex)
{
System.out.println("Exception In getDBRowCount method of BudgetGroupAcct Class : "+ex.getMessage());
ex.printStackTrace();
}finally{
try{
if(pstmt!=null){
pstmt.close();
pstmt = null;
}
if(rs!=null){
rs.close();
rs = null;
}
}catch (SQLException se) {
se.printStackTrace();
}
}
}else{
try {
throw new SQLException("Connection passed to BudgetGroupAcct.getDBRowCount() method is null");
} catch (SQLException e) {
e.printStackTrace();
}
}
return count;
}
private String getNameOrDescrForCode(Connection conn, String table_name, String descr_col_name,String whrCondCol, String whrCondVal)
{
String descr = null;
if(conn!=null){
ResultSet rs=null;
PreparedStatement pstmt = null;
String sql="SELECT "+descr_col_name+" FROM "+table_name+" WHERE "+whrCondCol+" = ?";
System.out.println("SQL in getNameOrDescrForCode method : "+sql);
try
{
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,whrCondVal);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString(1) == null ? "": rs.getString(1);
}
}
catch(SQLException e)
{
System.out.println("SQL Exception In getNameOrDescrForCode method of BudgetGroupAcct Class : "+e.getMessage());
e.printStackTrace();
}
catch(Exception ex)
{
System.out.println("Exception In getNameOrDescrForCode method of BudgetGroupAcct Class : "+ex.getMessage());
ex.printStackTrace();
}finally{
try{
if(pstmt!=null){
pstmt.close();
pstmt = null;
}
if(rs!=null){
rs.close();
rs = null;
}
}catch (SQLException se) {
se.printStackTrace();
}
}
}else{
try {
throw new SQLException("Connection passed to BudgetGroupAcct.getNameOrDescrForCode() method is null");
} catch (SQLException e) {
e.printStackTrace();
}
}
return descr;
}
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
@Stateless
public class BudgetGroupAlloAmd extends ValidatorEJB implements BudgetGroupAlloAmdLocal,BudgetGroupAlloAmdRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
public String wfValData(String xmlString, String xmlString1, String xmlString2,String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("------------ BudgetGroupAcctAmd wfvalData method called-----------------");
System.out.println("xmlString --->>> [["+xmlString+" ]]");
String errString = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
dom2 = parseString(xmlString2);
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : BudgetGroupAcctAmd.java : wfValData(String xmlString) : ==>\n"+e.getMessage());
throw new ITMException(e);
}
return errString;
} //end of wfValData
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;;
int ctr = 0,cnt = 0;
String childNodeName = null, errString = "",errCode="",userId = "";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int currentFormNo=0;
int childNodeListLength;
try
{
ConnDriver connDriver = new ConnDriver();
GenericUtility genericUtility = GenericUtility.getInstance();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
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(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
//changes by deepak
// if (childNodeName.equalsIgnoreCase("amd_no"))
// {
// if(!editFlag.equalsIgnoreCase("A"))
// {
// String amdno="";
// amdno = genericUtility.getColumnValue("amd_no",dom);
//
// if (amdno == null || amdno.trim().length() == 0 )
// {
// errCode = "VMAMNIE";
// errString = getErrorString("amd_no",errCode,userId);
// break;
// }
// else
// {
// if(!editFlag.equalsIgnoreCase("E"))
// {
// cnt= getDBRowCount(conn,"budgrp_allo_amd","amd_no",amdno);
// }
// if(cnt == 1)
// {
// errCode = "VMAMNOE";
// errString = getErrorString("amd_no",errCode,userId);
// break;
// }
// }
// }
// }
//changes by deepak
if (childNodeName.equalsIgnoreCase("budget_id"))
{
String budgetId="";
budgetId = genericUtility.getColumnValue("budget_id",dom);
if (budgetId == null || budgetId.trim().length() == 0 )
{
errCode = "VMBDEMPY";
errString = getErrorString("budget_id",errCode,userId);
break;
}
else
{
cnt= getDBRowCount(conn,"bud_grp_allo","budget_id",budgetId);
if(cnt == 0)
{
errCode = "VMBDNTFM";
errString = getErrorString("budget_id",errCode,userId);
break;
}
}
}
else if (childNodeName.equalsIgnoreCase("remarks"))
{
String remarks="";
remarks = genericUtility.getColumnValue("remarks",dom);
if (remarks == null || remarks.trim().length() == 0 )
{
errCode = "VMREMNN";
errString = getErrorString("remarks",errCode,userId);
break;
}
}
}// for loop end
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("------Detail2 --- child Node : "+childNodeName);
if (childNodeName.equalsIgnoreCase("bud_group_code"))
{
String budGroupCode="";
budGroupCode = genericUtility.getColumnValue("bud_group_code",dom);
if (budGroupCode == null || budGroupCode.trim().length() == 0 )
{
errCode = "VMBDGREM";
errString = getErrorString("bud_group_code",errCode,userId);
break;
}
else
{
System.out.println("hhhhhh");
cnt= getDBRowCount(conn,"bud_group","bud_group_code",budGroupCode);
if(cnt == 0)
{
errCode = "VTBDGRNF";
errString = getErrorString("bud_group_code",errCode,userId);
break;
}else
{
String budgetId="";
budgetId = genericUtility.getColumnValue("budget_id",dom1);
System.out.println("for chaeck syXX"+budgetId);
// String sql1="select budgetacctdet.budget_amt " +
// " from bud_grp_allo budgetacct,bud_grp_allodet budgetacctdet " +
// " where budgetacct.tran_id = budgetacctdet.tran_id and budgetacct.budget_id = ? and budgetacctdet.bud_group_code = ?";
String sql1="select count(1) " +
" from bud_grp_allo budgetacct,bud_grp_allodet budgetacctdet " +
" where budgetacct.tran_id = budgetacctdet.tran_id and budgetacct.budget_id = ? and budgetacctdet.bud_group_code = ?";
System.out.println("dddd");
int cnt1 = 0;
System.out.println("SQL------ : ["+sql1+"]");
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1,budgetId);
pstmt.setString(2,budGroupCode);
rs = pstmt.executeQuery();
if(rs.next())
{
//bGroupCode=rs.getString(1)==null ? "" : rs.getString(1);
cnt1 = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt1 == 0 || cnt1 == 0.0)
{
errCode = "VMIBGCMI";
errString = getErrorString("budget_amt_old",errCode,userId);
break;
}
//
}
}
}
//changes by deepak
else if (childNodeName.equalsIgnoreCase("budget_amt"))
{
String budamt="";
budamt = genericUtility.getColumnValue("budget_amt",dom);
if (budamt == null || budamt.trim().length() == 0 )
{
errCode = "VTBDATNUL";
errString = getErrorString("budget_amt",errCode,userId);
break;
}
}
else if (childNodeName.equalsIgnoreCase("remarks"))
{
String remarks="";
remarks = genericUtility.getColumnValue("remarks",dom);
if (remarks == null || remarks.trim().length() == 0 )
{
errCode = "VMREMNN";
errString = getErrorString("remarks",errCode,userId);
break;
}
}
//changes by deepak
}// for loop end
break;
} //end switch
}//end try
catch(Exception e)
{
e.printStackTrace();
errString = e.getMessage();
}
finally
{
try
{
if(conn!=null)
{
conn.close();
conn = null;
}
if(pstmt != null )
{
pstmt.close();
pstmt = null;
}
if(rs != null )
{
rs.close();
rs = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
return errString;
}
public String itemChanged(String xmlString,String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("------------------ itemChanged called------------------");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
dom2 = parseString(xmlString2);
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [BudgetGroupAcctAmd ][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String childNodeName = null;
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
int currentFormNo =0;
String columnValue = null,budget_Id="";
int ctr=0;
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver=null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext.trim());
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("-------- currentFormNo : "+currentFormNo);
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail1>");
//int childNodeListLength = childNodeList.getLength();
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if( currentColumn.trim().equalsIgnoreCase( "itm_default" ) )
{
String confValue="N";
valueXmlString.append("<confirmed><![CDATA[").append(confValue).append("]]></confirmed>");
}
if((currentColumn.trim().equalsIgnoreCase("budget_id")))
{
String budgetId = genericUtility.getColumnValue("budget_id",dom);
//budget_Id=budgetId;
System.out.println("budget Id ----- :->> "+budgetId);
if(budgetId != null && budgetId.trim().length()>0 )
{
String budgetIdDesc = "";
budgetIdDesc = getNameOrDescrForCode(conn, "budgets", "descr", "budget_id", budgetId);
valueXmlString.append("<budgets_descr>").append("<![CDATA[" + budgetIdDesc + "]]>").append("</budgets_descr>");
System.out.println("budgets_descr ---------- >> : "+budgetIdDesc);
}
else
{
valueXmlString.append("<budgets_descr>").append("<![CDATA[]]>").append("</budgets_descr>");
}
}
valueXmlString.append("</Detail1>");
break;
case 2:
valueXmlString.append("<Detail2>");
//SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
//childNodeListLength = childNodeList.getLength();
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.trim().equals("bud_group_code"))
{
String budGrpCode="", budId="",tranid="",bGroupCode="";
budGrpCode= genericUtility.getColumnValue("bud_group_code",dom);
budget_Id=genericUtility.getColumnValue("budget_id",dom1);
System.out.println("budGrp Code ----- ID :->> "+budGrpCode+" BUdget Id : "+budget_Id);
if(budGrpCode != null && budGrpCode.trim().length()>0 )
{
String budgetGrpCodeDesc = "";
double budgetAmt=0.0;
budgetGrpCodeDesc = getNameOrDescrForCode(conn, "bud_group", "descr", "bud_group_code", budGrpCode);
//budgetAmt = getNameOrDescrForCode(conn, "bud_grp_allodet", "budget_amt", "bud_group_code", budGrpCode);
tranid = getNameOrDescrForCode(conn, "bud_grp_allo", "tran_id", "budget_id", budget_Id);
System.out.println("transaction id------@@ "+tranid);
// String sql1="select budgetacct.tran_id,budgetacct.budget_id,budgetacctdet.BUD_GROUP_CODE,budgetacctdet.budget_amt " +
// " from bud_grp_allo budgetacct,bud_grp_allodet budgetacctdet " +
// " where budgetacct.tran_id= ? and budgetacctdet.bud_group_code = ?";
String sql1="select budgetacctdet.budget_amt " +
" from bud_grp_allo budgetacct,bud_grp_allodet budgetacctdet " +
" where budgetacct.tran_id = budgetacctdet.tran_id and budgetacct.budget_id = ? and budgetacctdet.bud_group_code = ?";
System.out.println("SQL------ : ["+sql1+"]");
try
{
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1,budget_Id);
pstmt.setString(2,budGrpCode);
rs = pstmt.executeQuery();
if(rs.next())
{
//bGroupCode=rs.getString(1)==null ? "" : rs.getString(1);
budgetAmt=rs.getDouble("budget_amt");
}
System.out.println("budget amount---- >>"+budgetAmt);
}
catch(SQLException e)
{
System.out.println("SQL Exception BudgetGroupAcctAmd Class (item change) : "+e.getMessage());
e.printStackTrace();
}
catch(Exception ex)
{
System.out.println("Exception: BudgetGroupAcctAmd Class (item change) : "+ex.getMessage());
ex.printStackTrace();
}
valueXmlString.append("<descr>").append("<![CDATA[" + budgetGrpCodeDesc + "]]>").append("</descr>");
valueXmlString.append("<budget_amt_old>").append("<![CDATA[" + budgetAmt + "]]>").append("</budget_amt_old>");
System.out.println("bud_group_descr ---------- >> : "+budgetGrpCodeDesc);
}
else
{
valueXmlString.append("<bud_group_descr>").append("<![CDATA[]]>").append("</bud_group_descr>");
}
}
valueXmlString.append("</Detail2>");
}// end switch
valueXmlString.append("</Root>");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn!=null)
{
conn.close();
conn = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private int getDBRowCount(Connection conn, String table_name, String whrCondCol, String whrCondVal)
{
int count=-1;
if(conn!=null){
ResultSet rs=null;
PreparedStatement pstmt = null;
String sql="select count(1) from "+table_name+" where "+whrCondCol+" = ?";
System.out.println("SQL in getDBRowCount method : "+sql);
try
{
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,whrCondVal);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
}
catch(SQLException e)
{
System.out.println("SQL Exception In getDBRowCount method of BudgetGroupAcctAmd Class : "+e.getMessage());
e.printStackTrace();
}
catch(Exception ex)
{
System.out.println("Exception In getDBRowCount method of BudgetGroupAcctAmd Class : "+ex.getMessage());
ex.printStackTrace();
}finally{
try{
if(pstmt!=null){
pstmt.close();
pstmt = null;
}
if(rs!=null){
rs.close();
rs = null;
}
}catch (SQLException se) {
se.printStackTrace();
}
}
}else{
try {
throw new SQLException("Connection passed to BudgetGroupAcctAmd.getDBRowCount() method is null");
} catch (SQLException e) {
e.printStackTrace();
}
}
return count;
}
private String getNameOrDescrForCode(Connection conn, String table_name, String descr_col_name,String whrCondCol, String whrCondVal)
{
String descr = null;
if(conn!=null){
ResultSet rs=null;
PreparedStatement pstmt = null;
String sql="SELECT "+descr_col_name+" FROM "+table_name+" WHERE "+whrCondCol+" = ?";
System.out.println("SQL in getNameOrDescrForCode method : "+sql);
try
{
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,whrCondVal);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString(descr_col_name);
}
}
catch(SQLException e)
{
System.out.println("SQL Exception In getNameOrDescrForCode method of BudgetGroupAcctAmd Class : "+e.getMessage());
e.printStackTrace();
}
catch(Exception ex)
{
System.out.println("Exception In getNameOrDescrForCode method of BudgetGroupAcctAmd Class : "+ex.getMessage());
ex.printStackTrace();
}finally{
try{
if(pstmt!=null){
pstmt.close();
pstmt = null;
}
if(rs!=null){
rs.close();
rs = null;
}
}catch (SQLException se) {
se.printStackTrace();
}
}
}else{
try {
throw new SQLException("Connection passed to BudgetGroupAcctAmd.getNameOrDescrForCode() method is null");
} catch (SQLException e) {
e.printStackTrace();
}
}
return descr;
}
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.ejb.Stateless;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
@Stateless
public class BudgetGroupAlloAmdConfirm extends ActionHandlerEJB implements BudgetGroupAlloAmdConfirmLocal,BudgetGroupAlloAmdConfirmRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String chgUser =null, chgTerm = null, userId = null;
String errString="";
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
String retString = "";
try
{
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "logincode");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chg_term");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chg_user");
retString = confirmAmmend(tranId,xtraParams,forcedFlag);
}
catch(Exception e)
{
System.out.println("Exception :BudgetGroupAcctAmdConfirm :actionHandler():" + e.getMessage() + ":");
retString = GenericUtility.getInstance().createErrorString(e);
e.printStackTrace();
}
return retString;
}
private String confirmAmmend(String tranIdAmd,String xtraParams,String forcedFlag)
{
System.out.println("--------------confirm method of BudgetGroupAcctAmdConfirm ------------- ");
Connection conn=null;
ConnDriver ConnDriver = new ConnDriver();
ITMDBAccessEJB itmdbAccess=new ITMDBAccessEJB();
ResultSet rs = null;
PreparedStatement pstmt = null;
String sql = "",confirmed="";
try
{
conn = ConnDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
sql = "select confirmed from budgrp_allo_amd where amd_no = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranIdAmd);
rs = pstmt.executeQuery();
if( rs.next() )
{
confirmed =rs.getString(1)==null ? "":rs.getString(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
System.out.println("Confirmed ----- : "+confirmed);
if( confirmed != null && confirmed.equalsIgnoreCase("Y") )
{
errString = itmdbAccess.getErrorString("", "VTALLCONF", "", "", conn);
return errString;
}
else
{
errString =updateBudgetAmmend(conn,tranIdAmd,xtraParams);
return errString;
}
}
catch(Exception e)
{
try
{
conn.rollback();
}
catch (Exception e1)
{
}
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
}
finally
{
try
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (conn!=null)
{
conn.close();
conn=null;
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}
System.out.println("Returning Result ::"+errString);
return errString;
}
private String updateBudgetAmmend(Connection conn,String tranIdAmd,String xtraParams)
{
System.out.println("---------in updateConfirm method------------");
String loginEmpCode ="",sql="",budGrpCode="",budgetId="",tran_id="";
double budAmount=0.0;
PreparedStatement pstmt1=null;
ResultSet rs1=null;
int count=0,countAcctdet=0;
PreparedStatement pstmtBudGrp = null;
ResultSet rsBudgrp = null;
try
{
sql="select budget_id from budgrp_allo_amd where amd_no = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, tranIdAmd);
rs1 = pstmt1.executeQuery();
if( rs1.next() )
{
budgetId =rs1.getString(1)==null ? "":rs1.getString(1);
}
System.out.println("In updateBudgetAmmend : budget_id : "+budgetId);
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
/*sql="select tran_id from bud_grp_allo where budget_id = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, budgetId);
rs1 = pstmt1.executeQuery();
while( rs1.next() )
{
tran_id =rs1.getString(1)==null ? "":rs1.getString(1);
}
System.out.println("In updateBudgetAmmend : tran_id : "+tran_id);
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;*/
conn.setAutoCommit(false);
sql="select bud_group_code,budget_amt from budgrp_allodet_amd where amd_no = ? ";
pstmtBudGrp = conn.prepareStatement(sql);
pstmtBudGrp.setString(1, tranIdAmd);
rsBudgrp = pstmtBudGrp.executeQuery();
while( rsBudgrp.next() )
{
budGrpCode =rsBudgrp.getString(1)==null ? "":rsBudgrp.getString(1);
budAmount=rsBudgrp.getDouble(2);
System.out.println("In updateBudgetAmmend : budGrpCode : "+budgetId+" budAmount : "+budAmount);
System.out.println("new query addedaa");
sql="select acct.tran_id from bud_grp_allo acct, bud_grp_allodet det " +
" where acct.tran_id = det.tran_id and det.bud_group_code = ? " +
" and acct.budget_id = ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, budGrpCode);
pstmt1.setString(2, budgetId);
rs1 = pstmt1.executeQuery();
if( rs1.next() )
{
tran_id =rs1.getString(1)==null ? "":rs1.getString(1);
}
System.out.println("In updateBudgetAmmend : budget_id : "+budgetId);
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
//--------------------------------------------------------------------------------
sql=null;
sql="update bud_grp_allodet set budget_amt = ? where tran_id = ? and bud_group_code = ?";
pstmt1 = conn.prepareStatement( sql );
pstmt1.setDouble(1, budAmount);
pstmt1.setString(2, tran_id);
pstmt1.setString(3, budGrpCode);
countAcctdet = pstmt1.executeUpdate();
System.out.println("----countAcctdet : "+countAcctdet);
sql="update budgrp_allo_amd set confirmed = ?,conf_date = ?,emp_code__aprv = ? where amd_no = ?";
loginEmpCode=GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
pstmt1 = conn.prepareStatement( sql );
pstmt1.setString(1, "Y");
pstmt1.setTimestamp(2, this.getCurrdateAppFormat());
pstmt1.setString(3, loginEmpCode);
pstmt1.setString(4, tranIdAmd);
count = pstmt1.executeUpdate();
System.out.println("confirm updated -------->>>>>>>>>updCount :"+count);
// Added by deepak
String finEntity1 = null;
Double final_budget_amt = 0.00;
Float allocperc1 = 0.00f;
Date fromDate = null ;
sql = "select fin_entity,from_date from budgets where budget_id= ?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1,budgetId);
ResultSet rs = pstmt.executeQuery();
finEntity1 = null;
fromDate = null;
if(rs.next()){
finEntity1 = rs.getString(1);
fromDate = rs.getDate(2);
}
if(finEntity1==null||fromDate==null){
//Error : Required data not found from budgets
errString = itmDBAccessEJB.getErrorString("","VTBUDINFNF",chgUser);
return errString;
}
String acctcode1="",cctrcode1="",analcode1="",deptcode1="";
String sqlQuery="select acct_code, cctr_code, anal_code, dept_code,alloc_perc from bud_group_det where bud_group_code = ?";
PreparedStatement Mysql1pstmt = conn.prepareStatement(sqlQuery);
Mysql1pstmt.setString(1, budGrpCode);
ResultSet Mysql1rs1 = Mysql1pstmt.executeQuery();
while( Mysql1rs1.next() )
{
acctcode1 =Mysql1rs1.getString(1)==null ? "":Mysql1rs1.getString(1);
cctrcode1 =Mysql1rs1.getString(2)==null ? "":Mysql1rs1.getString(2);
analcode1 =Mysql1rs1.getString(3)==null ? "":Mysql1rs1.getString(3);
deptcode1 =Mysql1rs1.getString(4)==null ? "":Mysql1rs1.getString(4);
allocperc1 = Mysql1rs1.getFloat(5);
if(deptcode1==null||analcode1==null||cctrcode1==null||acctcode1==null){
errString = itmDBAccessEJB.getErrorString("","VTBUDGRPNF",chgUser);
return errString;
}
System.out.println("ghrttt");
final_budget_amt = (budAmount * allocperc1)/100;
PreparedStatement Mysqlpstmt;
String Mysql=null;
Mysql="update acctbudget set budget_amt = ? where fin_entity= ? and acct_code= ? and cctr_code = ? and anal_code = ? and dept_code = ? and from_date = ? and budget_id = ? and bud_group_code = ?";
Mysqlpstmt = conn.prepareStatement(Mysql);
Mysqlpstmt.setDouble(1, final_budget_amt);
Mysqlpstmt.setString(2, finEntity1);
Mysqlpstmt.setString(3, acctcode1);
Mysqlpstmt.setString(4, cctrcode1);
Mysqlpstmt.setString(5, analcode1);
Mysqlpstmt.setString(6, deptcode1);
Mysqlpstmt.setDate(7,(java.sql.Date)fromDate);
Mysqlpstmt.setString(8, budgetId);
Mysqlpstmt.setString(9, budGrpCode);
int MysqlcountAcctdet = Mysqlpstmt.executeUpdate();
Mysqlpstmt.close();
Mysqlpstmt = null;
System.out.println("----MysqlcountAcctdet : "+MysqlcountAcctdet);
}
System.out.println(acctcode1+""+cctrcode1+""+analcode1+""+deptcode1+""+allocperc1);
Mysql1rs1.close();
Mysql1rs1=null;
Mysql1pstmt.close();
Mysql1pstmt=null;
} // End of outer while
conn.commit();
errString=new ITMDBAccessEJB().getErrorString("", "VTCONSUCC", "", "", conn);
return errString;
}
catch(SQLException se)
{
se.printStackTrace();
try
{
conn.rollback();
}
catch(Exception e1)
{
e1.printStackTrace();
}
}
catch(Exception e)
{
try
{
conn.rollback();
}
catch(Exception e1)
{
e1.printStackTrace();
}
e.printStackTrace();
}
try
{
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
return errString;
}
private java.sql.Timestamp getCurrdateAppFormat()
{
GenericUtility genericUtility = GenericUtility.getInstance();
Timestamp timestamp = null;
try
{
java.util.Date date = null;
timestamp = new Timestamp(System.currentTimeMillis());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
}
catch(Exception exception)
{
System.out.println("Exception in [BudgetGroupAcctAmdConfirm] getCurrdateAppFormat " + exception.getMessage());
exception.printStackTrace();
}
return timestamp;
}
}
package ibase.webitm.ejb.fin;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
@Local
public interface BudgetGroupAlloAmdConfirmLocal extends ActionHandlerLocal
{
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote;
@Remote
public interface BudgetGroupAlloAmdConfirmRemote extends ActionHandlerRemote
{
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import ibase.webitm.ejb.ValidatorLocal;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
@Local
public interface BudgetGroupAlloAmdLocal extends ValidatorLocal{
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
@Remote
public interface BudgetGroupAlloAmdRemote extends ValidatorRemote
{
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
@Stateless
public class BudgetGroupAlloConfirm extends ActionHandlerEJB implements BudgetGroupAlloConfirmLocal,BudgetGroupAlloConfirmRemote
{
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("--------------actionHandler method of BudgetGroupAcctConfirm ------------- : ");
String retString = "";
try
{
retString = confirmBudget(tranId,xtraParams,forcedFlag);
}
catch(Exception e)
{
System.out.println("Exception :BudgetGroupAcctConfirm :actionHandler():" + e.getMessage() + ":");
retString = GenericUtility.getInstance().createErrorString(e);
e.printStackTrace();
}
return retString;
}
private String confirmBudget(String tranId,String xtraParams,String forcedFlag)
{
System.out.println("--------------confirm method of BudgetGroupAcctConfirm ------------- ");
Connection conn=null;
ConnDriver ConnDriver = new ConnDriver();
ITMDBAccessEJB itmdbAccess=new ITMDBAccessEJB();
ResultSet rs = null;
PreparedStatement pstmt = null;
String retString = "",errString="";
String sql = "",confirmed="";
try
{
conn = ConnDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
sql = "select confirmed from bud_grp_allo where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if( rs.next() )
{
confirmed =rs.getString(1)==null ? "":rs.getString(1);
}
rs.close();
rs=null;
pstmt.close();
pstmt=null;
if( confirmed != null && confirmed.equalsIgnoreCase("Y") )
{
errString = itmdbAccess.getErrorString("", "VTALLCONF", "", "", conn);
return errString;
}
else
{
int updCnt =updateConfirm(conn,tranId,xtraParams);
System.out.println("UPDATE COUNT --updCnt-->>"+updCnt);
if (updCnt > 0 )
{
retString=new ITMDBAccessEJB().getErrorString("", "VTCONSUCC", "", "", conn);
conn.commit();
System.out.println("Confirm and conf date updated successfully.......");
}
}
}
catch(Exception e)
{
try
{
conn.rollback();
}
catch (Exception e1)
{
}
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
}
finally
{
try
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (conn!=null)
{
conn.close();
conn=null;
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}
System.out.println("Returning Result ::"+retString);
return retString;
}
private int updateConfirm(Connection conn,String tranId,String xtraParams)
{
System.out.println("---------in updateConfirm method------------");
String loginEmpCode ="",sql;
PreparedStatement pstmt1=null;
int count=0;
sql="update bud_grp_allo set confirmed = ?,conf_date = ?,emp_code__aprv = ? where tran_id = ?";
try
{
loginEmpCode=GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
pstmt1 = conn.prepareStatement( sql );
pstmt1.setString(1, "Y");
pstmt1.setTimestamp(2, this.getCurrdateAppFormat());
pstmt1.setString(3, loginEmpCode);
pstmt1.setString(4, tranId);
count = pstmt1.executeUpdate();
System.out.println("confirm updated -------->>>>>>>>>updCount :"+count);
}
catch(SQLException se)
{
se.printStackTrace();
try
{
conn.rollback();
}
catch(Exception e1)
{
e1.printStackTrace();
}
}
catch(Exception e)
{
try
{
conn.rollback();
}
catch(Exception e1)
{
e1.printStackTrace();
}
e.printStackTrace();
}
try
{
if(pstmt1 != null)
{
pstmt1.close();
pstmt1 = null;
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
return count;
}
private java.sql.Timestamp getCurrdateAppFormat()
{
GenericUtility genericUtility = GenericUtility.getInstance();
Timestamp timestamp = null;
try
{
java.util.Date date = null;
timestamp = new Timestamp(System.currentTimeMillis());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
}
catch(Exception exception)
{
System.out.println("Exception in [BudgetGroupAcctConfirm] getCurrdateAppFormat " + exception.getMessage());
exception.printStackTrace();
}
return timestamp;
}
}
package ibase.webitm.ejb.fin;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
@Local
public interface BudgetGroupAlloConfirmLocal extends ActionHandlerLocal{
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote;
@Remote
public interface BudgetGroupAlloConfirmRemote extends ActionHandlerRemote
{
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import ibase.webitm.ejb.ValidatorLocal;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
@Local
public interface BudgetGroupAlloLocal extends ValidatorLocal
{
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote;
@Remote
public interface BudgetGroupAlloRemote extends ValidatorRemote
{
public String wfValData(String xmlString, String xmlString1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
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