Commit 442f0013 authored by psawant's avatar psawant

Realignment of chart of account

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@189215 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 13a00d60
package ibase.webitm.ejb.fin; package ibase.webitm.ejb.fin;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
//import ibase.webitm.utility.GenericUtility; //import ibase.webitm.utility.GenericUtility;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
/** /**
* Session Bean implementation class AccountsIC * Session Bean implementation class AccountsIC
*/ */
@Stateless @Stateless
public class AccountsIC extends ValidatorEJB implements AccountsICRemote, AccountsICLocal public class AccountsIC extends ValidatorEJB implements AccountsICRemote, AccountsICLocal
{ {
//changes and commented by sarita on 01/06/2017 // changes and commented by sarita on 01/06/2017
//changed by sarita on 09MAR2018 // changed by sarita on 09MAR2018
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
//GenericUtility genericUtility = GenericUtility.getInstance();
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException // GenericUtility genericUtility = GenericUtility.getInstance();
//Changed by Pooja S. on 13-AUG-18
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams, String formName) throws RemoteException, ITMException
{ {
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
String retString = ""; String retString = "";
try try
{ {
if(xmlString != null && xmlString.trim().length() > 0) if (xmlString != null && xmlString.trim().length() > 0)
{ {
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
} }
if(xmlString1 != null && xmlString1.trim().length() > 0) if (xmlString1 != null && xmlString1.trim().length() > 0)
{ {
dom1 = genericUtility.parseString(xmlString1); dom1 = genericUtility.parseString(xmlString1);
} }
if(xmlString2 != null && xmlString2.trim().length() > 0) if (xmlString2 != null && xmlString2.trim().length() > 0)
{ {
dom2 = genericUtility.parseString(xmlString2); dom2 = genericUtility.parseString(xmlString2);
} }
retString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams); retString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams, formName);
System.out.println("retString:::"+retString); System.out.println("retString:::" + retString);
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println(":::" + getClass().getSimpleName() + "::"+ e.getMessage()); System.out.println(":::" + getClass().getSimpleName() + "::" + e.getMessage());
e.getMessage(); e.getMessage();
} }
return retString; return retString;
} }
private String checkNull(String input) private String checkNull(String input)
{ {
return input == null ? "" : input; return input == null ? "" : input;
} }
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException //Changed by Pooja S. on 13-AUG-18
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams, String formName) throws RemoteException, ITMException
{ {
//changes and commented by sarita on 01/06/2017 // changes and commented by sarita on 01/06/2017
//changed by sarita on 09MAR2018 // changed by sarita on 09MAR2018
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
//GenericUtility genericUtility = GenericUtility.getInstance(); // GenericUtility genericUtility = GenericUtility.getInstance();
int childNodeLength = 0; int childNodeLength = 0;
int currentFormNo=0; int currentFormNo = 0;
int ctr=0,cnt=0; int ctr = 0, cnt = 0;
Connection conn = null; Connection conn = null;
//Added by sarita on 01/06/2017 // Added by sarita on 01/06/2017
ConnDriver connDriver = null; ConnDriver connDriver = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null;
NodeList parentNodeList = null; NodeList parentNodeList = null;
Node parentNode = null; Node parentNode = null;
NodeList childNodeList = null; NodeList childNodeList = null;
Node childNode = null; Node childNode = null;
String childNodeName = ""; String childNodeName = "";
String userId=""; String userId = "";
String acct_code__par="",sgroup_code="",curr_code="",acct_code__ntyp="",ls_acc="",acct_code="",sundry_type=""; String acct_code__par="",sgroup_code="",curr_code="",acct_code__ntyp="",ls_acc="",acct_code="",sundry_type="";
String sundtype = ""; String sundtype = "";
String sql = ""; String sql = "";
String errCode = ""; String errCode = "";
ArrayList<String> errList = new ArrayList<String>(); ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>(); ArrayList<String> errFields = new ArrayList<String>();
String errorType = "",errString=""; String errorType = "", errString = "";
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>"); StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try try
{ {
//changes and commented by sarita for DBConnection on 01/06/2017 :START // changes and commented by sarita for DBConnection on 01/06/2017 :START
//changed by sarita on 09MAR2018 // changed by sarita on 09MAR2018
conn = getConnection(); conn = getConnection();
/*connDriver = new ConnDriver(); /*connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false); conn.setAutoCommit(false);
connDriver = null;*/ connDriver = null;*/
//changes and commented by sarita for DBConnection on 01/06/2017 :END // changes and commented by sarita for DBConnection on 01/06/2017 :END
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length() > 0) if (objContext != null && objContext.trim().length() > 0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo:::"+currentFormNo); System.out.println("currentFormNo:::" + currentFormNo);
//Changed by Pooja S. on 13-AUG-18 START
switch(currentFormNo) System.out.println("formName:::" + formName);
{ // switch(currentFormName)
case 1: // {
{ if (currentFormNo == 1 || "accounts".equals(formName))
parentNodeList = dom.getElementsByTagName("Detail1"); {
parentNode = parentNodeList.item(0); parentNodeList = dom.getElementsByTagName("Detail1");
childNodeList = parentNode.getChildNodes(); parentNode = parentNodeList.item(0);
childNodeLength = childNodeList.getLength(); childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeLength; ctr++) for (ctr = 0; ctr < childNodeLength; ctr++)
{ {
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if("acct_code__par".equalsIgnoreCase(childNodeName)) if ("acct_code__par".equalsIgnoreCase(childNodeName))
{
acct_code__par = checkNull(genericUtility.getColumnValue("acct_code__par", dom)).trim();
acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom)).trim();
System.out.println("acct_code__par>>>>>" + acct_code__par);
if (!(acct_code__par.equalsIgnoreCase(acct_code)))
{ {
acct_code__par = checkNull(genericUtility.getColumnValue("acct_code__par",dom)).trim(); sql = "select count(*) as cnt from accounts where acct_code =?";
acct_code = checkNull(genericUtility.getColumnValue("acct_code",dom)).trim(); pstmt = conn.prepareStatement(sql);
System.out.println("acct_code__par>>>>>"+acct_code__par); pstmt.setString(1, acct_code__par);
rs = pstmt.executeQuery();
if(!(acct_code__par.equalsIgnoreCase(acct_code)))
if (rs.next())
{ {
sql = "select count(*) as cnt from accounts where acct_code =?"; cnt = rs.getInt("cnt");
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acct_code__par);
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 = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} }
}// end if block for acct_code__par if (pstmt != null)
{
else if("sgroup_code".equalsIgnoreCase(childNodeName)) pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
if (cnt == 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
} // end if block for acct_code__par
else if ("sgroup_code".equalsIgnoreCase(childNodeName))
{
sgroup_code = checkNull(genericUtility.getColumnValue("sgroup_code", dom)).trim();
System.out.println("sgroup_code>>>>>" + sgroup_code);
sql = "select count(*) as cnt from acctsgrp where sgroup_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sgroup_code);
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 = "VMACCTSGR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} // end if block for sgroup_code
else if ("curr_code".equalsIgnoreCase(childNodeName))
{
curr_code = checkNull(genericUtility.getColumnValue("curr_code", dom)).trim();
System.out.println("curr_code>>>>>" + curr_code);
sql = "select count(*) as cnt from currency where curr_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, curr_code);
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 = "VMCUR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} // end if block for curr_code
else if ("acct_code__ntyp".equalsIgnoreCase(childNodeName))
{
acct_code__ntyp = checkNull(genericUtility.getColumnValue("acct_code__ntyp", dom)).trim();
System.out.println("acct_code__ntyp>>>>>" + acct_code__ntyp);
if (acct_code__ntyp != null && acct_code__ntyp.trim().length() > 0)
{ {
sgroup_code = checkNull(genericUtility.getColumnValue("sgroup_code",dom)).trim(); sql = "select count(*) as cnt from accounts where acct_code =?";
System.out.println("sgroup_code>>>>>"+sgroup_code);
sql = "select count(*) as cnt from acctsgrp where sgroup_code =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,sgroup_code); pstmt.setString(1, acct_code__ntyp);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next())
{ {
cnt = rs.getInt("cnt"); cnt = rs.getInt("cnt");
} }
if(pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(rs != null) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if(cnt == 0) if(cnt == 0)
{ {
errCode = "VMACCTSGR1"; errCode = "VMACCT";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
}
}// end if block for sgroup_code } // end if block for acct_code__ntyp
else if("curr_code".equalsIgnoreCase(childNodeName)) else if ("sundry_type".equalsIgnoreCase(childNodeName))
{
acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom)).trim();
if ("E".equalsIgnoreCase(editFlag))
{ {
curr_code = checkNull(genericUtility.getColumnValue("curr_code",dom)).trim(); sql = "select sundry_type from accounts where acct_code=?";
System.out.println("curr_code>>>>>"+curr_code); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acct_code);
sql = "select count(*) as cnt from currency where curr_code =?"; rs = pstmt.executeQuery();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,curr_code); if (rs.next())
{
sundtype = rs.getString("sundry_type");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
sql = "select count(acct_code) as cnt from gltrace where acct_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acct_code);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next())
{ {
cnt = rs.getInt("cnt"); cnt = rs.getInt("cnt");
} }
if(pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(rs != null) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if(cnt == 0) if (cnt > 0)
{ {
errCode = "VMCUR1"; errCode = "VMACCTSRS1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
}// end if block for curr_code }
} // end of if block for sundry_type
else if("acct_code__ntyp".equalsIgnoreCase(childNodeName)) }
} // end case1
else if (currentFormNo == 2 || "siteaccount".equals(formName))
{
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("acct_code"))
{
String acctcode = checkNull(genericUtility.getColumnValue("acct_code", dom));
if (acctcode == null || acctcode.length() <= 0)
{ {
acct_code__ntyp = checkNull(genericUtility.getColumnValue("acct_code__ntyp",dom)).trim(); errCode = "VMACCT1";
System.out.println("acct_code__ntyp>>>>>"+acct_code__ntyp); errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
if(acct_code__ntyp != null && acct_code__ntyp.trim().length() > 0) System.out.println("acctcode is not entered");
{ break;
sql = "select count(*) as cnt from accounts where acct_code =?"; }
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acct_code__ntyp); }
rs = pstmt.executeQuery(); else if ("site_code".equalsIgnoreCase(childNodeName))
{
if(rs.next())
{ NodeList siteParentNode = null;
cnt = rs.getInt("cnt"); ArrayList<String> sitecodeall = new ArrayList<String>();
}
if(pstmt != null)
{ if ("A".equalsIgnoreCase(editFlag))
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(cnt == 0)
{
errCode = "VMACCT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}// end if block for acct_code__ntyp
else if("sundry_type".equalsIgnoreCase(childNodeName))
{ {
acct_code = checkNull(genericUtility.getColumnValue("acct_code",dom)).trim();
if("E".equalsIgnoreCase(editFlag)) int ctr2 = 0;
int childNodeListLength2 = 0;
siteParentNode = dom2.getElementsByTagName("Detail2");
System.out.println("2 domm all siteParentNode = " + siteParentNode);
System.out.println("3 domm all siteParentNode = " + siteParentNode.getLength());
for (ctr2 = 0; ctr2 < siteParentNode.getLength(); ctr2++)
{ {
sql = "select sundry_type from accounts where acct_code=?"; System.out.println("4 In for Parent loop " + ctr2);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acct_code); Node parentNode2 = siteParentNode.item(ctr2);
rs = pstmt.executeQuery(); System.out.println("5 parentNode= parentNodeList.item(0) = " + parentNode2);
System.out.println();
if(rs.next())
{ NodeList childNodeList2 = parentNode2.getChildNodes();
sundtype = rs.getString("sundry_type"); System.out.println(
} "6 childNodeList= parentNode.getChildNodes(); = " + childNodeList2);
if(pstmt != null) System.out.println();
{
pstmt.close(); childNodeListLength2 = childNodeList2.getLength();
pstmt = null; for (int ctr3 = 0; ctr3 < childNodeListLength2; ctr3++)
}
if(rs != null)
{
rs.close();
rs = null;
}
sql = "select count(acct_code) as cnt from gltrace where acct_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,acct_code);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt("cnt");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{ {
rs.close(); Node childNode2 = childNodeList2.item(ctr3);
rs = null; System.out.println("childNode= childNodeList.item(ctr3) = " + childNode2);
System.out.println();
String childNodeName2 = childNode2.getNodeName();
System.out.println("current column " + ctr3 + " " + childNodeName2);
System.out.println();
if (childNodeName2.equalsIgnoreCase("site_code"))
{
System.out.println("Final Array " + sitecodeall);
String siteCode = checkNull(
genericUtility.getColumnValueFromNode("site_code", parentNode2))
.trim();
System.out.println("Node value Site_code " + siteCode);
if (sitecodeall.contains(siteCode))
{
System.out.println("0 site_code should not be duplicate dom");
errCode = "VMACCTSRS1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sitecodeall.add(siteCode);
System.out.println("In Else add in array so now array " + sitecodeall);
}
}
} }
if(cnt > 0) }
{
errCode = "VMACCTSRS1"; }
errList.add(errCode); }
errFields.add(childNodeName.toLowerCase()); }
} }
else if (currentFormNo == 3 || "acctcostcntre".equals(formName))
{
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("acct_code"))
{
String acctcode = checkNull(genericUtility.getColumnValue("acct_code", dom));
if (acctcode == null || acctcode.length() <= 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("acctcode is not entered");
break;
}
}
else if (childNodeName.equalsIgnoreCase("cctr_code"))
{
String costcntrcode = checkNull(genericUtility.getColumnValue("cctr_code", dom));
if (costcntrcode == null || costcntrcode.length() <= 0)
{
errCode = "VMCCTR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("costcntrcode is not entered");
break;
}
else if (costcntrcode != null && costcntrcode.trim().length() > 0)
{
sql = "select count(*) as cnt from costctr where cctr_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, costcntrcode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("cnt");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
} }
}//end of if block for sundry_type
} if (cnt == 0)
}// end case1 {
break; errCode = "VMCCTR";
}// end switch errList.add(errCode);
int errListSize = errList.size(); errFields.add(childNodeName.toLowerCase());
System.out.println("errListSize::::::::::"+errListSize); }
int count = 0; }
String errFldName = null;
if (errList != null && errListSize > 0) }
}
}
else if (currentFormNo == 4 || "acctanal".equals(formName))
{ {
for (count = 0; count < errListSize; count++) parentNodeList = dom.getElementsByTagName("Detail4");
{ parentNode = parentNodeList.item(0);
errCode = errList.get(count); childNodeList = parentNode.getChildNodes();
errFldName = errFields.get(count); childNodeLength = childNodeList.getLength();
System.out.println(" testing :errCode .:" + errCode); for (ctr = 0; ctr < childNodeLength; ctr++)
errString = getErrorString(errFldName, errCode, userId); {
System.out.println("errString>>>>>>>>>"+errString); childNode = childNodeList.item(ctr);
errorType = errorType(conn, errCode); childNodeName = childNode.getNodeName();
if (errString.length() > 0) if (childNodeName.equalsIgnoreCase("acct_code"))
{ {
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>")); String acctcode = checkNull(genericUtility.getColumnValue("acct_code", dom));
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString); if (acctcode == null || acctcode.length() <= 0)
errString = ""; {
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("acctcode is not entered");
break;
}
} }
if (errorType.equalsIgnoreCase("E")) if (childNodeName.equalsIgnoreCase("anal_code"))
{ {
break; String analcode = checkNull(genericUtility.getColumnValue("anal_code", dom));
if (analcode == null || analcode.length() <= 0)
{
errCode = "VMANAL1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("analcode is not entered");
break;
}
else if (analcode != null && analcode.trim().length() > 0)
{
sql = "select count(*) as cnt from analysis where anal_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, analcode);
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 = "VMANAL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
} }
} }
errList.clear();
errList = null;
errFields.clear();
errFields = null;
errStringXml.append("</Errors> </Root> \r\n");
} }
else else if (currentFormNo == 5 || "acctdept".equals(formName))
{ {
errStringXml = new StringBuffer(""); parentNodeList = dom.getElementsByTagName("Detail5");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("acct_code"))
{
String acctcode = checkNull(genericUtility.getColumnValue("acct_code", dom));
if (acctcode == null || acctcode.length() <= 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("acctcode is not entered");
break;
}
}
if (childNodeName.equalsIgnoreCase("dept_code"))
{
String deptcode = checkNull(genericUtility.getColumnValue("dept_code", dom));
if (deptcode == null || deptcode.length() <= 0)
{
errCode = "VMDEPT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("deptcode is not entered");
break;
}
else if (deptcode != null && deptcode.trim().length() > 0)
{
sql = "select count(*) as cnt from departments where dept_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, deptcode);
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 = "VMDEPT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
} }
} // end switch
//Changed by Pooja S. on 13-AUG-18 End
int errListSize = errList.size();
System.out.println("errListSize::::::::::" + errListSize);
int count = 0;
String errFldName = null;
if (errList != null && errListSize > 0)
{
for (count = 0; count < errListSize; count++)
{
errCode = errList.get(count);
errFldName = errFields.get(count);
System.out.println(" testing :errCode .:" + errCode);
errString = getErrorString(errFldName, errCode, userId);
System.out.println("errString>>>>>>>>>" + errString);
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);
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 try block }
catch(Exception e) // end of try block
catch (Exception e)
{ {
System.out.println(":::" + getClass().getSimpleName() + "::"+ e.getMessage()); System.out.println(":::" + getClass().getSimpleName() + "::" + e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
finally finally
{ {
try try
{ {
if (conn != null) if (conn != null)
{ {
if (rs != null) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
} }
if (pstmt != null) if (pstmt != null)
{ {
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
conn.close(); conn.close();
} }
conn = null; conn = null;
} }
catch (Exception d) catch (Exception d)
{ {
d.printStackTrace(); d.printStackTrace();
throw new ITMException(d); throw new ITMException(d);
...@@ -391,322 +698,441 @@ public class AccountsIC extends ValidatorEJB implements AccountsICRemote, Accoun ...@@ -391,322 +698,441 @@ public class AccountsIC extends ValidatorEJB implements AccountsICRemote, Accoun
return errString; return errString;
} }
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException //Changed by Pooja S. on 13-AUG-18
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName) throws RemoteException, ITMException
{ {
Document dom = null; Document dom = null;
Document domhr = null; Document domhr = null;
Document domAll = null; Document domAll = null;
String retString=""; String retString = "";
try try
{ {
System.out.println("************** Inside itemChanged method ****************"); System.out.println("************** Inside itemChanged method ****************");
if(xmlString != null && xmlString.trim().length() > 0) if (xmlString != null && xmlString.trim().length() > 0)
{ {
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
} }
if(xmlString1 != null && xmlString1.trim().length() > 0) if (xmlString1 != null && xmlString1.trim().length() > 0)
{ {
domhr = genericUtility.parseString(xmlString1); domhr = genericUtility.parseString(xmlString1);
} }
if(xmlString2 != null && xmlString2.trim().length() > 0) if (xmlString2 != null && xmlString2.trim().length() > 0)
{ {
domAll = genericUtility.parseString(xmlString2); domAll = genericUtility.parseString(xmlString2);
} }
retString = itemChanged(dom,domhr,domAll,objContext,currentColumn,editFlag,xtraParams); //Changed by Pooja S. on 13-AUG-18
System.out.println("retString::::::::::"+retString); retString = itemChanged(dom, domhr, domAll, objContext, currentColumn, editFlag, xtraParams, formName);
} System.out.println("retString::::::::::" + retString);
catch(Exception e) }
catch (Exception e)
{ {
System.out.println(":::" + getClass().getSimpleName() + "::"+ e.getMessage()); System.out.println(":::" + getClass().getSimpleName() + "::" + e.getMessage());
e.getMessage(); e.getMessage();
} }
return retString; return retString;
} }
//Changed by Pooja S. on 13-AUG-18
public String itemChanged(Document dom, Document dom1, Document dom2,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, String formName) throws RemoteException, ITMException
{ {
Connection conn = null; Connection conn = null;
//Added by sarita on 01/06/2017 // Added by sarita on 01/06/2017
ConnDriver connDriver = null; ConnDriver connDriver = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null;
SimpleDateFormat sdf; SimpleDateFormat sdf;
int childNodeListLength = 0; int childNodeListLength = 0;
int currentFormNo=0,ctr=0; int currentFormNo = 0, ctr = 0;
StringBuffer valueXmlString = new StringBuffer(); StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null; NodeList parentNodeList = null;
NodeList childNodeList = null; NodeList childNodeList = null;
Node parentNode = null; Node parentNode = null;
Node childNode = null; Node childNode = null;
String childNodeName = null; String childNodeName = null;
String acct_code=""; String acct_code = "";
String acct_code__par=""; String acct_code__par = "";
String sgroup_code=""; String sgroup_code = "";
String sql = ""; String sql = "";
String ls_descr = ""; String ls_descr = "";
String ls_descr1 = "",acctgrp_descr="",curr_code=""; String ls_descr1 = "", acctgrp_descr = "", curr_code = "";
String currency_descr = "",acct_type=""; String currency_descr = "", acct_type = "";
String sundry_type = "",group_code = ""; //Changed by Pooja S. on 13-AUG-18
String sundry_type = "", group_code = "", sh_descr = "", descr = "", acct_type2 = "", descr2 = "",
try sh_descr2 = "", analysisdescr = "", descr3 = "", descr4 = "";
try
{ {
//changes and commented by sarita for DBConnection on 01/06/2017 :START // changes and commented by sarita for DBConnection on 01/06/2017 :START
//changed by sarita on 09MARCH2018 // changed by sarita on 09MARCH2018
conn = getConnection(); conn = getConnection();
/*connDriver = new ConnDriver(); /*connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false); conn.setAutoCommit(false);
connDriver = null;*/ connDriver = null;*/
//changes and commented by sarita for DBConnection on 01/06/2017 :END // changes and commented by sarita for DBConnection on 01/06/2017 :END
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(objContext != null && objContext.trim().length()>0) if (objContext != null && objContext.trim().length() > 0)
{ {
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
System.out.println("[AccountsIC] [itemChanged] :currentFormNo ....." +currentFormNo); System.out.println("[AccountsIC] [itemChanged] :currentFormNo ....." + currentFormNo);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>"); valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>"); valueXmlString.append(editFlag).append("</editFlag></header>");
switch(currentFormNo) /*
* switch(currentFormNo) { case 1:
* {
*/
//Changed by Pooja S. on 13-AUG-18
System.out.println("Currentform 0 " + formName + "" + currentFormNo);
//Changed by Pooja S. on 13-AUG-18
if (currentFormNo == 1 || "accounts".equals(formName))
{ {
case 1: parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
do
{ {
parentNodeList = dom.getElementsByTagName("Detail1"); childNode = childNodeList.item(ctr);
parentNode = parentNodeList.item(0); childNodeName = childNode.getNodeName();
childNodeList = parentNode.getChildNodes(); ctr++;
valueXmlString.append("<Detail1>"); } while (ctr < childNodeListLength && !childNodeName.equals(currentColumn));
childNodeListLength = childNodeList.getLength();
do if ("itm_defaultedit".equalsIgnoreCase(currentColumn.trim()))
{ {
childNode = childNodeList.item(ctr); acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom));
childNodeName = childNode.getNodeName(); acct_code__par = checkNull(genericUtility.getColumnValue("acct_code__par", dom));
ctr ++;
if (acct_code__par == null || acct_code__par.trim().length() == 0)
{
valueXmlString.append("<acct_code__par>").append("<![CDATA["+acct_code+"]]>").append("</acct_code__par>");
} }
while(ctr < childNodeListLength && ! childNodeName.equals(currentColumn));
sgroup_code = checkNull(genericUtility.getColumnValue("sgroup_code", dom));
if("itm_defaultedit".equalsIgnoreCase(currentColumn.trim())) System.out.println("sgroup_code>>>>>>>>>>"+sgroup_code);
sql = "select descr,group_code from acctsgrp where sgroup_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sgroup_code);
rs = pstmt.executeQuery();
while (rs.next())
{
ls_descr = rs.getString("descr");
ls_descr1 = rs.getString("group_code");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<acctsgrp_descr>").append("<![CDATA[" + ls_descr + "]]>").append("</acctsgrp_descr>");
valueXmlString.append("<group_code>").append("<![CDATA[" + ls_descr1 + "]]>").append("</group_code>");
sql = "select descr from acctgrp where group_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_descr1);
rs = pstmt.executeQuery();
if (rs.next())
{
acctgrp_descr = rs.getString("descr");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<acctgrp_descr>").append("<![CDATA[" + acctgrp_descr + "]]>").append("</acctgrp_descr>");
curr_code = checkNull(genericUtility.getColumnValue("curr_code", dom));
System.out.println("curr_code>>>>>>>>>>" + curr_code);
sql = "Select descr from currency where curr_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, curr_code);
rs = pstmt.executeQuery();
if (rs.next())
{
currency_descr = rs.getString("descr");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<currency_descr>").append("<![CDATA["+currency_descr+"]]>").append("</currency_descr>");
acct_type = checkNull(genericUtility.getColumnValue("acct_type", dom));
System.out.println("acct_type>>>>>>>>>>" + acct_type);
if (acct_type.equals("O"))
{ {
acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom));
acct_code__par = checkNull(genericUtility.getColumnValue("acct_code__par", dom));
if(acct_code__par == null || acct_code__par.trim().length() == 0)
{
valueXmlString.append("<acct_code__par>").append("<![CDATA["+acct_code+"]]>").append("</acct_code__par>");
}
sgroup_code = checkNull(genericUtility.getColumnValue("sgroup_code", dom));
System.out.println("sgroup_code>>>>>>>>>>"+sgroup_code);
sql = "select descr,group_code from acctsgrp where sgroup_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,sgroup_code);
rs = pstmt.executeQuery();
while(rs.next())
{
ls_descr = rs.getString("descr");
ls_descr1 = rs.getString("group_code");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<acctsgrp_descr>").append("<![CDATA["+ls_descr+"]]>").append("</acctsgrp_descr>");
valueXmlString.append("<group_code>").append("<![CDATA["+ls_descr1+"]]>").append("</group_code>");
sql = "select descr from acctgrp where group_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,ls_descr1);
rs = pstmt.executeQuery();
if(rs.next())
{
acctgrp_descr = rs.getString("descr");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<acctgrp_descr>").append("<![CDATA["+acctgrp_descr+"]]>").append("</acctgrp_descr>");
curr_code = checkNull(genericUtility.getColumnValue("curr_code", dom));
System.out.println("curr_code>>>>>>>>>>"+curr_code);
sql = "Select descr from currency where curr_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,curr_code);
rs = pstmt.executeQuery();
if(rs.next())
{
currency_descr = rs.getString("descr");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<currency_descr>").append("<![CDATA["+currency_descr+"]]>").append("</currency_descr>");
acct_type = checkNull(genericUtility.getColumnValue("acct_type", dom));
System.out.println("acct_type>>>>>>>>>>"+acct_type);
if(acct_type.equals("O"))
{
valueXmlString.append("<sundry_type protect='1'>").append("<![CDATA["+"1"+"]]>").append("</sundry_type>"); valueXmlString.append("<sundry_type protect='1'>").append("<![CDATA["+"1"+"]]>").append("</sundry_type>");
} }
else else
{ {
valueXmlString.append("<sundry_type protect='O'>").append("<![CDATA["+"O"+"]]>").append("</sundry_type>"); valueXmlString.append("<sundry_type protect='O'>").append("<![CDATA["+"O"+"]]>").append("</sundry_type>");
}
} }
}
if("acct_code".equalsIgnoreCase(currentColumn.trim()))
if ("acct_code".equalsIgnoreCase(currentColumn.trim()))
{
acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom));
acct_code__par = checkNull(genericUtility.getColumnValue("acct_code__par", dom));
if(acct_code__par == null || acct_code__par.trim().length() == 0)
{ {
acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom));
acct_code__par = checkNull(genericUtility.getColumnValue("acct_code__par", dom));
if(acct_code__par == null || acct_code__par.trim().length() == 0)
{
valueXmlString.append("<acct_code__par>").append("<![CDATA["+acct_code+"]]>").append("</acct_code__par>"); valueXmlString.append("<acct_code__par>").append("<![CDATA["+acct_code+"]]>").append("</acct_code__par>");
}
} // end of if block for acct_code
else if ("sgroup_code".equalsIgnoreCase(currentColumn.trim()))
{
sgroup_code = checkNull(genericUtility.getColumnValue("sgroup_code", dom));
System.out.println("sgroup_code>>>>>>>>>>" + sgroup_code);
sql = "select descr,group_code from acctsgrp where sgroup_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sgroup_code);
rs = pstmt.executeQuery();
while (rs.next())
{
ls_descr = rs.getString("descr");
ls_descr1 = rs.getString("group_code");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<acctsgrp_descr>").append("<![CDATA["+ls_descr+"]]>").append("</acctsgrp_descr>");
valueXmlString.append("<group_code>").append("<![CDATA["+ls_descr1+"]]>").append("</group_code>");
sql = "select descr from acctgrp where group_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_descr1);
rs = pstmt.executeQuery();
if (rs.next())
{
acctgrp_descr = rs.getString("descr");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<acctgrp_descr>").append("<![CDATA["+acctgrp_descr+"]]>").append("</acctgrp_descr>");
}
else if ("curr_code".equalsIgnoreCase(currentColumn.trim()))
{
curr_code = checkNull(genericUtility.getColumnValue("curr_code", dom));
System.out.println("curr_code>>>>>>>>>>" + curr_code);
sql = "Select descr from currency where curr_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, curr_code);
rs = pstmt.executeQuery();
if (rs.next())
{
currency_descr = rs.getString("descr");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<currency_descr>").append("<![CDATA["+currency_descr+"]]>").append("</currency_descr>");
} // end of if block for curr_code
else if ("acct_type".equalsIgnoreCase(currentColumn.trim()))
{
acct_type = checkNull(genericUtility.getColumnValue("acct_type", dom));
System.out.println("acct_type>>>>>>>>>>" + acct_type);
if (acct_type.equals("O"))
{
valueXmlString.append("<sundry_type protect='1'>").append("<![CDATA["+"1"+"]]>").append("</sundry_type>");
} }
}// end of if block for acct_code else
{
else if("sgroup_code".equalsIgnoreCase(currentColumn.trim())) valueXmlString.append("<sundry_type protect='O'>").append("<![CDATA["+"O"+"]]>").append("</sundry_type>");
{ }
sgroup_code = checkNull(genericUtility.getColumnValue("sgroup_code", dom));
System.out.println("sgroup_code>>>>>>>>>>"+sgroup_code); } // end of if block for acct_type
valueXmlString.append("</Detail1>");
sql = "select descr,group_code from acctsgrp where sgroup_code=?"; } // end of case1
//Changed by Pooja S. on 13-AUG-18 START
else if (currentFormNo == 2 || "siteaccount".equals(formName))
{
valueXmlString.append("<Detail2>");
if ("itm_default".equalsIgnoreCase(currentColumn.trim()))
{
String site_code = checkNull(genericUtility.getColumnValue("site_code", dom));
if (site_code == null || site_code.trim().length() == 0)
{
site_code = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
valueXmlString.append("<site_code>").append("<![CDATA[" + site_code + "]]>").append("</site_code>");
}
}
valueXmlString.append("</Detail2>");
}
else if (currentFormNo == 3 || "acctcostcntre".equals(formName))
{
valueXmlString.append("<Detail3>");
if ("cctr_code".equalsIgnoreCase(currentColumn.trim()))
{
String cctr_code = checkNull(genericUtility.getColumnValue("cctr_code", dom));
System.out.print("Value valueXmlString cctr_code\n [" + cctr_code + "]");
if (cctr_code != null)
{
sql = "select descr,sh_descr from costctr where cctr_code=?";
System.out.print("Value valueXmlString 100000000 \n [" + sql + "]");
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,sgroup_code); pstmt.setString(1, cctr_code);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next())
while(rs.next())
{
ls_descr = rs.getString("descr");
ls_descr1 = rs.getString("group_code");
}
if(pstmt != null)
{ {
pstmt.close(); descr = checkNull(rs.getString("descr"));
pstmt = null; sh_descr = checkNull(rs.getString("sh_descr"));
} }
if(rs != null) rs.close();
{ rs = null;
rs.close(); pstmt.close();
rs = null; pstmt = null;
} System.out.print("Value valueXmlString Pricelist \n [" + sql + "]");
valueXmlString.append("<acctsgrp_descr>").append("<![CDATA["+ls_descr+"]]>").append("</acctsgrp_descr>"); valueXmlString.append("<descr ><![CDATA[" + descr + "]]></descr>");
valueXmlString.append("<group_code>").append("<![CDATA["+ls_descr1+"]]>").append("</group_code>"); valueXmlString.append("<sh_descr ><![CDATA[" + sh_descr + "]]></sh_descr>");
}
sql = "select descr from acctgrp where group_code=?"; }
valueXmlString.append("</Detail3>");
}
else if (currentFormNo == 4 || "acctanal".equals(formName))
{
valueXmlString.append("<Detail4>");
if ("anal_code".equalsIgnoreCase(currentColumn.trim()))
{
String anal_code = checkNull(genericUtility.getColumnValue("anal_code", dom));
System.out.print("Value valueXmlString cctr_code\n [" + anal_code + "]");
if (anal_code != null)
{
sql = "select descr from analysis where anal_code=?";
System.out.print("Value valueXmlString 100000000 \n [" + sql + "]");
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,ls_descr1); pstmt.setString(1, anal_code);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next())
if(rs.next())
{
acctgrp_descr = rs.getString("descr");
}
if(pstmt != null)
{ {
pstmt.close(); analysisdescr = checkNull(rs.getString("descr"));
pstmt = null;
} }
if(rs != null) rs.close();
{ rs = null;
rs.close(); pstmt.close();
rs = null; pstmt = null;
} System.out.print("Value valueXmlString Pricelist \n [" + sql + "]");
valueXmlString.append("<acctgrp_descr>").append("<![CDATA["+acctgrp_descr+"]]>").append("</acctgrp_descr>"); valueXmlString.append("<analysis_descr ><![CDATA[" + analysisdescr + "]]></analysis_descr>");
} }
}
else if("curr_code".equalsIgnoreCase(currentColumn.trim())) valueXmlString.append("</Detail4>");
}
else if (currentFormNo == 5 || "acctdept".equals(formName))
{
valueXmlString.append("<Detail5>");
if ("dept_code".equalsIgnoreCase(currentColumn.trim()))
{
String dept_code = checkNull(genericUtility.getColumnValue("dept_code", dom));
System.out.print("Value valueXmlString cctr_code\n [" + dept_code + "]");
if (dept_code != null)
{ {
curr_code = checkNull(genericUtility.getColumnValue("curr_code", dom)); sql = "select descr from department where dept_code=?";
System.out.println("curr_code>>>>>>>>>>"+curr_code);
System.out.print("Value valueXmlString 100000000 \n [" + sql + "]");
sql = "Select descr from currency where curr_code =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,curr_code); pstmt.setString(1, dept_code);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next())
if(rs.next())
{
currency_descr = rs.getString("descr");
}
if(pstmt != null)
{ {
pstmt.close(); descr4 = checkNull(rs.getString("descr"));
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<currency_descr>").append("<![CDATA["+currency_descr+"]]>").append("</currency_descr>");
}// end of if block for curr_code
else if("acct_type".equalsIgnoreCase(currentColumn.trim()))
{
acct_type = checkNull(genericUtility.getColumnValue("acct_type", dom));
System.out.println("acct_type>>>>>>>>>>"+acct_type);
if(acct_type.equals("O"))
{
valueXmlString.append("<sundry_type protect='1'>").append("<![CDATA["+"1"+"]]>").append("</sundry_type>");
} }
else rs.close();
{ rs = null;
valueXmlString.append("<sundry_type protect='O'>").append("<![CDATA["+"O"+"]]>").append("</sundry_type>"); pstmt.close();
} pstmt = null;
}// end of if block for acct_type System.out.print("Value valueXmlString Pricelist \n [" + sql + "]");
}// end of case1 valueXmlString.append("<department_descr ><![CDATA[" + descr4 + "]]></department_descr>");
valueXmlString.append("</Detail1>"); }
break; }
}// end of switch statement valueXmlString.append("</Detail5>");
valueXmlString.append("</Root>"); }
}// end of try block valueXmlString.append("</Root>");
catch(Exception e) // end of switch statement
} // end of try block
//Changed by Pooja S. on 13-AUG-18 END
catch (Exception e)
{ {
System.out.println(":::" + getClass().getSimpleName() + "::"+ e.getMessage()); System.out.println(":::" + getClass().getSimpleName() + "::" + e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
finally finally
{ {
try try
{ {
if(conn != null){conn.close();conn = null;} if (conn != null)
} {
catch(Exception e) conn.close();
conn = null;
}
}
catch (Exception e)
{ {
System.out.println("Exception in EJB["+ getClass().getSimpleName() + "]::itemChanged::["+ e.getMessage() + "]"); System.out.println("Exception in EJB["+ getClass().getSimpleName() + "]::itemChanged::["+ e.getMessage() + "]");
} }
} }
return valueXmlString.toString(); return valueXmlString.toString();
} }
private String errorType(Connection conn, String errorCode) throws ITMException private String errorType(Connection conn, String errorCode) throws ITMException
{ {
String msgType = ""; String msgType = "";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
...@@ -726,16 +1152,16 @@ public class AccountsIC extends ValidatorEJB implements AccountsICRemote, Accoun ...@@ -726,16 +1152,16 @@ public class AccountsIC extends ValidatorEJB implements AccountsICRemote, Accoun
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
catch (Exception ex) catch (Exception ex)
{ {
ex.printStackTrace(); ex.printStackTrace();
throw new ITMException(ex); throw new ITMException(ex);
} }
finally finally
{ {
try try
{ {
if (rs != null) if (rs != null)
{ {
rs.close(); rs.close();
rs = null; rs = null;
......
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
//import ibase.webitm.utility.GenericUtility;
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.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
/**
* Session Bean implementation class AccountsIC
*/
@Stateless
public class AccountsIC extends ValidatorEJB implements AccountsICRemote, AccountsICLocal
{
// changes and commented by sarita on 01/06/2017
// changed by sarita on 09MAR2018
E12GenericUtility genericUtility = new E12GenericUtility();
// GenericUtility genericUtility = GenericUtility.getInstance();
//Changed by Pooja S. on 13-AUG-18
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams, String formName) 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, formName);
System.out.println("retString:::" + retString);
}
catch(Exception e)
{
System.out.println(":::" + getClass().getSimpleName() + "::" + e.getMessage());
e.getMessage();
}
return retString;
}
private String checkNull(String input)
{
return input == null ? "" : input;
}
//Changed by Pooja S. on 13-AUG-18
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams, String formName) throws RemoteException, ITMException
{
// changes and commented by sarita on 01/06/2017
// changed by sarita on 09MAR2018
E12GenericUtility genericUtility = new E12GenericUtility();
// GenericUtility genericUtility = GenericUtility.getInstance();
int childNodeLength = 0;
int currentFormNo = 0;
int ctr = 0, cnt = 0;
Connection conn = null;
// Added by sarita on 01/06/2017
ConnDriver connDriver = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
NodeList parentNodeList = null;
Node parentNode = null;
NodeList childNodeList = null;
Node childNode = null;
String childNodeName = "";
String userId = "";
String acct_code__par="",sgroup_code="",curr_code="",acct_code__ntyp="",ls_acc="",acct_code="",sundry_type="";
String sundtype = "";
String sql = "";
String errCode = "";
ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>();
String errorType = "", errString = "";
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
try
{
// changes and commented by sarita for DBConnection on 01/06/2017 :START
// changed by sarita on 09MAR2018
conn = getConnection();
/*connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;*/
// changes and commented by sarita for DBConnection on 01/06/2017 :END
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo:::" + currentFormNo);
//Changed by Pooja S. on 13-AUG-18 START
System.out.println("formName:::" + formName);
// switch(currentFormName)
// {
if (currentFormNo == 1 || "accounts".equals(formName))
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if ("acct_code__par".equalsIgnoreCase(childNodeName))
{
acct_code__par = checkNull(genericUtility.getColumnValue("acct_code__par", dom)).trim();
acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom)).trim();
System.out.println("acct_code__par>>>>>" + acct_code__par);
if (!(acct_code__par.equalsIgnoreCase(acct_code)))
{
sql = "select count(*) as cnt from accounts where acct_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acct_code__par);
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 = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
} // end if block for acct_code__par
else if ("sgroup_code".equalsIgnoreCase(childNodeName))
{
sgroup_code = checkNull(genericUtility.getColumnValue("sgroup_code", dom)).trim();
System.out.println("sgroup_code>>>>>" + sgroup_code);
sql = "select count(*) as cnt from acctsgrp where sgroup_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sgroup_code);
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 = "VMACCTSGR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} // end if block for sgroup_code
else if ("curr_code".equalsIgnoreCase(childNodeName))
{
curr_code = checkNull(genericUtility.getColumnValue("curr_code", dom)).trim();
System.out.println("curr_code>>>>>" + curr_code);
sql = "select count(*) as cnt from currency where curr_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, curr_code);
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 = "VMCUR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
} // end if block for curr_code
else if ("acct_code__ntyp".equalsIgnoreCase(childNodeName))
{
acct_code__ntyp = checkNull(genericUtility.getColumnValue("acct_code__ntyp", dom)).trim();
System.out.println("acct_code__ntyp>>>>>" + acct_code__ntyp);
if (acct_code__ntyp != null && acct_code__ntyp.trim().length() > 0)
{
sql = "select count(*) as cnt from accounts where acct_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acct_code__ntyp);
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 = "VMACCT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
} // end if block for acct_code__ntyp
else if ("sundry_type".equalsIgnoreCase(childNodeName))
{
acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom)).trim();
if ("E".equalsIgnoreCase(editFlag))
{
sql = "select sundry_type from accounts where acct_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acct_code);
rs = pstmt.executeQuery();
if (rs.next())
{
sundtype = rs.getString("sundry_type");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
sql = "select count(acct_code) as cnt from gltrace where acct_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acct_code);
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 = "VMACCTSRS1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
} // end of if block for sundry_type
}
} // end case1
else if (currentFormNo == 2 || "siteaccount".equals(formName))
{
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("acct_code"))
{
String acctcode = checkNull(genericUtility.getColumnValue("acct_code", dom));
if (acctcode == null || acctcode.length() <= 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("acctcode is not entered");
break;
}
}
else if ("site_code".equalsIgnoreCase(childNodeName))
{
NodeList siteParentNode = null;
ArrayList<String> sitecodeall = new ArrayList<String>();
if ("A".equalsIgnoreCase(editFlag))
{
int ctr2 = 0;
int childNodeListLength2 = 0;
siteParentNode = dom2.getElementsByTagName("Detail2");
System.out.println("2 domm all siteParentNode = " + siteParentNode);
System.out.println("3 domm all siteParentNode = " + siteParentNode.getLength());
for (ctr2 = 0; ctr2 < siteParentNode.getLength(); ctr2++)
{
System.out.println("4 In for Parent loop " + ctr2);
Node parentNode2 = siteParentNode.item(ctr2);
System.out.println("5 parentNode= parentNodeList.item(0) = " + parentNode2);
System.out.println();
NodeList childNodeList2 = parentNode2.getChildNodes();
System.out.println(
"6 childNodeList= parentNode.getChildNodes(); = " + childNodeList2);
System.out.println();
childNodeListLength2 = childNodeList2.getLength();
for (int ctr3 = 0; ctr3 < childNodeListLength2; ctr3++)
{
Node childNode2 = childNodeList2.item(ctr3);
System.out.println("childNode= childNodeList.item(ctr3) = " + childNode2);
System.out.println();
String childNodeName2 = childNode2.getNodeName();
System.out.println("current column " + ctr3 + " " + childNodeName2);
System.out.println();
if (childNodeName2.equalsIgnoreCase("site_code"))
{
System.out.println("Final Array " + sitecodeall);
String siteCode = checkNull(
genericUtility.getColumnValueFromNode("site_code", parentNode2))
.trim();
System.out.println("Node value Site_code " + siteCode);
if (sitecodeall.contains(siteCode))
{
System.out.println("0 site_code should not be duplicate dom");
errCode = "VMACCTSRS1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
break;
}
else
{
sitecodeall.add(siteCode);
System.out.println("In Else add in array so now array " + sitecodeall);
}
}
}
}
}
}
}
}
else if (currentFormNo == 3 || "acctcostcntre".equals(formName))
{
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("acct_code"))
{
String acctcode = checkNull(genericUtility.getColumnValue("acct_code", dom));
if (acctcode == null || acctcode.length() <= 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("acctcode is not entered");
break;
}
}
else if (childNodeName.equalsIgnoreCase("cctr_code"))
{
String costcntrcode = checkNull(genericUtility.getColumnValue("cctr_code", dom));
if (costcntrcode == null || costcntrcode.length() <= 0)
{
errCode = "VMCCTR1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("costcntrcode is not entered");
break;
}
else if (costcntrcode != null && costcntrcode.trim().length() > 0)
{
sql = "select count(*) as cnt from costctr where cctr_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, costcntrcode);
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 = "VMCCTR";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
else if (currentFormNo == 4 || "acctanal".equals(formName))
{
parentNodeList = dom.getElementsByTagName("Detail4");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("acct_code"))
{
String acctcode = checkNull(genericUtility.getColumnValue("acct_code", dom));
if (acctcode == null || acctcode.length() <= 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("acctcode is not entered");
break;
}
}
if (childNodeName.equalsIgnoreCase("anal_code"))
{
String analcode = checkNull(genericUtility.getColumnValue("anal_code", dom));
if (analcode == null || analcode.length() <= 0)
{
errCode = "VMANAL1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("analcode is not entered");
break;
}
else if (analcode != null && analcode.trim().length() > 0)
{
sql = "select count(*) as cnt from analysis where anal_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, analcode);
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 = "VMANAL";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
else if (currentFormNo == 5 || "acctdept".equals(formName))
{
parentNodeList = dom.getElementsByTagName("Detail5");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("acct_code"))
{
String acctcode = checkNull(genericUtility.getColumnValue("acct_code", dom));
if (acctcode == null || acctcode.length() <= 0)
{
errCode = "VMACCT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("acctcode is not entered");
break;
}
}
if (childNodeName.equalsIgnoreCase("dept_code"))
{
String deptcode = checkNull(genericUtility.getColumnValue("dept_code", dom));
if (deptcode == null || deptcode.length() <= 0)
{
errCode = "VMDEPT1";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
System.out.println("deptcode is not entered");
break;
}
else if (deptcode != null && deptcode.trim().length() > 0)
{
sql = "select count(*) as cnt from departments where dept_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, deptcode);
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 = "VMDEPT";
errList.add(errCode);
errFields.add(childNodeName.toLowerCase());
}
}
}
}
}
} // end switch
//Changed by Pooja S. on 13-AUG-18 End
int errListSize = errList.size();
System.out.println("errListSize::::::::::" + errListSize);
int count = 0;
String errFldName = null;
if (errList != null && errListSize > 0)
{
for (count = 0; count < errListSize; count++)
{
errCode = errList.get(count);
errFldName = errFields.get(count);
System.out.println(" testing :errCode .:" + errCode);
errString = getErrorString(errFldName, errCode, userId);
System.out.println("errString>>>>>>>>>" + errString);
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);
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 try block
catch (Exception e)
{
System.out.println(":::" + getClass().getSimpleName() + "::" + 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();
throw new ITMException(d);
}
}
errString = errStringXml.toString();
System.out.println("testing : final errString : " + errString);
return errString;
}
//Changed by Pooja S. on 13-AUG-18
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName) throws RemoteException, ITMException
{
Document dom = null;
Document domhr = null;
Document domAll = null;
String retString = "";
try
{
System.out.println("************** Inside itemChanged method ****************");
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
domhr = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length() > 0)
{
domAll = genericUtility.parseString(xmlString2);
}
//Changed by Pooja S. on 13-AUG-18
retString = itemChanged(dom, domhr, domAll, objContext, currentColumn, editFlag, xtraParams, formName);
System.out.println("retString::::::::::" + retString);
}
catch (Exception e)
{
System.out.println(":::" + getClass().getSimpleName() + "::" + e.getMessage());
e.getMessage();
}
return retString;
}
//Changed by Pooja S. on 13-AUG-18
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName) throws RemoteException, ITMException
{
Connection conn = null;
// Added by sarita on 01/06/2017
ConnDriver connDriver = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
SimpleDateFormat sdf;
int childNodeListLength = 0;
int currentFormNo = 0, ctr = 0;
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
String acct_code = "";
String acct_code__par = "";
String sgroup_code = "";
String sql = "";
String ls_descr = "";
String ls_descr1 = "", acctgrp_descr = "", curr_code = "";
String currency_descr = "", acct_type = "";
//Changed by Pooja S. on 13-AUG-18
String sh_descr = "", descr = "",
analysisdescr = "", descr4 = "";
try
{
// changes and commented by sarita for DBConnection on 01/06/2017 :START
// changed by sarita on 09MARCH2018
conn = getConnection();
/*connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;*/
// changes and commented by sarita for DBConnection on 01/06/2017 :END
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("[AccountsIC] [itemChanged] :currentFormNo ....." + currentFormNo);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
/*
* switch(currentFormNo) { case 1:
* {
*/
//Changed by Pooja S. on 13-AUG-18
System.out.println("Currentform 0 " + formName + "" + currentFormNo);
//Changed by Pooja S. on 13-AUG-18
if (currentFormNo == 1 || "accounts".equals(formName))
{
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 ("itm_defaultedit".equalsIgnoreCase(currentColumn.trim()))
{
acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom));
acct_code__par = checkNull(genericUtility.getColumnValue("acct_code__par", dom));
if (acct_code__par == null || acct_code__par.trim().length() == 0)
{
valueXmlString.append("<acct_code__par>").append("<![CDATA["+acct_code+"]]>").append("</acct_code__par>");
}
sgroup_code = checkNull(genericUtility.getColumnValue("sgroup_code", dom));
System.out.println("sgroup_code>>>>>>>>>>"+sgroup_code);
sql = "select descr,group_code from acctsgrp where sgroup_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sgroup_code);
rs = pstmt.executeQuery();
while (rs.next())
{
ls_descr = rs.getString("descr");
ls_descr1 = rs.getString("group_code");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<acctsgrp_descr>").append("<![CDATA[" + ls_descr + "]]>").append("</acctsgrp_descr>");
valueXmlString.append("<group_code>").append("<![CDATA[" + ls_descr1 + "]]>").append("</group_code>");
sql = "select descr from acctgrp where group_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_descr1);
rs = pstmt.executeQuery();
if (rs.next())
{
acctgrp_descr = rs.getString("descr");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<acctgrp_descr>").append("<![CDATA[" + acctgrp_descr + "]]>").append("</acctgrp_descr>");
curr_code = checkNull(genericUtility.getColumnValue("curr_code", dom));
System.out.println("curr_code>>>>>>>>>>" + curr_code);
sql = "Select descr from currency where curr_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, curr_code);
rs = pstmt.executeQuery();
if (rs.next())
{
currency_descr = rs.getString("descr");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<currency_descr>").append("<![CDATA["+currency_descr+"]]>").append("</currency_descr>");
acct_type = checkNull(genericUtility.getColumnValue("acct_type", dom));
System.out.println("acct_type>>>>>>>>>>" + acct_type);
if (acct_type.equals("O"))
{
valueXmlString.append("<sundry_type protect='1'>").append("<![CDATA["+"1"+"]]>").append("</sundry_type>");
}
else
{
valueXmlString.append("<sundry_type protect='O'>").append("<![CDATA["+"O"+"]]>").append("</sundry_type>");
}
}
if ("acct_code".equalsIgnoreCase(currentColumn.trim()))
{
acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom));
acct_code__par = checkNull(genericUtility.getColumnValue("acct_code__par", dom));
if(acct_code__par == null || acct_code__par.trim().length() == 0)
{
valueXmlString.append("<acct_code__par>").append("<![CDATA["+acct_code+"]]>").append("</acct_code__par>");
}
} // end of if block for acct_code
else if ("sgroup_code".equalsIgnoreCase(currentColumn.trim()))
{
sgroup_code = checkNull(genericUtility.getColumnValue("sgroup_code", dom));
System.out.println("sgroup_code>>>>>>>>>>" + sgroup_code);
sql = "select descr,group_code from acctsgrp where sgroup_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, sgroup_code);
rs = pstmt.executeQuery();
while (rs.next())
{
ls_descr = rs.getString("descr");
ls_descr1 = rs.getString("group_code");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<acctsgrp_descr>").append("<![CDATA["+ls_descr+"]]>").append("</acctsgrp_descr>");
valueXmlString.append("<group_code>").append("<![CDATA["+ls_descr1+"]]>").append("</group_code>");
sql = "select descr from acctgrp where group_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ls_descr1);
rs = pstmt.executeQuery();
if (rs.next())
{
acctgrp_descr = rs.getString("descr");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<acctgrp_descr>").append("<![CDATA["+acctgrp_descr+"]]>").append("</acctgrp_descr>");
}
else if ("curr_code".equalsIgnoreCase(currentColumn.trim()))
{
curr_code = checkNull(genericUtility.getColumnValue("curr_code", dom));
System.out.println("curr_code>>>>>>>>>>" + curr_code);
sql = "Select descr from currency where curr_code =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, curr_code);
rs = pstmt.executeQuery();
if (rs.next())
{
currency_descr = rs.getString("descr");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
valueXmlString.append("<currency_descr>").append("<![CDATA["+currency_descr+"]]>").append("</currency_descr>");
} // end of if block for curr_code
else if ("acct_type".equalsIgnoreCase(currentColumn.trim()))
{
acct_type = checkNull(genericUtility.getColumnValue("acct_type", dom));
System.out.println("acct_type>>>>>>>>>>" + acct_type);
if (acct_type.equals("O"))
{
valueXmlString.append("<sundry_type protect='1'>").append("<![CDATA["+"1"+"]]>").append("</sundry_type>");
}
else
{
valueXmlString.append("<sundry_type protect='O'>").append("<![CDATA["+"O"+"]]>").append("</sundry_type>");
}
} // end of if block for acct_type
valueXmlString.append("</Detail1>");
} // end of case1
//Changed by Pooja S. on 13-AUG-18 START
else if (currentFormNo == 2 || "siteaccount".equals(formName))
{
valueXmlString.append("<Detail2>");
if ("itm_default".equalsIgnoreCase(currentColumn.trim()))
{
String site_code = checkNull(genericUtility.getColumnValue("site_code", dom));
if (site_code == null || site_code.trim().length() == 0)
{
site_code = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
valueXmlString.append("<site_code>").append("<![CDATA[" + site_code + "]]>").append("</site_code>");
}
}
valueXmlString.append("</Detail2>");
}
else if (currentFormNo == 3 || "acctcostcntre".equals(formName))
{
valueXmlString.append("<Detail3>");
if ("cctr_code".equalsIgnoreCase(currentColumn.trim()))
{
String cctr_code = checkNull(genericUtility.getColumnValue("cctr_code", dom));
System.out.print("Value valueXmlString cctr_code\n [" + cctr_code + "]");
if (cctr_code != null)
{
sql = "select descr,sh_descr from costctr where cctr_code=?";
System.out.print("Value valueXmlString 100000000 \n [" + sql + "]");
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, cctr_code);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = checkNull(rs.getString("descr"));
sh_descr = checkNull(rs.getString("sh_descr"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.print("Value valueXmlString Pricelist \n [" + sql + "]");
valueXmlString.append("<descr ><![CDATA[" + descr + "]]></descr>");
valueXmlString.append("<sh_descr ><![CDATA[" + sh_descr + "]]></sh_descr>");
}
}
valueXmlString.append("</Detail3>");
}
else if (currentFormNo == 4 || "acctanal".equals(formName))
{
valueXmlString.append("<Detail4>");
if ("anal_code".equalsIgnoreCase(currentColumn.trim()))
{
String anal_code = checkNull(genericUtility.getColumnValue("anal_code", dom));
System.out.print("Value valueXmlString cctr_code\n [" + anal_code + "]");
if (anal_code != null)
{
sql = "select descr from analysis where anal_code=?";
System.out.print("Value valueXmlString 100000000 \n [" + sql + "]");
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, anal_code);
rs = pstmt.executeQuery();
if (rs.next())
{
analysisdescr = checkNull(rs.getString("descr"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.print("Value valueXmlString Pricelist \n [" + sql + "]");
valueXmlString.append("<analysis_descr ><![CDATA[" + analysisdescr + "]]></analysis_descr>");
}
}
valueXmlString.append("</Detail4>");
}
else if (currentFormNo == 5 || "acctdept".equals(formName))
{
valueXmlString.append("<Detail5>");
if ("dept_code".equalsIgnoreCase(currentColumn.trim()))
{
String dept_code = checkNull(genericUtility.getColumnValue("dept_code", dom));
System.out.print("Value valueXmlString cctr_code\n [" + dept_code + "]");
if (dept_code != null)
{
sql = "select descr from department where dept_code=?";
System.out.print("Value valueXmlString 100000000 \n [" + sql + "]");
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, dept_code);
rs = pstmt.executeQuery();
if (rs.next())
{
descr4 = checkNull(rs.getString("descr"));
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.print("Value valueXmlString Pricelist \n [" + sql + "]");
valueXmlString.append("<department_descr ><![CDATA[" + descr4 + "]]></department_descr>");
}
}
valueXmlString.append("</Detail5>");
}
valueXmlString.append("</Root>");
// end of switch statement
} // end of try block
//Changed by Pooja S. on 13-AUG-18 END
catch (Exception e)
{
System.out.println(":::" + getClass().getSimpleName() + "::" + e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if (conn != null)
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
System.out.println("Exception in EJB["+ getClass().getSimpleName() + "]::itemChanged::["+ e.getMessage() + "]");
}
}
return valueXmlString.toString();
}
private String errorType(Connection conn, String errorCode) throws ITMException
{
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, errorCode);
rs = pstmt.executeQuery();
if (rs.next())
{
msgType = rs.getString("MSG_TYPE");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new ITMException(ex);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return msgType;
}
}
update obj_forms set FORM_NAME='accounts' where win_name='w_accounts' and FORM_NO=1;
insert into obj_forms (win_name,Tittle,Form_No,FORM_NAME) values ('w_accounts','Site Account',2,'site_account');
insert into obj_forms (win_name,Tittle,Form_No,FORM_NAME) values ('w_accounts','Account Cost Centre',3,'acct_cost_cntre');
insert into obj_forms (win_name,Tittle,Form_No,FORM_NAME) values ('w_accounts','Account Analysis',4,'acct_anal');
insert into obj_forms (win_name,Tittle,Form_No,FORM_NAME) values ('w_accounts','Account Department',5,'acct_dept');
update SYSTEM_EVENTS set SERVICE_CODE='poic_default_ejb_1' ,COMP_NAME='ibase.webitm.ejb.fin.AccountsIC' , comp_type='JB' where obj_name='accounts' and EVENT_CODE='post_item_change';
update SYSTEM_EVENTS set SERVICE_CODE='prv_default_ejb_1',COMP_NAME='ibase.webitm.ejb.fin.AccountsIC',comp_type='JB' where obj_name ='accounts' and EVENT_CODE='pre_validate';
-- SYSTEM_EVENT_SERVICES----------------------------------------------------------------------------------------------------------------------------
Insert into SYSTEM_EVENT_SERVICES (SERVICE_CODE,SERVICE_DESCR,SERVICE_URI,SERVICE_PROVIDER,METHOD_NAME,RETURN_VALUE,RETURN_TYPE,RETURN_DESCR,RETURN_XFRM,CHG_DATE,CHG_USER,CHG_TERM)
values ('prv_default_ejb_1',null,'http://localhost:9090/axis/services/ValidatorService','base','wfValData','String','S',null,null,sysdate,'base','base');
Insert into SYSTEM_EVENT_SERVICES (SERVICE_CODE,SERVICE_DESCR,SERVICE_URI,SERVICE_PROVIDER,METHOD_NAME,RETURN_VALUE,RETURN_TYPE,RETURN_DESCR,RETURN_XFRM,CHG_DATE,CHG_USER,CHG_TERM)
values ('poic_default_ejb_1',null,'http://localhost:9090/axis/services/ValidatorService','base','itemChanged','String','S',null,null,sysdate,'base','base');
-- SYSTEM_SERVICE_ARGS
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('prv_default_ejb_1',1,'COMPONENT_TYPE','I',null,'C.String',null,sysdate,'base ','BASE','JB');
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('prv_default_ejb_1',2,'COMPONENT_NAME','I',null,'C.String',null,sysdate,'base ','BASE',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('prv_default_ejb_1',3,'XML_DATA','I',null,'S',null,sysdate,'base','BASE ',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('prv_default_ejb_1',4,'XML_DATA_1','I',null,'S',null,sysdate,'base','BASE ',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('prv_default_ejb_1',5,'XML_DATA_ALL','I',null,'S',null,sysdate,'base','BASE',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('prv_default_ejb_1',6,'OBJ_CONTEXT','I',null,'S',null,sysdate,'base','BASE ',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('prv_CustomerDefaultEJB',7,'EDIT_FLAG','I',null,'S',null,sysdate,'base','BASE ',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('prv_default_ejb_1',8,'XTRA_PARAMS','I',null,'S',null,sysdate,'base','BASE ',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('prv_default_ejb_1',9,'FORM_NAME','I',null,'S',null,sysdate,'base','BASE ',null);
--------------------------------------------------------------------------------------------------------------------------------------
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('poic_default_ejb_1',1,'COMPONENT_TYPE','I',null,'S',null,sysdate,'base','BASE','JB');
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('poic_default_ejb_1',2,'COMPONENT_NAME','I',null,'S',null,sysdate,'base','BASE',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('poic_default_ejb_1',3,'XML_DATA','I',null,'S',null,sysdate,'base','BASE',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('poic_default_ejb_1',4,'XML_DATA_1','I',null,'S',null,sysdate,'base','BASE',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('poic_default_ejb_1',5,'XML_DATA_2','I',null,'S',null,sysdate,'base','BASE',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('poic_default_ejb_1',6,'OBJ_CONTEXT','I',null,'S',null,sysdate,'base','BASE',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('poic_default_ejb_1',7,'FOCUSED_COLUMN','I',null,'S',null,sysdate,'base','BASE',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('poic_default_ejb_1',8,'EDIT_FLAG','I',null,'S',null,sysdate,'base','BASE',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('poic_default_ejb_1',9,'XTRA_PARAMS','I',null,'S',null,sysdate,'base','BASE',null);
Insert into SYSTEM_SERVICE_ARGS (SERVICE_CODE,LINE_NO,ARG_NAME,ARG_MODE,DESCR,ARG_TYPE,ARG_XFRM,CHG_DATE,CHG_USER,CHG_TERM,ARG_VALUE)
values ('poic_default_ejb_1',10,'FORM_NAME','I',null,'S',null,sysdate,'base','BASE ',null);
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