Commit c65afd14 authored by pgole's avatar pgole

Updated ejb component


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@101355 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8205ccbd
/********************************************************
Title : RelaPartyApplIC [F16ASUN006]
Date : 21 - APR - 2016
Author: Poonam Gole
********************************************************/
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import java.text.*;
import java.util.Date;
import java.util.Calendar;
import java.sql.*;
import java.text.SimpleDateFormat;
import org.w3c.dom.*;
import javax.ejb.*;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
@Stateless
public class RelaPartyApplIC extends ValidatorEJB implements RelaPartyApplICRemote,RelaPartyApplICLocal
{
E12GenericUtility genericUtility = new E12GenericUtility();
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String itemChanged() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("Validation Start..........");
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : RelaPartyApplIC() : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = " ";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String columnValue = null;
String childNodeName = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String errCode = null;
String userId = null,loginSite = null;
int cnt = 0;
int ctr = 0;
int currentFormNo = 0;
int childNodeListLength=0;
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
String sql = null;
ConnDriver connDriver = new ConnDriver();
String lineNoDet = null;
String updateFlag = null;
String finEntity = "";
String acctPrd = "";
String proTurnover = "";
double turnOver = 0;
String relatedAllow = "";
double relatedAllowPer = 0;
String sqlfin = "";
int cntfin = 0;
ResultSet finrs = null;
try
{
System.out.println( "wfValData called" );
conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
System.out.println("VALIDATION FOR DETAIL [ 1 ]..........");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
//System.out.println("childNodeName["+childNodeName+"]");
if ( childNodeName.equalsIgnoreCase( "fin_entity" ) )
{
//System.out.println("Inside wfval fin_entity>>>");
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("FIN_ENTITY","NULLFINENT",userId);
break ;
}
else
{
finEntity = genericUtility.getColumnValue( "fin_entity", dom, "1" );
//System.out.println("Inside wfval fin_entity else>>>"+finEntity);
sql = " SELECT COUNT(*) FROM FINENT WHERE FIN_ENTITY ='" + finEntity.trim() + "'";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
if( cnt == 0 )
{
errCode = "INVDFINENT";
errString = getErrorString( "FIN_ENTITY", errCode, userId );
break ;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
if ( childNodeName.equalsIgnoreCase( "acct_prd" ) )
{
//System.out.println("Inside wfval acct_prd>>>");
if ( childNode.getFirstChild() == null )
{
errString =itmDBAccessEJB.getErrorString("ACCT_PRD","NULLACCPRD",userId);
break ;
}
else
{
//System.out.println("Inside wfval acct_prd else>>>");
acctPrd = genericUtility.getColumnValue( "acct_prd", dom).trim();
finEntity = genericUtility.getColumnValue( "fin_entity", dom).trim();
//System.out.println(" wf else acctPrd[" + acctPrd + "]" + "finEntity "+finEntity);
sql = "SELECT COUNT(1) FROM ACCTPRD WHERE CODE = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,acctPrd);
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cnt +editFlag+ "]");
if( cnt == 0 )
{
errString = getErrorString( "acct_prd","INVDACCPR",userId );
break ;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ("A".equalsIgnoreCase(editFlag) && childNode.getFirstChild() != null )
{
sqlfin = "SELECT COUNT(1) FROM RELA_PARTY_APPL WHERE FIN_ENTITY = ? AND ACCT_PRD = ?";
pstmt = conn.prepareStatement( sqlfin );
pstmt.setString(1,finEntity);
pstmt.setString(2,acctPrd);
finrs = pstmt.executeQuery();
if( finrs.next() )
{
cntfin = finrs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cntfin + "]");
if( cntfin > 0 )
{
errString = getErrorString( "acct_prd","VTDUFINENT",userId );
break ;
}
finrs.close();
finrs = null;
pstmt.close();
pstmt = null;
}
}
}
if ( childNodeName.equalsIgnoreCase( "proj_turnover" ) )
{
//System.out.println("Inside wfval proj_turnover>>>");
proTurnover = genericUtility.getColumnValue( "proj_turnover", dom).trim();
if(proTurnover!=null && proTurnover.trim().length() > 0)
{
turnOver = Double.parseDouble(proTurnover);
//System.out.println("Inside wfval turnOver>>>"+turnOver);
if(turnOver<=0)
{
errString =itmDBAccessEJB.getErrorString("proj_turnover","VMPROJTURN",userId);
break ;
}
}
}
if ( childNodeName.equalsIgnoreCase( "relp_allw_perc" ) )
{
//System.out.println("Inside wfval relp_allw_perc>>>");
relatedAllow = genericUtility.getColumnValue( "relp_allw_perc", dom).trim();
if(relatedAllow!=null && relatedAllow.trim().length() > 0)
{
relatedAllowPer = Double.parseDouble(relatedAllow);
//System.out.println("Inside wfval relatedAllowPer>>>"+relatedAllowPer);
if(relatedAllowPer < 0 || relatedAllowPer > 100 )
{
errString =itmDBAccessEJB.getErrorString("relp_allw_perc","VMRELPALLW",userId);
break ;
}
}
}
}
break;
}
}
catch(Exception e)
{
System.out.println("Exception ::" +e);
e.printStackTrace();
errCode = "VALEXCEP";
errString = getErrorString( "", errCode, userId );
}
finally
{
try
{
if(conn != null)
{
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( rs != null )
{
rs.close();
rs = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
System.out.println(" < RelaPartyApplIC > CONNECTION IS CLOSED");
}
System.out.println("ErrString ::" + errString);
return errString;
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = null;
try
{
System.out.println("xmlString" + xmlString);
dom = parseString(xmlString);
System.out.println("xmlString1" + xmlString1);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
System.out.println("xmlString2" + xmlString2);
dom2 = parseString("<Root>" + xmlString2 + "</Root>");
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [RelaPartyApplIC][itemChanged] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = null;
int currentFormNo = 0;
StringBuffer valueXmlString = new StringBuffer();
String columnValue = null;
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
String childNodeName = null;
int childNodeListLength = 0;
int ctr = 0;
int cnt = 0;
String loginSite = null;
String chguserhdr = null;
String chgtermhdr = null;
SimpleDateFormat sdf = null;
String currDate="";
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
Timestamp timestamp = null,ordDate=null;
String finEntityDescr = "";
String finEntity = "";
String loginSiteCode = null;
String siteDescr = null;
String acctPrd = "";
try
{
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
timestamp = new Timestamp(System.currentTimeMillis());
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
chguserhdr = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgtermhdr = getValueFromXTRA_PARAMS(xtraParams, "chgTerm");
currDate = (sdf.format(timestamp).toString()).trim();
System.out.println("loginSite["+loginSite+"][chguserhdr "+chguserhdr +"][chgtermhdr "+chgtermhdr+"][currDate"+currDate+"]");
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("Current Form No ["+currentFormNo+"]");
switch (currentFormNo)
{
case 1:
valueXmlString.append("<Detail1>");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.trim().equals( "itm_default" ))
{
System.out.println("Inside itm_default...");
loginSiteCode = null;
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
if( loginSiteCode != null || loginSiteCode.trim().length()==0 )
{
valueXmlString.append("<chg_user>").append("<![CDATA["+ chguserhdr + "]]>").append("</chg_user>");
valueXmlString.append("<chg_term>").append("<![CDATA["+ chgtermhdr + "]]>").append("</chg_term>");
valueXmlString.append("<chg_date>").append("<![CDATA["+ currDate + "]]>").append("</chg_date>");
valueXmlString.append("<add_date>").append("<![CDATA["+ currDate + "]]>").append("</add_date>");
valueXmlString.append("<add_user>").append("<![CDATA["+ chguserhdr + "]]>").append("</add_user>");
valueXmlString.append("<add_term>").append("<![CDATA["+ chgtermhdr + "]]>").append("</add_term>");
}
}
if(currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
System.out.println("Inside itm_defaultedit...");
valueXmlString.append("<chg_user>").append("<![CDATA["+ chguserhdr + "]]>").append("</chg_user>");
valueXmlString.append("<chg_term>").append("<![CDATA["+ chgtermhdr + "]]>").append("</chg_term>");
valueXmlString.append("<chg_date>").append("<![CDATA["+ currDate + "]]>").append("</chg_date>");
}
if (currentColumn.trim().equals( "fin_entity" ))
{
//System.out.println("Inside fin_entity...");
finEntity = genericUtility.getColumnValue( "fin_entity", dom );
//System.out.println("Inside fin_entity..." +finEntity);
sql = "SELECT F.DESCR FINENT_DESCR FROM FINENT F WHERE F.FIN_ENTITY = ? ";
pStmt = conn.prepareStatement( sql );
pStmt.setString(1,finEntity);
rs = pStmt.executeQuery();
if( rs.next() )
{
finEntityDescr = rs.getString( "FINENT_DESCR" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
valueXmlString.append("<finent_descr>").append("<![CDATA[" + ( finEntityDescr != null ? finEntityDescr.trim() : "" )+ "]]>").append("</finent_descr>");
}
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
break;
}//END OF TRY
}
catch(Exception e)
{
System.out.println("RelaPartyApplIC Exception ::"+ e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pStmt != null )
{
pStmt.close();
pStmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception ::" + e);
e.printStackTrace();
}
}
return valueXmlString.toString();
}
}
/********************************************************
Title : RelaPartyApplIC [F16ASUN006]
Date : 21 - APR - 2016
Author: Poonam Gole
********************************************************/
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Local; // added for ejb3
import ibase.webitm.ejb.ValidatorLocal;// added for ejb3
@Local // added for ejb3
public interface RelaPartyApplICLocal extends ValidatorLocal
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : RelaPartyApplIC [F16ASUN006]
Date : 21 - APR - 2016
Author: Poonam Gole
********************************************************/
package ibase.webitm.ejb.fin;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Remote; // added for ejb3
import ibase.webitm.ejb.ValidatorRemote;// added for ejb3
@Remote // added for ejb3
public interface RelaPartyApplICRemote extends ValidatorRemote
{
public String wfValData() throws RemoteException,ITMException;
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException, ITMException;
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged() throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
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