Commit 261043ec authored by dpawar's avatar dpawar

added budget group acct ammd source code


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93101 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 87d46e57
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 BudgetGroupAcctAmd extends ValidatorEJB implements BudgetGroupAcctAmdLocal,BudgetGroupAcctAmdRemote
{
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();
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 = "VMSITENULL";
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;
}
}
}
}// 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;
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);
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 = genericUtility.getColumnValue("bud_group_code",dom);
System.out.println("budGrp Code ----- :->> "+budGrpCode);
if(budGrpCode != null && budGrpCode.trim().length()>0 )
{
String budgetGrpCodeDesc = null,budgetAmt=null;
budgetGrpCodeDesc = getNameOrDescrForCode(conn, "bud_group", "descr", "bud_group_code", budGrpCode);
budgetAmt = getNameOrDescrForCode(conn, "bud_grp_acctdet", "budget_amt", "bud_group_code", budGrpCode);
valueXmlString.append("<bud_group_descr>").append("<![CDATA[" + budgetGrpCodeDesc + "]]>").append("</bud_group_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 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 BudgetGroupAcctAmdConfirm extends ActionHandlerEJB implements BudgetGroupAcctAmdConfirmLocal,BudgetGroupAcctAmdConfirmRemote
{
public String actionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
String retString = "";
try
{
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 tranId,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 retString = "",errString="";
String sql = "",confirmed="";
try
{
conn = ConnDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
sql = "select confirmed from budgrp_acct_amd where amd_no = ?";
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;
System.out.println("Confirmed ----- : "+confirmed);
if( confirmed != null && confirmed.equalsIgnoreCase("Y") )
{
errString = itmdbAccess.getErrorString("", "VTALLCONF", "", "", conn);
return errString;
}
else
{
int updCnt =updateBudgetAmmend(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 updateBudgetAmmend(Connection conn,String tranId,String xtraParams)
{
System.out.println("---------in updateConfirm method------------");
String loginEmpCode ="",sql="",budGrpCode="",budgetId="",finEntity="";
double budAmount=0.0;
PreparedStatement pstmt1=null;
ResultSet rs1=null;
int count=0;
try
{
sql="select budget_id,bud_group_code,budget_amt from budgrp_actdet_amd where amd_no = ?";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1, tranId);
rs1=pstmt1.executeQuery();
if(rs1.next())
{
budgetId=rs1.getString(1);
budGrpCode=rs1.getString(2)==null ? "" : rs1.getString(1);
budAmount=rs1.getDouble(3);
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
sql="select fin_entity from budgets where budget_id = ? ";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1, budgetId);
rs1=pstmt1.executeQuery();
if(rs1.next())
{
finEntity=rs1.getString(1);
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
sql="select acct_code,cctr_code from bud_group_det where bud_group_code = ? ";
sql="update bud_grp_acctdet set budget_amt = ? where bud_group_code = ?";
pstmt1=conn.prepareStatement(sql);
pstmt1.setDouble(1, budAmount);
pstmt1.setString(2, budGrpCode);
count = pstmt1.executeUpdate();
pstmt1.close();pstmt1=null;
}
catch(SQLException se)
{
System.out.println("SQL Exception : In updateBudgetAmmend() method");
se.printStackTrace();
}
sql="update budgrp_acct_amd set confirmed = ?,conf_date = ?,emp_code__aprv = ? where amd_no = ?";
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 [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 BudgetGroupAcctAmdConfirmLocal 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 BudgetGroupAcctAmdConfirmRemote 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 BudgetGroupAcctAmdLocal 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 BudgetGroupAcctAmdRemote 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