Commit a53adbea authored by pshinde's avatar pshinde

Source code for Itemchanged and validation and post save for Period Table Generation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@99977 ce508802-f39f-4f6c-b175-0d175dae99d5
parent af3fc9c2
This diff is collapsed.
/********************************************************
Title : BankGauranteeLocal [F15DSUN018]
Date : 22/JUL/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface PrdTableGenICLocal extends ValidatorLocal
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
/********************************************************
Title : BankGauranteeRemote [F15DSUN018]
Date : 22/JUL/15
Developer: Pankaj R.
********************************************************/
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface PrdTableGenICRemote extends ValidatorRemote
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import org.w3c.dom.*;
import ibase.utility.CommonConstants;
import ibase.utility.GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.utility.E12GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import ibase.webitm.ejb.ITMDBAccessEJB;
import javax.ejb.Stateless;
@Stateless
public class PrdTableGenPostSave extends ValidatorEJB implements PrdTableGenPostSaveLocal,PrdTableGenPostSaveRemote {
//E12GenericUtility genericUtility = new E12GenericUtility();
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException
{
System.out.println("------------ postSave method called-111111111----------------PrdTableGenPostSave : ");
System.out.println("tranId111--->>["+tranId+"]");
System.out.println("xml String--->>["+xmlString+"]");
Document dom = null;
String errString="";
try
{
if (xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString);
errString = postSave(dom,tranId,xtraParams,conn);
}
}
catch(Exception e)
{
System.out.println("Exception : PrdTableGenPostSave.java : postSave : ==>\n"+e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String postSave(Document dom,String tranId,String xtraParams,Connection conn) throws ITMException
{
System.out.println("in EcollectionPostSave tran_id---->>["+tranId+"]");
ResultSet rs=null;
PreparedStatement pstmt=null;
SimpleDateFormat sdf =null;
Timestamp currDate = null,fromDate=null,tooDate=null;
String sql="",errorString="";
String prdCode="",prdTblNo="",frDate="",toDate="",prdClose="";
String chgUser="",chgTerm="";
String errString = "";
int cnt=0,updateCount=0,detCnt=0;
ITMDBAccessEJB itmDBAccessEJB = null;
boolean value=false;
ibase.utility.E12GenericUtility genericUtility = null;
genericUtility = new ibase.utility.E12GenericUtility();
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
chgUser =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
chgTerm =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "chgTerm"));
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new Timestamp(System.currentTimeMillis());
System.out.println("TimeStamp>>>>>>>>>>"+currDate);
NodeList hdrDommList = dom.getElementsByTagName("Detail2");
System.out.println("hdrDommList==="+hdrDommList);
System.out.println("len===["+hdrDommList.getLength()+"]");
for (int dtlCtr = 0; dtlCtr < hdrDommList.getLength(); dtlCtr++)
{
Node detailListNode = hdrDommList.item(dtlCtr);
NodeList detail2List= detailListNode.getChildNodes();
// System.out.println("@@@@@@@@@node name[" + detailListNode.getNodeName()+"]");
if("Detail2".equalsIgnoreCase(detailListNode.getNodeName()))
{
// System.out.println("@@@@inside detail4----------------");
for (int cntr = 0; cntr < detail2List.getLength(); cntr++)
{
Node detail2Node = detail2List.item(cntr);
if("prd_code".equalsIgnoreCase( detail2Node.getNodeName()))
{
if( detail2List.item(cntr).getFirstChild() != null)
{
prdCode = detail2List.item(cntr).getFirstChild().getNodeValue();
}
else
{
prdCode= "";
}
}
if("prd_tblno".equalsIgnoreCase( detail2Node.getNodeName()))
{
if( detail2List.item(cntr).getFirstChild() != null)
{
prdTblNo = detail2List.item(cntr).getFirstChild().getNodeValue();
}
else
{
prdTblNo= "";
}
}
if("fr_date".equalsIgnoreCase( detail2Node.getNodeName()))
{
if( detail2List.item(cntr).getFirstChild() != null)
{
frDate = detail2List.item(cntr).getFirstChild().getNodeValue();
}
else
{
frDate= "";
}
}
if("to_date".equalsIgnoreCase( detail2Node.getNodeName()))
{
if( detail2List.item(cntr).getFirstChild() != null)
{
toDate = detail2List.item(cntr).getFirstChild().getNodeValue();
}
else
{
toDate= "";
}
}
if("prd_closed".equalsIgnoreCase( detail2Node.getNodeName()))
{
if( detail2List.item(cntr).getFirstChild() != null)
{
prdClose = detail2List.item(cntr).getFirstChild().getNodeValue();
}
else
{
prdClose= "";
}
}
}
fromDate = Timestamp.valueOf(genericUtility.getValidDateString(frDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set as fromDate@@@@@@@==="+fromDate);
tooDate = Timestamp.valueOf(genericUtility.getValidDateString(toDate, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
System.out.println("Date to be set as tooDate @@@@@@@==="+tooDate);
System.out.println("@@@@ctr["+dtlCtr+"]Period code["+prdCode+"]-Period table Code["+prdTblNo+"]-from date["+frDate+"]To Date["+toDate+"]period closed["+prdClose+"]@@@");
sql="select count(1) from period_tbl where prd_code= ? and prd_tblno= ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, prdTblNo);
rs=pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
System.out.println("CNT==="+cnt);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(cnt==0)
{
System.out.println("New Exist@@@@@@@");
sql="Insert into period_tbl (PRD_CODE,PRD_TBLNO,FR_DATE,TO_DATE,PRD_CLOSED,CHG_DATE,CHG_USER,CHG_TERM) " +
"values (?,?,?,?,?,?,?,?)";
System.out.println("header sql :"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode);
pstmt.setString(2,prdTblNo);
pstmt.setTimestamp(3,fromDate);
pstmt.setTimestamp(4,tooDate);
pstmt.setString(5,prdClose);
pstmt.setTimestamp(6,currDate);
pstmt.setString(7,chgUser);
pstmt.setString(8,chgTerm);
detCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("Insert Count==="+detCnt);
}
else
{
System.out.println("Record Exist@@@@@@@");
sql = "update period_tbl set FR_DATE= ? ,TO_DATE=?, PRD_CLOSED=?,CHG_DATE=?,CHG_USER=?,CHG_TERM=? where prd_code= ? and prd_tblno= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,fromDate);
pstmt.setTimestamp(2,tooDate);
pstmt.setString(3,prdClose);
pstmt.setTimestamp(4,currDate);
pstmt.setString(5,chgUser);
pstmt.setString(6,chgTerm);
pstmt.setString(7,prdCode);
pstmt.setString(8,prdTblNo);
updateCount = pstmt.executeUpdate();
System.out.println("no of row update: "+updateCount);
pstmt.close();
pstmt = null;
}
if(detCnt>0 ||updateCount>0)
{
System.out.println(">>The selected transaction is confirmed");
errString = itmDBAccessEJB.getErrorString("","VTCONSUCF","","",conn);
}
}
}
}
catch(Exception e)
{
System.out.println("Exception ::"+e.getMessage());
errString = GenericUtility.getInstance().createErrorString(e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println(">>>>>In finally errString:"+errString);
if(errString != null && errString.trim().length() > 0)
{
if(errString.indexOf("VTCONSUCF") > -1)
{
conn.commit();
System.out.println("Commit Completed");
}
else
{
conn.rollback();
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//conn.close();
}
catch(Exception e)
{
System.out.println("Exception : "+e);e.printStackTrace();
throw new ITMException(e);
}
}
return errorString;
}
private String checkNull( String input )
{
if (input == null )
{
input = "";
}
return input;
}//end of
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Local;
@Local
public interface PrdTableGenPostSaveLocal extends ValidatorLocal {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Remote;
@Remote
public interface PrdTableGenPostSaveRemote extends ValidatorRemote {
public String postSave(String xmlString,String tranId,String editFlag, String xtraParams,Connection conn) 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