Commit ef4e68bc authored by mnair's avatar mnair

Updated new component ItemAcctDetrIC

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@183453 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 13dda27e
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.sql.SQLException;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
@Stateless
public class ItemAcctDetrIC extends ValidatorEJB implements
ItemAcctDetrICLocal, ItemAcctDetrICRemote
{
E12GenericUtility genericUtility = new E12GenericUtility();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String retString = "";
try{
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if(xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = genericUtility.parseString(xmlString2);
}
retString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
System.out.println("retString:::"+retString);
}
catch(Exception e){
System.out.println("Exception : ItemAcctDetrIC.java : wfValData(String xmlString) : ==>\n"+e.getMessage());
throw new ITMException(e);
}
return retString;
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
int cnt=0,ctr=0,childNodeLength = 0;
int currentFormNo=0;
NodeList parentNodeList = null;
Node parentNode = null;
NodeList childNodeList = null;
Node childNode = null;
String childNodeName = "",itemSer="",itemCode="",grpCode="",finEntity="",active="",tranCat="",cctrCode="",acctCode="",sql="";
/*String acct_code__sal="",acct_code__dis="",acct_code__depr="",acct_code__acc_depr="",acct_code__depr_wb="",
acct_code__fa="",acct_code__pl="",acct_code__in="",acct_code__pr="",acct_code__ph="",acct_code__ap="",
acct_code__reco="",acct_code__wp="",acct_code__oh="",acct_code__ciss="",acct_code__wp_rcp="",
acct_code__qc_sample="",acct_code__yld_loss="",acct_code__yld_gain="",acct_code__arev="",
acct_code__crrev="",acct_code__tot_ar="",acct_code__inrev="";
String cctr_code__sal="",cctr_code__dis="",cctr_code__depr="",cctr_code__acc_depr="",cctr_code__depr_wb="",
cctr_code__fa="",cctr_code__pl="",cctr_code__in="",cctr_code__pr="",cctr_code__ph="",cctr_code__ap="",
cctr_code__recp="",cctr_code__wp="",cctr_code__oh="",cctr_code__ciss="",ctr_code__wp_rcp="",
cctr_code__qc_sample="",cctr_code__yld_loss="",cctr_code__yld_gain="",cctr_code__arev="",
cctr_code__crrev="",cctr_code__tot_ar="",cctr_code__inrev="";
*/String errString="",errCode="",errorType="",userId="";
ArrayList <String> errList = new ArrayList<String>();
ArrayList <String>errFields = new ArrayList <String> ();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try{
conn = getConnection();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("user ID form XtraParam : "+userId +"Edit Flag -->>: "+editFlag);
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo:::"+currentFormNo);
switch(currentFormNo)
{
case 1:{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
System.out.println("childNodeLength>>"+childNodeLength);
for(ctr = 0; ctr < childNodeLength; ctr++)
{
System.out.println("childNode>>"+childNode);
childNode = childNodeList.item(ctr);
System.out.println("childNode>>"+childNode);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName>>"+childNodeName);
//Item_ser
if("item_ser".equalsIgnoreCase(childNodeName))
{
itemSer = genericUtility.getColumnValue("item_ser",dom).trim();
System.out.println("item_ser>>>>>"+itemSer);
if(itemSer == null || (itemSer.trim().length() == 0))
{
System.out.println("NULL ITEM SER!");
errCode = "VMNULLSER";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else
{
sql ="select count(*) as cnt from itemser where item_ser=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemSer);
System.out.println("itemSer"+itemSer);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt == 0)
{
System.out.println("Item ser entered does not exist, please enter valid item ser !");
errCode = "VITEMSER";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}//end of else
}// end of if block for item_ser
//Item_code
else if("item_code".equalsIgnoreCase(childNodeName))
{
itemCode = genericUtility.getColumnValue("item_code",dom).trim();
System.out.println("item_code>>>>>"+itemCode);
if(itemCode != null && itemCode.trim().length() > 0)
{
sql = "select count(*) as cnt from item where item_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("cnt");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(cnt == 0)
{
errCode = "VMITEM1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
//Grp_Code
else if("grp_code".equalsIgnoreCase(childNodeName))
{
grpCode = genericUtility.getColumnValue("grp_code",dom).trim();
System.out.println("grp_code>>>>>"+grpCode);
if(grpCode == null || grpCode.trim().length() == 0)
{
System.out.println("NULL GROUP CODE!");
errCode = "NULLGRPCODE";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
//Acct_Code
else if("acct_code__sal".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__sal",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__sal["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__dis".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__dis",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__dis["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__depr".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__depr",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__depr["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__acc_depr".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__acc_depr",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__acc_depr["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__depr_wb".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__depr_wb",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__depr_wb["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__fa".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__fa",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__fa["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__pl".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__pl",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__pl["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__in".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__in",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__in["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__pr".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__pr",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__pr["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__ph".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__ph",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__ph["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__ap".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__ap",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__ap["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__reco".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__reco",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__reco["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__wp".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__wp",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__wp["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__oh".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__oh",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__oh["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__ciss".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__ciss",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__ciss["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__wp_rcp".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__wp_rcp",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__wp_rcp["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__qc_sample".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__qc_sample",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__qc_sample["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__yld_loss".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__yld_loss",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__yld_loss["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__yld_gain".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__yld_gain",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__yld_gain["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__arev".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__arev",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__arev["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__crrev".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__crrev",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__crrev["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__tot_ar".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__tot_ar",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__tot_ar["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
else if("acct_code__inrev".equalsIgnoreCase(childNodeName))
{
acctCode=genericUtility.getColumnValue("acct_code__inrev",dom).trim();
if(acctCode != null && acctCode.trim().length() > 0)
{
cnt = getAccountDetail(acctCode,conn);
System.out.println("acct_code__inrev["+cnt+"]");
if(cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
//Cctr_Code
else if("cctr_code__sal".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__sal",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__sal["+cnt+"]");
}
else if("cctr_code__dis".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__dis",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__dis["+cnt+"]");
}
else if("cctr_code__depr".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__depr",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__depr["+cnt+"]");
}
else if("cctr_code__acc_depr".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__acc_depr",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__acc_depr["+cnt+"]");
}
else if("cctr_code__depr_wb".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__depr_wb",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__depr_wb["+cnt+"]");
}
else if("cctr_code__fa".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__fa",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__fa["+cnt+"]");
}
else if("cctr_code__pl".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__pl",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__pl["+cnt+"]");
}
else if("cctr_code__in".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__in",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__in["+cnt+"]");
}
else if("cctr_code__pr".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__pr",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__pr["+cnt+"]");
}
else if("cctr_code__ph".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__ph",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__ph["+cnt+"]");
}
else if("cctr_code__ap".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__ap",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__ap["+cnt+"]");
}
else if("cctr_code__recp".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__recp",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__recp["+cnt+"]");
}
else if("cctr_code__wp".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__wp",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__wp["+cnt+"]");
}
else if("cctr_code__oh".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__oh",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__oh["+cnt+"]");
}
else if("cctr_code__ciss".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__ciss",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__ciss["+cnt+"]");
}
else if("ctr_code__wp_rcp".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("ctr_code__wp_rcp",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("ctr_code__wp_rcp["+cnt+"]");
}
else if("cctr_code__qc_sample".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__qc_sample",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__qc_sample["+cnt+"]");
}
else if("cctr_code__yld_loss".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__yld_loss",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__yld_loss["+cnt+"]");
}
else if("cctr_code__yld_gain".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__yld_gain",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__yld_gain["+cnt+"]");
}
else if("cctr_code__arev".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__arev",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__arev["+cnt+"]");
}
else if("cctr_code__crrev".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__crrev",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__crrev["+cnt+"]");
}
else if("cctr_code__tot_ar".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__tot_ar",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__tot_ar["+cnt+"]");
}
else if("cctr_code__inrev".equalsIgnoreCase(childNodeName))
{
cctrCode=genericUtility.getColumnValue("cctr_code__inrev",dom).trim();
cnt = getCostCtrDetail(cctrCode,conn);
System.out.println("cctr_code__inrev["+cnt+"]");
}
//Fin_entity
else if("fin_entity".equalsIgnoreCase(childNodeName))
{
finEntity = genericUtility.getColumnValue("fin_entity",dom).trim();
System.out.println("fin_entity>>>>>"+finEntity);
if(finEntity != null && finEntity.trim().length() > 0)
{
sql = "select count(1) as cnt from finent where fin_entity=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,finEntity);
rs=pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(rs!=null)
{
rs.close();
rs=null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt=null;
}
if(cnt == 0)
{
errCode="VMFENTY1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
//Tran_cat
else if("tran_cat".equalsIgnoreCase(childNodeName))
{
tranCat = genericUtility.getColumnValue("tran_cat",dom).trim();
System.out.println("tran_cat>>>>>"+tranCat);
if(tranCat != null && tranCat.trim().length()>0)
{
sql = "select count(1) as cnt from transaction_cat where tran_cat=?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,tranCat);
rs=pstmt.executeQuery();
if(rs.next())
{
cnt=rs.getInt("cnt");
if(cnt == 0)
{
errCode="VMTRNCAT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
else if(cnt != 0)
{
sql = "select active from transaction_cat where tran_cat = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,tranCat);
rs=pstmt.executeQuery();
if(rs.next())
{
active = rs.getString("active");
System.out.println("Active"+active);
if("N".equals(active))
{
errCode="VMTRNCAT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}//end of else
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}//end of if
}//end of tran cat
}//end of for loop
}//end of case 1
break;
}//end of switch
int errListSize = errList.size();
cnt =0;
String errFldName = null;
if ( errList != null && errListSize > 0 )
{
for (cnt = 0; cnt < errListSize; cnt++ )
{
errCode = errList.get(cnt);
errFldName = errFields.get(cnt);
System.out.println("errCode .........."+errCode);
errString = getErrorString( errFldName, errCode, userId );
errorType = errorType( conn, errCode );
if ( errString.length() > 0)
{
String bifurErrString = errString.substring( errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>"));
bifurErrString =bifurErrString+errString.substring( errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString);
System.out.println("errStringXml .........."+errStringXml);
errString = "";
}
if ( errorType.equalsIgnoreCase("E"))
{
break;
}
}
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors></Root>\r\n");
}
else
{
errStringXml = new StringBuffer( "" );
}
}//end of if
}//end of try
catch(Exception e){
}
finally{
try{
if(conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
}
catch(Exception e){
e.printStackTrace();
throw new ITMException(e);
}
}
errString = errStringXml.toString();
System.out.println("testing : final errString : " + errString);
return errString;
}//end of wfValdata
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
System.out.println("itemChanged() called for ItemAcctDetrIC ...editFlag["+editFlag+"]");
String valueXmlString = "";
try
{
System.out.println("@@@@@@@@@@@@@@@ xmlString["+xmlString+"]");
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
}
System.out.println("@@@@@@@@@@@@@@@ xmlString1["+xmlString1+"]");
if(xmlString1 != null && xmlString1.trim().length() > 0)
{
dom1 = parseString(xmlString1);
}
System.out.println("@@@@@@@@@@@@@@@ xmlString2["+xmlString2+"]");
if(xmlString2 != null && xmlString2.trim().length() > 0)
{
dom2 = parseString(xmlString2);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [ItemAcctDetrIC][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
{
int currentFormNo =0,ctr=0;
int childNodeListLength = 0;
String itemCode="",grpCode="",tranType="";
String sql = "",descr="",itemSer="",acctCodeSal="",acctCodeDis="";
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
E12GenericUtility genericUtility = new E12GenericUtility();
try{
conn = getConnection();
//sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("[ItemAcctDetrIC] [itemChanged] :currentFormNo ....." +currentFormNo);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("**********ITEMCHANGE FOR CASE"+currentFormNo+"**************");
switch(currentFormNo)
{
case 1:
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
ctr ++;
}while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
grpCode = checkNull(genericUtility.getColumnValue("group_code", dom));
tranType = checkNull(genericUtility.getColumnValue("tran_type", dom));
valueXmlString.append("<grp_code protect='0'>").append("<![CDATA[" + grpCode +"]]>").append("</grp_code>");
valueXmlString.append("<item_code protect='0'>").append("<![CDATA["+ itemCode + " ]]>").append("</item_code>");
valueXmlString.append("<tran_type protect='0'>").append("<![CDATA["+ tranType + " ]]>").append("</tran_type>");
}
if(currentColumn.trim().equalsIgnoreCase("itm_default_edit"))
{
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
grpCode = checkNull(genericUtility.getColumnValue("group_code", dom));
tranType = checkNull(genericUtility.getColumnValue("tran_type", dom));
valueXmlString.append("<grp_code protect='1'>").append("<![CDATA[" + grpCode +"]]>").append("</grp_code>");
valueXmlString.append("<item_code protect='1'>").append("<![CDATA["+ itemCode + " ]]>").append("</item_code>");
valueXmlString.append("<tran_type protect='1'>").append("<![CDATA["+ tranType + " ]]>").append("</tran_type>");
}
if( currentColumn.trim().equalsIgnoreCase( "item_ser" ) )
{
sql ="select descr from itemser where item_ser=?";
pstmt =conn.prepareStatement(sql);
pstmt.setString(1, descr);
rs = pstmt.executeQuery();
if(rs.next())
{
itemSer=rs.getString("item_ser");
System.out.println("Item ser>>>>>>"+itemSer);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<item_ser>").append("<![CDATA[" + itemSer + "]]>").append("</item_ser>");
}
if( currentColumn.trim().equalsIgnoreCase( "item_code" ) )
{
sql ="select descr from item where item_code=?";
pstmt =conn.prepareStatement(sql);
pstmt.setString(1, descr);
rs = pstmt.executeQuery();
if(rs.next())
{
itemCode=rs.getString("item_code");
System.out.println("Item code>>>>>>"+itemCode);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<item_code>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
}
//acct_code__sal is not present in the accounts table
if( currentColumn.trim().equalsIgnoreCase( "acct_code__sal" ) )
{
sql ="select descr from accounts where acct_code__sal=?";
pstmt =conn.prepareStatement(sql);
pstmt.setString(1, descr);
rs = pstmt.executeQuery();
if(rs.next())
{
acctCodeSal=rs.getString("acct_code__sal");
System.out.println("Acct Code sal>>>>>>"+acctCodeSal);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<acct_code__sal>").append("<![CDATA[" + acctCodeSal + "]]>").append("</acct_code__sal>");
}
//acct_code__dis is not present in the accounts table
if( currentColumn.trim().equalsIgnoreCase( "acct_code__dis" ) )
{
sql ="select descr from accounts where acct_code__dis=?";
pstmt =conn.prepareStatement(sql);
pstmt.setString(1, descr);
rs = pstmt.executeQuery();
if(rs.next())
{
acctCodeDis=rs.getString("acct_code__dis");
System.out.println("Acct Code Dis>>>>>>"+acctCodeDis);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("<acct_code__dis>").append("<![CDATA[" + acctCodeDis + "]]>").append("</acct_code__dis>");
}
}//end of case 1
valueXmlString.append("</Detail1>");
break;
}//end of switch case
valueXmlString.append("</Root>");
}
catch(Exception e){
e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage());
throw new ITMException(e);
}
finally{
try
{
if(conn != null)
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private String errorType( Connection conn , String errorCode )
{
String msgType = "";
PreparedStatement pstmt = null ;
ResultSet rs = null;
try
{
String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, checkNull(errorCode));
rs = pstmt.executeQuery();
while( rs.next() )
{
msgType = rs.getString("MSG_TYPE");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch ( Exception e )
{
e.printStackTrace();
}
}
return msgType;
}//end of errorType method
public String checkNull(String input)
{
if (input == null)
{
input="";
}
return input.trim();
}//end of checkNull method
private int getAccountDetail(String acctCode,Connection conn) throws ITMException
{
PreparedStatement pstmt = null ;
ResultSet rs = null;
String sql="";
int count=0;
try{
sql ="select count(*) as cnt from accounts where acct_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acctCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}//end of try
catch(SQLException e){
System.out.println("Exception in getAccountDetail ::"+e);
e.printStackTrace();
}//end of catch
catch(Exception ex)
{
System.out.println("Exception In getAccountDetail method of ItemAcctDetrIC Class : "+ex.getMessage());
ex.printStackTrace();
}
finally{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (SQLException se)
{
se.printStackTrace();
}
}//end of finally
return count;
}//end of method
private int getCostCtrDetail(String cctrCode,Connection conn) throws ITMException
{
PreparedStatement pstmt = null ;
ResultSet rs = null;
String sql="",errCode="",childNodeName="";
int count=0;
ArrayList <String> errList = new ArrayList<String>();
ArrayList <String>errFields = new ArrayList <String> ();
try{
if(cctrCode != null && cctrCode.trim().length() > 0)
{
sql ="select count(*) as cnt from costctr where cctr_code= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,cctrCode);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt("cnt");
if(count == 0)
{
errCode = "VMCCTR";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}//end of try block
catch(SQLException e){
System.out.println("Exception in getCostCtrDetail ::"+e);
e.printStackTrace();
}//end of catch
catch(Exception ex)
{
System.out.println("Exception In getCostCtrDetail method of ItemAcctDetrIC Class : "+ex.getMessage());
ex.printStackTrace();
}
finally{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception in finally block of getCostCtrDetail method ::"+e);
e.printStackTrace();
}
}//end of finally
return count;
}
}
package ibase.webitm.ejb.fin;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
@Local
public interface ItemAcctDetrICLocal {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.fin;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
@Remote
public interface ItemAcctDetrICRemote {
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, 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