Commit 819a428d authored by sgadve's avatar sgadve

Relook and Realignment of Cost Center Code and Cost Center Account

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@189349 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 1878b35e
/**
DEVELOPED BY Saiprasad G ON 16/08/18
PURPOSE : Cost cetnter code and Cost Center Account*/
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
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;
/**
* Session Bean implementation class CostCentre
*/
@Stateless
public class CostCentre extends ValidatorEJB implements CostCentreRemote, CostCentreLocal
{
private E12GenericUtility genericUtility = new E12GenericUtility();
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;
}//end of the wfvaldata
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams, String formName) throws RemoteException, ITMException
{
int childNodeLength = 0;
int currentFormNo = 0;
StringBuffer valueXmlString = new StringBuffer();
String sql="";
int ctr = 0, cnt = 0;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
NodeList parentNodeList = null;
Node parentNode = null;
NodeList childNodeList = null;
Node childNode = null;
String childNodeName = "";
String userId = "";
String cctr_code = "", acct_code = "", level_no = "";
String errString = "";
try
{
conn = getConnection();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("currentFormNo:::" + currentFormNo);
System.out.println("formName:::" + formName);
}
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>");
/*
* switch (currentFormNo) { case 1:
*/
if (currentFormNo == 1 || "costctr".equals(formName))
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
valueXmlString.append("<Detail1>");
for (ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName" + childNodeName);
if (childNodeName.equalsIgnoreCase("cctr_code"))
{
cctr_code = checkNull(genericUtility.getColumnValue("cctr_code", dom));
System.out.println("cctrcode" + cctr_code);
if (cctr_code == null || cctr_code.length() <= 0)
{
errString = getErrorString("cctr_code", "VMCCTRCODE", userId);
System.out.println("cctr_code is not entered");
break;
}
} // end of the cctr_code
else if(childNodeName.equalsIgnoreCase("descr"))
{
String descr = checkNull(genericUtility.getColumnValue("descr", dom)).trim();
System.out.println("descr = "+descr);
if(descr.length() == 0)
{
errString = getErrorString("descr", "VMCCTRDESC", userId);
break;
}
}// end if block for descr
else if(childNodeName.equalsIgnoreCase("dept_code"))
{
String dept_code = checkNull(genericUtility.getColumnValue("dept_code", dom)).trim();
System.out.println("dataModel = "+dept_code);
sql="select dept_code from department where dept_code=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, dept_code);
rs = pstmt.executeQuery();
if(!rs.next())
{
errString = getErrorString("dept_code", "VTDEPT1", userId);
break;
}
}// end if block for dept_code
else if (childNodeName.equalsIgnoreCase("level_no"))
{
level_no = checkNull(genericUtility.getColumnValue("level_no", dom));
System.out.println("level_no:" + level_no);
if(level_no.length() == 0)
{
errString = getErrorString("level_no", "VMCCTRLEV", userId);
break;
}
else
{
int i = 0;
for (i = 0; i < level_no.length(); i++)
{
char level = level_no.charAt(i);
if (!Character.isDigit(level))
{
errString = getErrorString("level_no", "VMCCTRLEV1", userId);
System.out.println("level_no is not number");
break;
}
}//end of for Loop
}
}// end if block for level_no
}
valueXmlString.append("</Detail1>");
} // end case1
else if (currentFormNo == 2 || "cctracct".equals(formName))
{
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeLength = childNodeList.getLength();
valueXmlString.append("<Detail2>");
for (ctr = 0; ctr < childNodeLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("acct_code"))
{
acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom));
if (acct_code == null || acct_code.length() <= 0)
{
errString = getErrorString("acct_code", "VMCCTRACCT", userId);
break;
}
} // end if block for acct_code
}
valueXmlString.append("</Detail2>");
} // end case2
valueXmlString.append("</Root>");
}
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);
}
}
return errString;
}
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 dom1 = null;
Document dom2 = null;
String valueXmlString = "";
try
{
System.out.println("xmlString " + xmlString);
System.out.println("xmlString1 " + xmlString1);
System.out.println("xmlString2 " + xmlString2);
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);
}
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams, formName);
System.out.println("valueXmlString[" + valueXmlString + "]");
}// end of the try block
catch (Exception e)
{
System.out.println("Exception : [MiscVal][itemChanged( String, String )] :==>\n" + e.getMessage());
throw new ITMException(e);
}// end of the catch block
System.out.println("VALUE HELLO PRINTA[" + valueXmlString + "]");
return valueXmlString;
}// end of the itemchaned
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams, String formName) throws RemoteException, ITMException
{
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int ctr = 0;
String descr = "", Shdescr = "";
String childNodeName = null;
String columnValue = null;
// SimpleDateFormat sdf;
int currentFormNo = 0, cnt = 0;
// String cadreCode="" ;
String sql = "", cctr_code = "",dept_code = "", acct_code = "";
String deptdescr = "", acctdescr = "", acctshdescr = "";
E12GenericUtility genericUtility = new E12GenericUtility();
try
{
System.out.println("******************CostCentre(ItemChanged)**************************");
conn = getConnection();
conn.setAutoCommit(false);
if (objContext != null && objContext.trim().length() > 0)
{
currentFormNo = Integer.parseInt(objContext);
System.out.println("currentformno" + currentFormNo);
}
System.out.println("[CostCentre][ItemChanged][FORM NO][" + currentFormNo + "]");
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("Currentform 0 " + formName + "" + currentFormNo);
/*
* switch (currentFormNo) { case 1:
*/
if (currentFormNo == 1 || "costctr".equals(formName))
{
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail1>");
ctr = 0;
int childNodeListLength = childNodeList.getLength();
System.out.println("childNodelistLength" + childNodeListLength);
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("ChildNodeName" + childNodeName);
System.out.println("currentformno12233" + currentFormNo);
if (childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue = childNode.getFirstChild().getNodeValue().trim();
System.out.println("ColumnValue0.102151211" + columnValue);
}
}
ctr++;
} while (ctr < childNodeListLength && !childNodeName.equals(currentColumn));
if (currentColumn.trim().equalsIgnoreCase("cctr_code"))
{
cctr_code = checkNull(genericUtility.getColumnValue("cctr_code", dom));
System.out.println("cost centre code " + cctr_code);
if (cctr_code != null && cctr_code.trim().length() > 0)
{
sql = "select descr,sh_descr from costctr where cctr_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, cctr_code);
rs = pstmt.executeQuery();
if (rs.next())
{
descr = checkNull(rs.getString("descr"));
Shdescr = checkNull(rs.getString("sh_descr"));
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<descr>").append("<![CDATA[" + descr.trim() + "]]>").append("</descr>");
valueXmlString.append("<sh_descr>").append("<![CDATA[" + Shdescr.trim() + "]]>").append("</sh_descr>");
}
}//end of itemchanged cctr_code
else if (currentColumn.trim().equalsIgnoreCase("dept_code"))
{
dept_code = checkNull(genericUtility.getColumnValue("dept_code", dom));
System.out.println("department code " + dept_code);
if (dept_code != null && dept_code.trim().length() > 0)
{
sql = "select descr from department where dept_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, dept_code);
rs = pstmt.executeQuery();
if (rs.next())
{
deptdescr = checkNull(rs.getString("descr"));
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<department_descr>").append("<![CDATA[" + deptdescr.trim() + "]]>").append("</department_descr>");
}
}//end of itemchanged dept_code
valueXmlString.append("</Detail1>");
} // end of if for the form name
else if (currentFormNo == 2 || "cctracct".equals(formName))
{
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
valueXmlString.append("<Detail2>");
ctr = 0;
int childNodeListLength1 = childNodeList.getLength();
System.out.println("childNodelistLength1" + childNodeListLength1);
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("ChildNodeName" + childNodeName);
System.out.println("currentformno;" + currentFormNo);
if (childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue = childNode.getFirstChild().getNodeValue().trim();
System.out.println("ColumnValue:" + columnValue);
}
}
ctr++;
} while (ctr < childNodeListLength1 && !childNodeName.equals(currentColumn));
if ( "itm_default".equalsIgnoreCase( currentColumn.trim() ) || "itm_defaultedit".equalsIgnoreCase( currentColumn.trim() ) )
{
cctr_code = checkNull(genericUtility.getColumnValue("cctr_code", dom1));
valueXmlString.append("<cctr_code protect = \"1\"><![CDATA[" + cctr_code + "]]></cctr_code>");
}
else if (currentColumn.trim().equalsIgnoreCase("acct_code"))
{
acct_code = checkNull(genericUtility.getColumnValue("acct_code", dom));
System.out.println("account code " + acct_code);
if (acct_code != null && acct_code.trim().length() > 0)
{
sql = "select descr,sh_descr from accounts where acct_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, acct_code);
rs = pstmt.executeQuery();
if (rs.next())
{
acctdescr = checkNull(rs.getString("descr"));
acctshdescr = checkNull(rs.getString("sh_descr"));
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<descr>").append("<![CDATA[" + acctdescr.trim() + "]]>").append("</descr>");
valueXmlString.append("<sh_descr>").append("<![CDATA[" + acctshdescr.trim() + "]]>").append("</sh_descr>");
}
}//end of itemchanged for the acct_code
valueXmlString.append("</Detail2>");
} // end of else if
valueXmlString.append("</Root>");
} // END OF TRY
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
} //end of the catch block
finally
{
try
{
if (conn != null)
{
if (pstmt != null)
pstmt.close();
if (rs != null)
rs.close();
rs = null;
pstmt = null;
conn.close();
}
conn = null;
}
catch (Exception d)
{
d.printStackTrace();
throw new ITMException(d);
}
}// end of the finally block
return valueXmlString.toString();
}// end of itemchanged method
private String checkNull(String str)
{
if (str == null)
{
return "";
} else
{
return str;
}
} //end of the checknull method.
}
\ No newline at end of file
/**
DEVELOPED BY Saiprasad G ON 16/08/18
PURPOSE : Cost cetnter code and Cost Center Account */
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Local;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
@Local
public interface CostCentreLocal extends ValidatorLocal
{
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams,String formName) 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;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag,String xtraParams, String formName) throws RemoteException, ITMException ;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag,String xtraParams, String formName) throws RemoteException, ITMException ;
}
/**
DEVELOPED BY Saiprasad G ON 16/08/18
PURPOSE : Cost cetnter code and Cost Center Account*/
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import javax.ejb.Remote;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
@Remote
public interface CostCentreRemote extends ValidatorRemote
{
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams,String formName) 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;
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag,String xtraParams, String formName) throws RemoteException, ITMException ;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag,String xtraParams, String formName) 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